Boost logo

Boost Users :

Subject: Re: [Boost-users] [test] how to test std::pair with BOOST_TEST
From: ttan (TTan_at_[hidden])
Date: 2016-05-29 10:36:29


Edward Diener-3 wrote
> On 5/29/2016 8:10 AM, Tan, Tom (Shanghai) wrote:
>> The following snippet does not compile with VS2015 and boost 1.61. What
>> should the correct way to do it? Thanks.
>>
>>>
>> // compile with cl.exe /EHSc
>>
>> #define BOOST_TEST_MODULE pair
>>
>> #include <boost/test/included/unit_test.hpp>
>>
>>
>>
>> std::pair<uint32_t, uint32_t> v()
>>
>> {
>>
>> return std::make_pair(0, 0);
>>
>> }
>>
>> BOOST_AUTO_TEST_CASE(range)
>>
>> {
>>> BOOST_TEST(std::make_pair(0, 0) == v());
>>> }
>>
>>
>
> std::make_pair(0,0) returns a value with the type std::pair<int,int>
> whereas v() returns a variable of the type
> std::pair<uint32_t,uint32_t>.
> These are different types and there is no equality operator to compare
> them.

Thanks, my code above is misleading. Iwas actually intended to illustrate
the support of std::pair by BOOST_TEST, like below

BOOST_AUTO_TEST_CASE(range)
{
    (std::make_pair(uint32_t(0), uint32_t(0)) == v()); // this is OK
    BOOST_TEST(std::make_pair(uint32_t(0), uint32_t(0)) == v()); // this not
}

judging from the error, operator << is not support by std::pair in
boost.test. What is the best way, I mean where, to add the support?

C:\3rd\boost_1_61_0\boost/test/tools/detail/print_helper.hpp(47): error
C2338: Type has to implement operator<< to be printable

--
View this message in context: http://boost.2283326.n4.nabble.com/test-how-to-test-std-pair-with-BOOST-TEST-tp4686592p4686595.html
Sent from the Boost - Users mailing list archive at Nabble.com.

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