| 10 | using namespace testing; |
| 11 | |
| 12 | TEST(IterateValues, ConstMappingIteration) { |
| 13 | const std::map<int, int> squares{ |
| 14 | {1, 1}, |
| 15 | {2, 4}, |
| 16 | {3, 9}, |
| 17 | }; |
| 18 | EXPECT_THAT( |
| 19 | IterateValues(squares), |
| 20 | ElementsAre(1, 4, 9) |
| 21 | ); |
| 22 | |
| 23 | const std::unordered_map<int, int> roots{ |
| 24 | {49, 7}, |
| 25 | {36, 6}, |
| 26 | {25, 5}, |
| 27 | }; |
| 28 | EXPECT_THAT( |
| 29 | IterateValues(roots), |
| 30 | UnorderedElementsAre(5, 6, 7) |
| 31 | ); |
| 32 | |
| 33 | const std::map<int, std::string> translations{ |
| 34 | {1, "one"}, |
| 35 | {2, "two"}, |
| 36 | {3, "three"}, |
| 37 | }; |
| 38 | EXPECT_EQ( |
| 39 | Accumulate(IterateValues(translations), std::string{}), |
| 40 | "onetwothree" |
| 41 | ); |
| 42 | } |
| 43 | |
| 44 | TEST(IterateValues, NonConstMappingIteration) { |
| 45 | std::map<int, int> squares{ |
nothing calls this directly
no test coverage detected