Testing: Added macro 'REGISTER_TEST'

This commit is contained in:
Daniel Marjamäki 2008-10-15 06:48:18 +00:00
parent d330eb197a
commit 1978ac3562
6 changed files with 24 additions and 7 deletions

View File

@ -319,6 +319,6 @@ private:
};
static TestBufferOverrun testbufferoverrun;
REGISTER_TEST( TestBufferOverrun );

View File

@ -77,5 +77,5 @@ private:
}
};
static TestCharVar testcharvar;
REGISTER_TEST( TestCharVar );

View File

@ -97,4 +97,4 @@ private:
};
static TestConstructors testconstructors;
REGISTER_TEST( TestConstructors );

View File

@ -128,6 +128,6 @@ private:
}
};
static TestDivision testdivision;
REGISTER_TEST( TestDivision );

View File

@ -61,6 +61,7 @@ private:
TEST_CASE( func2 );
TEST_CASE( class1 );
TEST_CASE( class2 );
}
void simple1()
@ -461,14 +462,29 @@ private:
"}\n" );
ASSERT_EQUALS( std::string("[test.cpp:8]: Memory leak: p\n"), errout.str() );
}
void func6()
{
check( "struct ab\n"
"{\n"
" int a;\n"
" int b;\n"
"};\n"
"\n"
"static void f()\n"
"{\n"
" struct ab *p = malloc(sizeof(struct ab));\n"
" foo(&p->b);\n"
"}\n" );
ASSERT_EQUALS( std::string("[test.cpp:11]: Memory leak: p\n"), errout.str() );
}
*/
void class1()
{
check( "class Fred\n"
@ -526,6 +542,6 @@ private:
};
static TestMemleak testmemleak;
REGISTER_TEST( TestMemleak );

View File

@ -28,4 +28,5 @@ public:
#define TEST_CASE( NAME ) if ( runTest(#NAME) ) NAME ();
#define ASSERT_EQUALS( EXPECTED , ACTUAL ) if (EXPECTED!=ACTUAL) assertFail(__FILE__, __LINE__);
#define REGISTER_TEST( CLASSNAME ) namespace { CLASSNAME instance; };