diff options
author | Max Kellermann <max@musicpd.org> | 2018-10-16 19:01:13 +0200 |
---|---|---|
committer | Max Kellermann <max@musicpd.org> | 2018-10-16 21:26:04 +0200 |
commit | 01b6e1cbf28f54793e22cc40affac7fb03511180 (patch) | |
tree | 5ac27527b2c5f36384f2c42d3907f12fa96067af /test/test_protocol.cxx | |
parent | eefc0f5d80fbcb485db230c3df090b69994a75ce (diff) |
test: use GTest instead of cppunit
Diffstat (limited to 'test/test_protocol.cxx')
-rw-r--r-- | test/test_protocol.cxx | 48 |
1 files changed, 10 insertions, 38 deletions
diff --git a/test/test_protocol.cxx b/test/test_protocol.cxx index b587561a6..86c4a7206 100644 --- a/test/test_protocol.cxx +++ b/test/test_protocol.cxx @@ -4,52 +4,24 @@ #include "protocol/RangeArg.hxx" #include "util/Compiler.h" -#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 <stdlib.h> -class ArgParserTest : public CppUnit::TestFixture { - CPPUNIT_TEST_SUITE(ArgParserTest); - CPPUNIT_TEST(TestRange); - CPPUNIT_TEST_SUITE_END(); - -public: - void TestRange(); -}; - -void -ArgParserTest::TestRange() +TEST(ArgParser, Range) { RangeArg range = ParseCommandArgRange("1"); - CPPUNIT_ASSERT_EQUAL(1u, range.start); - CPPUNIT_ASSERT_EQUAL(2u, range.end); + EXPECT_EQ(1u, range.start); + EXPECT_EQ(2u, range.end); range = ParseCommandArgRange("1:5"); - CPPUNIT_ASSERT_EQUAL(1u, range.start); - CPPUNIT_ASSERT_EQUAL(5u, range.end); + EXPECT_EQ(1u, range.start); + EXPECT_EQ(5u, range.end); range = ParseCommandArgRange("1:"); - CPPUNIT_ASSERT_EQUAL(1u, range.start); - CPPUNIT_ASSERT(range.end >= 999999u); - - try { - range = ParseCommandArgRange("-2"); - CPPUNIT_ASSERT(false); - } catch (const ProtocolError &) { - CPPUNIT_ASSERT(true); - } -} - -CPPUNIT_TEST_SUITE_REGISTRATION(ArgParserTest); + EXPECT_EQ(1u, range.start); + EXPECT_GE(range.end, 999999u); -int -main(gcc_unused int argc, gcc_unused char **argv) -{ - CppUnit::TextUi::TestRunner runner; - auto ®istry = CppUnit::TestFactoryRegistry::getRegistry(); - runner.addTest(registry.makeTest()); - return runner.run() ? EXIT_SUCCESS : EXIT_FAILURE; + EXPECT_THROW(range = ParseCommandArgRange("-2"), + ProtocolError); } |