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

Function main

test/parser_action.cpp:81–227  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

79BOOST_PARSER_DEFINE_RULES(str_rule_7);
80
81int main()
82{
83
84// side_effects
85{
86 int i = 0;
87 auto increment_i = [&i](auto & ctx) { ++i; };
88
89 using no_attribute_return = decltype(parse("xyz", char_('a')[increment_i]));
90 static_assert(std::is_same_v<no_attribute_return, bool>);
91
92 {
93 std::string const str = "xyz";
94 BOOST_TEST(!parse(str, char_('a')[increment_i]));
95 BOOST_TEST(i == 0);
96 BOOST_TEST(!parse(str, char_('x')[increment_i]));
97 BOOST_TEST(i == 1);
98 auto first = str.c_str();
99 BOOST_TEST(prefix_parse(
100 first, boost::parser::detail::text::null_sentinel, char_('x')[increment_i]));
101 BOOST_TEST(i == 2);
102 BOOST_TEST(!parse(str, char_('a')[increment_i]));
103 BOOST_TEST(i == 2);
104 BOOST_TEST(!parse(str, char_('x')[increment_i]));
105 BOOST_TEST(i == 3);
106 first = str.c_str();
107 BOOST_TEST(prefix_parse(
108 first, boost::parser::detail::text::null_sentinel, char_('x')[increment_i]));
109 BOOST_TEST(i == 4);
110 }
111}
112
113// pass
114{
115 {
116 std::string const str = "xyz";
117 auto const result = parse(str, abc_def);
118 BOOST_TEST(!result);
119 }
120 {
121 std::string const str = "abc";
122 auto const result = parse(str, abc_def);
123 BOOST_TEST(result);
124 BOOST_TEST(*result == "abc");
125 }
126 {
127 std::string const str = "def";
128 auto const result = parse(str, abc_def);
129 BOOST_TEST(result);
130 BOOST_TEST(*result == "def");
131 }
132 {
133 std::string const str = "abc";
134 auto const result = parse(str, fail_abc_pass_def);
135 BOOST_TEST(!result);
136 }
137 {
138 std::string const str = "def";

Callers

nothing calls this directly

Calls 2

prefix_parseFunction · 0.85
parseFunction · 0.50

Tested by

no test coverage detected