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

Side by Side Diff: base/pickle_unittest.cc

Issue 290173008: Refactor PickleIterator. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
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 <string> 5 #include <string>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/pickle.h" 9 #include "base/pickle.h"
10 #include "base/strings/string16.h" 10 #include "base/strings/string16.h"
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 EXPECT_EQ(pickle.payload_size(), payload_size_after_header); 255 EXPECT_EQ(pickle.payload_size(), payload_size_after_header);
256 256
257 // fill out a full page (noting data header) 257 // fill out a full page (noting data header)
258 pickle.WriteData(data_ptr, static_cast<int>(unit - sizeof(uint32))); 258 pickle.WriteData(data_ptr, static_cast<int>(unit - sizeof(uint32)));
259 cur_payload += unit; 259 cur_payload += unit;
260 EXPECT_EQ(unit * 2, pickle.capacity_after_header()); 260 EXPECT_EQ(unit * 2, pickle.capacity_after_header());
261 EXPECT_EQ(cur_payload, pickle.payload_size()); 261 EXPECT_EQ(cur_payload, pickle.payload_size());
262 262
263 // one more byte should double the capacity 263 // one more byte should double the capacity
264 pickle.WriteData(data_ptr, 1); 264 pickle.WriteData(data_ptr, 1);
265 cur_payload += 5; 265 cur_payload += 8;
266 EXPECT_EQ(unit * 4, pickle.capacity_after_header()); 266 EXPECT_EQ(unit * 4, pickle.capacity_after_header());
267 EXPECT_EQ(cur_payload, pickle.payload_size()); 267 EXPECT_EQ(cur_payload, pickle.payload_size());
268 } 268 }
269 269
270 namespace { 270 namespace {
271 271
272 struct CustomHeader : Pickle::Header { 272 struct CustomHeader : Pickle::Header {
273 int blah; 273 int blah;
274 }; 274 };
275 275
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 EXPECT_TRUE(pickle.WriteBytes(&data, sizeof(data))); 355 EXPECT_TRUE(pickle.WriteBytes(&data, sizeof(data)));
356 356
357 PickleIterator iter(pickle); 357 PickleIterator iter(pickle);
358 const char* outdata_char = NULL; 358 const char* outdata_char = NULL;
359 EXPECT_TRUE(pickle.ReadBytes(&iter, &outdata_char, sizeof(data))); 359 EXPECT_TRUE(pickle.ReadBytes(&iter, &outdata_char, sizeof(data)));
360 360
361 int outdata; 361 int outdata;
362 memcpy(&outdata, outdata_char, sizeof(outdata)); 362 memcpy(&outdata, outdata_char, sizeof(outdata));
363 EXPECT_EQ(data, outdata); 363 EXPECT_EQ(data, outdata);
364 } 364 }
OLDNEW
« no previous file with comments | « base/pickle.cc ('k') | chrome/browser/extensions/api/messaging/native_message_process_host_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698