mirror of
https://github.com/boostorg/lexical_cast.git
synced 2026-01-19 04:22:08 +00:00
Fix regression in unsigned short to wstring casting without wchar_t b… (#92)
…uiltin type Fixes: https://github.com/boostorg/lexical_cast/issues/89
This commit is contained in:
@@ -293,10 +293,12 @@ namespace boost { namespace detail { namespace lcast {
|
||||
bool stream_in(lcast::exact<char> x) { return shl_char(x.payload); }
|
||||
bool stream_in(lcast::exact<unsigned char> x) { return shl_char(static_cast<char>(x.payload)); }
|
||||
bool stream_in(lcast::exact<signed char> x) { return shl_char(static_cast<char>(x.payload)); }
|
||||
|
||||
|
||||
#if !defined(BOOST_NO_INTRINSIC_WCHAR_T)
|
||||
template <class C>
|
||||
typename std::enable_if<boost::detail::is_character<C>::value, bool>::type
|
||||
stream_in(lcast::exact<C> x) { return shl_char(x.payload); }
|
||||
#endif
|
||||
|
||||
template <class Type>
|
||||
enable_if_compatible_char_t<Type>
|
||||
|
||||
@@ -32,9 +32,22 @@ void test_typedefed_wchar_t_runtime()
|
||||
test_typedefed_wchar_t(L'0');
|
||||
}
|
||||
|
||||
void test_unsigned_short_to_wstring()
|
||||
{
|
||||
// Test case from https://github.com/boostorg/lexical_cast/issues/89
|
||||
unsigned short number = 4550;
|
||||
|
||||
auto res1 = boost::lexical_cast<std::wstring>(number);
|
||||
BOOST_TEST(res1 == L"4550");
|
||||
|
||||
auto res2 = boost::lexical_cast<std::string>(number);
|
||||
BOOST_TEST_EQ(res2, "4550");
|
||||
}
|
||||
|
||||
int main()
|
||||
{
|
||||
test_typedefed_wchar_t_runtime();
|
||||
test_unsigned_short_to_wstring();
|
||||
|
||||
return boost::report_errors();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user