boost.test fails to zip custom datasets

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

boost.test fails to zip custom datasets

Boost - Users mailing list
I am trying to understand how to use datasets with the boost.test library. I am following the documentation here 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 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


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: boost.test fails to zip custom datasets

Boost - Users mailing list
AMDG

On 12/07/2017 03:47 PM, Georgios Sermaidis via Boost-users wrote:

> 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 {<snip>
> };
>
> 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.
>
> <snip>
> // 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!
>

The operator is not in scope and cannot be found by ADL.  Try
  using bdata::monomorphic::operator^;

In Christ,
Steven Watanabe

_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users
Reply | Threaded
Open this post in threaded view
|

Re: boost.test fails to zip custom datasets

Boost - Users mailing list
Thank you very much, that did it!


On 8 Dec 2017, at 00:11, Steven Watanabe via Boost-users <[hidden email]> wrote:

Steven Watanabe


_______________________________________________
Boost-users mailing list
[hidden email]
https://lists.boost.org/mailman/listinfo.cgi/boost-users