aboutsummaryrefslogtreecommitdiffstats
path: root/test/test_byte_reverse.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2013-10-16 21:55:00 +0200
committerMax Kellermann <max@duempel.org>2013-10-16 23:36:36 +0200
commit401a799a1b5de5d70a6b4c1d49235af0d5618f37 (patch)
tree503db86df98400dac818fa3bbfbe20e2055a1fa4 /test/test_byte_reverse.cxx
parentba98518c69d0501e67ef707f0d718cc678851415 (diff)
downloadmpd-401a799a1b5de5d70a6b4c1d49235af0d5618f37.tar.gz
mpd-401a799a1b5de5d70a6b4c1d49235af0d5618f37.tar.xz
mpd-401a799a1b5de5d70a6b4c1d49235af0d5618f37.zip
test: use the CPPUNIT framework for unit tests
Diffstat (limited to 'test/test_byte_reverse.cxx')
-rw-r--r--test/test_byte_reverse.cxx62
1 files changed, 41 insertions, 21 deletions
diff --git a/test/test_byte_reverse.cxx b/test/test_byte_reverse.cxx
index 67e394454..2730dbdb0 100644
--- a/test/test_byte_reverse.cxx
+++ b/test/test_byte_reverse.cxx
@@ -19,11 +19,34 @@
#include "util/ByteReverse.hxx"
#include "util/Macros.hxx"
+#include "Compiler.h"
-#include <glib.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/extensions/TestFactoryRegistry.h>
+#include <cppunit/ui/text/TestRunner.h>
-static void
-test_byte_reverse_2(void)
+#include <string.h>
+
+class ByteReverseTest : public CppUnit::TestFixture {
+ CPPUNIT_TEST_SUITE(ByteReverseTest);
+ CPPUNIT_TEST(TestByteReverse2);
+ CPPUNIT_TEST(TestByteReverse3);
+ CPPUNIT_TEST(TestByteReverse4);
+ CPPUNIT_TEST(TestByteReverse5);
+ CPPUNIT_TEST_SUITE_END();
+
+public:
+ void TestByteReverse2();
+ void TestByteReverse3();
+ void TestByteReverse4();
+ void TestByteReverse5();
+};
+
+CPPUNIT_TEST_SUITE_REGISTRATION(ByteReverseTest);
+
+void
+ByteReverseTest::TestByteReverse2()
{
static const char src[] = "123456";
static const char result[] = "214365";
@@ -31,11 +54,11 @@ test_byte_reverse_2(void)
reverse_bytes(dest, (const uint8_t *)src,
(const uint8_t *)(src + ARRAY_SIZE(src) - 1), 2);
- g_assert_cmpstr((const char *)dest, ==, result);
+ CPPUNIT_ASSERT(strcmp(result, (const char *)dest) == 0);
}
-static void
-test_byte_reverse_3(void)
+void
+ByteReverseTest::TestByteReverse3()
{
static const char src[] = "123456";
static const char result[] = "321654";
@@ -43,11 +66,11 @@ test_byte_reverse_3(void)
reverse_bytes(dest, (const uint8_t *)src,
(const uint8_t *)(src + ARRAY_SIZE(src) - 1), 3);
- g_assert_cmpstr((const char *)dest, ==, result);
+ CPPUNIT_ASSERT(strcmp(result, (const char *)dest) == 0);
}
-static void
-test_byte_reverse_4(void)
+void
+ByteReverseTest::TestByteReverse4()
{
static const char src[] = "12345678";
static const char result[] = "43218765";
@@ -55,11 +78,11 @@ test_byte_reverse_4(void)
reverse_bytes(dest, (const uint8_t *)src,
(const uint8_t *)(src + ARRAY_SIZE(src) - 1), 4);
- g_assert_cmpstr((const char *)dest, ==, result);
+ CPPUNIT_ASSERT(strcmp(result, (const char *)dest) == 0);
}
-static void
-test_byte_reverse_5(void)
+void
+ByteReverseTest::TestByteReverse5()
{
static const char src[] = "1234567890";
static const char result[] = "5432109876";
@@ -67,17 +90,14 @@ test_byte_reverse_5(void)
reverse_bytes(dest, (const uint8_t *)src,
(const uint8_t *)(src + ARRAY_SIZE(src) - 1), 5);
- g_assert_cmpstr((const char *)dest, ==, result);
+ CPPUNIT_ASSERT(strcmp(result, (const char *)dest) == 0);
}
int
-main(int argc, char **argv)
+main(gcc_unused int argc, gcc_unused char **argv)
{
- g_test_init (&argc, &argv, NULL);
- g_test_add_func("/util/byte_reverse/2", test_byte_reverse_2);
- g_test_add_func("/util/byte_reverse/3", test_byte_reverse_3);
- g_test_add_func("/util/byte_reverse/4", test_byte_reverse_4);
- g_test_add_func("/util/byte_reverse/5", test_byte_reverse_5);
-
- g_test_run();
+ CppUnit::TextUi::TestRunner runner;
+ auto &registry = CppUnit::TestFactoryRegistry::getRegistry();
+ runner.addTest(registry.makeTest());
+ return runner.run() ? EXIT_SUCCESS : EXIT_FAILURE;
}