37 std::cout <<
"Not equal:\nexpected: " <<
expected <<
"\nactual: " << actual << std::endl;
52 const std::optional<V>& actual,
double tol = 1
e-9) {
54 std::cout <<
"expected is {}, while actual is not" << std::endl;
58 std::cout <<
"actual is {}, while expected is not" << std::endl;
69 std::cout <<
"actual is {}" << std::endl;
77 const std::optional<std::reference_wrapper<const V>>& actual,
double tol = 1
e-9) {
79 std::cout <<
"actual is std::nullopt" << std::endl;
89 template<
class V1,
class V2>
91 typedef typename std::map<V1,V2> Map;
93 if (
expected.size() != actual.size())
95 typename Map::const_iterator
97 itAct = actual.begin();
99 for (; itExp!=
expected.end() && itAct!=actual.end(); ++itExp, ++itAct) {
108 std::cout <<
"expected: " << std::endl;
109 for(
const typename Map::value_type&
a:
expected) {
110 a.first.print(
"key");
111 a.second.print(
" value");
113 std::cout <<
"\nactual: " << std::endl;
114 for(
const typename Map::value_type&
a: actual) {
115 a.first.print(
"key");
116 a.second.print(
" value");
118 std::cout << std::endl;
129 typedef typename std::map<size_t,V2> Map;
131 if (
expected.size() != actual.size())
133 typename Map::const_iterator
135 itAct = actual.begin();
137 for (; itExp!=
expected.end() && itAct!=actual.end(); ++itExp, ++itAct) {
138 if (itExp->first != itAct->first ||
146 std::cout <<
"expected: " << std::endl;
147 for(
const typename Map::value_type&
a:
expected) {
148 std::cout <<
"Key: " <<
a.first << std::endl;
149 a.second.print(
" value");
151 std::cout <<
"\nactual: " << std::endl;
152 for(
const typename Map::value_type&
a: actual) {
153 std::cout <<
"Key: " <<
a.first << std::endl;
154 a.second.print(
" value");
156 std::cout << std::endl;
165 template<
class V1,
class V2>
167 const std::vector<std::pair<V1,V2> >& actual,
double tol = 1
e-9) {
168 typedef typename std::vector<std::pair<V1,V2> > VectorPair;
170 if (
expected.size() != actual.size())
172 typename VectorPair::const_iterator
174 itAct = actual.begin();
176 for (; itExp!=
expected.end() && itAct!=actual.end(); ++itExp, ++itAct) {
185 std::cout <<
"expected: " << std::endl;
186 for(
const typename VectorPair::value_type&
a:
expected) {
187 a.first.print(
" first ");
188 a.second.print(
" second");
190 std::cout <<
"\nactual: " << std::endl;
191 for(
const typename VectorPair::value_type&
a: actual) {
192 a.first.print(
" first ");
193 a.second.print(
" second");
195 std::cout << std::endl;
208 typename V::const_iterator
210 itAct = actual.begin();
212 for (; itExp!=
expected.end() && itAct!=actual.end(); ++itExp, ++itAct) {
218 if(itExp !=
expected.end() || itAct != actual.end())
222 std::cout <<
"expected: " << std::endl;
223 for(
const typename V::value_type&
a:
expected) {
a.print(
" "); }
224 std::cout <<
"\nactual: " << std::endl;
225 for(
const typename V::value_type&
a: actual) {
a.print(
" "); }
226 std::cout << std::endl;
238 typedef typename std::map<size_t,V2> Map;
240 if (
expected.size() != actual.size())
242 typename Map::const_iterator
244 itAct = actual.begin();
246 for (; itExp!=
expected.end() && itAct!=actual.end(); ++itExp, ++itAct) {
247 if (itExp->first != itAct->first || itExp->second != itAct->second) {
254 std::cout <<
"expected: " << std::endl;
255 for(
const typename Map::value_type&
a:
expected) {
256 std::cout <<
"Key: " <<
a.first << std::endl;
257 std::cout <<
"Value: " <<
a.second << std::endl;
259 std::cout <<
"\nactual: " << std::endl;
260 for(
const typename Map::value_type&
a: actual) {
261 std::cout <<
"Key: " <<
a.first << std::endl;
262 std::cout <<
"Value: " <<
a.second << std::endl;
264 std::cout << std::endl;
277 if (
expected.size() != actual.size())
279 typename V::const_iterator
281 itAct = actual.begin();
283 for (; itExp!=
expected.end() && itAct!=actual.end(); ++itExp, ++itAct) {
284 if (*itExp != *itAct) {
291 std::cout <<
"expected: " << std::endl;
292 for(
const typename V::value_type&
a:
expected) { std::cout <<
a <<
" "; }
293 std::cout <<
"\nactual: " << std::endl;
294 for(
const typename V::value_type&
a: actual) { std::cout <<
a <<
" "; }
295 std::cout << std::endl;
307 printf(
"Not equal:\n");
308 std::cout <<
"expected: [" <<
expected <<
"]\n";
309 std::cout <<
"actual: [" << actual <<
"]" << std::endl;
320 printf(
"Erroneously equal:\n");
322 actual.print(
"actual");
334 std::streambuf* old = std::cout.rdbuf(
buffer.rdbuf());
340 std::string actual_ =
buffer.str();
341 std::cout.rdbuf(old);
353 const std::string&
s =
"") {
357 std::streambuf* old = std::cout.rdbuf(
buffer.rdbuf());
363 std::string actual_ =
buffer.str();
364 std::cout.rdbuf(old);