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 <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" |
11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
12 | 12 |
| 13 // Remove when this file is in the base namespace. |
| 14 using base::string16; |
| 15 |
13 namespace { | 16 namespace { |
14 | 17 |
15 const int testint = 2093847192; | 18 const int testint = 2093847192; |
16 const std::string teststr("Hello world"); // note non-aligned string length | 19 const std::string teststr("Hello world"); // note non-aligned string length |
17 const std::wstring testwstr(L"Hello, world"); | 20 const std::wstring testwstr(L"Hello, world"); |
18 const char testdata[] = "AAA\0BBB\0"; | 21 const char testdata[] = "AAA\0BBB\0"; |
19 const int testdatalen = arraysize(testdata) - 1; | 22 const int testdatalen = arraysize(testdata) - 1; |
20 const bool testbool1 = false; | 23 const bool testbool1 = false; |
21 const bool testbool2 = true; | 24 const bool testbool2 = true; |
22 const uint16 testuint16 = 32123; | 25 const uint16 testuint16 = 32123; |
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
352 EXPECT_TRUE(pickle.WriteBytes(&data, sizeof(data))); | 355 EXPECT_TRUE(pickle.WriteBytes(&data, sizeof(data))); |
353 | 356 |
354 PickleIterator iter(pickle); | 357 PickleIterator iter(pickle); |
355 const char* outdata_char = NULL; | 358 const char* outdata_char = NULL; |
356 EXPECT_TRUE(pickle.ReadBytes(&iter, &outdata_char, sizeof(data))); | 359 EXPECT_TRUE(pickle.ReadBytes(&iter, &outdata_char, sizeof(data))); |
357 | 360 |
358 int outdata; | 361 int outdata; |
359 memcpy(&outdata, outdata_char, sizeof(outdata)); | 362 memcpy(&outdata, outdata_char, sizeof(outdata)); |
360 EXPECT_EQ(data, outdata); | 363 EXPECT_EQ(data, outdata); |
361 } | 364 } |
OLD | NEW |