#include <cstdlib>
#include <string>
#include <iostream>
#include <testngpp/testngpp.hpp>
USING_TESTNGPP_NS
struct CFoo
{
virtual void foo() = 0;
virtual ~CFoo() {}
};
struct Hell : public CFoo
{
Hell() { p = new char[10]; }
~Hell() { delete [] p; }
void foo() {}
char *p;
};
Hell hell[100];
struct TestBar1 : public TESTNGPP_NS::TestFixture
{
Hell* hellInstance;
struct CBar : public CFoo{
void foo() {}
void testNothing() {}
};
struct CBar;
struct CBar cbar;
struct CBar cbars[2][5];
SETUP()
{
}
TEARDOWN()
{
}
void case10()
{
INFO("this is case 10");
ASSERT_FALSE(true);
}
A possible way to write annotation:
/// @test( depends=load
/// , tags="it fast" )
///
/// @desc("测试ASSERT_TRUE")
void compare(unsigned int a, CFoo* foo)
{
ASSERT_EQ(a, foo->getValue());
}
*/
void case11()
{
INFO("this is case 11");
ASSERT_TRUE(true);
}
TEST(case13)
{ INFO("this is case 13"); }
TEST(case14)
{
INFO("this is case 14");
#if defined(__GNUC__)
ASSERT_TRUE(true);
#endif
}
#if defined(__GNUC__)
TEST(case15)
{
INFO("this is case 15");
ASSERT_FALSE(true);
}
#else
TEST(case16)
{
INFO("this is case 16");
exit(-1);
}
#endif
};
class TestBar2 : public TestFixture
{
public:
void case20()
{
WARN("this test is gonna crash 'coz of invalid memory access");
char* p = 0;
TS_ASSERT(true);
}
};
struct TestBar3 : public TESTNGPP_NS::TestFixture
{
void case30() {ASSERT_FALSE(true);}
void case31()
{}
void case32()
{}
void case33()
{}
void case34()
{}
void case35()
{}
void case36()
{}
void case37()
{}
void case38()
{}
void case39()
{}
};