Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: test/CommunicationTest.cpp

Issue 4806567450902528: Issue 1794 - add handling of std::vector<std::string> by Communication::{Input,Output}Buffer (Closed)
Patch Set: Created Dec. 19, 2014, 9:42 a.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« src/shared/Communication.h ('K') | « src/shared/Communication.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/CommunicationTest.cpp
diff --git a/test/CommunicationTest.cpp b/test/CommunicationTest.cpp
index 2cb62e8b4882cf8219bd3d1146927f1f0d9cd001..368cf000f0cc041a04ad1ecc83e8366200bad7ae 100644
--- a/test/CommunicationTest.cpp
+++ b/test/CommunicationTest.cpp
@@ -112,3 +112,44 @@ TEST(CommunicationTest, SendReceive)
ASSERT_EQ(7, int32Value);
ASSERT_FALSE(boolValue);
}
+
+TEST(InputOutputBuffersTests, EmptyVector)
+{
+ std::vector<std::string> emptySrcVector;
+ Communication::OutputBuffer outputBuffer;
Eric 2015/01/13 16:20:45 The core of these tests is the same code. It would
+ outputBuffer << emptySrcVector;
+ Communication::InputBuffer inputBuffer(outputBuffer.Get());
+ std::vector<std::string> dstVector;
+ inputBuffer >> dstVector;
+ EXPECT_TRUE(dstVector.empty());
+}
+
+TEST(InputOutputBuffersTests, NonemptyVectors)
Eric 2015/01/13 16:20:45 I'd make this two tests.
+{
+ {
+ std::vector<std::string> srcVector;
+ srcVector.emplace_back("string1");
+ Communication::OutputBuffer outputBuffer;
+ outputBuffer << srcVector;
+ Communication::InputBuffer inputBuffer(outputBuffer.Get());
+ std::vector<std::string> dstVector;
+ inputBuffer >> dstVector;
+ ASSERT_EQ(1, dstVector.size());
+ EXPECT_EQ("string1", dstVector[0]);
+ }
+ {
+ std::vector<std::string> srcVector;
+ srcVector.emplace_back("string1");
+ srcVector.emplace_back("str2");
+ srcVector.emplace_back("value");
+ Communication::OutputBuffer outputBuffer;
+ outputBuffer << srcVector;
+ Communication::InputBuffer inputBuffer(outputBuffer.Get());
+ std::vector<std::string> dstVector;
+ inputBuffer >> dstVector;
+ ASSERT_EQ(3, dstVector.size());
+ EXPECT_EQ("string1", dstVector[0]);
+ EXPECT_EQ("str2", dstVector[1]);
+ EXPECT_EQ("value", dstVector[2]);
+ }
+}
« src/shared/Communication.h ('K') | « src/shared/Communication.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld