1 // Copyright (C) 2014 Google Inc.
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 #include <libaddressinput/null_storage.h>
17 #include <libaddressinput/callback.h>
18 #include <libaddressinput/storage.h>
19 #include <libaddressinput/util/basictypes.h>
20 #include <libaddressinput/util/scoped_ptr.h>
25 #include <gtest/gtest.h>
29 using i18n::addressinput::BuildCallback;
30 using i18n::addressinput::NullStorage;
31 using i18n::addressinput::scoped_ptr;
32 using i18n::addressinput::Storage;
34 class NullStorageTest : public testing::Test {
37 : data_ready_(BuildCallback(this, &NullStorageTest::OnDataReady)) {}
43 const scoped_ptr<const Storage::Callback> data_ready_;
45 static const char kKey[];
48 void OnDataReady(bool success, const std::string& key, std::string* data) {
49 ASSERT_FALSE(success && data == NULL);
58 DISALLOW_COPY_AND_ASSIGN(NullStorageTest);
61 const char NullStorageTest::kKey[] = "foo";
63 TEST_F(NullStorageTest, Put) {
64 // The Put() method should not do anything, so this test only tests that the
65 // code compiles and that the call doesn't crash.
66 storage_.Put(kKey, new std::string("bar"));
69 TEST_F(NullStorageTest, Get) {
70 storage_.Get(kKey, *data_ready_);
71 EXPECT_FALSE(success_);
72 EXPECT_EQ(kKey, key_);
73 EXPECT_TRUE(data_.empty());