2017-05-20 23:34:45 +02:00
|
|
|
#ifndef TAGPARSER_TEST_HELPER
|
|
|
|
#define TAGPARSER_TEST_HELPER
|
|
|
|
|
2018-03-05 17:49:29 +01:00
|
|
|
#include "../diagnostics.h"
|
2020-12-13 18:37:15 +01:00
|
|
|
#include "../localehelper.h"
|
2018-03-07 01:17:50 +01:00
|
|
|
#include "../size.h"
|
|
|
|
#include "../tagvalue.h"
|
2017-05-20 23:34:45 +02:00
|
|
|
|
|
|
|
#include <ostream>
|
|
|
|
|
2019-06-10 22:49:11 +02:00
|
|
|
namespace CppUtilities {
|
2017-08-17 18:40:34 +02:00
|
|
|
|
2018-03-07 01:17:50 +01:00
|
|
|
std::ostream &operator<<(std::ostream &os, const TagParser::TagTextEncoding &encoding);
|
2017-05-20 23:34:45 +02:00
|
|
|
|
|
|
|
/*!
|
|
|
|
* \brief Prints a TagValue UTF-8 encoded to enable CPPUNIT_ASSERT_EQUAL for tag values.
|
|
|
|
*/
|
2018-03-07 01:17:50 +01:00
|
|
|
inline std::ostream &operator<<(std::ostream &os, const TagParser::TagValue &tagValue)
|
2017-05-20 23:34:45 +02:00
|
|
|
{
|
2018-03-11 22:24:57 +01:00
|
|
|
os << tagValue.toString(TagParser::TagTextEncoding::Utf8);
|
|
|
|
if (!tagValue.description().empty()) {
|
|
|
|
os << ", description: " << tagValue.description();
|
|
|
|
}
|
|
|
|
return os << " (encoding: " << tagValue.dataEncoding() << ", description encoding: " << tagValue.descriptionEncoding() << ')';
|
2017-05-20 23:34:45 +02:00
|
|
|
}
|
|
|
|
|
2017-06-03 20:38:46 +02:00
|
|
|
/*!
|
2017-08-17 18:43:19 +02:00
|
|
|
* \brief Prints a PositionInSet to enable using it in CPPUNIT_ASSERT_EQUAL.
|
2017-06-03 20:38:46 +02:00
|
|
|
*/
|
2018-03-07 01:17:50 +01:00
|
|
|
inline std::ostream &operator<<(std::ostream &os, const TagParser::PositionInSet &pos)
|
2017-06-03 20:38:46 +02:00
|
|
|
{
|
|
|
|
return os << pos.toString();
|
|
|
|
}
|
|
|
|
|
2018-03-06 21:01:43 +01:00
|
|
|
/*!
|
|
|
|
* \brief Prints a Size to enable using it in CPPUNIT_ASSERT_EQUAL.
|
|
|
|
*/
|
2018-03-07 01:17:50 +01:00
|
|
|
inline std::ostream &operator<<(std::ostream &os, const TagParser::Size &size)
|
2018-03-06 21:01:43 +01:00
|
|
|
{
|
|
|
|
return os << size.toString();
|
|
|
|
}
|
|
|
|
|
2017-08-17 18:43:19 +02:00
|
|
|
/*!
|
2018-03-05 17:49:29 +01:00
|
|
|
* \brief Prints a DiagMessage to enable using it in CPPUNIT_ASSERT_EQUAL.
|
2017-08-17 18:43:19 +02:00
|
|
|
*/
|
2018-03-07 01:17:50 +01:00
|
|
|
inline std::ostream &operator<<(std::ostream &os, const TagParser::DiagMessage &diagMessage)
|
2017-08-17 18:43:19 +02:00
|
|
|
{
|
2018-03-05 17:49:29 +01:00
|
|
|
return os << diagMessage.levelName() << ':' << ' ' << diagMessage.message() << ' ' << '(' << diagMessage.context() << ')';
|
2017-08-17 18:43:19 +02:00
|
|
|
}
|
|
|
|
|
2020-12-13 18:37:15 +01:00
|
|
|
/*!
|
|
|
|
* \brief Prints a Locale to enable using it in CPPUNIT_ASSERT_EQUAL.
|
|
|
|
*/
|
|
|
|
inline std::ostream &operator<<(std::ostream &os, const TagParser::Locale &locale)
|
|
|
|
{
|
|
|
|
return os << locale.toString();
|
|
|
|
}
|
|
|
|
|
2019-06-12 20:40:45 +02:00
|
|
|
} // namespace CppUtilities
|
2017-06-03 20:38:46 +02:00
|
|
|
|
2017-05-20 23:34:45 +02:00
|
|
|
#endif // TAGPARSER_TEST_HELPER
|