[Boost-bugs] [Boost C++ Libraries] #6749: PARAM_TEST_CASE works poorly with abstract objects

Subject: [Boost-bugs] [Boost C++ Libraries] #6749: PARAM_TEST_CASE works poorly with abstract objects
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2012-03-30 14:52:32


#6749: PARAM_TEST_CASE works poorly with abstract objects
-------------------------------------------------+--------------------------
 Reporter: philipp.moeller@… | Owner: rogeeff
     Type: Feature Requests | Status: new
Milestone: To Be Determined | Component: test
  Version: Boost 1.49.0 | Severity: Cosmetic
 Keywords: |
-------------------------------------------------+--------------------------
 Using abstract classes as arguments to tests works poorly and requires a
 workaround:

 {{{
 #include <boost/test/included/unit_test.hpp>
 #include <boost/test/parameterized_test.hpp>
 #include <boost/test/unit_test_suite.hpp>
 #include <boost/ptr_container/ptr_vector.hpp>
 using namespace boost::unit_test;

 class F {
 public:
   virtual void foo()=0;
   virtual ~F();
 };

 struct D : public F {
   void foo() {}
 };

 void test(const F&) {}
 void test2(const F*) {}

 test_suite*
 init_unit_test_suite()
 {
   boost::ptr_vector<F> params;
   params.push_back(new D);
   // borks
   // boost::unit_test::framework::master_test_suite().
   // add( BOOST_PARAM_TEST_CASE( &test, params.begin(), params.end()));
   F* f = new D;
   F* arr[] = {f};
   framework::master_test_suite().
     add( BOOST_PARAM_TEST_CASE( &test2, arr, arr + 1));

   return 0;
 }

 }}}

 It would be nice this weren't required as it adds the additional burden of
 maintaining memory on the test author and the tests cases shouldn't be
 required to work on pointers.

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/6749>
Boost C++ Libraries <http://www.boost.org/>
Boost provides free peer-reviewed portable C++ source libraries.

This archive was generated by hypermail 2.1.7 : 2017-02-16 18:50:09 UTC