blob: 33123d299b8a4affea9e413a061531451b498233 [file] [log] [blame]
Darin Petkov7f060332012-03-14 11:46:47 +01001// 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
9using testing::Test;
10
11namespace shill {
12
13class KeyValueStoreTest : public Test {
14 public:
15 KeyValueStoreTest() {}
16
17 protected:
18 KeyValueStore store_;
19};
20
21TEST_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 Stewart88125fb2012-03-26 07:13:51 -070027TEST_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 Petkov7f060332012-03-14 11:46:47 +010038} // namespace shill