using namespace std; #include #include #include #include #include namespace Test{ class A{ public: A(){ cout << "A() called" << endl; } A(const A &a){ cout << "A(A) called" << endl; } virtual ~A(){ cout << "~A() called" << endl; } virtual void hoge() = 0; }; class B : public A{ public: void hoge(){ cout << "hoge called" << endl; } B() : A(){ cout << "B() called" << endl; } B(const B &b) : A(b){ cout << "B(B) called" << endl; } ~B(){ cout << "~B() called" << endl; } }; class C: public B{ private: const int (*int_func)(int); public: C(const int (*_int_func)(int)) : B(), int_func(_int_func){} int test(int arg){return int_func(arg);} }; }; class ClassTestSuite : public Test::Suite{ public: ClassTestSuite(){ TEST_ADD(ClassTestSuite::test1); } protected: virtual void setup(){} virtual void tear_down(){} private: void test1(){ Test::B *b1 = new Test::B(); Test::C *c1 = new Test::C(NULL); c1->test(10); delete b1; } }; bool run_tests(){ ClassTestSuite test_suits; Test::TextOutput output(Test::TextOutput::Verbose); return test_suits.run(output, false); // Note the 'false' parameter } int main(){run_tests();return 0;}