mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
test: build_stl_str_hl (#8703)
Improve coverage of `build_stl_str_hl`. Minor removal of dead code in the tested function.
This commit is contained in:
parent
2574f299e5
commit
627cc1b3d8
@ -3273,9 +3273,6 @@ int build_stl_str_hl(
|
||||
// Two `%` in a row is the escape sequence to print a
|
||||
// single `%` in the output buffer.
|
||||
if (*fmt_p == '%') {
|
||||
// Ignore the character if we're out of room in the output buffer.
|
||||
if (out_p >= out_end_p)
|
||||
break;
|
||||
*out_p++ = *fmt_p++;
|
||||
prevchar_isflag = prevchar_isitem = false;
|
||||
continue;
|
||||
|
@ -282,6 +282,12 @@ describe('buffer functions', function()
|
||||
end)
|
||||
end
|
||||
|
||||
-- expression testing
|
||||
statusline_test('Should expand expression', 2,
|
||||
'%!expand(20+1)', '21')
|
||||
statusline_test('Should expand broken expression to itself', 11,
|
||||
'%!expand(20+1', 'expand(20+1')
|
||||
|
||||
-- file name testing
|
||||
statusline_test('should print no file name', 10,
|
||||
'%f', '[No Name]',
|
||||
@ -306,6 +312,12 @@ describe('buffer functions', function()
|
||||
statusline_test('should put fillchar `~` in between text', 10,
|
||||
'abc%=def', 'abc~~~~def',
|
||||
{fillchar=('~'):byte()})
|
||||
statusline_test('should handle zero-fillchar as a space', 10,
|
||||
'abcde%=', 'abcde ',
|
||||
{fillchar=0})
|
||||
statusline_test('should handle multibyte-fillchar as a dash', 10,
|
||||
'abcde%=', 'abcde-----',
|
||||
{fillchar=0x80})
|
||||
statusline_test('should print the tail file name', 80,
|
||||
'%t', 'buffer_spec.lua',
|
||||
{file_name='test/unit/buffer_spec.lua', expected_cell_count=15})
|
||||
@ -352,6 +364,8 @@ describe('buffer functions', function()
|
||||
statusline_test('should truncate at the first `<`', 10,
|
||||
'abc%<def%<ghijklm', 'abc<hijklm')
|
||||
|
||||
statusline_test('should ignore trailing %', 3, 'abc%', 'abc')
|
||||
|
||||
-- alignment testing
|
||||
statusline_test('should right align when using =', 20,
|
||||
'neo%=vim', 'neo vim')
|
||||
@ -452,5 +466,10 @@ describe('buffer functions', function()
|
||||
'Ą%=mid%=end', 'Ą@mid@@end',
|
||||
{fillchar=('@'):byte(), expected_byte_length=11})
|
||||
|
||||
-- escaping % testing
|
||||
statusline_test('should handle escape of %', 4, 'abc%%', 'abc%')
|
||||
statusline_test('case where escaped % does not fit', 3, 'abc%%abcabc', '<bc')
|
||||
statusline_test('escaped % is first', 1, '%%', '%')
|
||||
|
||||
end)
|
||||
end)
|
||||
|
Loading…
Reference in New Issue
Block a user