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

Function test_empty_catch_block

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

Source from the content-addressed store, hash-verified

9
10
11def test_empty_catch_block(tmp_path):
12 test_file = tmp_path / 'test.cpp'
13 with open(test_file, 'wt') as f:
14 f.write("""
15void f()
16{
17 try
18 {
19 }
20 catch (...)
21 {
22 }
23}
24""")
25
26 rule_file = os.path.join(__rules_dir, 'empty-catch-block.xml')
27 args = [
28 '--template=simple',
29 '--rule-file={}'.format(rule_file),
30 str(test_file)
31 ]
32 ret, stdout, stderr = cppcheck(args)
33 assert ret == 0
34 assert stdout.splitlines() == [
35 'Checking {} ...'.format(test_file),
36 'Processing rule: \\}\\s*catch\\s*\\(.*\\)\\s*\\{\\s*\\}'
37 ]
38 assert stderr.splitlines() == [
39 '{}:6:0: style: Empty catch block found. [rule]'.format(test_file)
40 ]
41
42
43def test_show_all_defines(tmp_path):

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