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

Function test_show_all_defines

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

Source from the content-addressed store, hash-verified

41
42
43def test_show_all_defines(tmp_path):
44 test_file = tmp_path / 'test.cpp'
45 with open(test_file, 'wt') as f:
46 f.write("""
47#define DEF_1
48
49void f()
50{
51}
52""")
53
54 rule_file = os.path.join(__rules_dir, 'show-all-defines.rule')
55 args = [
56 '--template=simple',
57 '-DDEF_2',
58 '--rule-file={}'.format(rule_file),
59 str(test_file)
60 ]
61 ret, stdout, stderr = cppcheck(args)
62 assert ret == 0
63 assert stdout.splitlines() == [
64 'Checking {} ...'.format(test_file),
65 'Processing rule: .*',
66 'Checking {}: DEF_2=1...'.format(test_file)
67 ]
68 if sys.platform == 'win32':
69 test_file = str(test_file).replace('\\', '/')
70 assert stderr.splitlines() == [
71 # TODO: this message looks strange
72 ":1:0: information: found ' # line 2 \"{}\" # define DEF_1' [showalldefines]".format(test_file)
73 ]
74
75
76def test_stl(tmp_path):

Callers

nothing calls this directly

Calls 6

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

Tested by

no test coverage detected