Need help with BOOST unit test framework!
hi,
Essentially what I'm trying to do(the code is attached below) , is
pass a base class member pointer (member function should
automatically be visible in the derived class) , to the BOOST
framework.
However, since the member function is statically not visible in the
derived class, a compile time error is generated .
I'm *thinking* that some kind of casting operation is required but
not very sure how!
could anybody enlighten me as to how to get the code snippet below
running?
Thanks!
CODE:
#include
#include
better be
#include
using boost::unit_test_framework::test_suite;
class baseTrailTest{ public: baseTrailTest(){}; ~baseTrailTest(){};
you need virtual ~baseTrailTest(){};
protected :
This makes trail() protected and inaccessible at point where you refer to it.
void trail(){ cout << " trail!!!! " << endl; } };
class TrailTest: public baseTrailTest{
You may use public: using baseTrailTest::trail; to provide access to trail();
};
struct trail_test_suite : public test_suite { trail_test_suite() : test_suite("trail_test_suite") { // add member function test cases to a test suite
boost::shared_ptr<TrailTest> instance(new TrailTest);
You need boost::shared_ptr<baseTrailTest> instance(new TrailTest);
add( BOOST_CLASS_TEST_CASE( &TrailTest::trail ,instance ),
0 );
} };
test_suite* init_unit_test_suite( int argc, char * argv[] ) { std::auto_ptr
test( BOOST_TEST_SUITE( "example" ) ); /*if( argc < 2 ) return (test_suite*)0;*/
test->add( new trail_test_suite);
return test.release(); }
participants (2)
-
Gennadiy E. Rozental
-
rudugani