Browse Source

Allow printing iteratable objects

So those can be asserted using CPPUNIT_ASSERT_EQUAL
testing/bash_completion_debugging
Martchus 5 years ago
parent
commit
cab1a76ecf
  1. 12
      tests/testutils.h

12
tests/testutils.h

@ -2,6 +2,7 @@
#define TESTUTILS_H
#include "../application/argumentparser.h"
#include "../misc/traits.h"
#include <ostream>
#include <string>
@ -170,6 +171,17 @@ 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 iteratable objects so those can be asserted using CPPUNIT_ASSERT_EQUAL.
*/
template <typename Iteratable, Traits::EnableIf<Traits::IsIteratable<Iteratable>, Traits::Not<Traits::IsString<Iteratable>>>...>
inline std::ostream &operator<<(std::ostream &out, const Iteratable &iteratable)
{
for (const auto &item : iteratable)
out << item << '\n';
return out;
}
}
#endif // TESTUTILS_H

Loading…
Cancel
Save