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

Function main

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