test: Minor polishing
This commit is contained in:
parent
7a07284c7e
commit
3d6093b970
|
@ -52,6 +52,7 @@ public:
|
||||||
//TEST_CASE( array_index_12 );
|
//TEST_CASE( array_index_12 );
|
||||||
|
|
||||||
TEST_CASE( buffer_overrun_1 );
|
TEST_CASE( buffer_overrun_1 );
|
||||||
|
TEST_CASE( buffer_overrun_2 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
42
tests.cpp
42
tests.cpp
|
@ -21,7 +21,7 @@ bool Debug = false;
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
static unsigned int FailCount, SuccessCount;
|
static unsigned int FailCount, SuccessCount;
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
static void buffer_overrun();
|
|
||||||
static void constructors();
|
static void constructors();
|
||||||
static void operator_eq();
|
static void operator_eq();
|
||||||
static void memleak_in_function();
|
static void memleak_in_function();
|
||||||
|
@ -40,9 +40,6 @@ int main()
|
||||||
// Don't filter out duplicate error messages..
|
// Don't filter out duplicate error messages..
|
||||||
OnlyReportUniqueErrors = false;
|
OnlyReportUniqueErrors = false;
|
||||||
|
|
||||||
// Check that buffer overruns are detected
|
|
||||||
buffer_overrun();
|
|
||||||
|
|
||||||
// Test the constructor-checks
|
// Test the constructor-checks
|
||||||
constructors();
|
constructors();
|
||||||
|
|
||||||
|
@ -115,43 +112,6 @@ static void check(void (chk)(),
|
||||||
}
|
}
|
||||||
//---------------------------------------------------------------------------
|
//---------------------------------------------------------------------------
|
||||||
|
|
||||||
static void buffer_overrun()
|
|
||||||
{
|
|
||||||
// There are 3 sections..
|
|
||||||
// 1. No errors
|
|
||||||
// 2. Array index out of bounds
|
|
||||||
// 3. Buffer overrun
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
////////////////////////////////////////////////
|
|
||||||
// Buffer overrun
|
|
||||||
////////////////////////////////////////////////
|
|
||||||
|
|
||||||
|
|
||||||
code = "void f()\n"
|
|
||||||
"{\n"
|
|
||||||
" char str[3];\n"
|
|
||||||
" strcpy(str, \"abc\");\n"
|
|
||||||
"}\n";
|
|
||||||
check( CheckBufferOverrun, __LINE__, code, "[test.cpp:4]: Buffer overrun\n" );
|
|
||||||
|
|
||||||
|
|
||||||
code = "struct ABC\n"
|
|
||||||
"{\n"
|
|
||||||
" char str[5];\n"
|
|
||||||
"};\n"
|
|
||||||
"\n"
|
|
||||||
"static void f(ABC *abc)\n"
|
|
||||||
"{\n"
|
|
||||||
" strcpy( abc->str, \"abcdef\" );\n"
|
|
||||||
"}\n";
|
|
||||||
check( CheckBufferOverrun, __LINE__, code, "[test.cpp:8]: Buffer overrun\n" );
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
//---------------------------------------------------------------------------
|
|
||||||
|
|
||||||
static void constructors()
|
static void constructors()
|
||||||
{
|
{
|
||||||
// Test1: No constructor
|
// Test1: No constructor
|
||||||
|
|
Loading…
Reference in New Issue