Modify

#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@…> 23 months ago.
Source and CMake file to reproduce error
reproduction.2.zip (694 bytes) - added by Martin Schulze <spam.martin.schulze@…> 23 months ago.
Source and CMake file to reproduce error

Download all attachments as: .zip

Change History (16)

Changed 23 months ago by Martin Schulze <spam.martin.schulze@…>

Attachment: reproduction.zip added

Source and CMake file to reproduce error

Changed 23 months ago by Martin Schulze <spam.martin.schulze@…>

Attachment: reproduction.2.zip added

Source and CMake file to reproduce error

comment:1 Changed 23 months ago by Martin Schulze <spam.martin.schulze@…>

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

comment:2 Changed 23 months ago by Raffi Enficiaud

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 Changed 23 months ago by Martin Schulze <spam.martin.schulze@…>

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 Changed 23 months ago by Raffi Enficiaud

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 Changed 23 months ago by Raffi Enficiaud

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

comment:6 Changed 23 months ago by Martin Schulze <spam.martin.schulze@…>

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 Changed 23 months ago by Raffi Enficiaud

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 Changed 23 months ago by Raffi Enficiaud

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 Changed 23 months ago by Martin Schulze <spam.martin.schulze@…>

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 Changed 23 months ago by Raffi Enficiaud

Perfect, this should be available for the next release.

comment:11 Changed 23 months ago by Raffi Enficiaud

Owner: changed from Gennadiy Rozental to Raffi Enficiaud

comment:12 Changed 23 months ago by Raffi Enficiaud

Status: newassigned

comment:13 Changed 23 months ago by Raffi Enficiaud

Milestone: To Be DeterminedBoost 1.61.0

comment:14 Changed 22 months ago by Raffi Enficiaud

Resolution: fixed
Status: assignedclosed

Commits:

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

Merged in master: 2b918d0bd56cd2add28a1e35c6a2d0fd8c60cf90

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Raffi Enficiaud.
The resolution will be deleted.

Add Comment


E-mail address and name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.