tagparser/tests/helper.h
Martchus 6b469f1c26 Add Locale class to deal with differently specified languages/countries
Different media/tag formats specify languages and countries
differently. This change introduces a Locale class to keep track
of the format being used. So far there are no automatic conversions
implemented so it is entirely up to the user to pass valid values using
a format which matches the one required by the media/tag format.

This change also adds support for Matroska's IETF elements so at least the
raw value can be read, written and is preserved.
2020-12-16 17:48:08 +01:00

62 lines
1.7 KiB
C++

#ifndef TAGPARSER_TEST_HELPER
#define TAGPARSER_TEST_HELPER
#include "../diagnostics.h"
#include "../localehelper.h"
#include "../size.h"
#include "../tagvalue.h"
#include <ostream>
namespace CppUtilities {
std::ostream &operator<<(std::ostream &os, const TagParser::TagTextEncoding &encoding);
/*!
* \brief Prints a TagValue UTF-8 encoded to enable CPPUNIT_ASSERT_EQUAL for tag values.
*/
inline std::ostream &operator<<(std::ostream &os, const TagParser::TagValue &tagValue)
{
os << tagValue.toString(TagParser::TagTextEncoding::Utf8);
if (!tagValue.description().empty()) {
os << ", description: " << tagValue.description();
}
return os << " (encoding: " << tagValue.dataEncoding() << ", description encoding: " << tagValue.descriptionEncoding() << ')';
}
/*!
* \brief Prints a PositionInSet to enable using it in CPPUNIT_ASSERT_EQUAL.
*/
inline std::ostream &operator<<(std::ostream &os, const TagParser::PositionInSet &pos)
{
return os << pos.toString();
}
/*!
* \brief Prints a Size to enable using it in CPPUNIT_ASSERT_EQUAL.
*/
inline std::ostream &operator<<(std::ostream &os, const TagParser::Size &size)
{
return os << size.toString();
}
/*!
* \brief Prints a DiagMessage to enable using it in CPPUNIT_ASSERT_EQUAL.
*/
inline std::ostream &operator<<(std::ostream &os, const TagParser::DiagMessage &diagMessage)
{
return os << diagMessage.levelName() << ':' << ' ' << diagMessage.message() << ' ' << '(' << diagMessage.context() << ')';
}
/*!
* \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();
}
} // namespace CppUtilities
#endif // TAGPARSER_TEST_HELPER