lexical_cast_typedefed_wchar_test_runtime.cpp 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Unit test for boost::lexical_cast.
  2. //
  3. // See http://www.boost.org for most recent version, including documentation.
  4. //
  5. // Copyright Antony Polukhin, 2011-2019.
  6. //
  7. // Distributed under the Boost
  8. // Software License, Version 1.0. (See accompanying file
  9. // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt).
  10. #include <boost/config.hpp>
  11. #if defined(__INTEL_COMPILER)
  12. #pragma warning(disable: 193 383 488 981 1418 1419)
  13. #elif defined(BOOST_MSVC)
  14. #pragma warning(disable: 4097 4100 4121 4127 4146 4244 4245 4511 4512 4701 4800)
  15. #endif
  16. #include <boost/lexical_cast.hpp>
  17. #include <boost/test/unit_test.hpp>
  18. using namespace boost;
  19. void test_typedefed_wchar_t_runtime()
  20. {
  21. #ifndef BOOST_LCAST_NO_WCHAR_T
  22. #ifdef BOOST_MSVC
  23. BOOST_STATIC_ASSERT((boost::is_same<wchar_t, unsigned short>::value));
  24. BOOST_CHECK_EQUAL(boost::lexical_cast<int>(L'A'), 65);
  25. BOOST_CHECK_EQUAL(boost::lexical_cast<int>(L'B'), 66);
  26. BOOST_CHECK_EQUAL(boost::lexical_cast<wchar_t>(L"65"), 65);
  27. BOOST_CHECK_EQUAL(boost::lexical_cast<wchar_t>(L"66"), 66);
  28. #endif
  29. #endif
  30. BOOST_CHECK(1);
  31. }
  32. unit_test::test_suite *init_unit_test_suite(int, char *[])
  33. {
  34. unit_test::test_suite *suite =
  35. BOOST_TEST_SUITE("lexical_cast typedefed wchar_t runtime test");
  36. suite->add(BOOST_TEST_CASE(&test_typedefed_wchar_t_runtime));
  37. return suite;
  38. }