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

Method testContext

test/value_from.cpp:599–646  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

597 }
598
599 void
600 testContext()
601 {
602 value jv = value_from(
603 value_from_test_ns::T1{}, value_from_test_ns::custom_context() );
604 BOOST_TEST( jv == 42 );
605
606 jv = value_from(
607 value_from_test_ns::T12{},
608 value_from_test_ns::custom_context() );
609 BOOST_TEST( jv == "T12" );
610
611 jv = value_from(
612 value_from_test_ns::T13{},
613 std::make_tuple(
614 value_from_test_ns::custom_context(),
615 value_from_test_ns::another_context() ) );
616 BOOST_TEST( jv == "T13" );
617
618 jv = value_from(
619 std::pair<value_from_test_ns::T12, value_from_test_ns::T13>(),
620 std::make_tuple(
621 value_from_test_ns::custom_context(),
622 value_from_test_ns::another_context() ) );
623 BOOST_TEST( jv == (array{ "T12", "T13" }) );
624
625
626 auto ctx = std::make_tuple(
627 value_from_test_ns::custom_context(),
628 value_from_test_ns::another_context() );
629 using Ctx = decltype(ctx);
630 using Sup = detail::supported_context<
631 Ctx,
632 std::vector<value_from_test_ns::T12>,
633 detail::value_from_conversion >;
634 BOOST_CORE_STATIC_ASSERT( Sup::index::value == 1 );
635 BOOST_CORE_STATIC_ASSERT((
636 std::is_same<
637 Sup::type,
638 value_from_test_ns::another_context>::value));
639
640 jv = value_from(
641 std::vector<value_from_test_ns::T12>(2),
642 std::make_tuple(
643 value_from_test_ns::custom_context(),
644 value_from_test_ns::another_context() ) );
645 BOOST_TEST( jv == (object{ {"1", "T12"}, {"2", "T12"} }) );
646 }
647
648 struct run_templated_tests
649 {

Callers

nothing calls this directly

Calls 3

value_fromFunction · 0.85
another_contextClass · 0.85
custom_contextClass · 0.70

Tested by

no test coverage detected