| 18 | using namespace boost::parser; |
| 19 | |
| 20 | int main() |
| 21 | { |
| 22 | |
| 23 | // for_each |
| 24 | { |
| 25 | { |
| 26 | tuple<std::string, int> t{"foo", 4}; |
| 27 | std::ostringstream oss; |
| 28 | detail::hl::for_each(t, [&](auto x) { oss << x << ' '; }); |
| 29 | BOOST_TEST(get(t, llong<0>{}) == "foo"); |
| 30 | BOOST_TEST(oss.str() == "foo 4 "); |
| 31 | } |
| 32 | { |
| 33 | tuple<std::string, int> t{"foo", 4}; |
| 34 | std::ostringstream oss; |
| 35 | detail::hl::for_each(std::move(t), [&](auto x) { oss << x << ' '; }); |
| 36 | BOOST_TEST(get(t, llong<0>{}) == ""); |
| 37 | BOOST_TEST(oss.str() == "foo 4 "); |
| 38 | } |
| 39 | } |
| 40 | |
| 41 | // transform |
| 42 | { |
| 43 | { |
| 44 | tuple<std::string, int> t{"foo", 4}; |
| 45 | auto t2 = detail::hl::transform( |
| 46 | t, [&](auto x) { return std::optional<decltype(x)>{x}; }); |
| 47 | BOOST_TEST(get(t, llong<0>{}) == "foo"); |
| 48 | BOOST_TEST(get(t2, llong<0>{}) == std::optional<std::string>{"foo"}); |
| 49 | BOOST_TEST(get(t2, llong<1>{}) == std::optional<int>{4}); |
| 50 | } |
| 51 | { |
| 52 | tuple<std::string, int> t{"foo", 4}; |
| 53 | auto t2 = detail::hl::transform(std::move(t), [&](auto x) { |
| 54 | return std::optional<decltype(x)>{x}; |
| 55 | }); |
| 56 | BOOST_TEST(get(t, llong<0>{}) == ""); |
| 57 | BOOST_TEST(get(t2, llong<0>{}) == std::optional<std::string>{"foo"}); |
| 58 | BOOST_TEST(get(t2, llong<1>{}) == std::optional<int>{4}); |
| 59 | } |
| 60 | } |
| 61 | |
| 62 | // fold_left |
| 63 | { |
| 64 | tuple<std::string, int> t{"foo", 4}; |
| 65 | auto t2 = |
| 66 | detail::hl::fold_left(t, tuple<>{}, [](auto const & state, auto x) { |
| 67 | return detail::hl::append(state, x); |
| 68 | }); |
| 69 | BOOST_TEST(t == t2); |
| 70 | } |
| 71 | |
| 72 | // size |
| 73 | { |
| 74 | { |
| 75 | tuple<std::string, int> t{"foo", 4}; |
| 76 | BOOST_TEST(detail::hl::size(t).value == 2u); |
| 77 | } |
nothing calls this directly
no test coverage detected