MCPcopy Create free account
hub / github.com/boostorg/parser / main

Function main

test/parser_seq_permutations_1.cpp:37–341  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35using namespace std::literals;
36
37int main()
38{
39 [[maybe_unused]] int dummy = 0; // for clang-format(!)
40
41 // P0
42 {
43 auto result =
44 bp::parse("foofoo", bp::string("foo") >> bp::string("foo"));
45 BOOST_TEST(result);
46 BOOST_TEST(*result == (make::tuple("foo"s, "foo"s)));
47 }
48 {
49 auto result =
50 bp::parse("foobar", bp::string("foo") >> bp::string("bar"));
51 BOOST_TEST(result);
52 BOOST_TEST(*result == (make::tuple("foo"s, "bar"s)));
53 }
54 {
55 auto result = bp::parse("foo42", bp::string("foo") >> bp::int_);
56 BOOST_TEST(result);
57 BOOST_TEST(*result == (make::tuple("foo"s, 42)));
58 }
59 {
60 auto result = bp::parse("fooc", bp::string("foo") >> bp::char_('c'));
61 BOOST_TEST(result);
62 BOOST_TEST(*result == "fooc"s);
63 }
64 {
65 auto result = bp::parse("foo", bp::string("foo") >> bp::eps);
66 BOOST_TEST(result);
67 BOOST_TEST(*result == "foo"s);
68 }
69 {
70 auto result =
71 bp::parse("foofoofoo", bp::string("foo") >> *bp::string("foo"));
72 BOOST_TEST(result);
73 BOOST_TEST(*result == std::vector({"foo"s, "foo"s, "foo"s}));
74 }
75 {
76 auto result = bp::parse("foo", bp::string("foo") >> -bp::string("foo"));
77 BOOST_TEST(result);
78 BOOST_TEST(*result == (make::tuple("foo"s, std::optional<std::string>{})));
79 }
80 {
81 auto result = bp::parse(
82 "foofoo42", bp::string("foo") >> (bp::string("foo") >> bp::int_));
83 BOOST_TEST(result);
84 BOOST_TEST(*result == (make::tuple("foo"s, "foo"s, 42)));
85 }
86 {
87 auto result = bp::parse(
88 "foofoobar",
89 bp::string("foo") >> -(bp::string("foo") >> bp::string("bar")));
90 BOOST_TEST(result);
91 BOOST_TEST(
92 *result ==
93 (make::tuple("foo"s, std::optional(make::tuple("foo"s, "bar"s)))));
94 }

Callers

nothing calls this directly

Calls 4

vectorClass · 0.85
tupleFunction · 0.70
parseFunction · 0.50
stringClass · 0.50

Tested by

no test coverage detected