From cbdc3194cc20aa5abcce8b53c44d46a96002ad3a Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 11 Aug 2015 21:35:52 +0200 Subject: protocol/ArgParser: add struct RangeArg --- test/test_protocol.cxx | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'test') diff --git a/test/test_protocol.cxx b/test/test_protocol.cxx index fb35cbc66..d5b60323a 100644 --- a/test/test_protocol.cxx +++ b/test/test_protocol.cxx @@ -32,21 +32,22 @@ void ArgParserTest::TestRange() { Client &client = *(Client *)nullptr; - unsigned a, b; - CPPUNIT_ASSERT(check_range(client, &a, &b, "1")); - CPPUNIT_ASSERT_EQUAL(1u, a); - CPPUNIT_ASSERT_EQUAL(2u, b); + RangeArg range; - CPPUNIT_ASSERT(check_range(client, &a, &b, "1:5")); - CPPUNIT_ASSERT_EQUAL(1u, a); - CPPUNIT_ASSERT_EQUAL(5u, b); + CPPUNIT_ASSERT(ParseCommandArg(client, range, "1")); + CPPUNIT_ASSERT_EQUAL(1u, range.start); + CPPUNIT_ASSERT_EQUAL(2u, range.end); - CPPUNIT_ASSERT(check_range(client, &a, &b, "1:")); - CPPUNIT_ASSERT_EQUAL(1u, a); - CPPUNIT_ASSERT(b >= 999999u); + CPPUNIT_ASSERT(ParseCommandArg(client, range, "1:5")); + CPPUNIT_ASSERT_EQUAL(1u, range.start); + CPPUNIT_ASSERT_EQUAL(5u, range.end); - CPPUNIT_ASSERT(!check_range(client, &a, &b, "-2")); + CPPUNIT_ASSERT(ParseCommandArg(client, range, "1:")); + CPPUNIT_ASSERT_EQUAL(1u, range.start); + CPPUNIT_ASSERT(range.end >= 999999u); + + CPPUNIT_ASSERT(!ParseCommandArg(client, range, "-2")); CPPUNIT_ASSERT_EQUAL(ACK_ERROR_ARG, last_error); } -- cgit v1.2.3