// // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // // Official repository: https://github.com/boostorg/json // // Test that header file is self-contained. #include #include "test_suite.hpp" #include #include #include BOOST_JSON_NS_BEGIN class value_to_test { public: template void check(T t) { BOOST_TEST(value_to(value_from(t)) == t); } void testNumberCast() { check((short)-1); check((int)-2); check((long)-3); check((long long)-4); check((unsigned short)1); check((unsigned int)2); check((unsigned long)3); check((unsigned long long)4); check((float)1.5); check((double)2.5); check(true); } void testJsonTypes() { value_to(value(object_kind)); value_to(value(array_kind)); value_to(value(string_kind)); } void testGenerics() { check(std::string("test")); check(std::map { {"a", 1}, {"b", 2}, {"c", 3} }); check(std::unordered_map { { "a", 1 }, {"b", 2}, {"c", 3} }); check(std::vector{1, 2, 3, 4}); } void run() { testNumberCast(); testJsonTypes(); testGenerics(); } }; TEST_SUITE(value_to_test, "boost.json.value_to"); BOOST_JSON_NS_END