// Unit test for boost::lexical_cast. // // See http://www.boost.org for most recent version, including documentation. // // Copyright Antony Polukhin, 2012-2014. // // 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). #include #include #include template static void test_optimized_types_to_string_const() { namespace de = boost::detail; typedef de::lexical_cast_stream_traits trait_1; BOOST_CHECK(!trait_1::is_source_input_not_optimized_t::value); BOOST_CHECK((boost::is_same::value)); BOOST_CHECK((boost::is_same::value)); BOOST_CHECK((boost::is_same::value)); BOOST_CHECK(!trait_1::is_string_widening_required_t::value); BOOST_CHECK(!trait_1::is_source_input_not_optimized_t::value); typedef de::lexical_cast_stream_traits trait_2; BOOST_CHECK(!trait_2::is_source_input_not_optimized_t::value); BOOST_CHECK((boost::is_same::value)); BOOST_CHECK((boost::is_same::value)); BOOST_CHECK((boost::is_same::value)); BOOST_CHECK(!trait_2::is_string_widening_required_t::value); BOOST_CHECK(!trait_2::is_source_input_not_optimized_t::value); typedef de::lexical_cast_stream_traits trait_3; BOOST_CHECK(!trait_3::is_source_input_not_optimized_t::value); BOOST_CHECK((boost::is_same::value)); BOOST_CHECK((boost::is_same::value)); BOOST_CHECK((boost::is_same::value)); BOOST_CHECK((boost::detail::is_character::value != trait_3::is_string_widening_required_t::value)); BOOST_CHECK(!trait_3::is_source_input_not_optimized_t::value); } template static void test_optimized_types_to_string() { test_optimized_types_to_string_const(); namespace de = boost::detail; typedef de::lexical_cast_stream_traits trait_4; BOOST_CHECK(!trait_4::is_source_input_not_optimized_t::value); BOOST_CHECK((boost::is_same::value)); BOOST_CHECK((boost::is_same::value)); BOOST_CHECK((boost::is_same::value)); BOOST_CHECK(!trait_4::is_string_widening_required_t::value); BOOST_CHECK(!trait_4::is_source_input_not_optimized_t::value); typedef de::lexical_cast_stream_traits trait_5; BOOST_CHECK(!trait_5::is_source_input_not_optimized_t::value); BOOST_CHECK((boost::is_same::value)); BOOST_CHECK((boost::is_same::value)); BOOST_CHECK((boost::is_same::value)); BOOST_CHECK(!trait_5::is_string_widening_required_t::value); BOOST_CHECK(!trait_5::is_source_input_not_optimized_t::value); typedef de::lexical_cast_stream_traits trait_6; BOOST_CHECK(!trait_6::is_source_input_not_optimized_t::value); BOOST_CHECK((boost::is_same::value)); BOOST_CHECK((boost::is_same::value)); BOOST_CHECK((boost::is_same::value)); BOOST_CHECK(!trait_6::is_string_widening_required_t::value); } void test_metafunctions() { test_optimized_types_to_string(); test_optimized_types_to_string(); test_optimized_types_to_string(); test_optimized_types_to_string(); test_optimized_types_to_string(); test_optimized_types_to_string(); test_optimized_types_to_string(); test_optimized_types_to_string(); test_optimized_types_to_string(); test_optimized_types_to_string(); #if defined(BOOST_HAS_LONG_LONG) test_optimized_types_to_string(); test_optimized_types_to_string(); #elif defined(BOOST_HAS_MS_INT64) test_optimized_types_to_string(); test_optimized_types_to_string<__int64>(); #endif test_optimized_types_to_string(); test_optimized_types_to_string(); //test_optimized_types_to_string(); //test_optimized_types_to_string(); test_optimized_types_to_string(); //test_optimized_types_to_string(); //test_optimized_types_to_string(); test_optimized_types_to_string(); //test_optimized_types_to_string(); //test_optimized_types_to_string(); test_optimized_types_to_string >(); test_optimized_types_to_string >(); test_optimized_types_to_string >(); test_optimized_types_to_string >(); test_optimized_types_to_string >(); test_optimized_types_to_string >(); test_optimized_types_to_string >(); test_optimized_types_to_string >(); test_optimized_types_to_string >(); test_optimized_types_to_string_const >(); test_optimized_types_to_string_const >(); test_optimized_types_to_string_const >(); test_optimized_types_to_string_const >(); test_optimized_types_to_string_const >(); test_optimized_types_to_string_const >(); test_optimized_types_to_string_const >(); test_optimized_types_to_string_const >(); test_optimized_types_to_string_const >(); #ifndef BOOST_NO_CXX11_HDR_ARRAY test_optimized_types_to_string >(); test_optimized_types_to_string >(); test_optimized_types_to_string >(); test_optimized_types_to_string >(); test_optimized_types_to_string >(); test_optimized_types_to_string >(); test_optimized_types_to_string_const >(); test_optimized_types_to_string_const >(); test_optimized_types_to_string_const >(); test_optimized_types_to_string_const >(); test_optimized_types_to_string_const >(); test_optimized_types_to_string_const >(); #endif } boost::unit_test::test_suite *init_unit_test_suite(int, char *[]) { boost::unit_test::test_suite *suite = BOOST_TEST_SUITE("lexical_cast traits tests"); suite->add(BOOST_TEST_CASE(&test_metafunctions)); return suite; }