Boost logo

Boost :

Subject: Re: [boost] [boost-test] question about using templates for tests
From: Damian Vicino (damian.vicino_at_[hidden])
Date: 2014-07-20 14:21:22


Thank you so much Andrey!

Just in case someone found this thread in the mailing list, this is a working example of the solution proposed in previous emails passing 3 types to evaluate:

using test_types=boost::mpl::list<boost::mpl::vector<int, double, boost::mpl::quote2<std::pair>>,boost::mpl::vector<double, double, boost::mpl::quote2<std::pair>>>;

BOOST_AUTO_TEST_CASE_TEMPLATE( types_match_test, T, test_types ){
    //geting the types
    using A=typename boost::mpl::at<T, boost::mpl::int_<0>>::type;
    using B=typename boost::mpl::at<T, boost::mpl::int_<1>>::type;
    using C=typename boost::mpl::at<T, boost::mpl::int_<2>>::type;
    //creating the variables
    A a=0.5;
    B b=0.5;
    using CAB = typename C::template apply<A,B>::type;
    CAB c(a, b);

    BOOST_CHECK_EQUAL( a, b);
    BOOST_CHECK_EQUAL( c.first, c.second);
}

This fails 2 times and passes 2 times.


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk