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

Method testVariant

test/parse_into.cpp:445–480  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

443
444 template< template<class...> class Variant, class Monostate >
445 void testVariant()
446 {
447 testParseInto< Variant<int> >( 1 );
448 testParseInto< Variant<int, std::string> >( 1 );
449 testParseInto< Variant<int, std::string> >( "qwerty" );
450 testParseInto< Variant<Monostate, int, std::string> >( {} );
451 testParseInto< Variant<Monostate, int, std::string> >( 1 );
452 testParseInto< Variant<Monostate, int, std::string> >( "qwerty" );
453 testParseInto< Variant<bool, std::uint64_t> >( true );
454 testParseInto< Variant<bool, std::uint64_t> >( UINT64_MAX );
455
456 testParseInto< Variant< std::vector<int> > >(
457 std::vector<int>{1, 2, 3, 4, 5} );
458 testParseInto< Variant< Monostate, std::vector<int> > >(
459 std::vector<int>{1, 2, 3, 4, 5} );
460
461 testParseInto< std::vector< Variant<int, std::string> > >(
462 {1, 2, 3, "four", 5, "six", "seven", 8});
463
464 using V = Variant<
465 std::vector< int >,
466 std::tuple< int, std::string, std::map<std::string, int> >,
467 std::tuple< int, std::string, std::map<std::string, double> > >;
468 testParseInto< V >(
469 std::make_tuple(
470 5,
471 "five",
472 std::map<std::string, double>{ {"one", 1}, {"pi", 3.14} }));
473
474 testParseIntoErrors< Variant<Monostate> >(
475 error::exhausted_variants, "a" );
476 testParseIntoErrors< Variant<int> >(
477 error::exhausted_variants, "a" );
478 testParseIntoErrors< Variant<Monostate, int, bool> >(
479 error::exhausted_variants, "a" );
480 }
481
482 void testOptional()
483 {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected