| 15 | using namespace std::literals; |
| 16 | |
| 17 | int main() |
| 18 | { |
| 19 | { |
| 20 | constexpr auto parser = bp::int_ || bp::string("foo"); |
| 21 | |
| 22 | { |
| 23 | auto result = bp::parse("42 foo", parser, bp::ws); |
| 24 | BOOST_TEST(result); |
| 25 | BOOST_TEST(*result == (bp::tuple<int, std::string>(42, "foo"s))); |
| 26 | } |
| 27 | { |
| 28 | auto result = bp::parse("42foo", parser, bp::ws); |
| 29 | BOOST_TEST(result); |
| 30 | BOOST_TEST(*result == (bp::tuple<int, std::string>(42, "foo"s))); |
| 31 | } |
| 32 | { |
| 33 | auto result = bp::parse("foo 42", parser, bp::ws); |
| 34 | BOOST_TEST(result); |
| 35 | BOOST_TEST(*result == (bp::tuple<int, std::string>(42, "foo"s))); |
| 36 | } |
| 37 | { |
| 38 | auto result = bp::parse("foo42", parser, bp::ws); |
| 39 | BOOST_TEST(result); |
| 40 | BOOST_TEST(*result == (bp::tuple<int, std::string>(42, "foo"s))); |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | { |
| 45 | constexpr auto parser = bp::int_ || bp::string("foo") || bp::char_('g'); |
| 46 | |
| 47 | { |
| 48 | auto result = bp::parse("42 foo g", parser, bp::ws); |
| 49 | BOOST_TEST(result); |
| 50 | BOOST_TEST( |
| 51 | *result == |
| 52 | (bp::tuple<int, std::string, double>(42, "foo"s, 'g'))); |
| 53 | } |
| 54 | { |
| 55 | auto result = bp::parse("42 g foo", parser, bp::ws); |
| 56 | BOOST_TEST(result); |
| 57 | BOOST_TEST( |
| 58 | *result == |
| 59 | (bp::tuple<int, std::string, double>(42, "foo"s, 'g'))); |
| 60 | } |
| 61 | { |
| 62 | auto result = bp::parse("foo 42 g", parser, bp::ws); |
| 63 | BOOST_TEST(result); |
| 64 | BOOST_TEST( |
| 65 | *result == |
| 66 | (bp::tuple<int, std::string, double>(42, "foo"s, 'g'))); |
| 67 | } |
| 68 | { |
| 69 | auto result = bp::parse("foo g 42", parser, bp::ws); |
| 70 | BOOST_TEST(result); |
| 71 | BOOST_TEST( |
| 72 | *result == |
| 73 | (bp::tuple<int, std::string, double>(42, "foo"s, 'g'))); |
| 74 | } |