| 259 | } |
| 260 | |
| 261 | void 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 | |
| 290 | namespace github_issue_248_ { |
| 291 | namespace bp = boost::parser; |