|
Boost Testing : |
Subject: [Boost-testing] Boost.Test: ~test_suite() is protected
From: manyu (abhimanyu.aditya_at_[hidden])
Date: 2009-04-16 18:31:02
Hi, I'm new to linux and boost so if I am doing something stupid pardon me. I
am trying to incorporate boost testing into my project. The plan is to build
a bunch of test suites hierarchially. This is the first one I was making:
////////////////////////////////////////////////////////////////// BEGIN
CODE ///////////////////////////////////////////////////////////////
// the test classes
#define EPSILON (1e-5)
// for BOOST testing
#include <boost/test/unit_test.hpp>
#include "allknn.h" // the class being tested
using boost::unit_test_framework::test_suite;
using boost::unit_test_framework::test_case;
class TestAllkNN { // wrapper for the test cases
public:
/* CLASS STUFF */
void TestDualTreeVsNaive1() { /* STUFF */ }
void TestDualTreeVsNaive2() { /* stuff */ }
void TestSingleTreeVsNaive() { /* function */ }
private: // more stuff
};
class TestSuiteAllkNN : public test_suite
{
public:
TestSuiteAllkNN() : test_suite("AllkNN Test Suite.")
{
// create an instance of the test cases class
boost::shared_ptr<TestAllkNN> instance(new TestAllkNN());
// create the test cases
test_case* TestDualTreeVsNaive1 = BOOST_CLASS_TEST_CASE(
&TestAllkNN::TestDualTreeVsNaive1, instance );
test_case* TestDualTreeVsNaive2 = BOOST_CLASS_TEST_CASE(
&TestAllkNN::TestDualTreeVsNaive2, instance );
test_case* TestSingleTreeVsNaive = BOOST_CLASS_TEST_CASE(
&TestAllkNN::TestSingleTreeVsNaive, instance
);
// add the test cases to the test suite
add(TestDualTreeVsNaive1);
add(TestDualTreeVsNaive2);
add(TestSingleTreeVsNaive);
}
};
test_suite* init_unit_test_suite(int arv, char** argc)
{
// create the top test suite
std::auto_ptr<test_suite> top_test_suite(BOOST_TEST_SUITE("Master test
suite"));
top_test_suite->add( new TestSuiteAllkNN() );
return top_test_suite.release();
}
////////////////////////////////////////////////////// END CODE
//////////////////////////////////////////////////////////////
Now when I compile (we have our own build system) I get the following error
... Making
bin/x86_64_Linux_check_gcc_.._.._lib_libboost_unit_test_framework-gcc43-mt-1_38.so.1.38.0/obj/mlpack_allknn_allknn_test.o
/usr/include/boost/test/unit_test_suite_impl.hpp: In destructor
âstd::auto_ptr<_Tp>::~auto_ptr() [with _Tp = boost::unit_test::test_suite]â:
allknn_test.cc:145: instantiated from here
/usr/include/boost/test/unit_test_suite_impl.hpp:130: error: âvirtual
boost::unit_test::test_suite::~test_suite()â is protected
/usr/include/c++/4.3/backward/auto_ptr.h:173: error: within this context
My build command looks like this:
../../script/fl-build
--cflags="../../lib/libboost_unit_test_framework-gcc43-mt-1_38.so.1.38.0"
allknn_test
The take home point from the command is that I am linking to the dynamic
library I have generated for boost.test.
I don't understand this. How do I run my test cases?? Upto the part where
init_unit_test_suite starts compiles just fine. I'm trying to find a way to
run the test. I tried this:
test_suite* test = BOOST_TEST_SUITE( "" );
test->add( TestSuiteAllkNN() );
unit_test::framework::run( test );
But that can't seem to recognize framework or something. I've officially
gone nuts by now.
-- View this message in context: http://www.nabble.com/Boost.Test%3A-%7Etest_suite%28%29-is-protected-tp23087785p23087785.html Sent from the Boost - Testing mailing list archive at Nabble.com.