OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/browser/indexed_db/list_set.h" | 5 #include "content/browser/indexed_db/list_set.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 | 8 |
9 #include "base/memory/ptr_util.h" | 9 #include "base/memory/ptr_util.h" |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 const list_set<int>& ref = set; | 43 const list_set<int>& ref = set; |
44 | 44 |
45 list_set<int>::const_iterator it = ref.begin(); | 45 list_set<int>::const_iterator it = ref.begin(); |
46 for (int i = 5; i > 0; --i) { | 46 for (int i = 5; i > 0; --i) { |
47 EXPECT_EQ(i, *it); | 47 EXPECT_EQ(i, *it); |
48 ++it; | 48 ++it; |
49 } | 49 } |
50 EXPECT_EQ(ref.end(), it); | 50 EXPECT_EQ(ref.end(), it); |
51 } | 51 } |
52 | 52 |
| 53 TEST(ListSetTest, ListSetInsertFront) { |
| 54 list_set<int> set; |
| 55 for (int i = 5; i > 0; --i) |
| 56 set.insert(i); |
| 57 for (int i = 6; i <= 10; ++i) |
| 58 set.insert_front(i); |
| 59 |
| 60 const list_set<int>& ref = set; |
| 61 |
| 62 list_set<int>::const_iterator it = ref.begin(); |
| 63 for (int i = 10; i > 0; --i) { |
| 64 EXPECT_EQ(i, *it); |
| 65 ++it; |
| 66 } |
| 67 EXPECT_EQ(ref.end(), it); |
| 68 } |
| 69 |
53 TEST(ListSetTest, ListSetPrimitive) { | 70 TEST(ListSetTest, ListSetPrimitive) { |
54 list_set<int> set; | 71 list_set<int> set; |
55 EXPECT_TRUE(set.empty()); | 72 EXPECT_TRUE(set.empty()); |
56 EXPECT_EQ(0u, set.size()); | 73 EXPECT_EQ(0u, set.size()); |
57 { | 74 { |
58 list_set<int>::iterator it = set.begin(); | 75 list_set<int>::iterator it = set.begin(); |
59 EXPECT_EQ(set.end(), it); | 76 EXPECT_EQ(set.end(), it); |
60 } | 77 } |
61 | 78 |
62 for (int i = 5; i > 0; --i) | 79 for (int i = 5; i > 0; --i) |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
234 set.erase(r2); | 251 set.erase(r2); |
235 | 252 |
236 EXPECT_EQ(0u, set.size()); | 253 EXPECT_EQ(0u, set.size()); |
237 { | 254 { |
238 list_set<scoped_refptr<RefCounted<int> > >::iterator it = set.begin(); | 255 list_set<scoped_refptr<RefCounted<int> > >::iterator it = set.begin(); |
239 EXPECT_EQ(set.end(), it); | 256 EXPECT_EQ(set.end(), it); |
240 } | 257 } |
241 } | 258 } |
242 | 259 |
243 } // namespace content | 260 } // namespace content |
OLD | NEW |