Subject: [Boost-bugs] [Boost C++ Libraries] #5615: BOOST_CHECK_EQUAL does not work well with const static members
From: Boost C++ Libraries (noreply_at_[hidden])
Date: 2011-06-16 16:58:37
#5615: BOOST_CHECK_EQUAL does not work well with const static members
------------------------------+---------------------------------------------
Reporter: anonymous | Owner: rogeeff
Type: Feature Requests | Status: new
Milestone: To Be Determined | Component: test
Version: Boost 1.45.0 | Severity: Problem
Keywords: |
------------------------------+---------------------------------------------
I have tried to create set of test cases using
BOOST_AUTO_TEST_CASE_TEMPLATE() macro. Each tested class shares the same
interface, but values returned from functions are different. Therefore I
decided to use helper traits template to avoid code duplication. Each
traits struct contains arguments and expected results for tested classes,
stored as static const values - see example below. Unfortunately this code
does not link successfully - linker complains about missing static struct
members. Fortunately workaround is simple - just copy expected value to
temporary variable and use it in BOOST_CHECK_EQUAL().
Please fix this to allow this code to compile and link successfully,
without using workaround.
{{{
class SomeClass
{
public:
int test(int arg)
{
return arg + 1;
}
};
BOOST_AUTO_TEST_SUITE( Test_err )
template<typename TClass>
struct Tested_class_traits;
template<>
struct Tested_class_traits<SomeClass>
{
static const int arg = 1;
static const int result = 2;
};
typedef boost::mpl::list<
SomeClass
> Tested_types;
BOOST_AUTO_TEST_CASE_TEMPLATE( Test_err_test, TClass, Tested_types )
{
typedef Tested_class_traits<TClass> TestTraits;
TClass obj;
BOOST_CHECK_EQUAL( obj.test(TestTraits::arg), TestTraits::result
);
}
BOOST_AUTO_TEST_SUITE_END()
}}}
-- Ticket URL: <https://svn.boost.org/trac/boost/ticket/5615> 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:06 UTC