Skip to content

Commit ad913c3

Browse files
committed
testbufferoverrun.cpp: properly reset settings and adjusted some test results
1 parent 3679767 commit ad913c3

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

test/testbufferoverrun.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3451,9 +3451,7 @@ class TestBufferOverrun : public TestFixture {
34513451
"test.cpp:2:note:Assign p, buffer with size 10\n"
34523452
"test.cpp:3:note:Buffer overrun\n", errout.str());
34533453

3454-
// TODO: need to reset this but it breaks other tests
3455-
(void)settingsOld;
3456-
//settings0 = settingsOld;
3454+
settings0 = settingsOld;
34573455
}
34583456

34593457
void buffer_overrun_bailoutIfSwitch() {
@@ -3805,7 +3803,7 @@ class TestBufferOverrun : public TestFixture {
38053803
" std::string hi = \"hi\" + val;\n"
38063804
" std::cout << hi << std::endl;\n"
38073805
"}\n");
3808-
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3]: (portability) Undefined behaviour, pointer arithmetic '\"hi\"+val' is out of bounds.\n", errout.str());
3806+
ASSERT_EQUALS("[test.cpp:3]: (portability) Undefined behaviour, pointer arithmetic '\"hi\"+val' is out of bounds.\n", errout.str());
38093807

38103808
check("void f(const char* s, int len) {\n" // #11026
38113809
" const char* end = s + len;\n"
@@ -4053,14 +4051,14 @@ class TestBufferOverrun : public TestFixture {
40534051
" for (int i = 0; i < 3; i++)\n"
40544052
" a[i] = NULL;\n"
40554053
"}");
4056-
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (error) Array 'a[2]' accessed at index 2, which is out of bounds.\n", errout.str());
4054+
ASSERT_EQUALS("[test.cpp:4]: (error) Array 'a[2]' accessed at index 2, which is out of bounds.\n", errout.str());
40574055

40584056
check("void f() {\n"
40594057
" int **a = new int*[2];\n"
40604058
" for (int i = 0; i < 3; i++)\n"
40614059
" a[i] = NULL;\n"
40624060
"}");
4063-
ASSERT_EQUALS("[test.cpp:3] -> [test.cpp:4]: (error) Array 'a[2]' accessed at index 2, which is out of bounds.\n", errout.str());
4061+
ASSERT_EQUALS("[test.cpp:4]: (error) Array 'a[2]' accessed at index 2, which is out of bounds.\n", errout.str());
40644062
}
40654063

40664064
// statically allocated buffer
@@ -5136,7 +5134,7 @@ class TestBufferOverrun : public TestFixture {
51365134
" int* p = new int[d];\n"
51375135
" return p;\n"
51385136
"}\n");
5139-
ASSERT_EQUALS("[test.cpp:2] -> [test.cpp:3] -> [test.cpp:5]: (warning, inconclusive) Memory allocation size is negative.\n", errout.str());
5137+
ASSERT_EQUALS("[test.cpp:5]: (warning, inconclusive) Memory allocation size is negative.\n", errout.str());
51405138
}
51415139

51425140
void negativeArraySize() {

0 commit comments

Comments
 (0)