MCPcopy Create free account
hub / github.com/boostorg/json / testAccess

Method testAccess

test/array.cpp:452–614  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

450 }
451
452 void
453 testAccess()
454 {
455 // at(pos) &
456 {
457 array a({1, true, str_});
458 BOOST_TEST(a.at(0).is_number());
459 BOOST_TEST(a.at(1).is_bool());
460 BOOST_TEST(a.at(2).is_string());
461 BOOST_TEST_THROWS_WITH_LOCATION( a.at(3) );
462 }
463
464 // at(pos) &&
465 {
466 array a({1, true, str_});
467 BOOST_TEST(std::move(a).at(0).is_number());
468 BOOST_TEST(std::move(a).at(1).is_bool());
469 BOOST_TEST(std::move(a).at(2).is_string());
470 BOOST_TEST_THROWS_WITH_LOCATION( a.at(3) );
471 value&& rv = std::move(a).at(0);
472 (void)rv;
473 }
474
475 // at(pos) const&
476 {
477 array const a({1, true, str_});
478 BOOST_TEST(a.at(0).is_number());
479 BOOST_TEST(a.at(1).is_bool());
480 BOOST_TEST(a.at(2).is_string());
481 BOOST_TEST_THROWS_WITH_LOCATION( a.at(3) );
482 }
483
484 // try_at(pos)
485 {
486 array a({ 1, true, str_ });
487 BOOST_TEST( a.try_at(0)->is_number() );
488 BOOST_TEST( a.try_at(1)->is_bool() );
489 BOOST_TEST( a.try_at(2)->is_string() );
490
491 system::error_code const ec = a.try_at(3).error();
492 BOOST_TEST( ec == error::out_of_range );
493 BOOST_TEST( ec.has_location() );
494 }
495
496 // try_at(pos) const
497 {
498 array const a({1, true, str_});
499 BOOST_TEST(a.try_at(0)->is_number());
500 BOOST_TEST(a.try_at(1)->is_bool());
501 BOOST_TEST(a.try_at(2)->is_string());
502
503 system::error_code const ec = a.try_at(3).error();
504 BOOST_TEST( ec == error::out_of_range );
505 BOOST_TEST( ec.has_location() );
506 }
507
508 // operator[&](size_type) &
509 {

Callers

nothing calls this directly

Calls 5

is_numberMethod · 0.80
is_boolMethod · 0.80
is_stringMethod · 0.80
dataMethod · 0.45
beginMethod · 0.45

Tested by

no test coverage detected