Boost logo

Boost Users :

Subject: Re: [Boost-users] [test] how to test std::pair with BOOST_TEST
From: Edward Diener (eldiener_at_[hidden])
Date: 2016-05-29 08:31:55


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());
>
> }
>
>
>
> Here’s the error message:
>
> C:\3rd\boost_1_61_0\boost/test/tools/assertion.hpp(163): error C2678:
> binary '==': no operator found which takes a left-hand operand of type
> 'std::pair<int,int>' (or there is no acceptable conversion)

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.


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