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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
" Test for cinoptions and cindent
"
" TODO: rewrite test3.in into this new style test
func Test_cino_hash()
" Test that curbuf->b_ind_hash_comment is correctly reset
new
setlocal cindent cinoptions=#1
setlocal cinoptions=
call setline(1, ["#include <iostream>"])
call cursor(1, 1)
norm! o#include
"call feedkeys("o#include\<esc>", 't')
call assert_equal(["#include <iostream>", "#include"], getline(1,2))
bwipe!
endfunc
func Test_cino_extern_c()
" Test for cino-E
let without_ind = [
\ '#ifdef __cplusplus',
\ 'extern "C" {',
\ '#endif',
\ 'int func_a(void);',
\ '#ifdef __cplusplus',
\ '}',
\ '#endif'
\ ]
let with_ind = [
\ '#ifdef __cplusplus',
\ 'extern "C" {',
\ '#endif',
\ "\tint func_a(void);",
\ '#ifdef __cplusplus',
\ '}',
\ '#endif'
\ ]
new
setlocal cindent cinoptions=E0
call setline(1, without_ind)
call feedkeys("gg=G", 'tx')
call assert_equal(with_ind, getline(1, '$'))
setlocal cinoptions=E-s
call setline(1, with_ind)
call feedkeys("gg=G", 'tx')
call assert_equal(without_ind, getline(1, '$'))
setlocal cinoptions=Es
let tests = [
\ ['recognized', ['extern "C" {'], "\t\t;"],
\ ['recognized', ['extern "C++" {'], "\t\t;"],
\ ['recognized', ['extern /* com */ "C"{'], "\t\t;"],
\ ['recognized', ['extern"C"{'], "\t\t;"],
\ ['recognized', ['extern "C"', '{'], "\t\t;"],
\ ['not recognized', ['extern {'], "\t;"],
\ ['not recognized', ['extern /*"C"*/{'], "\t;"],
\ ['not recognized', ['extern "C" //{'], ";"],
\ ['not recognized', ['extern "C" /*{*/'], ";"],
\ ]
for pair in tests
let lines = pair[1]
call setline(1, lines)
call feedkeys(len(lines) . "Go;", 'tx')
call assert_equal(pair[2], getline(len(lines) + 1), 'Failed for "' . string(lines) . '"')
endfor
bwipe!
endfunc
" vim: shiftwidth=2 sts=2 expandtab
|