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

Method testAutoConversion

test/value_ref.cpp:392–411  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

390 }
391
392 void
393 testAutoConversion()
394 {
395 value jv = { 1, false, std::vector<int>{1,2,3} };
396 auto& ja = jv.as_array();
397 BOOST_TEST(ja.size() == 3);
398 BOOST_TEST(ja[0] == 1);
399 BOOST_TEST(ja[1] == false);
400 BOOST_TEST(( ja[2].as_array() == array{1,2,3} ));
401
402 jv = { {"a", std::vector<int>{1,2,3}}, {"b", std::string("foo")} };
403 auto& jo = jv.as_object();
404 BOOST_TEST(jo.size() == 2);
405 BOOST_TEST(( jo["a"] == array{1,2,3} ));
406 BOOST_TEST(( jo["b"] == "foo" ));
407
408 jv = {std::string("bar")};
409 BOOST_TEST( jv.is_string() );
410 BOOST_TEST(( jv == "bar" ));
411 }
412
413 void
414 run()

Callers

nothing calls this directly

Calls 3

is_stringMethod · 0.80
stringClass · 0.50
sizeMethod · 0.45

Tested by

no test coverage detected