#ifndef REFLECTIVE_RAPIDJSON_TESTS_HELPER_H #define REFLECTIVE_RAPIDJSON_TESTS_HELPER_H #include #include #include // ensure "operator<<" from TestUtilities is visible prior to the call site using CppUtilities::operator<<; #include namespace Traits = CppUtilities::Traits; /*! * \brief Asserts equality of two iteratables printing the differing indices. */ template , Traits::Not>> * = nullptr> inline void assertEqualityLinewise(const Iteratable &iteratable1, const Iteratable &iteratable2) { std::vector differentLines; std::size_t currentLine = 0; for (auto i1 = iteratable1.cbegin(), i2 = iteratable2.cbegin(); i1 != iteratable1.cend() || i2 != iteratable2.cend(); ++currentLine) { if (i1 != iteratable1.cend() && i2 != iteratable2.cend()) { if (*i1 != *i2) { differentLines.push_back(CppUtilities::numberToString(currentLine)); } ++i1, ++i2; } else if (i1 != iteratable1.cend()) { differentLines.push_back(CppUtilities::numberToString(currentLine)); ++i1; } else if (i2 != iteratable1.cend()) { differentLines.push_back(CppUtilities::numberToString(currentLine)); ++i2; } } if (!differentLines.empty()) { CPPUNIT_ASSERT_EQUAL_MESSAGE("the following lines differ: " + CppUtilities::joinStrings(differentLines, ", "), iteratable1, iteratable2); } } #endif // REFLECTIVE_RAPIDJSON_TESTS_HELPER_H