1 // Copyright (c) 2012 The Chromium 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.
5 #include "base/memory/scoped_ptr.h"
6 #include "base/values.h"
7 #include "extensions/common/value_counter.h"
8 #include "testing/gtest/include/gtest/gtest.h"
10 using ValueCounterTest
= testing::Test
;
12 namespace extensions
{
14 TEST_F(ValueCounterTest
, TestAddingSameValue
) {
16 base::ListValue value
;
17 ASSERT_TRUE(vc
.Add(value
));
18 ASSERT_FALSE(vc
.Add(value
));
21 TEST_F(ValueCounterTest
, TestAddingDifferentValue
) {
23 base::ListValue value1
;
24 base::DictionaryValue value2
;
25 ASSERT_TRUE(vc
.Add(value1
));
26 ASSERT_TRUE(vc
.Add(value2
));
29 TEST_F(ValueCounterTest
, TestRemovingSameValue
) {
31 base::ListValue value
;
34 ASSERT_FALSE(vc
.Remove(value
));
35 ASSERT_TRUE(vc
.Remove(value
));
36 ASSERT_FALSE(vc
.Remove(value
));
39 TEST_F(ValueCounterTest
, TestReAddingSameValue
) {
41 base::ListValue value
;
42 ASSERT_FALSE(vc
.Remove(value
));
43 ASSERT_TRUE(vc
.Add(value
));
44 ASSERT_TRUE(vc
.Remove(value
));
45 ASSERT_TRUE(vc
.Add(value
));
46 ASSERT_TRUE(vc
.Remove(value
));
47 ASSERT_FALSE(vc
.Remove(value
));
50 TEST_F(ValueCounterTest
, TestIsEmpty
) {
52 base::ListValue value1
;
53 base::DictionaryValue value2
;
54 ASSERT_TRUE(vc
.is_empty());
56 ASSERT_FALSE(vc
.is_empty());
58 ASSERT_TRUE(vc
.is_empty());
61 ASSERT_FALSE(vc
.is_empty());
63 ASSERT_FALSE(vc
.is_empty());
65 ASSERT_TRUE(vc
.is_empty());
68 } // namespace extensions