1868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
2868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
3868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)// found in the LICENSE file.
4868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
5868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/memory/ref_counted.h"
6868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "base/memory/scoped_ptr.h"
7868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "content/browser/indexed_db/list_set.h"
8868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)#include "testing/gtest/include/gtest/gtest.h"
9868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
10868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)namespace content {
11868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
12868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)TEST(ListSetTest, ListSetIterator) {
13868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  list_set<int> set;
14868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  for (int i = 3; i > 0; --i)
15868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    set.insert(i);
16868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
17868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  list_set<int>::iterator it = set.begin();
18868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  EXPECT_EQ(3, *it);
19868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  ++it;
20868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  EXPECT_EQ(2, *it);
21868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  it++;
22868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  EXPECT_EQ(1, *it);
23868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  --it;
24868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  EXPECT_EQ(2, *it);
25868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  it--;
26868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  EXPECT_EQ(3, *it);
27868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  ++it;
28868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  EXPECT_EQ(2, *it);
29868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  it++;
30868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  EXPECT_EQ(1, *it);
31868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  ++it;
32868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  EXPECT_EQ(set.end(), it);
33868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
34868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
35868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)TEST(ListSetTest, ListSetConstIterator) {
36868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  list_set<int> set;
37868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  for (int i = 5; i > 0; --i)
38868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    set.insert(i);
39868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
40868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  const list_set<int>& ref = set;
41868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
42868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  list_set<int>::const_iterator it = ref.begin();
43868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  for (int i = 5; i > 0; --i) {
44868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(i, *it);
45868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    ++it;
46868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
47868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  EXPECT_EQ(ref.end(), it);
48868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
49868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
50868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)TEST(ListSetTest, ListSetPrimitive) {
51868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  list_set<int> set;
52868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  EXPECT_TRUE(set.empty());
535d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_EQ(0u, set.size());
54868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  {
55868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    list_set<int>::iterator it = set.begin();
56868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(set.end(), it);
57868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
58868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
59868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  for (int i = 5; i > 0; --i)
60868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    set.insert(i);
615d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_EQ(5u, set.size());
62868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  EXPECT_FALSE(set.empty());
63868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
64868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  set.erase(3);
655d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_EQ(4u, set.size());
66868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
675d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_EQ(1u, set.count(2));
68868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  set.erase(2);
695d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_EQ(0u, set.count(2));
705d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_EQ(3u, set.size());
71868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
72868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  {
73868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    list_set<int>::iterator it = set.begin();
74868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(5, *it);
75868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    ++it;
76868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(4, *it);
77868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    ++it;
78868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(1, *it);
79868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    ++it;
80868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(set.end(), it);
81868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
82868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
83868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  set.erase(1);
84868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  set.erase(4);
85868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  set.erase(5);
86868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
875d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_EQ(0u, set.size());
88868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  EXPECT_TRUE(set.empty());
89868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  {
90868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    list_set<int>::iterator it = set.begin();
91868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(set.end(), it);
92868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
93868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
94868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
95868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)template <typename T>
96868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class Wrapped {
97868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) public:
98868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  explicit Wrapped(const T& value) : value_(value) {}
99868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  explicit Wrapped(const Wrapped<T>& other) : value_(other.value_) {}
100868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  Wrapped& operator=(const Wrapped<T>& rhs) {
101868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    value_ = rhs.value_;
102868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    return *this;
103868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
104868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  int value() const { return value_; }
105868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  bool operator<(const Wrapped<T>& rhs) const { return value_ < rhs.value_; }
106868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  bool operator==(const Wrapped<T>& rhs) const { return value_ == rhs.value_; }
107868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
108868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) private:
109868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  T value_;
110868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)};
111868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
112868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)TEST(ListSetTest, ListSetObject) {
113868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  list_set<Wrapped<int> > set;
1145d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_EQ(0u, set.size());
115868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  {
116868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    list_set<Wrapped<int> >::iterator it = set.begin();
117868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(set.end(), it);
118868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
119868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
120868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  set.insert(Wrapped<int>(0));
121868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  set.insert(Wrapped<int>(1));
122868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  set.insert(Wrapped<int>(2));
123868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
1245d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_EQ(3u, set.size());
125868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
126868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  {
127868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    list_set<Wrapped<int> >::iterator it = set.begin();
128868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(0, it->value());
129868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    ++it;
130868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(1, it->value());
131868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    ++it;
132868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(2, it->value());
133868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    ++it;
134868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(set.end(), it);
135868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
136868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
137868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  set.erase(Wrapped<int>(0));
138868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  set.erase(Wrapped<int>(1));
139868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  set.erase(Wrapped<int>(2));
140868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
1415d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_EQ(0u, set.size());
142868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  {
143868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    list_set<Wrapped<int> >::iterator it = set.begin();
144868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(set.end(), it);
145868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
146868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
147868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
148868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)TEST(ListSetTest, ListSetPointer) {
149868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  scoped_ptr<Wrapped<int> > w0(new Wrapped<int>(0));
150868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  scoped_ptr<Wrapped<int> > w1(new Wrapped<int>(1));
151868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  scoped_ptr<Wrapped<int> > w2(new Wrapped<int>(2));
152868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
153868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  list_set<Wrapped<int>*> set;
1545d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_EQ(0u, set.size());
155868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  {
156868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    list_set<Wrapped<int>*>::iterator it = set.begin();
157868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(set.end(), it);
158868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
159868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
160868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  set.insert(w0.get());
161868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  set.insert(w1.get());
162868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  set.insert(w2.get());
163868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
1645d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_EQ(3u, set.size());
165868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
166868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  {
167868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    list_set<Wrapped<int>*>::iterator it = set.begin();
168868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(0, (*it)->value());
169868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    ++it;
170868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(1, (*it)->value());
171868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    ++it;
172868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(2, (*it)->value());
173868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    ++it;
174868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(set.end(), it);
175868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
176868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
177868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  set.erase(w0.get());
178868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  set.erase(w1.get());
179868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  set.erase(w2.get());
180868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
1815d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_EQ(0u, set.size());
182868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  {
183868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    list_set<Wrapped<int>*>::iterator it = set.begin();
184868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(set.end(), it);
185868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
186868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
187868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
188868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)template <typename T>
189868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)class RefCounted : public base::RefCounted<RefCounted<T> > {
190868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) public:
191868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  explicit RefCounted(const T& value) : value_(value) {}
192868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  T value() { return value_; }
193868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
194868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) private:
195868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  virtual ~RefCounted() {}
196868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  friend class base::RefCounted<RefCounted<T> >;
197868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  T value_;
198868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)};
199868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
200868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)TEST(ListSetTest, ListSetRefCounted) {
201868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  list_set<scoped_refptr<RefCounted<int> > > set;
2025d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_EQ(0u, set.size());
203868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  {
204868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    list_set<scoped_refptr<RefCounted<int> > >::iterator it = set.begin();
205868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(set.end(), it);
206868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
207868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
208868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  scoped_refptr<RefCounted<int> > r0(new RefCounted<int>(0));
209868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  scoped_refptr<RefCounted<int> > r1(new RefCounted<int>(1));
210868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  scoped_refptr<RefCounted<int> > r2(new RefCounted<int>(2));
211868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
212868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  set.insert(r0);
213868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  set.insert(r1);
214868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  set.insert(r2);
215868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
2165d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_EQ(3u, set.size());
217868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
218868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  {
219868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    list_set<scoped_refptr<RefCounted<int> > >::iterator it = set.begin();
220868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(0, (*it)->value());
221868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    ++it;
222868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(1, (*it)->value());
223868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    ++it;
224868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(2, (*it)->value());
225868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    ++it;
226868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(set.end(), it);
227868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
228868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
229868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  set.erase(r0);
230868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  set.erase(r1);
231868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  set.erase(r2);
232868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
2335d1f7b1de12d16ceb2c938c56701a3e8bfa558f7Torne (Richard Coles)  EXPECT_EQ(0u, set.size());
234868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  {
235868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    list_set<scoped_refptr<RefCounted<int> > >::iterator it = set.begin();
236868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)    EXPECT_EQ(set.end(), it);
237868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)  }
238868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}
239868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
240868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)}  // namespace content
241