MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / test_unused_deref

Function test_unused_deref

test/cli/rules_test.py:162–186  ·  view source on GitHub ↗
(tmp_path)

Source from the content-addressed store, hash-verified

160
161
162def test_unused_deref(tmp_path):
163 test_file = tmp_path / 'test.cpp'
164 with open(test_file, 'wt') as f:
165 f.write("""
166void f(const char* p)
167{
168 *p++;
169}
170""")
171
172 rule_file = os.path.join(__rules_dir, 'unused-deref.xml')
173 args = [
174 '--template=simple',
175 '--rule-file={}'.format(rule_file),
176 str(test_file)
177 ]
178 ret, stdout, stderr = cppcheck(args)
179 assert ret == 0
180 assert stdout.splitlines() == [
181 'Checking {} ...'.format(test_file),
182 'Processing rule: [;{}] [*] \\w+? (\\+\\+|\\-\\-) ; '
183 ]
184 assert stderr.splitlines() == [
185 '{}:3:0: style: Redundant * found, "*p++" is the same as "*(p++)". [UnusedDeref]'.format(test_file)
186 ]

Callers

nothing calls this directly

Calls 5

cppcheckFunction · 0.90
strFunction · 0.85
formatMethod · 0.80
writeMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected