| 56 | |
| 57 | |
| 58 | TEST(LambdaTest, Map) |
| 59 | { |
| 60 | std::vector<int> expected = {1, 2, 3}; |
| 61 | |
| 62 | EXPECT_EQ( |
| 63 | expected, |
| 64 | lambda::map( |
| 65 | [](std::string s) { |
| 66 | return numify<int>(s).get(); |
| 67 | }, |
| 68 | std::vector<std::string>{"1", "2", "3"})); |
| 69 | |
| 70 | EXPECT_EQ( |
| 71 | expected, |
| 72 | lambda::map( |
| 73 | [](const std::string& s) { |
| 74 | return numify<int>(s).get(); |
| 75 | }, |
| 76 | std::vector<std::string>{"1", "2", "3"})); |
| 77 | |
| 78 | EXPECT_EQ( |
| 79 | expected, |
| 80 | lambda::map( |
| 81 | [](std::string&& s) { |
| 82 | return numify<int>(s).get(); |
| 83 | }, |
| 84 | std::vector<std::string>{"1", "2", "3"})); |
| 85 | |
| 86 | std::vector<std::string> concat = {"11", "22", "33"}; |
| 87 | |
| 88 | EXPECT_EQ( |
| 89 | concat, |
| 90 | lambda::map( |
| 91 | [](std::string&& s) { |
| 92 | return s + s; |
| 93 | }, |
| 94 | function())); |
| 95 | |
| 96 | std::vector<OnlyMoveable> v; |
| 97 | v.emplace_back(1); |
| 98 | v.emplace_back(2); |
| 99 | |
| 100 | std::vector<OnlyMoveable> result = lambda::map( |
| 101 | [](OnlyMoveable&& o) { |
| 102 | o.j = o.i; |
| 103 | return std::move(o); |
| 104 | }, |
| 105 | std::move(v)); |
| 106 | |
| 107 | for (const OnlyMoveable& o : result) { |
| 108 | EXPECT_EQ(o.i, o.j); |
| 109 | } |
| 110 | } |
| 111 | |
| 112 | |
| 113 | TEST(LambdaTest, Zip) |
nothing calls this directly
no test coverage detected