Reflection for RapidJSON 0.0.17
Reflection for serializing/deserializing with RapidJSON
Loading...
Searching...
No Matches
helper.h
Go to the documentation of this file.
1#ifndef REFLECTIVE_RAPIDJSON_TESTS_HELPER_H
2#define REFLECTIVE_RAPIDJSON_TESTS_HELPER_H
3
4#include <c++utilities/conversion/stringconversion.h>
5#include <c++utilities/misc/traits.h>
6#include <c++utilities/tests/testutils.h>
7
8// ensure "operator<<" from TestUtilities is visible prior to the call site
9using CppUtilities::operator<<;
10
11#include <cppunit/extensions/HelperMacros.h>
12
13namespace Traits = CppUtilities::Traits;
14
18template <typename Iteratable, Traits::EnableIf<Traits::IsIteratable<Iteratable>, Traits::Not<Traits::IsString<Iteratable>>> * = nullptr>
19inline void assertEqualityLinewise(const Iteratable &iteratable1, const Iteratable &iteratable2)
20{
21 std::vector<std::string> differentLines;
22 std::size_t currentLine = 0;
23
24 for (auto i1 = iteratable1.cbegin(), i2 = iteratable2.cbegin(); i1 != iteratable1.cend() || i2 != iteratable2.cend(); ++currentLine) {
25 if (i1 != iteratable1.cend() && i2 != iteratable2.cend()) {
26 if (*i1 != *i2) {
27 differentLines.push_back(CppUtilities::numberToString(currentLine));
28 }
29 ++i1, ++i2;
30 } else if (i1 != iteratable1.cend()) {
31 differentLines.push_back(CppUtilities::numberToString(currentLine));
32 ++i1;
33 } else if (i2 != iteratable1.cend()) {
34 differentLines.push_back(CppUtilities::numberToString(currentLine));
35 ++i2;
36 }
37 }
38 if (!differentLines.empty()) {
39 CPPUNIT_ASSERT_EQUAL_MESSAGE("the following lines differ: " + CppUtilities::joinStrings(differentLines, ", "), iteratable1, iteratable2);
40 }
41}
42
43#endif // REFLECTIVE_RAPIDJSON_TESTS_HELPER_H
void assertEqualityLinewise(const Iteratable &iteratable1, const Iteratable &iteratable2)
Asserts equality of two iteratables printing the differing indices.
Definition helper.h:19