mirror of
https://github.com/dhruvasagar/vim-table-mode.git
synced 2025-11-08 11:03:47 -05:00
Fixing tabular align for unicode characters
This commit is contained in:
18
t/align.vim
Normal file
18
t/align.vim
Normal file
@@ -0,0 +1,18 @@
|
||||
" vim: fdm=indent
|
||||
source t/config.vim
|
||||
|
||||
call vspec#hint({'scope': 'tablemode#align#scope()', 'sid': 'tablemode#align#sid()'})
|
||||
|
||||
describe 'Align'
|
||||
it 'should align table content correctly'
|
||||
let lines = ['| This | is a | table |', '| This | is also | a table |']
|
||||
let result = ['| This | is a | table |', '| This | is also | a table |']
|
||||
Expect tablemode#align#Align(lines) == result
|
||||
end
|
||||
|
||||
it 'should align table content with unicode characters correctly'
|
||||
let lines = ['| This | is 測試 | table |', '| This | is also | a table |']
|
||||
let result = ['| This | is 測試 | table |', '| This | is also | a table |']
|
||||
Expect tablemode#align#Align(lines) == result
|
||||
end
|
||||
end
|
||||
33
t/utils.vim
Normal file
33
t/utils.vim
Normal file
@@ -0,0 +1,33 @@
|
||||
" vim: fdm=indent
|
||||
source t/config.vim
|
||||
|
||||
call vspec#hint({'scope': 'tablemode#utils#scope()', 'sid': 'tablemode#utils#sid()'})
|
||||
|
||||
describe '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
|
||||
|
||||
describe 'strip'
|
||||
it 'should strip all initial or trailing whitespace from a string'
|
||||
let string = ' This is awesome '
|
||||
Expect tablemode#utils#strip(string) == 'This is awesome'
|
||||
end
|
||||
end
|
||||
|
||||
describe 'strlen'
|
||||
it 'should return the length of a string correctly'
|
||||
let string = 'this is a test'
|
||||
Expect tablemode#utils#strlen(string) == 14
|
||||
end
|
||||
|
||||
it 'should return the length of a unicode string correctly'
|
||||
let string = '測試 is good.'
|
||||
Expect tablemode#utils#strlen(string) == 11
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user