| 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 // Following tests are ported and extended tests from libcpp for std::set. | 7 // Following tests are ported and extended tests from libcpp for std::set. |
| 8 // They can be found here: | 8 // They can be found here: |
| 9 // https://github.com/llvm-mirror/libcxx/tree/master/test/std/containers/associa
tive/set | 9 // https://github.com/llvm-mirror/libcxx/tree/master/test/std/containers/associa
tive/set |
| 10 // | 10 // |
| (...skipping 1224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1235 | 1235 |
| 1236 EXPECT_EQ(biggest, biggest); | 1236 EXPECT_EQ(biggest, biggest); |
| 1237 EXPECT_NE(biggest, smallest); | 1237 EXPECT_NE(biggest, smallest); |
| 1238 EXPECT_LT(smallest, middle); | 1238 EXPECT_LT(smallest, middle); |
| 1239 EXPECT_LE(smallest, middle); | 1239 EXPECT_LE(smallest, middle); |
| 1240 EXPECT_LE(middle, middle); | 1240 EXPECT_LE(middle, middle); |
| 1241 EXPECT_GT(biggest, middle); | 1241 EXPECT_GT(biggest, middle); |
| 1242 EXPECT_GE(biggest, middle); | 1242 EXPECT_GE(biggest, middle); |
| 1243 EXPECT_GE(biggest, biggest); | 1243 EXPECT_GE(biggest, biggest); |
| 1244 } | 1244 } |
| 1245 |
| 1246 TEST(FlatSet, EraseIf) { |
| 1247 IntSet x; |
| 1248 base::EraseIf(x, [](int) { return false; }); |
| 1249 EXPECT_THAT(x, ElementsAre()); |
| 1250 |
| 1251 x = {1, 2, 3}; |
| 1252 base::EraseIf(x, [](int elem) { return !(elem & 1); }); |
| 1253 EXPECT_THAT(x, ElementsAre(1, 3)); |
| 1254 |
| 1255 x = {1, 2, 3, 4}; |
| 1256 base::EraseIf(x, [](int elem) { return elem & 1; }); |
| 1257 EXPECT_THAT(x, ElementsAre(2, 4)); |
| 1258 } |
| OLD | NEW |