Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#12241 closed Bugs (fixed)

Data-driven testing over a range of std::tuple has broken

Reported by: Tony Lewis <tonyelewis@…> Owned by: Raffi Enficiaud
Milestone: Boost 1.62.0 Component: test
Version: Boost 1.61.0 Severity: Regression
Keywords: test, tuple, data-driven, BOOST_DATA_TEST_CASE, std::tuple Cc:

Description

The following code, which compiled and ran under Boost 1.60.0, fails to compile under Boost 1.61.0.

#define BOOST_TEST_MODULE boost_test_tuple_prob

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

#include <tuple>
#include <vector>

const std::vector< std::tuple<int, int>> values = {
        std::tuple<int, int>{  1, 11 },
        std::tuple<int, int>{  2, 12 },
        std::tuple<int, int>{  3, 13 },
};

BOOST_DATA_TEST_CASE( test1, boost::unit_test::data::make( values ), var1, var2 ) {
        std::cout << var1 << ", " << var2 << "\n";
}

The compilation error is around line 66 of boost/test/data/for_each_sample.hpp and it's complaining about tuple_size< const tuple<int, int> &> being an incomplete type. I think the problem is just that tuple_size doesn't work on a const reference type and this can be fixed by changing the T in that line to typename std::decay<T>::type.

If this sort of use of std::tuple isn't supported (see ticket:12240) then I think Boost Test should be fixed to allow the above code but without var2.

Change History (6)

comment:1 by Raffi Enficiaud, 6 years ago

Milestone: To Be DeterminedBoost 1.62.0
Owner: changed from Gennadiy Rozental to Raffi Enficiaud
Status: newassigned

comment:2 by Raffi Enficiaud, 6 years ago

Please give a try to the branch origin/topic/12241-datasets-on-tuples, thanks!

comment:3 by Tony Lewis <tonyelewis@…>, 6 years ago

Apologies for the delay; I've been away.

Yes - that works for me.

comment:4 by Raffi Enficiaud, 6 years ago

Good, this has been merged to master (rev 6abd34d) last week, should be in 1.62.

comment:5 by Raffi Enficiaud, 6 years ago

Resolution: fixed
Status: assignedclosed

Released in 1.62

comment:6 by Tony Lewis <tonyelewis@…>, 6 years ago

Yes - that works for me. Thanks very much for this work.

Note: See TracTickets for help on using tickets.