Darin Petkov | 7f06033 | 2012-03-14 11:46:47 +0100 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "shill/key_value_store.h" |
| 6 | |
| 7 | #include <gtest/gtest.h> |
| 8 | |
| 9 | using testing::Test; |
| 10 | |
| 11 | namespace shill { |
| 12 | |
| 13 | class KeyValueStoreTest : public Test { |
| 14 | public: |
| 15 | KeyValueStoreTest() {} |
| 16 | |
| 17 | protected: |
| 18 | KeyValueStore store_; |
| 19 | }; |
| 20 | |
| 21 | TEST_F(KeyValueStoreTest, LookupString) { |
| 22 | EXPECT_EQ("bar", store_.LookupString("foo", "bar")); |
| 23 | store_.SetString("foo", "zoo"); |
| 24 | EXPECT_EQ("zoo", store_.LookupString("foo", "bar")); |
| 25 | } |
| 26 | |
Paul Stewart | 88125fb | 2012-03-26 07:13:51 -0700 | [diff] [blame] | 27 | TEST_F(KeyValueStoreTest, RemoveString) { |
| 28 | const std::string kKey("foo"); |
| 29 | store_.SetString(kKey, "zoo"); |
| 30 | EXPECT_EQ("zoo", store_.LookupString(kKey, "bar")); |
| 31 | store_.RemoveString(kKey); |
| 32 | EXPECT_EQ("bar", store_.LookupString(kKey, "bar")); |
| 33 | // Make sure we don't get an exception/infinite loop if we do a |
| 34 | // "RemoveString()" when the key does not exist. |
| 35 | store_.RemoveString(kKey); |
| 36 | } |
| 37 | |
Darin Petkov | 7f06033 | 2012-03-14 11:46:47 +0100 | [diff] [blame] | 38 | } // namespace shill |