Opened 7 years ago

Closed 7 years ago

#11889 closed Bugs (fixed)

BOOST_DATA_TEST_CASE fails to compile for 4D and higher dimensional grids

Reported by: Martin Schulze <spam.martin.schulze@…> Owned by: Raffi Enficiaud
Milestone: Boost 1.61.0 Component: test
Version: Boost 1.60.0 Severity: Problem
Keywords: Cc:

Description

Compiling the following code with GCC 5.3.0 (C++11/14) I get an error on the second but not on the first test case.

#include <boost/test/included/unit_test.hpp>
#include <boost/test/data/test_case.hpp>

using boost::unit_test::data::xrange;

BOOST_DATA_TEST_CASE(Test_3D_grid,
                     xrange(2) * xrange(2) * xrange(2), a, b, c) {}

BOOST_DATA_TEST_CASE(Test_4D_grid,
                     xrange(2) * xrange(2) * xrange(2) * xrange(2), a, b, c,
                     d) {}

The error reads

/usr/include/boost/test/data/test_case.hpp:107:5: error: no matching function for call to 'bind(<unresolved overloaded function type>, const std::tuple<int, int, int>&, const int&)'
     BOOST_PP_REPEAT_FROM_TO(1, 4, TC_MAKE, _)

Are four and more parameters not supported for data test cases?

The documentation says

BOOST_DATA_TEST_CASE(test_case_name, dataset, var1, ..., varN) { /* datasets of arity N */ }

without giving any limits on N.

Attachments (2)

reproduction.zip (694 bytes ) - added by Martin Schulze <spam.martin.schulze@…> 7 years ago.
Source and CMake file to reproduce error
reproduction.2.zip (694 bytes ) - added by Martin Schulze <spam.martin.schulze@…> 7 years ago.
Source and CMake file to reproduce error

Download all attachments as: .zip

Change History (16)

by Martin Schulze <spam.martin.schulze@…>, 7 years ago

Attachment: reproduction.zip added

Source and CMake file to reproduce error

by Martin Schulze <spam.martin.schulze@…>, 7 years ago

Attachment: reproduction.2.zip added

Source and CMake file to reproduce error

comment:1 by Martin Schulze <spam.martin.schulze@…>, 7 years ago

The second attachment (reproduction.2.zip) can be ignored. Due to reloading the first got uploaded twice. I apologize for the inconvenience.

comment:2 by Raffi Enficiaud, 7 years ago

You're correct, this piece of information is missing in the documentation. This fix is ready on the branch topic/data-variadic-template of boost.test. Can you please give a try?

comment:3 by Martin Schulze <spam.martin.schulze@…>, 7 years ago

I tried to set up modular boost and compile with that. The error message changed to

/tmp/modular-boost/boost/test/data/for_each_sample.hpp:52:11: 
error: no match for call to 
'(const boost::unit_test::data::ds_detail::test_case_gen<
    Test_4D_grid, boost::unit_test::data::monomorphic::grid<
        boost::unit_test::data::monomorphic::grid<
            boost::unit_test::data::monomorphic::grid<
                boost::unit_test::data::monomorphic::generated_by<
                    boost::unit_test::data::monomorphic::xrange_t<int, int> 
                >,
                boost::unit_test::data::monomorphic::generated_by<
                    boost::unit_test::data::monomorphic::xrange_t<int, int> 
                > 
            >,
            boost::unit_test::data::monomorphic::generated_by<
                boost::unit_test::data::monomorphic::xrange_t<int, int> 
            > 
        >,
        boost::unit_test::data::monomorphic::generated_by<
            boost::unit_test::data::monomorphic::xrange_t<int, int> 
        > 
    > 
>) 
(const int&, const int&, const int&, const int&)'
     action( std::get<I>(args)... );

/tmp/modular-boost/boost/test/data/test_case.hpp:100:13: 
note: candidate: 
template<class Arg0> void boost::unit_test::data::ds_detail::test_case_gen<TestCase, DataSet>::operator()(const Arg0&) const [with Arg0 = Arg0; TestCase = Test_4D_grid; DataSet = boost::unit_test::data::monomorphic::grid<boost::unit_test::data::monomorphic::grid<boost::unit_test::data::monomorphic::grid<boost::unit_test::data::monomorphic::generated_by<boost::unit_test::data::monomorphic::xrange_t<int, int> >, boost::unit_test::data::monomorphic::generated_by<boost::unit_test::data::monomorphic::xrange_t<int, int> > >, boost::unit_test::data::monomorphic::generated_by<boost::unit_test::data::monomorphic::xrange_t<int, int> > >, boost::unit_test::data::monomorphic::generated_by<boost::unit_test::data::monomorphic::xrange_t<int, int> > >]
     void    operator()( BOOST_PP_ENUM_BINARY_PARAMS(arity, Arg, const& arg) ) const \

in expansion of macro ... 

/tmp/modular-boost/boost/test/data/test_case.hpp:107:5: note: in expansion of macro 'BOOST_PP_REPEAT_FROM_TO'
     BOOST_PP_REPEAT_FROM_TO(1, 4, TC_MAKE, _)
     ^
/tmp/modular-boost/boost/test/data/for_each_sample.hpp:52:11: 
note:   candidate expects 1 argument, 4 provided
     action( std::get<I>(args)... );

/tmp/modular-boost/boost/test/data/test_case.hpp:100:13: 
note: candidate: 
template<class Arg0, class Arg1> void boost::unit_test::data::ds_detail::test_case_gen<TestCase, DataSet>::operator()(const Arg0&, const Arg1&) const [with Arg0 = Arg0; Arg1 = Arg1; TestCase = Test_4D_grid; DataSet = boost::unit_test::data::monomorphic::grid<boost::unit_test::data::monomorphic::grid<boost::unit_test::data::monomorphic::grid<boost::unit_test::data::monomorphic::generated_by<boost::unit_test::data::monomorphic::xrange_t<int, int> >, boost::unit_test::data::monomorphic::generated_by<boost::unit_test::data::monomorphic::xrange_t<int, int> > >, boost::unit_test::data::monomorphic::generated_by<boost::unit_test::data::monomorphic::xrange_t<int, int> > >, boost::unit_test::data::monomorphic::generated_by<boost::unit_test::data::monomorphic::xrange_t<int, int> > >]
     void    operator()( BOOST_PP_ENUM_BINARY_PARAMS(arity, Arg, const& arg) ) const \

in expansion of macro ... 

/tmp/modular-boost/boost/test/data/test_case.hpp:107:5: note: in expansion of macro 'BOOST_PP_REPEAT_FROM_TO'
     BOOST_PP_REPEAT_FROM_TO(1, 4, TC_MAKE, _)
     ^
tmp/modular-boost/boost/test/data/for_each_sample.hpp:52:11: note:   candidate expects 2 arguments, 4 provided
     action( std::get<I>(args)... );

/tmp/modular-boost/boost/test/data/test_case.hpp:100:13: 
note: candidate: 
template<class Arg0, class Arg1, class Arg2> void boost::unit_test::data::ds_detail::test_case_gen<TestCase, DataSet>::operator()(const Arg0&, const Arg1&, const Arg2&) const [with Arg0 = Arg0; Arg1 = Arg1; Arg2 = Arg2; TestCase = Test_4D_grid; DataSet = boost::unit_test::data::monomorphic::grid<boost::unit_test::data::monomorphic::grid<boost::unit_test::data::monomorphic::grid<boost::unit_test::data::monomorphic::generated_by<boost::unit_test::data::monomorphic::xrange_t<int, int> >, boost::unit_test::data::monomorphic::generated_by<boost::unit_test::data::monomorphic::xrange_t<int, int> > >, boost::unit_test::data::monomorphic::generated_by<boost::unit_test::data::monomorphic::xrange_t<int, int> > >, boost::unit_test::data::monomorphic::generated_by<boost::unit_test::data::monomorphic::xrange_t<int, int> > >]
     void    operator()( BOOST_PP_ENUM_BINARY_PARAMS(arity, Arg, const& arg) ) const \

/tmp/modular-boost/boost/test/data/test_case.hpp:107:5: note: in expansion of macro 'BOOST_PP_REPEAT_FROM_TO'
     BOOST_PP_REPEAT_FROM_TO(1, 4, TC_MAKE, _)
     ^
/tmp/modular-boost/boost/test/data/for_each_sample.hpp:52:11: note:   candidate expects 3 arguments, 4 provided
     action( std::get<I>(args)... );

when compiling the code in the reproduction.zip

comment:4 by Raffi Enficiaud, 7 years ago

Thank you for your quick feedback, I will have a look into it. As a side note: this feature request was planned but as you may see it is not mature enough.

comment:5 by Raffi Enficiaud, 7 years ago

I just pushed a change to this branch, would you please try again?

comment:6 by Martin Schulze <spam.martin.schulze@…>, 7 years ago

That one compiles. However, I cannot link for now (would have to build boost first), so there are no runtime results from my side yet.

Btw. can't you test the code from reproduction.zip on your machine or did it already work?

comment:7 by Raffi Enficiaud, 7 years ago

I created a similar test case in boost.test already (in the branch), and as for your specific example, you should not have any link issue since you are using the header only variant.

comment:8 by Raffi Enficiaud, 7 years ago

The documentation entry for building boost.test, just in case:

http://www.boost.org/doc/libs/master/libs/test/doc/html/boost_test/adv_scenarios/build_utf.html

comment:9 by Martin Schulze <spam.martin.schulze@…>, 7 years ago

I created a similar test case in boost.test already (in the branch),

So your tests passed but mine didn't?

you should not have any link issue since you are using the header only variant

Yes, I wondered too, but now it is clear that I forgot #define BOOST_TEST_MODULE. After adding that, I got no more linker errors and the tests seem to run correctly.

comment:10 by Raffi Enficiaud, 7 years ago

Perfect, this should be available for the next release.

comment:11 by Raffi Enficiaud, 7 years ago

Owner: changed from Gennadiy Rozental to Raffi Enficiaud

comment:12 by Raffi Enficiaud, 7 years ago

Status: newassigned

comment:13 by Raffi Enficiaud, 7 years ago

Milestone: To Be DeterminedBoost 1.61.0

comment:14 by Raffi Enficiaud, 7 years ago

Resolution: fixed
Status: assignedclosed

Commits:

  • 8ed17b554df2eaf9dfa4849012dc19e150d4c23c
  • 673c7aeb3932d67972659002b38b256d6cc4bdb3
  • 673c7aeb3932d67972659002b38b256d6cc4bdb3
  • 42de00192e0a2f1571d9025bf2207bf19540fe6f

Merged in master: 2b918d0bd56cd2add28a1e35c6a2d0fd8c60cf90

Note: See TracTickets for help on using tickets.