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

Function test_outputfile

test/cli/other_test.py:2680–2712  ·  view source on GitHub ↗
(tmp_path)

Source from the content-addressed store, hash-verified

2678
2679
2680def test_outputfile(tmp_path): # #14051
2681 test_file = tmp_path / 'test.cpp'
2682 out_file = tmp_path / 'out.txt'
2683 with open(test_file, 'wt') as f:
2684 f.write(
2685"""
2686int main()
2687{
2688 int x = 1 / 0;
2689}
2690""")
2691
2692 args = [
2693 '-q',
2694 '--output-file={}'.format(out_file),
2695 str(test_file)
2696 ]
2697
2698 out_exp = [
2699 '{}:4:15: error: Division by zero. [zerodiv]'.format(test_file),
2700 ' int x = 1 / 0;',
2701 ' ^',
2702 ]
2703
2704 exitcode, stdout, stderr = cppcheck(args)
2705 assert exitcode == 0, stdout
2706 assert stdout == ''
2707 assert stderr == ''
2708
2709 with open(out_file, 'rt') as f:
2710 out_text = f.read()
2711
2712 assert out_text.splitlines() == out_exp
2713
2714
2715def test_internal_error_loc_int(tmp_path):

Callers

nothing calls this directly

Calls 5

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

Tested by

no test coverage detected