| 361 | } |
| 362 | |
| 363 | int main() |
| 364 | { |
| 365 | |
| 366 | // detail_attr_search_repack_shim |
| 367 | { |
| 368 | using namespace bp::literals; |
| 369 | |
| 370 | { |
| 371 | std::string str = ""; |
| 372 | auto parser = bp::string("XYZ"); |
| 373 | |
| 374 | // Follows body of attr_search_impl() that constructs a custom parser |
| 375 | // from the given one. |
| 376 | auto first = bp::detail::text::detail::begin(str); |
| 377 | auto const last = bp::detail::text::detail::end(str); |
| 378 | auto match_first = first; |
| 379 | auto match_last = first; |
| 380 | auto before = [&match_first](auto & ctx) { |
| 381 | match_first = _where(ctx).begin(); |
| 382 | }; |
| 383 | auto after = [&match_last](auto & ctx) { |
| 384 | match_last = _where(ctx).begin(); |
| 385 | }; |
| 386 | auto const search_parser = |
| 387 | bp::omit[*(bp::char_ - parser)] >> |
| 388 | -bp::lexeme[bp::eps[before] >> bp::skip[parser] >> bp::eps[after]]; |
| 389 | |
| 390 | auto result = bp::prefix_parse( |
| 391 | first, last, search_parser, bp::ws, bp::trace::off); |
| 392 | static_assert(std::is_same_v< |
| 393 | decltype(result), |
| 394 | std::optional<std::optional<std::string>>>); |
| 395 | static_assert(std::is_same_v< |
| 396 | decltype(bp::prefix_parse( |
| 397 | first, last, search_parser, bp::ws, bp::trace::off)), |
| 398 | std::optional<std::optional<std::string>>>); |
| 399 | } |
| 400 | { |
| 401 | std::string str = ""; |
| 402 | auto parser = bp::string("XYZ"); |
| 403 | bp::detail::attr_search_impl(str, parser, bp::ws, bp::trace::off); |
| 404 | } |
| 405 | { |
| 406 | std::string str = ""; |
| 407 | auto result = bp::detail::attr_search_repack_shim( |
| 408 | str, bp::string("XYZ"), bp::ws, bp::trace::off); |
| 409 | auto subrng = bp::get(result, 0_c); |
| 410 | BOOST_TEST(subrng.begin() == std::begin(str)); |
| 411 | BOOST_TEST(subrng.end() == std::begin(str)); |
| 412 | auto result_str = bp::get(result, 1_c); |
| 413 | BOOST_TEST(result_str == ""); |
| 414 | } |
| 415 | { |
| 416 | char const str[] = "not here"; |
| 417 | auto result = bp::detail::attr_search_repack_shim( |
| 418 | str, bp::string("XYZ"), bp::ws, bp::trace::off); |
| 419 | auto subrng = bp::get(result, 0_c); |
| 420 | BOOST_TEST(subrng.begin() == std::end(str)); |
nothing calls this directly
no test coverage detected