Wludzik, Jozef | e236279 | 2020-10-27 17:23:55 +0100 | [diff] [blame^] | 1 | #include "utils/transform.hpp" |
| 2 | |
| 3 | #include <set> |
| 4 | #include <vector> |
| 5 | |
| 6 | #include <gmock/gmock.h> |
| 7 | |
| 8 | using namespace testing; |
| 9 | |
| 10 | TEST(TestTransform, transformsVector) |
| 11 | { |
| 12 | std::vector<int> input = {1, 2, 3}; |
| 13 | std::vector<std::string> output = |
| 14 | utils::transform(input, [](int v) { return std::to_string(v); }); |
| 15 | EXPECT_TRUE(utils::detail::has_member_reserve_v<std::vector<std::string>>); |
| 16 | ASSERT_THAT(output, ElementsAre("1", "2", "3")); |
| 17 | } |
| 18 | |
| 19 | TEST(TestTransform, transformsSet) |
| 20 | { |
| 21 | std::set<int> input = {1, 2, 3}; |
| 22 | std::set<std::string> output = |
| 23 | utils::transform(input, [](int v) { return std::to_string(v); }); |
| 24 | EXPECT_FALSE(utils::detail::has_member_reserve_v<std::set<std::string>>); |
| 25 | ASSERT_THAT(output, ElementsAre("1", "2", "3")); |
| 26 | } |