Boost logo

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
  void TestDualTreeVsNaive1() { /* STUFF */ }
   void TestDualTreeVsNaive2() { /* stuff */ }

  void TestSingleTreeVsNaive() { /* function */ }
 private: // more stuff

class TestSuiteAllkNN : public test_suite
   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


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
    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
/usr/include/boost/test/unit_test_suite_impl.hpp: In destructor
‘std::auto_ptr<_Tp>::~auto_ptr() [with _Tp = boost::unit_test::test_suite]’: 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:

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:
Sent from the Boost - Testing mailing list archive at

Boost-testing list run by mbergal at