mirror of
https://github.com/prabirshrestha/vim-lsp.git
synced 2025-12-14 20:35:59 +01:00
Add tests for lsp#utils#byteindex()
This commit is contained in:
@@ -1,2 +1,3 @@
|
||||
set encoding=utf-8
|
||||
call themis#option('recursive', 1)
|
||||
call themis#helper('command').with(themis#helper('assert'))
|
||||
|
||||
@@ -81,4 +81,32 @@ Describe lsp#utils
|
||||
endfor
|
||||
End
|
||||
End
|
||||
|
||||
Describe lsp#utils#byteindex
|
||||
It should return the byte-index from the given character-index on a buffer
|
||||
call setline(1, ['a β c', 'δ', ''])
|
||||
Assert lsp#utils#byteindex('%', 1, 0) == 1
|
||||
Assert lsp#utils#byteindex('%', 1, 1) == 2
|
||||
Assert lsp#utils#byteindex('%', 1, 2) == 3
|
||||
Assert lsp#utils#byteindex('%', 1, 3) == 5
|
||||
Assert lsp#utils#byteindex('%', 1, 4) == 6
|
||||
Assert lsp#utils#byteindex('%', 1, 5) == 7
|
||||
Assert lsp#utils#byteindex('%', 2, 0) == 1
|
||||
Assert lsp#utils#byteindex('%', 2, 1) == 3
|
||||
Assert lsp#utils#byteindex('%', 3, 0) == 1
|
||||
%delete
|
||||
End
|
||||
|
||||
It should return the byte-index from the given character-index in an unloaded file
|
||||
Assert lsp#utils#byteindex('./test/testfiles/multibyte.txt', 1, 0) == 1
|
||||
Assert lsp#utils#byteindex('./test/testfiles/multibyte.txt', 1, 1) == 2
|
||||
Assert lsp#utils#byteindex('./test/testfiles/multibyte.txt', 1, 2) == 3
|
||||
Assert lsp#utils#byteindex('./test/testfiles/multibyte.txt', 1, 3) == 5
|
||||
Assert lsp#utils#byteindex('./test/testfiles/multibyte.txt', 1, 4) == 6
|
||||
Assert lsp#utils#byteindex('./test/testfiles/multibyte.txt', 1, 5) == 7
|
||||
Assert lsp#utils#byteindex('./test/testfiles/multibyte.txt', 2, 0) == 1
|
||||
Assert lsp#utils#byteindex('./test/testfiles/multibyte.txt', 2, 1) == 3
|
||||
Assert lsp#utils#byteindex('./test/testfiles/multibyte.txt', 3, 0) == 1
|
||||
End
|
||||
End
|
||||
End
|
||||
|
||||
3
test/testfiles/multibyte.txt
Normal file
3
test/testfiles/multibyte.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
a β c
|
||||
δ
|
||||
|
||||
Reference in New Issue
Block a user