|
#ifndef _UNITTEST_H_
#define _UNITTEST_H_
// A basic test suite with a 'resource' for the tests to use
struct MySuite1 : TestSuite
{
MySuite1() : resource(0) {}
virtual void setup() { resource = 1; }
virtual void teardown() { resource = 0; }
int resource;
};
// A test case in plain ole C++
struct MySuite1Test1 : TestCase
{
const char* name() { return "Test case 1"; }
void test(TestSuite* suite)
{
MySuite1* data = static_cast<MySuite1*>(suite);
data->resource++;
// throw TestMessageException("manual exception");
}
};
// A test case that uses some helper macros
struct MySuite1Test2 : TestCase
{
T_NAME("Test case 2")
void test(TestSuite* suite)
{
T_DATA(data, MySuite1, suite);
data->resource++;
T_ASSERT(1 == 0);
}
};
// A test case with macros turned up to 11
T_TEST(MySuite1, MySuite1Test3)
{
data->resource++;
T_ASSERT(1 == 1);
}
#endif _UNITTEST_H_
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I work as a developer in the Seattle area. I am currently residing in France.