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

Side by Side Diff: base/data_pack_unittest.cc

Issue 193072: Move StringPiece into the base namespace. It is colliding (Closed)
Patch Set: take 2 Created 11 years, 3 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 | « base/data_pack.h ('k') | base/debug_util_posix.cc » ('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) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 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 "base/data_pack.h" 5 #include "base/data_pack.h"
6 6
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/path_service.h" 8 #include "base/path_service.h"
9 #include "base/string_piece.h" 9 #include "base/string_piece.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
11 11
12 class DataPackTest : public testing::Test { 12 class DataPackTest : public testing::Test {
13 public: 13 public:
14 DataPackTest() { 14 DataPackTest() {
15 PathService::Get(base::DIR_SOURCE_ROOT, &data_path_); 15 PathService::Get(base::DIR_SOURCE_ROOT, &data_path_);
16 data_path_ = data_path_.Append( 16 data_path_ = data_path_.Append(
17 FILE_PATH_LITERAL("base/data/data_pack_unittest/sample.pak")); 17 FILE_PATH_LITERAL("base/data/data_pack_unittest/sample.pak"));
18 } 18 }
19 19
20 FilePath data_path_; 20 FilePath data_path_;
21 }; 21 };
22 22
23 TEST_F(DataPackTest, Load) { 23 TEST_F(DataPackTest, Load) {
24 base::DataPack pack; 24 base::DataPack pack;
25 ASSERT_TRUE(pack.Load(data_path_)); 25 ASSERT_TRUE(pack.Load(data_path_));
26 26
27 StringPiece data; 27 base::StringPiece data;
28 ASSERT_TRUE(pack.Get(4, &data)); 28 ASSERT_TRUE(pack.Get(4, &data));
29 EXPECT_EQ("this is id 4", data); 29 EXPECT_EQ("this is id 4", data);
30 ASSERT_TRUE(pack.Get(6, &data)); 30 ASSERT_TRUE(pack.Get(6, &data));
31 EXPECT_EQ("this is id 6", data); 31 EXPECT_EQ("this is id 6", data);
32 32
33 // Try reading zero-length data blobs, just in case. 33 // Try reading zero-length data blobs, just in case.
34 ASSERT_TRUE(pack.Get(1, &data)); 34 ASSERT_TRUE(pack.Get(1, &data));
35 EXPECT_EQ(0U, data.length()); 35 EXPECT_EQ(0U, data.length());
36 ASSERT_TRUE(pack.Get(10, &data)); 36 ASSERT_TRUE(pack.Get(10, &data));
37 EXPECT_EQ(0U, data.length()); 37 EXPECT_EQ(0U, data.length());
38 38
39 // Try looking up an invalid key. 39 // Try looking up an invalid key.
40 ASSERT_FALSE(pack.Get(140, &data)); 40 ASSERT_FALSE(pack.Get(140, &data));
41 } 41 }
OLDNEW
« no previous file with comments | « base/data_pack.h ('k') | base/debug_util_posix.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698