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: remove WriteStrings and ReadStrings Created Feb. 9, 2015, 2:04 p.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/Utils.h ('K') | « src/shared/Utils.cpp ('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..fb9d4c34f35220fdaab146f480a15be2e9fff40d 100644
--- a/test/CommunicationTest.cpp
+++ b/test/CommunicationTest.cpp
@@ -112,3 +112,39 @@ TEST(CommunicationTest, SendReceive)
ASSERT_EQ(7, int32Value);
ASSERT_FALSE(boolValue);
}
+
+void SendReceiveStrings(const std::vector<std::string>& src)
+{
+ Communication::OutputBuffer outputBuffer;
+ outputBuffer << src;
+ Communication::InputBuffer inputBuffer(outputBuffer.Get());
Eric 2015/02/17 17:18:35 I don't like the use of Get() here, but I'll save
+ std::vector<std::string> dst;
+ inputBuffer >> dst;
+ auto dstSize = dst.size();
+ ASSERT_EQ(dstSize, src.size());
+ for (auto i = 0; i < dstSize; ++i)
+ {
+ EXPECT_EQ(dst[i], src[i]);
+ }
+}
+
+TEST(InputOutputBuffersTests, EmptyStrings)
+{
+ SendReceiveStrings(std::vector<std::string>());
+}
+
+TEST(InputOutputBuffersTests, StringsWithOneValue)
+{
+ std::vector<std::string> src;
+ src.emplace_back("string1");
+ SendReceiveStrings(src);
+}
+
+TEST(InputOutputBuffersTests, MultivalueStrings)
+{
+ std::vector<std::string> src;
+ src.emplace_back("string1");
+ src.emplace_back("str2");
+ src.emplace_back("value");
+ SendReceiveStrings(src);
+}
« src/shared/Utils.h ('K') | « src/shared/Utils.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld