diff options
author | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-08 19:51:09 +0000 |
---|---|---|
committer | evan@chromium.org <evan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-01-08 19:51:09 +0000 |
commit | 9a9df873c619cd08ac6fb14a510135f29d8cccd1 (patch) | |
tree | f057fade0f12e9c5bf6e0dcd3de5158ccca9defc /base/data_pack_unittest.cc | |
parent | 9dc2438fcf00c4ee2f30f66fc8b8bc2f6b7fc465 (diff) | |
download | chromium_src-9a9df873c619cd08ac6fb14a510135f29d8cccd1.zip chromium_src-9a9df873c619cd08ac6fb14a510135f29d8cccd1.tar.gz chromium_src-9a9df873c619cd08ac6fb14a510135f29d8cccd1.tar.bz2 |
Data pack file reader and unit test, used for resources on Linux.
See http://dev.chromium.org/developers/design-documents/linuxresourcesandlocalizedstrings for more details.
Review URL: http://codereview.chromium.org/17253
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@7751 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'base/data_pack_unittest.cc')
-rw-r--r-- | base/data_pack_unittest.cc | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/base/data_pack_unittest.cc b/base/data_pack_unittest.cc new file mode 100644 index 0000000..1f6b264 --- /dev/null +++ b/base/data_pack_unittest.cc @@ -0,0 +1,42 @@ +// Copyright (c) 2008 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#include "base/data_pack.h" + +#include "base/file_path.h" +#include "base/logging.h" +#include "base/path_service.h" +#include "base/string_piece.h" +#include "testing/gtest/include/gtest/gtest.h" + +class DataPackTest : public testing::Test { + public: + DataPackTest() { + PathService::Get(base::DIR_SOURCE_ROOT, &data_path_); + data_path_ = data_path_.Append( + FILE_PATH_LITERAL("base/data/data_pack_unittest/sample.pak")); + } + + FilePath data_path_; +}; + +TEST_F(DataPackTest, Load) { + base::DataPack pack; + ASSERT_TRUE(pack.Load(data_path_)); + + StringPiece data; + ASSERT_TRUE(pack.Get(4, &data)); + EXPECT_EQ("this is id 4", data); + ASSERT_TRUE(pack.Get(6, &data)); + EXPECT_EQ("this is id 6", data); + + // Try reading zero-length data blobs, just in case. + ASSERT_TRUE(pack.Get(1, &data)); + EXPECT_EQ(0U, data.length()); + ASSERT_TRUE(pack.Get(10, &data)); + EXPECT_EQ(0U, data.length()); + + // Try looking up an invalid key. + ASSERT_FALSE(pack.Get(140, &data)); +} |