testutils: Allow asserting maps/hashes

This commit is contained in:
Martchus 2017-11-13 20:06:09 +01:00
parent ab42e9d96c
commit cf4789e94d
1 changed files with 9 additions and 0 deletions

View File

@ -189,6 +189,15 @@ template <typename T> AsHexNumber<T> asHexNumber(const T &value)
#define TESTUTILS_ASSERT_EXEC(args) CPPUNIT_ASSERT_EQUAL(0, execApp(args, stdout, stderr))
#endif
/*!
* \brief Allows printing pairs so key/values of maps/hashes can be asserted using CPPUNIT_ASSERT_EQUAL.
*/
template <typename Pair, Traits::EnableIf<Traits::IsSpecializationOf<Pair, std::pair>>...>
inline std::ostream &operator<<(std::ostream &out, const Pair &pair)
{
return out << "key: " << pair.first << "; value: " << pair.second << '\n';
}
/*!
* \brief Allows printing iteratable objects so those can be asserted using CPPUNIT_ASSERT_EQUAL.
*/