Skip to content

Commit 089ca67

Browse files
Use TODO_ASSERT (cppcheck-opensource#3704)
1 parent 55ff684 commit 089ca67

4 files changed

Lines changed: 134 additions & 51 deletions

File tree

test/testbufferoverrun.cpp

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1093,7 +1093,9 @@ class TestBufferOverrun : public TestFixture {
10931093
" struct s1 obj;\n"
10941094
" x(obj.delay, 123);\n"
10951095
"}");
1096-
// TODO CTU ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:6]: (error) Array 'obj.delay[3]' accessed at index 4, which is out of bounds.\n", errout.str());
1096+
TODO_ASSERT_EQUALS("[test.cpp:11] -> [test.cpp:6]: (error) Array 'obj.delay[3]' accessed at index 4, which is out of bounds.\n",
1097+
"",
1098+
errout.str());
10971099

10981100
check("struct s1 {\n"
10991101
" float a[0];\n"
@@ -2317,7 +2319,9 @@ class TestBufferOverrun : public TestFixture {
23172319
" char x[2];\n"
23182320
" f1(x);\n"
23192321
"}");
2320-
// TODO CTU ASSERT_EQUALS("[test.cpp:6] -> [test.cpp:2]: (error) Array 'x[2]' accessed at index 4, which is out of bounds.\n", errout.str());
2322+
TODO_ASSERT_EQUALS("[test.cpp:6] -> [test.cpp:2]: (error) Array 'x[2]' accessed at index 4, which is out of bounds.\n",
2323+
"",
2324+
errout.str());
23212325
}
23222326

23232327
void array_index_string_literal() {
@@ -3780,7 +3784,9 @@ class TestBufferOverrun : public TestFixture {
37803784
check("void f() {\n"
37813785
" mymemset(\"abc\", 0, 20);\n"
37823786
"}", settings);
3783-
// TODO ASSERT_EQUALS("[test.cpp:2]: (error) Buffer is accessed out of bounds.\n", errout.str());
3787+
TODO_ASSERT_EQUALS("[test.cpp:2]: (error) Buffer is accessed out of bounds.\n",
3788+
"",
3789+
errout.str());
37843790

37853791
check("void f() {\n"
37863792
" mymemset(temp, \"abc\", 4);\n"
@@ -3852,7 +3858,9 @@ class TestBufferOverrun : public TestFixture {
38523858
" char buf[5];\n"
38533859
" a(buf);"
38543860
"}", settings);
3855-
// TODO CTU ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:1]: (error) Buffer is accessed out of bounds: buf\n", errout.str());
3861+
TODO_ASSERT_EQUALS("[test.cpp:4] -> [test.cpp:1]: (error) Buffer is accessed out of bounds: buf\n",
3862+
"",
3863+
errout.str());
38563864
}
38573865

38583866
void minsize_strlen() {

test/testimportproject.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,9 @@ class TestImportProject : public TestFixture {
224224
ASSERT_EQUALS("FILESDIR=\"/some/path\"", importer.fileSettings.begin()->defines);
225225
ASSERT_EQUALS(1, importer.fileSettings.begin()->includePaths.size());
226226
ASSERT_EQUALS("/home/danielm/cppcheck 2/b/lib/", importer.fileSettings.begin()->includePaths.front());
227-
// TODO ASSERT_EQUALS("/home/danielm/cppcheck 2/externals/", importer.fileSettings.begin()->includePaths.back());
227+
TODO_ASSERT_EQUALS("/home/danielm/cppcheck 2/externals/",
228+
"/home/danielm/cppcheck 2/b/lib/",
229+
importer.fileSettings.begin()->includePaths.back());
228230
}
229231

230232
void importCompileCommands8() const {

test/testother.cpp

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2978,7 +2978,9 @@ class TestOther : public TestFixture {
29782978
" strcpy(str, \"b'\");\n"
29792979
" }\n"
29802980
"}", nullptr, false, false, false);
2981-
// TODO ASSERT_EQUALS("[test.cpp:6] -> [test.cpp:8]: (style) Buffer 'str' is being written before its old content has been used. 'break;' missing?\n", errout.str());
2981+
TODO_ASSERT_EQUALS("[test.cpp:6] -> [test.cpp:8]: (style) Buffer 'str' is being written before its old content has been used. 'break;' missing?\n",
2982+
"",
2983+
errout.str());
29822984

29832985
check("void foo(int a) {\n"
29842986
" char str[10];\n"
@@ -2990,7 +2992,9 @@ class TestOther : public TestFixture {
29902992
" strncpy(str, \"b'\");\n"
29912993
" }\n"
29922994
"}");
2993-
// TODO ASSERT_EQUALS("[test.cpp:6] -> [test.cpp:8]: (style) Buffer 'str' is being written before its old content has been used. 'break;' missing?\n", errout.str());
2995+
TODO_ASSERT_EQUALS("[test.cpp:6] -> [test.cpp:8]: (style) Buffer 'str' is being written before its old content has been used. 'break;' missing?\n",
2996+
"",
2997+
errout.str());
29942998

29952999
check("void foo(int a) {\n"
29963000
" char str[10];\n"
@@ -3005,7 +3009,9 @@ class TestOther : public TestFixture {
30053009
" z++;\n"
30063010
" }\n"
30073011
"}", nullptr, false, false, false);
3008-
// TODO ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:10]: (style) Buffer 'str' is being written before its old content has been used. 'break;' missing?\n", errout.str());
3012+
TODO_ASSERT_EQUALS("[test.cpp:7] -> [test.cpp:10]: (style) Buffer 'str' is being written before its old content has been used. 'break;' missing?\n",
3013+
"",
3014+
errout.str());
30093015

30103016
check("void foo(int a) {\n"
30113017
" char str[10];\n"

0 commit comments

Comments
 (0)