Re: [Boost-bugs] [Boost C++ Libraries] #5615: BOOST_CHECK_EQUAL does not work well with const static members

Subject: Re: [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: 2013-01-27 23:15:16


#5615: BOOST_CHECK_EQUAL does not work well with const static members
-------------------------------+--------------------------------------------
  Reporter: anonymous | Owner: rogeeff
      Type: Feature Requests | Status: closed
 Milestone: To Be Determined | Component: test
   Version: Boost 1.45.0 | Severity: Problem
Resolution: wontfix | Keywords:
-------------------------------+--------------------------------------------

Comment (by anonymous):

 Replying to [comment:2 steven_watanabe]:
> This is not unique to Boost.Test. An out of line definition of a static
 constant is required in some circumstances. You can often get away
 without it, but it's safest just to provide it all the time.

 Hi, I've just tried two very similar test cases:

 {{{
 #define BOOST_TEST_MODULE geez
 #include <boost/test/unit_test.hpp>
 #include <boost/tuple/tuple.hpp>
 BOOST_AUTO_TEST_SUITE(foo)
 BOOST_AUTO_TEST_CASE(bar)
 {
   using boost::tuples::length;
   using boost::tuples::tuple;
   BOOST_CHECK_EQUAL( (length<tuple<int, char> >::value), 2);
 }
 BOOST_AUTO_TEST_SUITE_END()
 }}}

 this program won't link:

 {{{
 ptomulik_at_barakus:$ g++ -DBOOST_TEST_DYN_LINK=1 -ansi -Werror -Wall -Wextra
 -pedantic b.cpp -lboost_unit_test_framework
 /tmp/cc1snUGj.o: In function `foo::bar::test_method()':
 b.cpp:(.text+0x188): undefined reference to
 `boost::tuples::length<boost::tuples::tuple<int, char,
 boost::tuples::null_type, boost::tuples::null_type,
 boost::tuples::null_type, boost::tuples::null_type,
 boost::tuples::null_type, boost::tuples::null_type,
 boost::tuples::null_type, boost::tuples::null_type> >::value'
 collect2: error: ld returned 1 exit status
 }}}

 Quite suprising, but when I replace BOOST_CHECK_EQUAL(a,b) with
 BOOST_CHECK(a == b), the program compiles and links smoothly:


 {{{
 #define BOOST_TEST_MODULE geez
 #include <boost/test/unit_test.hpp>
 #include <boost/tuple/tuple.hpp>
 BOOST_AUTO_TEST_SUITE(foo)
 BOOST_AUTO_TEST_CASE(bar)
 {
   using boost::tuples::length;
   using boost::tuples::tuple;
   BOOST_CHECK( (length<tuple<int, char> >::value) == 2);
 }
 BOOST_AUTO_TEST_SUITE_END()
 }}}


 {{{
 ptomulik_at_barakus:$ g++ -DBOOST_TEST_DYN_LINK=1 -ansi -Werror -Wall -Wextra
 -pedantic b.cpp -lboost_unit_test_framework
 ptomulik_at_barakus:$
 }}}

 This is quite strange, and looks like bug in boost test framework, boost
 tuple implementation or elsewhere.

 Note, that very similar code with BOOST_CHECK_EQUAL but for std::tuple
 compiles and links just fine:


 {{{
 #define BOOST_TEST_MODULE geez
 #include <boost/test/unit_test.hpp>
 #include <tuple>
 BOOST_AUTO_TEST_SUITE(foo)
 BOOST_AUTO_TEST_CASE(bar)
 {
   using std::tuple_size;
   using std::tuple;
   BOOST_CHECK_EQUAL( (tuple_size<tuple<int, char> >::value), 2);
 }
 BOOST_AUTO_TEST_SUITE_END()
 }}}


 {{{
 ptomulik_at_barakus:$ g++ -DBOOST_TEST_DYN_LINK=1 -ansi -std=c++11 -Werror
 -Wall -Wextra -pedantic b.cpp -lboost_unit_test_framework
 ptomulik_at_barakus:$
 }}}

-- 
Ticket URL: <https://svn.boost.org/trac/boost/ticket/5615#comment:3>
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:11 UTC