mirror of
https://github.com/neovim/neovim.git
synced 2025-10-15 06:16:08 +00:00
vim-patch:8.0.1630: trimming white space is not that easy
Problem: Trimming white space is not that easy.
Solution: Add the trim() function. (Bukn, closes vim/vim#1280)
295ac5ab5e
This commit is contained in:
@@ -926,3 +926,26 @@ func Test_redo_in_nested_functions()
|
||||
delfunc Operator
|
||||
delfunc Apply
|
||||
endfunc
|
||||
|
||||
func Test_trim()
|
||||
call assert_equal("Testing", trim(" \t\r\r\x0BTesting \t\n\r\n\t\x0B\x0B"))
|
||||
call assert_equal("Testing", trim(" \t \r\r\n\n\x0BTesting \t\n\r\n\t\x0B\x0B"))
|
||||
call assert_equal("RESERVE", trim("xyz \twwRESERVEzyww \t\t", " wxyz\t"))
|
||||
call assert_equal("wRE \tSERVEzyww", trim("wRE \tSERVEzyww"))
|
||||
call assert_equal("abcd\t xxxx tail", trim(" \tabcd\t xxxx tail"))
|
||||
call assert_equal("\tabcd\t xxxx tail", trim(" \tabcd\t xxxx tail", " "))
|
||||
call assert_equal(" \tabcd\t xxxx tail", trim(" \tabcd\t xxxx tail", "abx"))
|
||||
call assert_equal("RESERVE", trim("你RESERVE好", "你好"))
|
||||
call assert_equal("您R E SER V E早", trim("你好您R E SER V E早好你你", "你好"))
|
||||
call assert_equal("你好您R E SER V E早好你你", trim(" \n\r\r 你好您R E SER V E早好你你 \t \x0B", ))
|
||||
call assert_equal("您R E SER V E早好你你 \t \x0B", trim(" 你好您R E SER V E早好你你 \t \x0B", " 你好"))
|
||||
call assert_equal("您R E SER V E早好你你 \t \x0B", trim(" tteesstttt你好您R E SER V E早好你你 \t \x0B ttestt", " 你好tes"))
|
||||
call assert_equal("您R E SER V E早好你你 \t \x0B", trim(" tteesstttt你好您R E SER V E早好你你 \t \x0B ttestt", " 你你你好好好tttsses"))
|
||||
call assert_equal("留下", trim("这些些不要这些留下这些", "这些不要"))
|
||||
call assert_equal("", trim("", ""))
|
||||
call assert_equal("a", trim("a", ""))
|
||||
call assert_equal("", trim("", "a"))
|
||||
|
||||
let chars = join(map(range(1, 0x20) + [0xa0], {n -> nr2char(n)}), '')
|
||||
call assert_equal("x", trim(chars . "x" . chars))
|
||||
endfunc
|
||||
|
Reference in New Issue
Block a user