Boost logo

Boost Users :

Subject: [Boost-users] [test] how to test std::pair with BOOST_TEST
From: Tan, Tom (Shanghai) (TTan_at_[hidden])
Date: 2016-05-29 08:10:12


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)
C:\3rd\boost_1_61_0\boost/function/function_base.hpp(740): note: could be 'bool boost::operator ==(boost::detail::function::useless_clear_type *,const boost::function_base &)'
C:\3rd\boost_1_61_0\boost/function/function_base.hpp(728): note: or 'bool boost::operator ==(const boost::function_base &,boost::detail::function::useless_clear_type *)'
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\exception(329): note: or 'bool
std::operator ==(const std::exception_ptr &,const std::exception_ptr &) throw()' [found using argument-dependent lookup]
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\exception(334): note: or 'bool
std::operator ==(std::nullptr_t,const std::exception_ptr &) throw()' [found using argument-dependent lookup]
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\exception(339): note: or 'bool
std::operator ==(const std::exception_ptr &,std::nullptr_t) throw()' [found using argument-dependent lookup]
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\system_error(365): note: or 'bool std::operator ==(const std::error_code &,const std::error_code &) noexcept' [found using argument-dependent lookup]
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\system_error(373): note: or 'bool std::operator ==(const std::error_code &,const std::error_condition &) noexcept' [found using argument-dependent lookup]
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\system_error(381): note: or 'bool std::operator ==(const std::error_condition &,const std::error_code &) noexcept' [found using argument-dependent lookup]
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\INCLUDE\system_error(389): note: or 'bool std::operator ==(const std::error_condition &,const std::error_condition &) noexcept' [found using argument-dependent lookup]
C:\3rd\boost_1_61_0\boost/function/function_base.hpp(799): note: or 'bool boost::operator ==<T>(Functor,const boost::function_base &)'
        with
        [
            T=std::pair<int,int>,
            Functor=std::pair<int,int>
        ]
C:\3rd\boost_1_61_0\boost/function/function_base.hpp(790): note: or 'bool boost::operator ==<T>(const boost::function_base &,Functor)'
        with
        [
            T=std::pair<uint32_t,uint32_t>,
            Functor=std::pair<uint32_t,uint32_t>
        ]
C:\3rd\boost_1_61_0\boost/test/tools/assertion.hpp(163): note: while trying to match the argument list '(std::pair<int,int>, std::pair<uint32_t,uint32_t>)'
C:\3rd\boost_1_61_0\boost/test/tools/assertion.hpp(326): note: see reference to class template instantiation 'boost::test_tools::assertion::op::EQ<ValType,T,void>' being compiled
        with
        [
            ValType=std::pair<int,int>,
            T=std::pair<uint32_t,uint32_t>
        ]
s.cpp(14): note: see reference to class template instantiation 'boost::test_tools::assertion::binary_expr<ExprType,std::pair<uint32_t,uint32_t>,boost::test_tools::assertion::op::EQ<ValType,T,void>>' being compiled
        with
        [
            ExprType=boost::test_tools::assertion::value_expr<std::pair<int,int>>,
            ValType=std::pair<int,int>,
            T=std::pair<uint32_t,uint32_t>
        ]
C:\3rd\boost_1_61_0\boost/test/tools/assertion.hpp(377): warning C4624: 'boost::test_tools::assertion::binary_expr<ExprType,std::pair<uint32_t,uint32_t>,boost::test_tools::assertion::op::EQ<ValType,T,void>>': destructor was implicitly defined as deleted
        with
        [
            ExprType=boost::test_tools::assertion::value_expr<std::pair<int,int>>,
            ValType=std::pair<int,int>,
            T=std::pair<uint32_t,uint32_t>
        ]



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