| 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-2024. |
| 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 | |
| 11 | #include <boost/lexical_cast.hpp> |
| 12 | |
| 13 | #include <boost/core/lightweight_test.hpp> |
| 14 | |
| 15 | void test_typedefed_wchar_t(unsigned short) // wchar_t is a typedef for unsigned short |
| 16 | { |
| 17 | BOOST_TEST(boost::lexical_cast<int>(L'A') == 65); |
| 18 | BOOST_TEST(boost::lexical_cast<int>(L'B') == 66); |
| 19 | |
| 20 | BOOST_TEST(boost::lexical_cast<wchar_t>(L"65") == 65); |
| 21 | BOOST_TEST(boost::lexical_cast<wchar_t>(L"66") == 66); |
| 22 | } |
| 23 | |
| 24 | template <class T> |
| 25 | void test_typedefed_wchar_t(T) |
| 26 | { |
| 27 | BOOST_TEST(1); |
| 28 | } |
| 29 | |
| 30 | void test_typedefed_wchar_t_runtime() |
| 31 | { |
| 32 | test_typedefed_wchar_t(L'0'); |
| 33 | } |
| 34 | |
| 35 | int main() |
| 36 | { |
| 37 | test_typedefed_wchar_t_runtime(); |
| 38 | |
| 39 | return boost::report_errors(); |
| 40 | } |
| 41 |
