Boost logo

Boost Users :

Subject: [Boost-users] boost.test fails to zip custom datasets
From: Georgios Sermaidis (g.sermaidis_at_[hidden])
Date: 2017-12-07 22:47:13


I am trying to understand how to use datasets with the boost.test library. I am following the documentation here <http://www.boost.org/doc/libs/1_65_1/libs/test/doc/html/boost_test/tests_organization/test_cases/test_case_generation/datasets.html> and have created my dataset as follows:

namespace bdata = boost::unit_test::data;

struct test_set {

    class iterator {

        int m_a;

    public:

        iterator()
        : m_a(0){}

        void operator++() {
            ++m_a;
        }

        int operator*() const {
            return m_a;
        }
    };

    using sample = int;
    enum {arity = 1};

    auto begin() const {
        return iterator{};
    }

    bdata::size_t size() const {
        return 5; // let's assume only 5 numbers
    }
};

namespace boost { namespace unit_test { namespace data { namespace monomorphic {

                template <>
                struct is_dataset<test_set> : std::true_type{};
            }}}}
which is very simple and iterates numbers from 0 to 4.

The following simple test compiles and runs just fine:

// this works as expected and prints 0, 1, 2, 3, 4
BOOST_DATA_TEST_CASE(
example_test1,
test_set(),
my_datum) {

        std::cout << my_datum << std::endl;
}
However, when I try to zip <http://www.boost.org/doc/libs/1_65_1/libs/test/doc/html/boost_test/tests_organization/test_cases/test_case_generation/operations.html#boost_test.tests_organization.test_cases.test_case_generation.operations.zips> two such datasets it fails to compile (Apple LLVM version 9.0.0 (clang-900.0.38)):

// error: invalid operands to binary expression ('typename data::result_of::make<test_set>::type' (aka 'test_set') and 'test_set') test_set() ^ test_set(),
// ~~~~~~~~~~~^~~~~~~~~~~~~
BOOST_DATA_TEST_CASE(
example_test2,
test_set() ^ test_set(),
my_datum1, my_datum2) {

        std::cout << my_datum1 << " " << my_datum2 << std::endl;
}
Is what I am trying to do legal? If so, what is the correct way to achieve it? Thank you for your help!

Live code here <https://wandbox.org/permlink/6CI286mynvVCjQdW>



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net