#define BOOST_TEST_MODULE "test_value" #ifdef UNITTEST_FRAMEWORK_LIBRARY_EXIST #include #else #define BOOST_TEST_NO_LIB #include #endif #include #include #include BOOST_AUTO_TEST_CASE(test_value_boolean) { toml::value v1(true); toml::value v2(false); BOOST_CHECK_EQUAL(v1.type(), toml::value_t::Boolean); BOOST_CHECK_EQUAL(v2.type(), toml::value_t::Boolean); BOOST_CHECK(v1.is(toml::value_t::Boolean)); BOOST_CHECK(v2.is(toml::value_t::Boolean)); BOOST_CHECK(v1.is()); BOOST_CHECK(v2.is()); BOOST_CHECK_EQUAL(v1.cast(), true); BOOST_CHECK_EQUAL(v2.cast(), false); v1 = false; v2 = true; BOOST_CHECK_EQUAL(v1.type(), toml::value_t::Boolean); BOOST_CHECK_EQUAL(v2.type(), toml::value_t::Boolean); BOOST_CHECK(v1.is(toml::value_t::Boolean)); BOOST_CHECK(v2.is(toml::value_t::Boolean)); BOOST_CHECK(v1.is()); BOOST_CHECK(v2.is()); BOOST_CHECK_EQUAL(v1.cast(), false); BOOST_CHECK_EQUAL(v2.cast(), true); toml::value v3(v1); toml::value v4(v2); BOOST_CHECK(v3 == v1); BOOST_CHECK(v4 == v2); BOOST_CHECK_EQUAL(v3.type(), toml::value_t::Boolean); BOOST_CHECK_EQUAL(v4.type(), toml::value_t::Boolean); BOOST_CHECK(v3.is(toml::value_t::Boolean)); BOOST_CHECK(v4.is(toml::value_t::Boolean)); BOOST_CHECK(v3.is()); BOOST_CHECK(v4.is()); BOOST_CHECK_EQUAL(v3.cast(), false); BOOST_CHECK_EQUAL(v4.cast(), true); toml::value v5(std::move(v1)); toml::value v6(std::move(v2)); BOOST_CHECK_EQUAL(v5.type(), toml::value_t::Boolean); BOOST_CHECK_EQUAL(v6.type(), toml::value_t::Boolean); BOOST_CHECK(v5.is(toml::value_t::Boolean)); BOOST_CHECK(v6.is(toml::value_t::Boolean)); BOOST_CHECK(v5.is()); BOOST_CHECK(v6.is()); BOOST_CHECK_EQUAL(v5.cast(), false); BOOST_CHECK_EQUAL(v6.cast(), true); v1 = 42; v2 = 3.14; BOOST_CHECK_EQUAL(v1.type(), toml::value_t::Integer); BOOST_CHECK_EQUAL(v2.type(), toml::value_t::Float); BOOST_CHECK(v1.is(toml::value_t::Integer)); BOOST_CHECK(v2.is(toml::value_t::Float)); BOOST_CHECK(v1.is()); BOOST_CHECK(v2.is()); BOOST_CHECK_EQUAL(v1.cast(), 42); BOOST_CHECK_EQUAL(v2.cast(), 3.14); } BOOST_AUTO_TEST_CASE(test_value_integer) { toml::value v1(-42); toml::value v2(42u); BOOST_CHECK_EQUAL(v1.type(), toml::value_t::Integer); BOOST_CHECK_EQUAL(v2.type(), toml::value_t::Integer); BOOST_CHECK(v1.is(toml::value_t::Integer)); BOOST_CHECK(v2.is(toml::value_t::Integer)); BOOST_CHECK(v1.is()); BOOST_CHECK(v2.is()); BOOST_CHECK_EQUAL(v1.cast(), -42); BOOST_CHECK_EQUAL(v2.cast(), 42u); v1 = 54; v2 = -54; BOOST_CHECK_EQUAL(v1.type(), toml::value_t::Integer); BOOST_CHECK_EQUAL(v2.type(), toml::value_t::Integer); BOOST_CHECK(v1.is(toml::value_t::Integer)); BOOST_CHECK(v2.is(toml::value_t::Integer)); BOOST_CHECK(v1.is()); BOOST_CHECK(v2.is()); BOOST_CHECK_EQUAL(v1.cast(), 54); BOOST_CHECK_EQUAL(v2.cast(), -54); toml::value v3(v1); toml::value v4(v2); BOOST_CHECK(v3 == v1); BOOST_CHECK(v4 == v2); BOOST_CHECK_EQUAL(v3.type(), toml::value_t::Integer); BOOST_CHECK_EQUAL(v4.type(), toml::value_t::Integer); BOOST_CHECK(v3.is(toml::value_t::Integer)); BOOST_CHECK(v4.is(toml::value_t::Integer)); BOOST_CHECK(v3.is()); BOOST_CHECK(v4.is()); BOOST_CHECK_EQUAL(v3.cast(), 54); BOOST_CHECK_EQUAL(v4.cast(), -54); toml::value v5(std::move(v1)); toml::value v6(std::move(v2)); BOOST_CHECK_EQUAL(v5.type(), toml::value_t::Integer); BOOST_CHECK_EQUAL(v6.type(), toml::value_t::Integer); BOOST_CHECK(v5.is(toml::value_t::Integer)); BOOST_CHECK(v6.is(toml::value_t::Integer)); BOOST_CHECK(v5.is()); BOOST_CHECK(v6.is()); BOOST_CHECK_EQUAL(v5.cast(), 54); BOOST_CHECK_EQUAL(v6.cast(), -54); v1 = true; v2 = false; BOOST_CHECK_EQUAL(v1.type(), toml::value_t::Boolean); BOOST_CHECK_EQUAL(v2.type(), toml::value_t::Boolean); BOOST_CHECK(v1.is(toml::value_t::Boolean)); BOOST_CHECK(v2.is(toml::value_t::Boolean)); BOOST_CHECK(v1.is()); BOOST_CHECK(v2.is()); BOOST_CHECK_EQUAL(v1.cast(), true); BOOST_CHECK_EQUAL(v2.cast(), false); } BOOST_AUTO_TEST_CASE(test_value_float) { toml::value v1(3.14); toml::value v2(3.14f); BOOST_CHECK_EQUAL(v1.type(), toml::value_t::Float); BOOST_CHECK_EQUAL(v2.type(), toml::value_t::Float); BOOST_CHECK(v1.is(toml::value_t::Float)); BOOST_CHECK(v2.is(toml::value_t::Float)); BOOST_CHECK(v1.is()); BOOST_CHECK(v2.is()); BOOST_CHECK_EQUAL(v1.cast(), 3.14); BOOST_CHECK_CLOSE_FRACTION(v2.cast(), 3.14, 1e-2); v1 = 2.718f; v2 = 2.718; BOOST_CHECK_EQUAL(v1.type(), toml::value_t::Float); BOOST_CHECK_EQUAL(v2.type(), toml::value_t::Float); BOOST_CHECK(v1.is(toml::value_t::Float)); BOOST_CHECK(v2.is(toml::value_t::Float)); BOOST_CHECK(v1.is()); BOOST_CHECK(v2.is()); BOOST_CHECK_CLOSE_FRACTION(v1.cast(), 2.718, 1e-3); BOOST_CHECK_EQUAL(v2.cast(), 2.718); toml::value v3(v1); toml::value v4(v2); BOOST_CHECK(v3 == v1); BOOST_CHECK(v4 == v2); BOOST_CHECK_EQUAL(v3.type(), toml::value_t::Float); BOOST_CHECK_EQUAL(v4.type(), toml::value_t::Float); BOOST_CHECK(v3.is(toml::value_t::Float)); BOOST_CHECK(v4.is(toml::value_t::Float)); BOOST_CHECK(v3.is()); BOOST_CHECK(v4.is()); BOOST_CHECK_CLOSE_FRACTION(v3.cast(), 2.718, 1e-3); BOOST_CHECK_EQUAL(v4.cast(), 2.718); toml::value v5(std::move(v1)); toml::value v6(std::move(v2)); BOOST_CHECK_EQUAL(v5.type(), toml::value_t::Float); BOOST_CHECK_EQUAL(v6.type(), toml::value_t::Float); BOOST_CHECK(v5.is(toml::value_t::Float)); BOOST_CHECK(v6.is(toml::value_t::Float)); BOOST_CHECK(v5.is()); BOOST_CHECK(v6.is()); BOOST_CHECK_CLOSE_FRACTION(v5.cast(), 2.718, 1e-3); BOOST_CHECK_EQUAL(v6.cast(), 2.718); v1 = true; v2 = false; BOOST_CHECK_EQUAL(v1.type(), toml::value_t::Boolean); BOOST_CHECK_EQUAL(v2.type(), toml::value_t::Boolean); BOOST_CHECK(v1.is(toml::value_t::Boolean)); BOOST_CHECK(v2.is(toml::value_t::Boolean)); BOOST_CHECK(v1.is()); BOOST_CHECK(v2.is()); BOOST_CHECK_EQUAL(v1.cast(), true); BOOST_CHECK_EQUAL(v2.cast(), false); } BOOST_AUTO_TEST_CASE(test_value_string) { toml::value v1(std::string("foo")); toml::value v2(std::string("foo"), toml::string_t::literal); toml::value v3("foo"); BOOST_CHECK_EQUAL(v1.type(), toml::value_t::String); BOOST_CHECK_EQUAL(v2.type(), toml::value_t::String); BOOST_CHECK_EQUAL(v3.type(), toml::value_t::String); BOOST_CHECK(v1.is(toml::value_t::String)); BOOST_CHECK(v2.is(toml::value_t::String)); BOOST_CHECK(v3.is(toml::value_t::String)); BOOST_CHECK(v1.is()); BOOST_CHECK(v2.is()); BOOST_CHECK(v3.is()); BOOST_CHECK_EQUAL(v1.cast(), "foo"); BOOST_CHECK_EQUAL(v2.cast(), "foo"); BOOST_CHECK_EQUAL(v3.cast(), "foo"); v1 = "bar"; v2 = "bar"; v3 = "bar"; BOOST_CHECK_EQUAL(v1.type(), toml::value_t::String); BOOST_CHECK_EQUAL(v2.type(), toml::value_t::String); BOOST_CHECK_EQUAL(v3.type(), toml::value_t::String); BOOST_CHECK(v1.is(toml::value_t::String)); BOOST_CHECK(v2.is(toml::value_t::String)); BOOST_CHECK(v3.is(toml::value_t::String)); BOOST_CHECK(v1.is()); BOOST_CHECK(v2.is()); BOOST_CHECK(v3.is()); BOOST_CHECK_EQUAL(v1.cast(), "bar"); BOOST_CHECK_EQUAL(v2.cast(), "bar"); BOOST_CHECK_EQUAL(v3.cast(), "bar"); toml::value v4(v1); toml::value v5(v2); toml::value v6(v3); BOOST_CHECK(v4 == v1); BOOST_CHECK(v5 == v2); BOOST_CHECK(v6 == v3); BOOST_CHECK_EQUAL(v4.type(), toml::value_t::String); BOOST_CHECK_EQUAL(v5.type(), toml::value_t::String); BOOST_CHECK_EQUAL(v6.type(), toml::value_t::String); BOOST_CHECK(v4.is(toml::value_t::String)); BOOST_CHECK(v5.is(toml::value_t::String)); BOOST_CHECK(v6.is(toml::value_t::String)); BOOST_CHECK(v4.is()); BOOST_CHECK(v5.is()); BOOST_CHECK(v6.is()); BOOST_CHECK_EQUAL(v4.cast(), "bar"); BOOST_CHECK_EQUAL(v5.cast(), "bar"); BOOST_CHECK_EQUAL(v6.cast(), "bar"); v4.cast().str.at(2) = 'z'; v5.cast().str.at(2) = 'z'; v6.cast().str.at(2) = 'z'; BOOST_CHECK_EQUAL(v4.type(), toml::value_t::String); BOOST_CHECK_EQUAL(v5.type(), toml::value_t::String); BOOST_CHECK_EQUAL(v6.type(), toml::value_t::String); BOOST_CHECK(v4.is(toml::value_t::String)); BOOST_CHECK(v5.is(toml::value_t::String)); BOOST_CHECK(v6.is(toml::value_t::String)); BOOST_CHECK(v4.is()); BOOST_CHECK(v5.is()); BOOST_CHECK(v6.is()); BOOST_CHECK_EQUAL(v4.cast(), "baz"); BOOST_CHECK_EQUAL(v5.cast(), "baz"); BOOST_CHECK_EQUAL(v6.cast(), "baz"); v1 = true; v2 = true; v3 = true; BOOST_CHECK_EQUAL(v1.type(), toml::value_t::Boolean); BOOST_CHECK_EQUAL(v2.type(), toml::value_t::Boolean); BOOST_CHECK_EQUAL(v3.type(), toml::value_t::Boolean); BOOST_CHECK(v1.is(toml::value_t::Boolean)); BOOST_CHECK(v2.is(toml::value_t::Boolean)); BOOST_CHECK(v3.is(toml::value_t::Boolean)); BOOST_CHECK(v1.is()); BOOST_CHECK(v2.is()); BOOST_CHECK(v3.is()); BOOST_CHECK_EQUAL(v1.cast(), true); BOOST_CHECK_EQUAL(v2.cast(), true); BOOST_CHECK_EQUAL(v3.cast(), true); } BOOST_AUTO_TEST_CASE(test_value_local_date) { toml::value v1(toml::local_date(2018, toml::month_t::Jan, 31)); BOOST_CHECK_EQUAL(v1.type(), toml::value_t::LocalDate); BOOST_CHECK(v1.is(toml::value_t::LocalDate)); BOOST_CHECK(v1.is()); BOOST_CHECK_EQUAL(v1.cast(), toml::local_date(2018, toml::month_t::Jan, 31)); v1 = toml::local_date(2018, toml::month_t::Apr, 1); BOOST_CHECK_EQUAL(v1.type(), toml::value_t::LocalDate); BOOST_CHECK(v1.is(toml::value_t::LocalDate)); BOOST_CHECK(v1.is()); BOOST_CHECK_EQUAL(v1.cast(), toml::local_date(2018, toml::month_t::Apr, 1)); toml::value v2(v1); BOOST_CHECK(v2 == v1); BOOST_CHECK_EQUAL(v2.type(), toml::value_t::LocalDate); BOOST_CHECK(v2.is(toml::value_t::LocalDate)); BOOST_CHECK(v2.is()); BOOST_CHECK_EQUAL(v2.cast(), toml::local_date(2018, toml::month_t::Apr, 1)); v1 = true; BOOST_CHECK_EQUAL(v1.type(), toml::value_t::Boolean); BOOST_CHECK(v1.is(toml::value_t::Boolean)); BOOST_CHECK(v1.is()); BOOST_CHECK_EQUAL(v1.cast(), true); } BOOST_AUTO_TEST_CASE(test_value_local_time) { toml::value v1(toml::local_time(12, 30, 45)); toml::value v2(std::chrono::hours(12) + std::chrono::minutes(30) + std::chrono::seconds(45)); BOOST_CHECK_EQUAL(v1.type(), toml::value_t::LocalTime); BOOST_CHECK_EQUAL(v2.type(), toml::value_t::LocalTime); BOOST_CHECK(v1.is(toml::value_t::LocalTime)); BOOST_CHECK(v2.is(toml::value_t::LocalTime)); BOOST_CHECK(v1.is()); BOOST_CHECK(v2.is()); BOOST_CHECK_EQUAL(v1.cast(), toml::local_time(12, 30, 45)); BOOST_CHECK_EQUAL(v2.cast(), toml::local_time(12, 30, 45)); BOOST_CHECK_EQUAL(v1.cast(), v2.cast()); v1 = toml::local_time(1, 30, 0, /*ms*/ 100, /*us*/ 0); BOOST_CHECK_EQUAL(v1.type(), toml::value_t::LocalTime); BOOST_CHECK(v1.is(toml::value_t::LocalTime)); BOOST_CHECK(v1.is()); BOOST_CHECK_EQUAL(v1.cast(), toml::local_time(1, 30, 0, 100, 0)); toml::value v3(v1); BOOST_CHECK(v3 == v1); BOOST_CHECK_EQUAL(v3.type(), toml::value_t::LocalTime); BOOST_CHECK(v3.is(toml::value_t::LocalTime)); BOOST_CHECK(v3.is()); BOOST_CHECK_EQUAL(v3.cast(), toml::local_time(1, 30, 0, 100, 0)); v1 = true; BOOST_CHECK_EQUAL(v1.type(), toml::value_t::Boolean); BOOST_CHECK(v1.is(toml::value_t::Boolean)); BOOST_CHECK(v1.is()); BOOST_CHECK_EQUAL(v1.cast(), true); } BOOST_AUTO_TEST_CASE(test_value_local_datetime) { toml::value v1(toml::local_datetime( toml::local_date(2018, toml::month_t::Jan, 31), toml::local_time(12, 30, 45) )); BOOST_CHECK_EQUAL(v1.type(), toml::value_t::LocalDatetime); BOOST_CHECK(v1.is(toml::value_t::LocalDatetime)); BOOST_CHECK(v1.is()); BOOST_CHECK_EQUAL(v1.cast(), toml::local_datetime( toml::local_date(2018, toml::month_t::Jan, 31), toml::local_time(12, 30, 45))); v1 = toml::local_datetime( toml::local_date(2018, toml::month_t::Apr, 1), toml::local_time(1, 15, 30)); BOOST_CHECK_EQUAL(v1.type(), toml::value_t::LocalDatetime); BOOST_CHECK(v1.is(toml::value_t::LocalDatetime)); BOOST_CHECK(v1.is()); BOOST_CHECK_EQUAL(v1.cast(), toml::local_datetime( toml::local_date(2018, toml::month_t::Apr, 1), toml::local_time(1, 15, 30))); toml::value v2(v1); BOOST_CHECK(v2 == v1); BOOST_CHECK_EQUAL(v2.type(), toml::value_t::LocalDatetime); BOOST_CHECK(v2.is(toml::value_t::LocalDatetime)); BOOST_CHECK(v2.is()); BOOST_CHECK_EQUAL(v2.cast(), toml::local_datetime( toml::local_date(2018, toml::month_t::Apr, 1), toml::local_time(1, 15, 30))); v1 = true; BOOST_CHECK_EQUAL(v1.type(), toml::value_t::Boolean); BOOST_CHECK(v1.is(toml::value_t::Boolean)); BOOST_CHECK(v1.is()); BOOST_CHECK_EQUAL(v1.cast(), true); } BOOST_AUTO_TEST_CASE(test_value_offset_datetime) { toml::value v1(toml::offset_datetime( toml::local_date(2018, toml::month_t::Jan, 31), toml::local_time(12, 30, 45), toml::time_offset(9, 0) )); BOOST_CHECK_EQUAL(v1.type(), toml::value_t::OffsetDatetime); BOOST_CHECK(v1.is(toml::value_t::OffsetDatetime)); BOOST_CHECK(v1.is()); BOOST_CHECK_EQUAL(v1.cast(), toml::offset_datetime( toml::local_date(2018, toml::month_t::Jan, 31), toml::local_time(12, 30, 45), toml::time_offset(9, 0) )); v1 = toml::offset_datetime( toml::local_date(2018, toml::month_t::Apr, 1), toml::local_time(1, 15, 30), toml::time_offset(9, 0)); BOOST_CHECK_EQUAL(v1.type(), toml::value_t::OffsetDatetime); BOOST_CHECK(v1.is(toml::value_t::OffsetDatetime)); BOOST_CHECK(v1.is()); BOOST_CHECK_EQUAL(v1.cast(), toml::offset_datetime( toml::local_date(2018, toml::month_t::Apr, 1), toml::local_time(1, 15, 30), toml::time_offset(9, 0))); toml::value v2(v1); BOOST_CHECK(v2 == v1); BOOST_CHECK_EQUAL(v2.type(), toml::value_t::OffsetDatetime); BOOST_CHECK(v2.is(toml::value_t::OffsetDatetime)); BOOST_CHECK(v2.is()); BOOST_CHECK_EQUAL(v2.cast(), toml::offset_datetime( toml::local_date(2018, toml::month_t::Apr, 1), toml::local_time(1, 15, 30), toml::time_offset(9, 0))); v1 = true; BOOST_CHECK_EQUAL(v1.type(), toml::value_t::Boolean); BOOST_CHECK(v1.is(toml::value_t::Boolean)); BOOST_CHECK(v1.is()); BOOST_CHECK_EQUAL(v1.cast(), true); } BOOST_AUTO_TEST_CASE(test_value_array) { std::vector v{1,2,3,4,5}; toml::value v1(v); toml::value v2{6,7,8,9,0}; BOOST_CHECK_EQUAL(v1.type(), toml::value_t::Array); BOOST_CHECK(v1.is(toml::value_t::Array)); BOOST_CHECK(v1.is()); BOOST_CHECK_EQUAL(v2.type(), toml::value_t::Array); BOOST_CHECK(v2.is(toml::value_t::Array)); BOOST_CHECK(v2.is()); BOOST_CHECK_EQUAL(v1.cast().at(0).cast(), 1); BOOST_CHECK_EQUAL(v1.cast().at(1).cast(), 2); BOOST_CHECK_EQUAL(v1.cast().at(2).cast(), 3); BOOST_CHECK_EQUAL(v1.cast().at(3).cast(), 4); BOOST_CHECK_EQUAL(v1.cast().at(4).cast(), 5); BOOST_CHECK_EQUAL(v2.cast().at(0).cast(), 6); BOOST_CHECK_EQUAL(v2.cast().at(1).cast(), 7); BOOST_CHECK_EQUAL(v2.cast().at(2).cast(), 8); BOOST_CHECK_EQUAL(v2.cast().at(3).cast(), 9); BOOST_CHECK_EQUAL(v2.cast().at(4).cast(), 0); v1 = {6,7,8,9,0}; v2 = v; BOOST_CHECK_EQUAL(v1.type(), toml::value_t::Array); BOOST_CHECK(v1.is(toml::value_t::Array)); BOOST_CHECK(v1.is()); BOOST_CHECK_EQUAL(v2.type(), toml::value_t::Array); BOOST_CHECK(v2.is(toml::value_t::Array)); BOOST_CHECK(v2.is()); BOOST_CHECK_EQUAL(v1.cast().at(0).cast(), 6); BOOST_CHECK_EQUAL(v1.cast().at(1).cast(), 7); BOOST_CHECK_EQUAL(v1.cast().at(2).cast(), 8); BOOST_CHECK_EQUAL(v1.cast().at(3).cast(), 9); BOOST_CHECK_EQUAL(v1.cast().at(4).cast(), 0); BOOST_CHECK_EQUAL(v2.cast().at(0).cast(), 1); BOOST_CHECK_EQUAL(v2.cast().at(1).cast(), 2); BOOST_CHECK_EQUAL(v2.cast().at(2).cast(), 3); BOOST_CHECK_EQUAL(v2.cast().at(3).cast(), 4); BOOST_CHECK_EQUAL(v2.cast().at(4).cast(), 5); toml::value v3(v1); BOOST_CHECK(v3 == v1); BOOST_CHECK_EQUAL(v3.type(), toml::value_t::Array); BOOST_CHECK(v3.is(toml::value_t::Array)); BOOST_CHECK(v3.is()); BOOST_CHECK_EQUAL(v3.cast().at(0).cast(), 6); BOOST_CHECK_EQUAL(v3.cast().at(1).cast(), 7); BOOST_CHECK_EQUAL(v3.cast().at(2).cast(), 8); BOOST_CHECK_EQUAL(v3.cast().at(3).cast(), 9); BOOST_CHECK_EQUAL(v3.cast().at(4).cast(), 0); v1 = true; BOOST_CHECK_EQUAL(v1.type(), toml::value_t::Boolean); BOOST_CHECK(v1.is(toml::value_t::Boolean)); BOOST_CHECK(v1.is()); BOOST_CHECK_EQUAL(v1.cast(), true); } BOOST_AUTO_TEST_CASE(test_value_table) { toml::value v1{{"foo", 42}, {"bar", 3.14}, {"baz", "qux"}}; BOOST_CHECK_EQUAL(v1.type(), toml::value_t::Table); BOOST_CHECK(v1.is(toml::value_t::Table)); BOOST_CHECK(v1.is()); BOOST_CHECK_EQUAL(v1.cast().at("foo").cast(), 42); BOOST_CHECK_EQUAL(v1.cast().at("bar").cast(), 3.14); BOOST_CHECK_EQUAL(v1.cast().at("baz").cast().str, "qux"); v1 = toml::table{{"foo", 2.71}, {"bar", 54}, {"baz", "quux"}}; BOOST_CHECK_EQUAL(v1.type(), toml::value_t::Table); BOOST_CHECK(v1.is(toml::value_t::Table)); BOOST_CHECK(v1.is()); BOOST_CHECK_EQUAL(v1.cast().at("foo").cast(), 2.71); BOOST_CHECK_EQUAL(v1.cast().at("bar").cast(), 54); BOOST_CHECK_EQUAL(v1.cast().at("baz").cast().str, "quux"); toml::value v3(v1); BOOST_CHECK(v3 == v1); BOOST_CHECK_EQUAL(v3.type(), toml::value_t::Table); BOOST_CHECK(v3.is(toml::value_t::Table)); BOOST_CHECK(v3.is()); BOOST_CHECK_EQUAL(v3.cast().at("foo").cast(), 2.71); BOOST_CHECK_EQUAL(v3.cast().at("bar").cast(), 54); BOOST_CHECK_EQUAL(v3.cast().at("baz").cast().str, "quux"); v1 = true; BOOST_CHECK_EQUAL(v1.type(), toml::value_t::Boolean); BOOST_CHECK(v1.is(toml::value_t::Boolean)); BOOST_CHECK(v1.is()); BOOST_CHECK_EQUAL(v1.cast(), true); }