-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathstr_test.vim
40 lines (34 loc) · 998 Bytes
/
str_test.vim
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
scriptencoding utf-8
call gopher#init#config()
fun! Test_has_prefix() abort
let l:tests = [
\ ['Hello', 'H', 1],
\ ['Hello', 'Hello', 1],
\ ['€x', '€', 1],
\ ['€£', '€', 1],
\ ['Hello', 'h', 0],
\ ]
for l:tt in l:tests
let [l:str, l:prefix, l:want] = l:tt
let l:out = gopher#str#has_prefix(l:str, l:prefix)
if l:out isnot l:want
call Errorf("has_prefix(%s, %s)\nwant: %d\nout: %d", l:str, l:prefix, l:want, l:out)
endif
endfor
endfun
fun! Test_has_suffix() abort
let l:tests = [
\ ['Hello', 'o', 1],
\ ['Hello', 'Hello', 1],
\ ['x€', '€', 1],
\ ['€£', '£', 1],
\ ['Hello', 'O', 0],
\ ]
for l:tt in l:tests
let [l:str, l:suffix, l:want] = l:tt
let l:out = gopher#str#has_suffix(l:str, l:suffix)
if l:out isnot l:want
call Errorf("has_suffix(%s, %s)\nwant: %d\nout: %d", l:str, l:suffix, l:want, l:out)
endif
endfor
endfun