OLD | NEW |
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 Loading... |
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 |
OLD | NEW |