Changeset 2983 for box/trunk/test/basicserver
- Timestamp:
- 27/08/2011 15:06:46 (9 months ago)
- Location:
- box/trunk/test/basicserver
- Files:
-
- 3 edited
-
Makefile.extra (modified) (1 diff)
-
TestCommands.cpp (modified) (5 diffs)
-
testbasicserver.cpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
box/trunk/test/basicserver/Makefile.extra
r2598 r2983 2 2 MAKEPROTOCOL = ../../lib/server/makeprotocol.pl 3 3 4 GEN_CMD_SRV = $(MAKEPROTOCOL) Server testprotocol.txt 5 GEN_CMD_CLI = $(MAKEPROTOCOL) Client testprotocol.txt 4 GEN_CMD = $(MAKEPROTOCOL) testprotocol.txt 6 5 7 6 # AUTOGEN SEEDING 8 autogen_TestProtocol Server.cpp: $(MAKEPROTOCOL) testprotocol.txt9 $(_PERL) $(GEN_CMD _SRV)7 autogen_TestProtocol.cpp: $(MAKEPROTOCOL) testprotocol.txt 8 $(_PERL) $(GEN_CMD) 10 9 11 10 autogen_TestProtocolServer.h: $(MAKEPROTOCOL) testprotocol.txt 12 $(_PERL) $(GEN_CMD _SRV)11 $(_PERL) $(GEN_CMD) 13 12 14 15 # AUTOGEN SEEDING16 autogen_TestProtocolClient.cpp: $(MAKEPROTOCOL) testprotocol.txt17 $(_PERL) $(GEN_CMD_CLI)18 19 autogen_TestProtocolClient.h: $(MAKEPROTOCOL) testprotocol.txt20 $(_PERL) $(GEN_CMD_CLI)21 -
box/trunk/test/basicserver/TestCommands.cpp
r710 r2983 6 6 #endif 7 7 8 #include "autogen_TestProtocol Server.h"8 #include "autogen_TestProtocol.h" 9 9 #include "CollectInBufferStream.h" 10 10 … … 12 12 13 13 14 std::auto_ptr< ProtocolObject> TestProtocolServerHello::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext)14 std::auto_ptr<TestProtocolMessage> TestProtocolHello::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 15 15 { 16 16 if(mNumber32 != 41 || mNumber16 != 87 || mNumber8 != 11 || mText != "pingu") 17 17 { 18 return std::auto_ptr< ProtocolObject>(new TestProtocolServerError(0, 0));18 return std::auto_ptr<TestProtocolMessage>(new TestProtocolError(0, 0)); 19 19 } 20 return std::auto_ptr< ProtocolObject>(new TestProtocolServerHello(12,89,22,std::string("Hello world!")));20 return std::auto_ptr<TestProtocolMessage>(new TestProtocolHello(12,89,22,std::string("Hello world!"))); 21 21 } 22 22 23 std::auto_ptr< ProtocolObject> TestProtocolServerLists::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext)23 std::auto_ptr<TestProtocolMessage> TestProtocolLists::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 24 24 { 25 return std::auto_ptr< ProtocolObject>(new TestProtocolServerListsReply(mLotsOfText.size()));25 return std::auto_ptr<TestProtocolMessage>(new TestProtocolListsReply(mLotsOfText.size())); 26 26 } 27 27 28 std::auto_ptr< ProtocolObject> TestProtocolServerQuit::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext)28 std::auto_ptr<TestProtocolMessage> TestProtocolQuit::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 29 29 { 30 return std::auto_ptr< ProtocolObject>(new TestProtocolServerQuit);30 return std::auto_ptr<TestProtocolMessage>(new TestProtocolQuit); 31 31 } 32 32 33 std::auto_ptr< ProtocolObject> TestProtocolServerSimple::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext)33 std::auto_ptr<TestProtocolMessage> TestProtocolSimple::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 34 34 { 35 return std::auto_ptr< ProtocolObject>(new TestProtocolServerSimpleReply(mValue+1));35 return std::auto_ptr<TestProtocolMessage>(new TestProtocolSimpleReply(mValue+1)); 36 36 } 37 37 … … 46 46 }; 47 47 48 std::auto_ptr< ProtocolObject> TestProtocolServerGetStream::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext)48 std::auto_ptr<TestProtocolMessage> TestProtocolGetStream::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 49 49 { 50 50 // make a new stream object … … 69 69 rProtocol.SendStreamAfterCommand(pstream); 70 70 71 return std::auto_ptr< ProtocolObject>(new TestProtocolServerGetStream(mStartingValue, mUncertainSize));71 return std::auto_ptr<TestProtocolMessage>(new TestProtocolGetStream(mStartingValue, mUncertainSize)); 72 72 } 73 73 74 std::auto_ptr< ProtocolObject> TestProtocolServerSendStream::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext)74 std::auto_ptr<TestProtocolMessage> TestProtocolSendStream::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 75 75 { 76 76 if(mValue != 0x73654353298ffLL) 77 77 { 78 return std::auto_ptr< ProtocolObject>(new TestProtocolServerError(0, 0));78 return std::auto_ptr<TestProtocolMessage>(new TestProtocolError(0, 0)); 79 79 } 80 80 … … 92 92 93 93 // tell the caller how many bytes there were 94 return std::auto_ptr< ProtocolObject>(new TestProtocolServerGetStream(bytes, uncertain));94 return std::auto_ptr<TestProtocolMessage>(new TestProtocolGetStream(bytes, uncertain)); 95 95 } 96 96 97 std::auto_ptr< ProtocolObject> TestProtocolServerString::DoCommand(TestProtocolServer &rProtocol, TestContext &rContext)97 std::auto_ptr<TestProtocolMessage> TestProtocolString::DoCommand(TestProtocolReplyable &rProtocol, TestContext &rContext) const 98 98 { 99 return std::auto_ptr< ProtocolObject>(new TestProtocolServerString(mTest));99 return std::auto_ptr<TestProtocolMessage>(new TestProtocolString(mTest)); 100 100 } 101 101 -
box/trunk/test/basicserver/testbasicserver.cpp
r2942 r2983 27 27 28 28 #include "TestContext.h" 29 #include "autogen_TestProtocolClient.h" 30 #include "autogen_TestProtocolServer.h" 29 #include "autogen_TestProtocol.h" 31 30 #include "ServerControl.h" 32 31 … … 394 393 void TestStreamReceive(TestProtocolClient &protocol, int value, bool uncertainstream) 395 394 { 396 std::auto_ptr<TestProtocol ClientGetStream> reply(protocol.QueryGetStream(value, uncertainstream));395 std::auto_ptr<TestProtocolGetStream> reply(protocol.QueryGetStream(value, uncertainstream)); 397 396 TEST_THAT(reply->GetStartingValue() == value); 398 397 … … 705 704 // Simple query 706 705 { 707 std::auto_ptr<TestProtocol ClientSimpleReply> reply(protocol.QuerySimple(41));706 std::auto_ptr<TestProtocolSimpleReply> reply(protocol.QuerySimple(41)); 708 707 TEST_THAT(reply->GetValuePlusOne() == 42); 709 708 } 710 709 { 711 std::auto_ptr<TestProtocol ClientSimpleReply> reply(protocol.QuerySimple(809));710 std::auto_ptr<TestProtocolSimpleReply> reply(protocol.QuerySimple(809)); 712 711 TEST_THAT(reply->GetValuePlusOne() == 810); 713 712 } … … 725 724 s.Write(buf, sizeof(buf)); 726 725 s.SetForReading(); 727 std::auto_ptr<TestProtocol ClientGetStream> reply(protocol.QuerySendStream(0x73654353298ffLL, s));726 std::auto_ptr<TestProtocolGetStream> reply(protocol.QuerySendStream(0x73654353298ffLL, s)); 728 727 TEST_THAT(reply->GetStartingValue() == sizeof(buf)); 729 728 } … … 732 731 for(int q = 0; q < 514; q++) 733 732 { 734 std::auto_ptr<TestProtocol ClientSimpleReply> reply(protocol.QuerySimple(q));733 std::auto_ptr<TestProtocolSimpleReply> reply(protocol.QuerySimple(q)); 735 734 TEST_THAT(reply->GetValuePlusOne() == (q+1)); 736 735 } … … 741 740 strings.push_back(std::string("test2")); 742 741 strings.push_back(std::string("test3")); 743 std::auto_ptr<TestProtocol ClientListsReply> reply(protocol.QueryLists(strings));742 std::auto_ptr<TestProtocolListsReply> reply(protocol.QueryLists(strings)); 744 743 TEST_THAT(reply->GetNumberOfStrings() == 3); 745 744 } … … 747 746 // And another 748 747 { 749 std::auto_ptr<TestProtocol ClientHello> reply(protocol.QueryHello(41,87,11,std::string("pingu")));748 std::auto_ptr<TestProtocolHello> reply(protocol.QueryHello(41,87,11,std::string("pingu"))); 750 749 TEST_THAT(reply->GetNumber32() == 12); 751 750 TEST_THAT(reply->GetNumber16() == 89);
Note: See TracChangeset
for help on using the changeset viewer.
