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

Side by Side Diff: ipc/ipc_message_utils_unittest.cc

Issue 2968003005: Support Serializing and Deserializing RepeatedField / RepeatedPtrField in IPC::Message (Closed)
Patch Set: Update IsPickleSizeSufficent to avoid GetSize Created 3 years, 5 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
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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after
248 248
249 EXPECT_EQ(sizer.payload_size(), pickle.payload_size()); 249 EXPECT_EQ(sizer.payload_size(), pickle.payload_size());
250 250
251 base::PickleIterator iter(pickle); 251 base::PickleIterator iter(pickle);
252 base::flat_map<std::string, int> output; 252 base::flat_map<std::string, int> output;
253 EXPECT_TRUE(IPC::ReadParam(&pickle, &iter, &output)); 253 EXPECT_TRUE(IPC::ReadParam(&pickle, &iter, &output));
254 254
255 EXPECT_EQ(input, output); 255 EXPECT_EQ(input, output);
256 } 256 }
257 257
258 TEST(IPCMessageUtilsTest, InvalidPickleShouldNotCrashFlatMapDeserialization) {
259 base::Pickle pickle;
260 IPC::WriteParam(&pickle, INT_MAX);
261 IPC::WriteParam(&pickle, 0);
262 IPC::WriteParam(&pickle, 0);
263
264 base::PickleIterator iter(pickle);
265 base::flat_map<int, int> output;
266 EXPECT_FALSE(IPC::ReadParam(&pickle, &iter, &output));
267 }
268
269 TEST(IPCMessageUtilsTest, InvalidPickleShouldNotCrashMapDeserialization) {
270 base::Pickle pickle;
271 IPC::WriteParam(&pickle, INT_MAX);
272 IPC::WriteParam(&pickle, 0);
273 IPC::WriteParam(&pickle, 0);
274
275 base::PickleIterator iter(pickle);
276 std::map<int, int> output;
277 EXPECT_FALSE(IPC::ReadParam(&pickle, &iter, &output));
278 }
279
258 } // namespace 280 } // namespace
259 } // namespace IPC 281 } // namespace IPC
OLDNEW
« ipc/ipc_message_utils.h ('K') | « ipc/ipc_message_utils.cc ('k') | ipc/test_proto.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698