Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(66)

Side by Side Diff: ipc/ipc_message_utils_unittest.cc

Issue 2825853002: Improvements to uses of base::SmallMap (Closed)
Patch Set: Review comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ipc/ipc_message_utils.h ('k') | net/quic/platform/impl/quic_containers_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ipc/ipc_message_utils.h" 5 #include "ipc/ipc_message_utils.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 #include <memory> 9 #include <memory>
10 10
(...skipping 197 matching lines...) Expand 10 before | Expand all | Expand 10 after
208 std::string log; 208 std::string log;
209 IPC::LogParam(token, &log); 209 IPC::LogParam(token, &log);
210 EXPECT_EQ(token.ToString(), log); 210 EXPECT_EQ(token.ToString(), log);
211 211
212 base::UnguessableToken deserialized_token; 212 base::UnguessableToken deserialized_token;
213 base::PickleIterator iter(pickle); 213 base::PickleIterator iter(pickle);
214 EXPECT_TRUE(IPC::ReadParam(&pickle, &iter, &deserialized_token)); 214 EXPECT_TRUE(IPC::ReadParam(&pickle, &iter, &deserialized_token));
215 EXPECT_EQ(token, deserialized_token); 215 EXPECT_EQ(token, deserialized_token);
216 } 216 }
217 217
218 TEST(IPCMessageUtilsTest, FlatMap) {
219 base::flat_map<std::string, int> input;
220 input["foo"] = 42;
221 input["bar"] = 96;
222
223 base::Pickle pickle;
224 IPC::WriteParam(&pickle, input);
225
226 base::PickleSizer sizer;
227 IPC::GetParamSize(&sizer, input);
228
229 EXPECT_EQ(sizer.payload_size(), pickle.payload_size());
230
231 base::PickleIterator iter(pickle);
232 base::flat_map<std::string, int> output;
233 EXPECT_TRUE(IPC::ReadParam(&pickle, &iter, &output));
234
235 EXPECT_EQ(input, output);
236 }
237
218 } // namespace 238 } // namespace
219 } // namespace IPC 239 } // namespace IPC
OLDNEW
« no previous file with comments | « ipc/ipc_message_utils.h ('k') | net/quic/platform/impl/quic_containers_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698