| 1 | // Copyright 2013 The Flutter Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include <unordered_map> |
| 6 | |
| 7 | #include "flutter/fml/container.h" |
| 8 | |
| 9 | #include "gtest/gtest.h" |
| 10 | |
| 11 | namespace fml { |
| 12 | namespace { |
| 13 | |
| 14 | TEST(ContainerTest, MapEraseIf) { |
| 15 | std::unordered_map<int, int> map = {{0, 1}, {2, 3}, {4, 5}}; |
| 16 | |
| 17 | fml::erase_if(container&: map, predicate: [](std::unordered_map<int, int>::iterator it) { |
| 18 | return it->first == 0 || it->second == 5; |
| 19 | }); |
| 20 | |
| 21 | EXPECT_EQ(map.size(), 1u); |
| 22 | EXPECT_TRUE(map.find(2) != map.end()); |
| 23 | } |
| 24 | |
| 25 | } // namespace |
| 26 | } // namespace fml |
| 27 | |