| 1457 | } |
| 1458 | |
| 1459 | void |
| 1460 | testMaxDepth() |
| 1461 | { |
| 1462 | { |
| 1463 | string_view s = "[[[[[]]]]]"; |
| 1464 | parse_options opt; |
| 1465 | opt.max_depth = 4; |
| 1466 | null_parser p(opt); |
| 1467 | system::error_code ec; |
| 1468 | p.write(s.data(), s.size(), ec); |
| 1469 | BOOST_TEST(ec == error::too_deep); |
| 1470 | BOOST_TEST(ec.has_location()); |
| 1471 | } |
| 1472 | { |
| 1473 | string_view s = "[[[[]]], [[[[]]]]]"; |
| 1474 | parse_options opt; |
| 1475 | opt.max_depth = 4; |
| 1476 | null_parser p(opt); |
| 1477 | system::error_code ec; |
| 1478 | p.write(s.data(), s.size(), ec); |
| 1479 | BOOST_TEST(ec == error::too_deep); |
| 1480 | BOOST_TEST(ec.has_location()); |
| 1481 | } |
| 1482 | { |
| 1483 | string_view s = |
| 1484 | "{\"a\":{\"b\":{\"c\":{}}},\"b\":{\"c\":{\"d\":{\"e\":{}}}}}"; |
| 1485 | parse_options opt; |
| 1486 | opt.max_depth = 4; |
| 1487 | null_parser p(opt); |
| 1488 | system::error_code ec; |
| 1489 | p.write(s.data(), s.size(), ec); |
| 1490 | BOOST_TEST(ec == error::too_deep); |
| 1491 | BOOST_TEST(ec.has_location()); |
| 1492 | } |
| 1493 | { |
| 1494 | string_view s = |
| 1495 | "{\"a\":{\"b\":{\"c\":{\"d\":{}}}}}"; |
| 1496 | parse_options opt; |
| 1497 | opt.max_depth = 4; |
| 1498 | null_parser p(opt); |
| 1499 | system::error_code ec; |
| 1500 | p.write(s.data(), s.size(), ec); |
| 1501 | BOOST_TEST(ec == error::too_deep); |
| 1502 | BOOST_TEST(ec.has_location()); |
| 1503 | } |
| 1504 | } |
| 1505 | |
| 1506 | class literal_parser |
| 1507 | { |