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

Function main

test/parser_or_permutations_2.cpp:37–314  ·  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 = bp::parse("foo", bp::string("bar") | bp::string("foo"));
44 BOOST_TEST(result);
45 BOOST_TEST(*result == "foo"s);
46 }
47 {
48 auto result = bp::parse("bar", bp::string("bar") | bp::string("bar"));
49 BOOST_TEST(result);
50 BOOST_TEST(*result == "bar"s);
51 }
52 {
53 auto result = bp::parse("42", bp::string("bar") | bp::int_);
54 BOOST_TEST(result);
55 BOOST_TEST(result->index() == 1u);
56 BOOST_TEST(std::get<int>(*result) == 42);
57 }
58 {
59 auto result = bp::parse("bar", bp::string("bar") | bp::char_('c'));
60 BOOST_TEST(result);
61 BOOST_TEST(result->index() == 0);
62 BOOST_TEST(std::get<std::string>(*result) == "bar"s);
63 }
64 {
65 auto result = bp::parse("", bp::string("bar") | bp::eps);
66 BOOST_TEST(result);
67 BOOST_TEST(*result == std::nullopt);
68 }
69 {
70 auto result =
71 bp::parse("foofoo", bp::string("bar") | *bp::string("foo"));
72 BOOST_TEST(result);
73 BOOST_TEST(result->index() == 1u);
74 BOOST_TEST(
75 std::get<std::vector<std::string>>(*result) ==
76 std::vector({"foo"s, "foo"s}));
77 }
78 {
79 auto result = bp::parse("bar", bp::string("bar") | -bp::string("foo"));
80 BOOST_TEST(result);
81 BOOST_TEST(result->index() == 0);
82 BOOST_TEST(std::get<std::string>(*result) == "bar"s);
83 }
84 {
85 auto result =
86 bp::parse("42", bp::string("bar") | (bp::string("foo") | bp::int_));
87 BOOST_TEST(result);
88 BOOST_TEST(result->index() == 1u);
89 BOOST_TEST(std::get<int>(*result) == 42);
90 }
91 {
92 auto result = bp::parse(
93 "bar",
94 bp::string("foo") | -(bp::string("foo") | bp::string("bar")));

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