]> git.madduck.net Git - etc/vim.git/blobdiff - .vim/bundle/vim-lsp/test/lsp/utils/position.vimspec

madduck's git repository

Every one of the projects in this repository is available at the canonical URL git://git.madduck.net/madduck/pub/<projectpath> — see each project's metadata for the exact URL.

All patches and comments are welcome. Please squash your changes to logical commits before using git-format-patch and git-send-email to patches@git.madduck.net. If you'd read over the Git project's submission guidelines and adhered to them, I'd be especially grateful.

SSH access, as well as push access can be individually arranged.

If you use my repositories frequently, consider adding the following snippet to ~/.gitconfig and using the third clone URL listed for each project:

[url "git://git.madduck.net/madduck/"]
  insteadOf = madduck:

Merge commit 'a39f715c13be3352193ffd9c5b7536b8786eff64' as '.vim/bundle/vim-lsp'
[etc/vim.git] / .vim / bundle / vim-lsp / test / lsp / utils / position.vimspec
diff --git a/.vim/bundle/vim-lsp/test/lsp/utils/position.vimspec b/.vim/bundle/vim-lsp/test/lsp/utils/position.vimspec
new file mode 100644 (file)
index 0000000..9892897
--- /dev/null
@@ -0,0 +1,65 @@
+Describe lsp#utils#position
+
+    Before each
+        % delete _
+    End
+
+    After all
+        % delete _
+    End
+
+    Describe lsp#utils#position#lsp_to_vim
+
+        It should return the byte-index from the given character-index on a buffer
+            call setline(1, ['a β c', 'δ', ''])
+            Assert Equals(lsp#utils#position#lsp_to_vim('%', { 'line': 0, 'character': 0 }), [1, 1])
+            Assert Equals(lsp#utils#position#lsp_to_vim('%', { 'line': 0, 'character': 1 }), [1, 2])
+            Assert Equals(lsp#utils#position#lsp_to_vim('%', { 'line': 0, 'character': 2 }), [1, 3])
+            Assert Equals(lsp#utils#position#lsp_to_vim('%', { 'line': 0, 'character': 3 }), [1, 5])
+            Assert Equals(lsp#utils#position#lsp_to_vim('%', { 'line': 0, 'character': 4 }), [1, 6])
+            Assert Equals(lsp#utils#position#lsp_to_vim('%', { 'line': 1, 'character': 0 }), [2, 1])
+            Assert Equals(lsp#utils#position#lsp_to_vim('%', { 'line': 1, 'character': 1 }), [2, 3])
+            Assert Equals(lsp#utils#position#lsp_to_vim('%', { 'line': 2, 'character': 0 }), [3, 1])
+        End
+
+        It should return the byte-index from the given character-index in an unloaded file
+            Assert Equals(lsp#utils#position#lsp_to_vim('./test/testfiles/multibyte.txt', { 'line': 0, 'character': 0 }), [1, 1])
+            Assert Equals(lsp#utils#position#lsp_to_vim('./test/testfiles/multibyte.txt', { 'line': 0, 'character': 1 }), [1, 2])
+            Assert Equals(lsp#utils#position#lsp_to_vim('./test/testfiles/multibyte.txt', { 'line': 0, 'character': 2 }), [1, 3])
+            Assert Equals(lsp#utils#position#lsp_to_vim('./test/testfiles/multibyte.txt', { 'line': 0, 'character': 3 }), [1, 5])
+            Assert Equals(lsp#utils#position#lsp_to_vim('./test/testfiles/multibyte.txt', { 'line': 0, 'character': 4 }), [1, 6])
+            Assert Equals(lsp#utils#position#lsp_to_vim('./test/testfiles/multibyte.txt', { 'line': 1, 'character': 0 }), [2, 1])
+            Assert Equals(lsp#utils#position#lsp_to_vim('./test/testfiles/multibyte.txt', { 'line': 1, 'character': 1 }), [2, 3])
+            Assert Equals(lsp#utils#position#lsp_to_vim('./test/testfiles/multibyte.txt', { 'line': 2, 'character': 0 }), [3, 1])
+        End
+
+    End
+
+    Describe lsp#utils#position#vim_to_lsp
+
+        It should return the character-index from the given byte-index on a buffer
+            call setline(1, ['a β c', 'δ', ''])
+            Assert Equals({ 'line': 0, 'character': 0 }, lsp#utils#position#vim_to_lsp('%', [1, 1]))
+            Assert Equals({ 'line': 0, 'character': 1 }, lsp#utils#position#vim_to_lsp('%', [1, 2]))
+            Assert Equals({ 'line': 0, 'character': 2 }, lsp#utils#position#vim_to_lsp('%', [1, 3]))
+            Assert Equals({ 'line': 0, 'character': 3 }, lsp#utils#position#vim_to_lsp('%', [1, 5]))
+            Assert Equals({ 'line': 0, 'character': 4 }, lsp#utils#position#vim_to_lsp('%', [1, 6]))
+            Assert Equals({ 'line': 1, 'character': 0 }, lsp#utils#position#vim_to_lsp('%', [2, 1]))
+            Assert Equals({ 'line': 1, 'character': 1 }, lsp#utils#position#vim_to_lsp('%', [2, 3]))
+            Assert Equals({ 'line': 2, 'character': 0 }, lsp#utils#position#vim_to_lsp('%', [3, 1]))
+        End
+
+        It should return the character-index from the given byte-index in an unloaded file
+            Assert Equals({ 'line': 0, 'character': 0 }, lsp#utils#position#vim_to_lsp('./test/testfiles/multibyte.txt', [1, 1]))
+            Assert Equals({ 'line': 0, 'character': 1 }, lsp#utils#position#vim_to_lsp('./test/testfiles/multibyte.txt', [1, 2]))
+            Assert Equals({ 'line': 0, 'character': 2 }, lsp#utils#position#vim_to_lsp('./test/testfiles/multibyte.txt', [1, 3]))
+            Assert Equals({ 'line': 0, 'character': 3 }, lsp#utils#position#vim_to_lsp('./test/testfiles/multibyte.txt', [1, 5]))
+            Assert Equals({ 'line': 0, 'character': 4 }, lsp#utils#position#vim_to_lsp('./test/testfiles/multibyte.txt', [1, 6]))
+            Assert Equals({ 'line': 1, 'character': 0 }, lsp#utils#position#vim_to_lsp('./test/testfiles/multibyte.txt', [2, 1]))
+            Assert Equals({ 'line': 1, 'character': 1 }, lsp#utils#position#vim_to_lsp('./test/testfiles/multibyte.txt', [2, 3]))
+            Assert Equals({ 'line': 2, 'character': 0 }, lsp#utils#position#vim_to_lsp('./test/testfiles/multibyte.txt', [3, 1]))
+        End
+
+    End
+
+End