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

Side by Side 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.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« src/shared/Communication.h ('K') | « src/shared/Communication.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 ASSERT_ANY_THROW(response >> int64Value); 105 ASSERT_ANY_THROW(response >> int64Value);
106 ASSERT_ANY_THROW(response >> int32Value); 106 ASSERT_ANY_THROW(response >> int32Value);
107 ASSERT_ANY_THROW(response >> boolValue); 107 ASSERT_ANY_THROW(response >> boolValue);
108 108
109 ASSERT_EQ("Foo Received", stringValue); 109 ASSERT_EQ("Foo Received", stringValue);
110 ASSERT_EQ(L"Bar \u043f\u0440\u0438\u043d\u044f\u0442\u043e", wstringValue); 110 ASSERT_EQ(L"Bar \u043f\u0440\u0438\u043d\u044f\u0442\u043e", wstringValue);
111 ASSERT_EQ(9876543211L, int64Value); 111 ASSERT_EQ(9876543211L, int64Value);
112 ASSERT_EQ(7, int32Value); 112 ASSERT_EQ(7, int32Value);
113 ASSERT_FALSE(boolValue); 113 ASSERT_FALSE(boolValue);
114 } 114 }
115
116 TEST(InputOutputBuffersTests, EmptyVector)
117 {
118 std::vector<std::string> emptySrcVector;
119 Communication::OutputBuffer outputBuffer;
Eric 2015/01/13 16:20:45 The core of these tests is the same code. It would
120 outputBuffer << emptySrcVector;
121 Communication::InputBuffer inputBuffer(outputBuffer.Get());
122 std::vector<std::string> dstVector;
123 inputBuffer >> dstVector;
124 EXPECT_TRUE(dstVector.empty());
125 }
126
127 TEST(InputOutputBuffersTests, NonemptyVectors)
Eric 2015/01/13 16:20:45 I'd make this two tests.
128 {
129 {
130 std::vector<std::string> srcVector;
131 srcVector.emplace_back("string1");
132 Communication::OutputBuffer outputBuffer;
133 outputBuffer << srcVector;
134 Communication::InputBuffer inputBuffer(outputBuffer.Get());
135 std::vector<std::string> dstVector;
136 inputBuffer >> dstVector;
137 ASSERT_EQ(1, dstVector.size());
138 EXPECT_EQ("string1", dstVector[0]);
139 }
140 {
141 std::vector<std::string> srcVector;
142 srcVector.emplace_back("string1");
143 srcVector.emplace_back("str2");
144 srcVector.emplace_back("value");
145 Communication::OutputBuffer outputBuffer;
146 outputBuffer << srcVector;
147 Communication::InputBuffer inputBuffer(outputBuffer.Get());
148 std::vector<std::string> dstVector;
149 inputBuffer >> dstVector;
150 ASSERT_EQ(3, dstVector.size());
151 EXPECT_EQ("string1", dstVector[0]);
152 EXPECT_EQ("str2", dstVector[1]);
153 EXPECT_EQ("value", dstVector[2]);
154 }
155 }
OLDNEW
« 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