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

Function main

test/parser_seq_permutations_2.cpp:37–372  ·  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 // P1
42 {
43 auto result =
44 bp::parse("barfoo", bp::string("bar") >> bp::string("foo"));
45 BOOST_TEST(result);
46 BOOST_TEST(*result == (make::tuple("bar"s, "foo"s)));
47 }
48 {
49 auto result =
50 bp::parse("barbar", bp::string("bar") >> bp::string("bar"));
51 BOOST_TEST(result);
52 BOOST_TEST(*result == (make::tuple("bar"s, "bar"s)));
53 }
54 {
55 auto result = bp::parse("bar42", bp::string("bar") >> bp::int_);
56 BOOST_TEST(result);
57 BOOST_TEST(*result == (make::tuple("bar"s, 42)));
58 }
59 {
60 auto result = bp::parse("barc", bp::string("bar") >> bp::char_('c'));
61 BOOST_TEST(result);
62 BOOST_TEST(*result == "barc"s);
63 }
64 {
65 auto result = bp::parse("bar", bp::string("bar") >> bp::eps);
66 BOOST_TEST(result);
67 BOOST_TEST(*result == "bar"s);
68 }
69 {
70 auto result =
71 bp::parse("barfoofoo", bp::string("bar") >> *bp::string("foo"));
72 BOOST_TEST(result);
73 BOOST_TEST(*result == std::vector({"bar"s, "foo"s, "foo"s}));
74 }
75 {
76 auto result =
77 bp::parse("barfoo", bp::string("bar") >> -bp::string("foo"));
78 BOOST_TEST(result);
79 BOOST_TEST(*result == (make::tuple("bar"s, std::optional("foo"s))));
80 }
81 {
82 auto result = bp::parse(
83 "barfoo42", bp::string("bar") >> (bp::string("foo") >> bp::int_));
84 BOOST_TEST(result);
85 BOOST_TEST(*result == (make::tuple("bar"s, "foo"s, 42)));
86 }
87 {
88 auto result = bp::parse(
89 "barfoobar",
90 bp::string("bar") >> -(bp::string("foo") >> bp::string("bar")));
91 BOOST_TEST(result);
92 BOOST_TEST(
93 *result ==
94 (make::tuple("bar"s, std::optional(make::tuple("foo"s, "bar"s)))));

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