On 5/29/2016 10:36 AM, ttan wrote:
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?
Something like:
#include <ostream>
template<typename T>
std::ostream & operator << (std::ostream & os,const std::pair
C:\3rd\boost_1_61_0\boost/test/tools/detail/print_helper.hpp(47): error C2338: Type has to implement operator<< to be printable