From 7652a2986b0d0ad55b2776685130f1c68d7108c7 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 6 Aug 2015 22:10:25 +0200 Subject: client/Response: new Client wrapper class for writing responses --- test/test_protocol.cxx | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) (limited to 'test') diff --git a/test/test_protocol.cxx b/test/test_protocol.cxx index d5b60323a..457083aee 100644 --- a/test/test_protocol.cxx +++ b/test/test_protocol.cxx @@ -1,6 +1,6 @@ #include "config.h" #include "protocol/ArgParser.hxx" -#include "protocol/Result.hxx" +#include "client/Response.hxx" #include "Compiler.h" #include @@ -13,10 +13,15 @@ static enum ack last_error = ack(-1); void -command_error(gcc_unused Client &client, enum ack error, - gcc_unused const char *fmt, ...) +Response::Error(enum ack code, gcc_unused const char *msg) { - last_error = error; + last_error = code; +} + +void +Response::FormatError(enum ack code, gcc_unused const char *fmt, ...) +{ + last_error = code; } class ArgParserTest : public CppUnit::TestFixture { @@ -32,22 +37,23 @@ void ArgParserTest::TestRange() { Client &client = *(Client *)nullptr; + Response r(client); RangeArg range; - CPPUNIT_ASSERT(ParseCommandArg(client, range, "1")); + CPPUNIT_ASSERT(ParseCommandArg(r, range, "1")); CPPUNIT_ASSERT_EQUAL(1u, range.start); CPPUNIT_ASSERT_EQUAL(2u, range.end); - CPPUNIT_ASSERT(ParseCommandArg(client, range, "1:5")); + CPPUNIT_ASSERT(ParseCommandArg(r, range, "1:5")); CPPUNIT_ASSERT_EQUAL(1u, range.start); CPPUNIT_ASSERT_EQUAL(5u, range.end); - CPPUNIT_ASSERT(ParseCommandArg(client, range, "1:")); + CPPUNIT_ASSERT(ParseCommandArg(r, range, "1:")); CPPUNIT_ASSERT_EQUAL(1u, range.start); CPPUNIT_ASSERT(range.end >= 999999u); - CPPUNIT_ASSERT(!ParseCommandArg(client, range, "-2")); + CPPUNIT_ASSERT(!ParseCommandArg(r, range, "-2")); CPPUNIT_ASSERT_EQUAL(ACK_ERROR_ARG, last_error); } -- cgit v1.2.3