Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(648)

Side by Side Diff: base/containers/flat_set_unittest.cc

Issue 2944523002: Improving flat containers interface. (Closed)
Patch Set: Removing redundant tests. Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <memory>
7 #include <string> 8 #include <string>
8 #include <vector> 9 #include <vector>
9 10
10 #include "base/containers/container_test_utils.h" 11 #include "base/containers/container_test_utils.h"
11 #include "base/macros.h" 12 #include "base/macros.h"
12 #include "testing/gmock/include/gmock/gmock.h" 13 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h" 14 #include "testing/gtest/include/gtest/gtest.h"
14 15
15 // A flat_set is basically a interface to flat_tree. So several basic 16 // A flat_set is basically a interface to flat_tree. So several basic
16 // operations are tested to make sure things are set up properly, but the bulk 17 // operations are tested to make sure things are set up properly, but the bulk
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
83 84
84 copy.erase(copy.begin()); 85 copy.erase(copy.begin());
85 copy.insert(10); 86 copy.insert(10);
86 EXPECT_THAT(copy, ElementsAre(2, 10)); 87 EXPECT_THAT(copy, ElementsAre(2, 10));
87 88
88 original.swap(copy); 89 original.swap(copy);
89 EXPECT_THAT(original, ElementsAre(2, 10)); 90 EXPECT_THAT(original, ElementsAre(2, 10));
90 EXPECT_THAT(copy, ElementsAre(1, 2)); 91 EXPECT_THAT(copy, ElementsAre(1, 2));
91 } 92 }
92 93
94 TEST(FlatSet, UniquePtrs) {
95 base::flat_set<std::unique_ptr<int>> s;
96 const auto& s1 = s;
97 int x = 0;
98 s.count(&x);
99 s1.count(&x);
100 s.find(&x);
101 s1.find(&x);
102 s.equal_range(&x);
103 s1.equal_range(&x);
104 s.lower_bound(&x);
105 s1.lower_bound(&x);
106 s.upper_bound(&x);
107 s1.upper_bound(&x);
108 s.erase(&x);
109
110 // Check if we broke overload resolution.
111 s.emplace(new int(0));
112 s.emplace(new int(1));
113 s.erase(s.begin());
114 s.erase(s.cbegin());
115 }
116
93 } // namespace base 117 } // namespace base
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698