mirror of
https://github.com/dhruvasagar/vim-table-mode.git
synced 2025-11-11 04:23:47 -05:00
Improved test for utils
This commit is contained in:
@@ -52,9 +52,7 @@ function! tablemode#utils#strlen(text)
|
|||||||
return strlen(substitute(a:text, '.', 'x', 'g'))
|
return strlen(substitute(a:text, '.', 'x', 'g'))
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
" Return the number of bytes in a string after expanding tabs to spaces. {{{2
|
function! tablemode#utils#StrDisplayWidth(string) "{{{2
|
||||||
" This expansion is done based on the current value of 'tabstop'
|
|
||||||
function! tablemode#utils#StrDisplayWidth(string)
|
|
||||||
if exists('*strdisplaywidth')
|
if exists('*strdisplaywidth')
|
||||||
return strdisplaywidth(a:string)
|
return strdisplaywidth(a:string)
|
||||||
else
|
else
|
||||||
@@ -77,4 +75,3 @@ function! tablemode#utils#StrDisplayWidth(string)
|
|||||||
return rv
|
return rv
|
||||||
endif
|
endif
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
|
|||||||
62
t/utils.vim
62
t/utils.vim
@@ -3,31 +3,45 @@ source t/config/options.vim
|
|||||||
|
|
||||||
call vspec#hint({'scope': 'tablemode#utils#scope()', 'sid': 'tablemode#utils#sid()'})
|
call vspec#hint({'scope': 'tablemode#utils#scope()', 'sid': 'tablemode#utils#sid()'})
|
||||||
|
|
||||||
describe 'line'
|
describe 'utils'
|
||||||
it 'should return the current line number'
|
describe 'line'
|
||||||
Expect tablemode#utils#line('.') == line('.')
|
it 'should return the current line number'
|
||||||
|
Expect tablemode#utils#line('.') == line('.')
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should return the line number itself if it is a number'
|
||||||
|
Expect tablemode#utils#line(1) == 1
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
it 'should return the line number itself if it is a number'
|
describe 'strip'
|
||||||
Expect tablemode#utils#line(1) == 1
|
it 'should strip all initial or trailing whitespace from a string'
|
||||||
end
|
let string = ' This is awesome '
|
||||||
end
|
Expect tablemode#utils#strip(string) == 'This is awesome'
|
||||||
|
end
|
||||||
describe 'strip'
|
end
|
||||||
it 'should strip all initial or trailing whitespace from a string'
|
|
||||||
let string = ' This is awesome '
|
describe 'strlen'
|
||||||
Expect tablemode#utils#strip(string) == 'This is awesome'
|
it 'should return the length of a string correctly'
|
||||||
end
|
let string = 'this is a test'
|
||||||
end
|
Expect tablemode#utils#strlen(string) == 14
|
||||||
|
end
|
||||||
describe 'strlen'
|
|
||||||
it 'should return the length of a string correctly'
|
it 'should return the length of a unicode string correctly'
|
||||||
let string = 'this is a test'
|
let string = '測試 is good.'
|
||||||
Expect tablemode#utils#strlen(string) == 14
|
Expect tablemode#utils#strlen(string) == 11
|
||||||
end
|
end
|
||||||
|
end
|
||||||
it 'should return the length of a unicode string correctly'
|
|
||||||
let string = '測試 is good.'
|
describe 'strdisplaywidth'
|
||||||
Expect tablemode#utils#strlen(string) == 11
|
it 'should return the display width of a string correctly'
|
||||||
|
let string = 'this is a test'
|
||||||
|
Expect tablemode#utils#StrDisplayWidth(string) == 14
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should return the display width of a unicode string correctly'
|
||||||
|
let string = '測試 is good.'
|
||||||
|
Expect tablemode#utils#StrDisplayWidth(string) == 13
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user