summaryrefslogtreecommitdiff
path: root/test/test_protocol.cxx
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2015-12-18 09:50:48 +0100
committerMax Kellermann <max@duempel.org>2015-12-18 09:53:02 +0100
commite939d667d9cbe459add98790c5c8b92d6aa5fa36 (patch)
treeabb4fda3a28dd153439ccb544fabed33a2c438f1 /test/test_protocol.cxx
parent8bb5a565cd9060b3b98bb7b9853fe99703fc18da (diff)
protocol/Ack: add exception class wrapping enum ack
Diffstat (limited to 'test/test_protocol.cxx')
-rw-r--r--test/test_protocol.cxx35
1 files changed, 10 insertions, 25 deletions
diff --git a/test/test_protocol.cxx b/test/test_protocol.cxx
index e683fe2cb..d6c8447e5 100644
--- a/test/test_protocol.cxx
+++ b/test/test_protocol.cxx
@@ -1,6 +1,6 @@
#include "config.h"
#include "protocol/ArgParser.hxx"
-#include "client/Response.hxx"
+#include "protocol/Ack.hxx"
#include "Compiler.h"
#include <cppunit/TestFixture.h>
@@ -10,20 +10,6 @@
#include <stdlib.h>
-static enum ack last_error = ack(-1);
-
-void
-Response::Error(enum ack code, gcc_unused const char *msg)
-{
- last_error = code;
-}
-
-void
-Response::FormatError(enum ack code, gcc_unused const char *fmt, ...)
-{
- last_error = code;
-}
-
class ArgParserTest : public CppUnit::TestFixture {
CPPUNIT_TEST_SUITE(ArgParserTest);
CPPUNIT_TEST(TestRange);
@@ -36,25 +22,24 @@ public:
void
ArgParserTest::TestRange()
{
- Client &client = *(Client *)nullptr;
- Response r(client, 0);
-
- RangeArg range;
-
- CPPUNIT_ASSERT(ParseCommandArg(r, range, "1"));
+ RangeArg range = ParseCommandArgRange("1");
CPPUNIT_ASSERT_EQUAL(1u, range.start);
CPPUNIT_ASSERT_EQUAL(2u, range.end);
- CPPUNIT_ASSERT(ParseCommandArg(r, range, "1:5"));
+ range = ParseCommandArgRange("1:5");
CPPUNIT_ASSERT_EQUAL(1u, range.start);
CPPUNIT_ASSERT_EQUAL(5u, range.end);
- CPPUNIT_ASSERT(ParseCommandArg(r, range, "1:"));
+ range = ParseCommandArgRange("1:");
CPPUNIT_ASSERT_EQUAL(1u, range.start);
CPPUNIT_ASSERT(range.end >= 999999u);
- CPPUNIT_ASSERT(!ParseCommandArg(r, range, "-2"));
- CPPUNIT_ASSERT_EQUAL(ACK_ERROR_ARG, last_error);
+ try {
+ range = ParseCommandArgRange("-2");
+ CPPUNIT_ASSERT(false);
+ } catch (ProtocolError) {
+ CPPUNIT_ASSERT(true);
+ }
}
CPPUNIT_TEST_SUITE_REGISTRATION(ArgParserTest);