boostorg / boostorg/test

boost::test complains about the type missing operator<< where the operator is present.

Open
#363 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
213
Forks
149
Avg merge
18h 17m
Merged PRs (30d)
2

Description

I tried to used boost::test with data driven tests, but one of my input samples is `vector`. Boost::test complains about missing operator<< even when I define it.

Self contained example:

```
#define BOOST_TEST_MODULE test module name

#include
#include
#include
#include

using namespace std;
using namespace std::string_literals;

ostream& operator<<(ostream& out, const vector& vs)
{
for (const auto& s:vs) out << s;
return out;
}

//#include
//#include
#include "boost_1_80_0/boost/test/included/unit_test.hpp"
#include "boost_1_80_0/boost/test/data/test_case.hpp"

namespace bdata = boost::unit_test::data;

BOOST_AUTO_TEST_CASE(test_case_name2)
{
cout << vector{"a"};
ostringstream sout;
sout << vector{{"ab"},{"cd"}};
BOOST_TEST(sout.str() == "abcd");
}

BOOST_DATA_TEST_CASE(test_case_name, bdata::make({vector{"a"},vector{"a"},vector{"a"}}), value)
{
}
```

fails to build with the error:

`/usr/include/boost/type_traits/detail/has_binary_operator.hpp:54:150: error: no match for ‘operator<<’ (operand types are ‘std::basic_ostream’ and ‘std::vector >’)`

see attachment for full error log
[error.txt](https://github.com/boostorg/test/files/9996899/error.txt)

If you comment-out the BOOST_DATA_TEST_CASE it builds and run correctly.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.