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

Function github_issue_223

test/github_issues.cpp:261–288  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

259}
260
261void github_issue_223()
262{
263 namespace bp = boost::parser;
264
265 // failing case
266 {
267 std::vector<char> v;
268 const auto parser = *('x' | bp::char_('y'));
269 bp::parse("xy", parser, bp::ws, v);
270
271 BOOST_TEST(v.size() == 1);
272 BOOST_TEST(v == std::vector<char>({'y'}));
273
274 // the assert fails since there are two elements in the vector: '\0'
275 // and 'y'. Seems pretty surprising to me
276 }
277
278 // working case
279 {
280 const auto parser = *('x' | bp::char_('y'));
281 const auto result = bp::parse("xy", parser, bp::ws);
282
283 BOOST_TEST(result->size() == 1);
284 BOOST_TEST(*(*result)[0] == 'y');
285
286 // success, the vector has only one 'y' element
287 }
288}
289
290namespace github_issue_248_ {
291 namespace bp = boost::parser;

Callers 1

mainFunction · 0.85

Calls 2

parseFunction · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected