OLD | NEW |
---|---|
1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 "base/containers/flat_set.h" | 5 #include "base/containers/flat_set.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/containers/container_test_utils.h" | 10 #include "base/containers/container_test_utils.h" |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
83 | 83 |
84 copy.erase(copy.begin()); | 84 copy.erase(copy.begin()); |
85 copy.insert(10); | 85 copy.insert(10); |
86 EXPECT_THAT(copy, ElementsAre(2, 10)); | 86 EXPECT_THAT(copy, ElementsAre(2, 10)); |
87 | 87 |
88 original.swap(copy); | 88 original.swap(copy); |
89 EXPECT_THAT(original, ElementsAre(2, 10)); | 89 EXPECT_THAT(original, ElementsAre(2, 10)); |
90 EXPECT_THAT(copy, ElementsAre(1, 2)); | 90 EXPECT_THAT(copy, ElementsAre(1, 2)); |
91 } | 91 } |
92 | 92 |
93 TEST(FlatSet, UniquePtrs) { | |
danakj
2017/06/26 19:33:12
same nit
dyaroshev
2017/06/26 22:40:42
Done
| |
94 using ExplicitInt = base::MoveOnlyInt; | |
95 base::flat_set<ExplicitInt> s; | |
96 const auto& s1 = s; | |
97 int x = 0; | |
98 | |
99 // Check if we can use lookup functions without converting to key_type. | |
100 // Correctness is checked in flat_tree tests. | |
101 s.count(x); | |
102 s1.count(x); | |
103 s.find(x); | |
104 s1.find(x); | |
105 s.equal_range(x); | |
106 s1.equal_range(x); | |
107 s.lower_bound(x); | |
108 s1.lower_bound(x); | |
109 s.upper_bound(x); | |
110 s1.upper_bound(x); | |
111 s.erase(x); | |
112 | |
113 // Check if we broke overload resolution. | |
114 s.emplace(0); | |
115 s.emplace(1); | |
116 s.erase(s.begin()); | |
117 s.erase(s.cbegin()); | |
118 } | |
119 | |
93 } // namespace base | 120 } // namespace base |
OLD | NEW |