summaryrefslogtreecommitdiff
path: root/test/test_icy_parser.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@musicpd.org>2018-10-16 19:01:13 +0200
committerMax Kellermann <max@musicpd.org>2018-10-16 21:26:04 +0200
commit01b6e1cbf28f54793e22cc40affac7fb03511180 (patch)
tree5ac27527b2c5f36384f2c42d3907f12fa96067af /test/test_icy_parser.cxx
parenteefc0f5d80fbcb485db230c3df090b69994a75ce (diff)
test: use GTest instead of cppunit
Diffstat (limited to 'test/test_icy_parser.cxx')
-rw-r--r--test/test_icy_parser.cxx56
1 files changed, 18 insertions, 38 deletions
diff --git a/test/test_icy_parser.cxx b/test/test_icy_parser.cxx
index c213f9656..14467ddb6 100644
--- a/test/test_icy_parser.cxx
+++ b/test/test_icy_parser.cxx
@@ -8,10 +8,7 @@
/* include the .cxx file to get access to internal functions */
#include "IcyMetaDataParser.cxx"
-#include <cppunit/TestFixture.h>
-#include <cppunit/extensions/TestFactoryRegistry.h>
-#include <cppunit/ui/text/TestRunner.h>
-#include <cppunit/extensions/HelperMacros.h>
+#include <gtest/gtest.h>
#include <string>
@@ -28,11 +25,11 @@ icy_parse_tag(const char *p)
static void
CompareTagTitle(const Tag &tag, const std::string &title)
{
- CPPUNIT_ASSERT_EQUAL(uint16_t(1), tag.num_items);
+ EXPECT_EQ(uint16_t(1), tag.num_items);
const TagItem &item = *tag.items[0];
- CPPUNIT_ASSERT_EQUAL(TAG_TITLE, item.type);
- CPPUNIT_ASSERT_EQUAL(title, std::string(item.value));
+ EXPECT_EQ(TAG_TITLE, item.type);
+ EXPECT_EQ(title, std::string(item.value));
}
static void
@@ -46,38 +43,21 @@ static void
TestIcyParserEmpty(const char *input)
{
const auto tag = icy_parse_tag(input);
- CPPUNIT_ASSERT_EQUAL(uint16_t(0), tag->num_items);
+ EXPECT_EQ(uint16_t(0), tag->num_items);
}
-class IcyTest : public CppUnit::TestFixture {
- CPPUNIT_TEST_SUITE(IcyTest);
- CPPUNIT_TEST(TestIcyMetadataParser);
- CPPUNIT_TEST_SUITE_END();
-
-public:
- void TestIcyMetadataParser() {
- TestIcyParserEmpty("foo=bar;");
- TestIcyParserTitle("StreamTitle='foo bar'", "foo bar");
- TestIcyParserTitle("StreamTitle='foo bar';", "foo bar");
- TestIcyParserTitle("StreamTitle='foo\"bar';", "foo\"bar");
- TestIcyParserTitle("StreamTitle='foo=bar';", "foo=bar");
- TestIcyParserTitle("a=b;StreamTitle='foo';", "foo");
- TestIcyParserTitle("a=;StreamTitle='foo';", "foo");
- TestIcyParserTitle("a=b;StreamTitle='foo';c=d", "foo");
- TestIcyParserTitle("a=b;StreamTitle='foo'", "foo");
- TestIcyParserTitle("a='b;c';StreamTitle='foo;bar'", "foo;bar");
- TestIcyParserTitle("a='b'c';StreamTitle='foo'bar'", "foo'bar");
- TestIcyParserTitle("StreamTitle='fo'o'b'ar';a='b'c'd'", "fo'o'b'ar");
- }
-};
-
-CPPUNIT_TEST_SUITE_REGISTRATION(IcyTest);
-
-int
-main(gcc_unused int argc, gcc_unused char **argv)
+TEST(IcyMetadataParserTest, Basic)
{
- CppUnit::TextUi::TestRunner runner;
- auto &registry = CppUnit::TestFactoryRegistry::getRegistry();
- runner.addTest(registry.makeTest());
- return runner.run() ? EXIT_SUCCESS : EXIT_FAILURE;
+ TestIcyParserEmpty("foo=bar;");
+ TestIcyParserTitle("StreamTitle='foo bar'", "foo bar");
+ TestIcyParserTitle("StreamTitle='foo bar';", "foo bar");
+ TestIcyParserTitle("StreamTitle='foo\"bar';", "foo\"bar");
+ TestIcyParserTitle("StreamTitle='foo=bar';", "foo=bar");
+ TestIcyParserTitle("a=b;StreamTitle='foo';", "foo");
+ TestIcyParserTitle("a=;StreamTitle='foo';", "foo");
+ TestIcyParserTitle("a=b;StreamTitle='foo';c=d", "foo");
+ TestIcyParserTitle("a=b;StreamTitle='foo'", "foo");
+ TestIcyParserTitle("a='b;c';StreamTitle='foo;bar'", "foo;bar");
+ TestIcyParserTitle("a='b'c';StreamTitle='foo'bar'", "foo'bar");
+ TestIcyParserTitle("StreamTitle='fo'o'b'ar';a='b'c'd'", "fo'o'b'ar");
}