comparison src/testdir/test_cscope.vim @ 9768:b31da25b19c4 v7.4.2159

commit https://github.com/vim/vim/commit/5971dab1126d6279c6e523f4fedc2f1e6fb9b4c9 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Aug 5 21:25:29 2016 +0200 patch 7.4.2159 Problem: Insufficient testing for cscope. Solution: Add more tests. (Dominique Pelle)
author Christian Brabandt <cb@256bit.org>
date Fri, 05 Aug 2016 21:30:05 +0200
parents ab96eb561a7e
children c470694733db
comparison
equal deleted inserted replaced
9767:27aa753f4dfc 9768:b31da25b19c4
38 set cscopeverbose 38 set cscopeverbose
39 catch 39 catch
40 call assert_true(0) 40 call assert_true(0)
41 endtry 41 endtry
42 call assert_fails('cscope add Xcscope.out', 'E568') 42 call assert_fails('cscope add Xcscope.out', 'E568')
43 call assert_fails('cscope add doesnotexist.out', 'E563')
44 call assert_fails('cscope kill 2', 'E261')
43 " Test 1: Find this C-Symbol 45 " Test 1: Find this C-Symbol
44 let a=execute('cscope find s main') 46 let a=execute('cscope find s main')
45 " Test 1.1 test where it moves the cursor 47 " Test 1.1 test where it moves the cursor
46 call assert_equal('main(void)', getline('.')) 48 call assert_equal('main(void)', getline('.'))
47 " Test 1.2 test the output of the :cs command 49 " Test 1.2 test the output of the :cs command
87 enew 89 enew
88 let a=execute('cscope find i assert.h') 90 let a=execute('cscope find i assert.h')
89 call assert_equal(['','"Xmemfile_test.c" 143L, 3137C','(1 of 1): <<global>> #include <assert.h>'], split(a, '\n', 1)) 91 call assert_equal(['','"Xmemfile_test.c" 143L, 3137C','(1 of 1): <<global>> #include <assert.h>'], split(a, '\n', 1))
90 call assert_equal('#include <assert.h>', getline('.')) 92 call assert_equal('#include <assert.h>', getline('.'))
91 93
92 " Test 9: Find places where this symbol is assigned a value 94 " Test 9: Invalid find command
95 call assert_fails('cs find x', 'E560')
96
97 " Test 10: Find places where this symbol is assigned a value
93 " this needs a cscope >= 15.8 98 " this needs a cscope >= 15.8
94 " unfortunatly, Travis has cscope version 15.7 99 " unfortunately, Travis has cscope version 15.7
95 let cscope_version=systemlist('cscope --version')[0] 100 let cscope_version=systemlist('cscope --version')[0]
96 let cs_version=str2float(matchstr(cscope_version, '\d\+\(\.\d\+\)\?')) 101 let cs_version=str2float(matchstr(cscope_version, '\d\+\(\.\d\+\)\?'))
97 if cs_version >= 15.8 102 if cs_version >= 15.8
98 let a=execute('cscope find a item') 103 let a=execute('cscope find a item')
99 call assert_equal(['', '(1 of 4): <<test_mf_hash>> item = (mf_hashitem_T *)lalloc_clear(sizeof(mf_hashtab_T), FALSE);'], split(a, '\n', 1)) 104 call assert_equal(['', '(1 of 4): <<test_mf_hash>> item = (mf_hashitem_T *)lalloc_clear(sizeof(mf_hashtab_T), FALSE);'], split(a, '\n', 1))
104 call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) 109 call assert_equal(' item = mf_hash_find(&ht, key);', getline('.'))
105 cnext 110 cnext
106 call assert_equal(' item = mf_hash_find(&ht, key);', getline('.')) 111 call assert_equal(' item = mf_hash_find(&ht, key);', getline('.'))
107 endif 112 endif
108 113
109 " Test 10: leading whitespace is not removed for cscope find text 114 " Test 11: leading whitespace is not removed for cscope find text
110 let a=execute('cscope find t test_mf_hash') 115 let a=execute('cscope find t test_mf_hash')
111 call assert_equal(['', '(1 of 1): <<<unknown>>> test_mf_hash();'], split(a, '\n', 1)) 116 call assert_equal(['', '(1 of 1): <<<unknown>>> test_mf_hash();'], split(a, '\n', 1))
112 call assert_equal(' test_mf_hash();', getline('.')) 117 call assert_equal(' test_mf_hash();', getline('.'))
113 118
114 " Test 11: cscope help 119 " Test 12: cscope help
115 let a=execute('cscope help') 120 let a=execute('cscope help')
116 call assert_match('^cscope commands:\n', a) 121 call assert_match('^cscope commands:\n', a)
117 call assert_match('\nadd :', a) 122 call assert_match('\nadd :', a)
118 call assert_match('\nfind :', a) 123 call assert_match('\nfind :', a)
119 call assert_match('\nhelp : Show this message', a) 124 call assert_match('\nhelp : Show this message', a)
120 call assert_match('\nkill : Kill a connection', a) 125 call assert_match('\nkill : Kill a connection', a)
121 call assert_match('\nreset: Reinit all connections', a) 126 call assert_match('\nreset: Reinit all connections', a)
122 call assert_match('\nshow : Show connections', a) 127 call assert_match('\nshow : Show connections', a)
123 128
124 " Test 12: reset connections 129 " Test 13: reset connections
125 let a=execute('cscope reset') 130 let a=execute('cscope reset')
126 call assert_match('\nAdded cscope database.*Xcscope.out (#0)', a) 131 call assert_match('\nAdded cscope database.*Xcscope.out (#0)', a)
127 call assert_match('\nAll cscope databases reset', a) 132 call assert_match('\nAll cscope databases reset', a)
128 133
129 " Test 13: cscope show 134 " Test 14: cscope show
130 let a=execute('cscope show') 135 let a=execute('cscope show')
131 call assert_match('\n 0 \d\+.*Xcscope.out\s*<none>', a) 136 call assert_match('\n 0 \d\+.*Xcscope.out\s*<none>', a)
132 137
133 " Test 14: 'csprg' option 138 " Test 15: cstag and 'csto' option
139 set csto=0
140 let a=execute('cstag TEST_COUNT')
141 call assert_match('(1 of 1): <<TEST_COUNT>> #define TEST_COUNT 50000', a)
142 call assert_equal('#define TEST_COUNT 50000', getline('.'))
143 set csto=1
144 let a=execute('cstag index_to_key')
145 call assert_match('(1 of 1): <<index_to_key>> #define index_to_key(i) ((i) ^ 15167)', a)
146 call assert_equal('#define index_to_key(i) ((i) ^ 15167)', getline('.'))
147 call assert_fails('cstag xxx', 'E257')
148 call assert_fails('cstag', 'E562')
149
150 " Test 15: 'csprg' option
134 call assert_equal('cscope', &csprg) 151 call assert_equal('cscope', &csprg)
152
153 " Test 16: 'cst' option
154 set cst
155 let a=execute('tag TEST_COUNT')
156 call assert_match('(1 of 1): <<TEST_COUNT>> #define TEST_COUNT 50000', a)
157 call assert_equal('#define TEST_COUNT 50000', getline('.'))
158 set nocst
159 call assert_fails('tag TEST_COUNT', 'E426')
135 160
136 " CleanUp 161 " CleanUp
137 call CscopeSetupOrClean(0) 162 call CscopeSetupOrClean(0)
163
164 " cscope command should fail after killing scope connection.
165 call assert_fails('cscope find s main', 'E567')
166
138 endfunc 167 endfunc
139 168
140 " vim: shiftwidth=2 sts=2 expandtab 169 " vim: shiftwidth=2 sts=2 expandtab