From cf4789e94d1eb786be120af3c8572eab9ec8fb3b Mon Sep 17 00:00:00 2001 From: Martchus Date: Mon, 13 Nov 2017 20:06:09 +0100 Subject: [PATCH] testutils: Allow asserting maps/hashes --- tests/testutils.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tests/testutils.h b/tests/testutils.h index ff07085..07588ab 100644 --- a/tests/testutils.h +++ b/tests/testutils.h @@ -189,6 +189,15 @@ template AsHexNumber 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 >...> +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. */