diff --git a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp --- a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp +++ b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.get/locale.money.get.members/get_long_double_zh_CN.pass.cpp @@ -9,7 +9,6 @@ // NetBSD does not support LC_MONETARY at the moment // XFAIL: netbsd -// XFAIL: LIBCXX-WINDOWS-FIXME // XFAIL: LIBCXX-AIX-FIXME // REQUIRES: locale.zh_CN.UTF-8 @@ -31,6 +30,7 @@ #include "test_macros.h" #include "test_iterators.h" +#include "locale_helpers.h" #include "platform_support.h" // locale name macros typedef std::money_get > Fn; @@ -69,6 +69,12 @@ ios.imbue(std::locale(ios.getloc(), new std::moneypunct_byname(loc_name))); #endif +#ifdef _WIN32 + std::string currency_name = "CNY"; +#else + std::string currency_name = "CNY "; +#endif + std::string currency_symbol(LocaleHelpers::currency_symbol_zh_CN()); { const my_facet f(1); // char, national @@ -128,7 +134,7 @@ assert(ex == -123456789); } { // zero, showbase - std::string v = "\xEF\xBF\xA5""0.00"; + std::string v = currency_symbol + "0.00"; typedef cpp17_input_iterator I; long double ex; std::ios_base::iostate err = std::ios_base::goodbit; @@ -139,7 +145,7 @@ assert(ex == 0); } { // zero, showbase - std::string v = "\xEF\xBF\xA5""0.00"; + std::string v = currency_symbol + "0.00"; std::showbase(ios); typedef cpp17_input_iterator I; long double ex; @@ -152,7 +158,7 @@ std::noshowbase(ios); } { // negative one, showbase - std::string v = "\xEF\xBF\xA5""-0.01"; + std::string v = currency_symbol + "-0.01"; typedef cpp17_input_iterator I; long double ex; std::ios_base::iostate err = std::ios_base::goodbit; @@ -163,7 +169,7 @@ assert(ex == -1); } { // negative one, showbase - std::string v = "\xEF\xBF\xA5""-0.01"; + std::string v = currency_symbol + "-0.01"; std::showbase(ios); typedef cpp17_input_iterator I; long double ex; @@ -176,7 +182,7 @@ std::noshowbase(ios); } { // positive, showbase - std::string v = "\xEF\xBF\xA5""1,234,567.89"; + std::string v = currency_symbol + "1,234,567.89"; typedef cpp17_input_iterator I; long double ex; std::ios_base::iostate err = std::ios_base::goodbit; @@ -187,7 +193,7 @@ assert(ex == 123456789); } { // positive, showbase - std::string v = "\xEF\xBF\xA5""1,234,567.89"; + std::string v = currency_symbol + "1,234,567.89"; std::showbase(ios); typedef cpp17_input_iterator I; long double ex; @@ -200,7 +206,7 @@ std::noshowbase(ios); } { // negative, showbase - std::string v = "\xEF\xBF\xA5""-1,234,567.89"; + std::string v = currency_symbol + "-1,234,567.89"; std::showbase(ios); typedef cpp17_input_iterator I; long double ex; @@ -305,7 +311,7 @@ assert(ex == 0); } { // zero, showbase - std::string v = "CNY 0.00"; + std::string v = currency_name + "0.00"; std::showbase(ios); typedef cpp17_input_iterator I; long double ex; @@ -318,7 +324,7 @@ std::noshowbase(ios); } { // negative one, showbase - std::string v = "CNY -0.01"; + std::string v = currency_name + "-0.01"; typedef cpp17_input_iterator I; long double ex; std::ios_base::iostate err = std::ios_base::goodbit; @@ -329,7 +335,7 @@ assert(ex == -1); } { // negative one, showbase - std::string v = "CNY -0.01"; + std::string v = currency_name + "-0.01"; std::showbase(ios); typedef cpp17_input_iterator I; long double ex; @@ -342,7 +348,7 @@ std::noshowbase(ios); } { // positive, showbase - std::string v = "CNY 1,234,567.89"; + std::string v = currency_name + "1,234,567.89"; typedef cpp17_input_iterator I; long double ex; std::ios_base::iostate err = std::ios_base::goodbit; @@ -353,7 +359,7 @@ assert(ex == 123456789); } { // positive, showbase - std::string v = "CNY 1,234,567.89"; + std::string v = currency_name + "1,234,567.89"; std::showbase(ios); typedef cpp17_input_iterator I; long double ex; @@ -366,7 +372,7 @@ std::noshowbase(ios); } { // negative, showbase - std::string v = "CNY -1,234,567.89"; + std::string v = currency_name + "-1,234,567.89"; std::showbase(ios); typedef cpp17_input_iterator I; long double ex; @@ -379,7 +385,7 @@ std::noshowbase(ios); } { // negative, showbase - std::string v = "\xEF\xBF\xA5""-1,234,567.89"; + std::string v = currency_symbol + "-1,234,567.89"; std::showbase(ios); typedef cpp17_input_iterator I; long double ex; @@ -391,7 +397,7 @@ std::noshowbase(ios); } { // negative, showbase - std::string v = "\xEF\xBF\xA5""-1,234,567.89"; + std::string v = currency_symbol + "-1,234,567.89"; typedef cpp17_input_iterator I; long double ex; std::ios_base::iostate err = std::ios_base::goodbit; @@ -402,6 +408,12 @@ } } #ifndef TEST_HAS_NO_WIDE_CHARACTERS +#ifdef _WIN32 + std::wstring w_currency_name = L"CNY"; +#else + std::wstring w_currency_name = L"CNY "; +#endif + std::wstring w_currency_symbol(LocaleHelpers::currency_symbol_zh_CN()); { const my_facetw f(1); // wchar_t, national @@ -461,7 +473,7 @@ assert(ex == -123456789); } { // zero, showbase - std::wstring v = L"\xFFE5""0.00"; + std::wstring v = w_currency_symbol + L"0.00"; typedef cpp17_input_iterator I; long double ex; std::ios_base::iostate err = std::ios_base::goodbit; @@ -472,7 +484,7 @@ assert(ex == 0); } { // zero, showbase - std::wstring v = L"\xFFE5""0.00"; + std::wstring v = w_currency_symbol + L"0.00"; std::showbase(ios); typedef cpp17_input_iterator I; long double ex; @@ -485,7 +497,7 @@ std::noshowbase(ios); } { // negative one, showbase - std::wstring v = L"\xFFE5""-0.01"; + std::wstring v = w_currency_symbol + L"-0.01"; typedef cpp17_input_iterator I; long double ex; std::ios_base::iostate err = std::ios_base::goodbit; @@ -496,7 +508,7 @@ assert(ex == -1); } { // negative one, showbase - std::wstring v = L"\xFFE5""-0.01"; + std::wstring v = w_currency_symbol + L"-0.01"; std::showbase(ios); typedef cpp17_input_iterator I; long double ex; @@ -509,7 +521,7 @@ std::noshowbase(ios); } { // positive, showbase - std::wstring v = L"\xFFE5""1,234,567.89"; + std::wstring v = w_currency_symbol + L"1,234,567.89"; typedef cpp17_input_iterator I; long double ex; std::ios_base::iostate err = std::ios_base::goodbit; @@ -520,7 +532,7 @@ assert(ex == 123456789); } { // positive, showbase - std::wstring v = L"\xFFE5""1,234,567.89"; + std::wstring v = w_currency_symbol + L"1,234,567.89"; std::showbase(ios); typedef cpp17_input_iterator I; long double ex; @@ -533,7 +545,7 @@ std::noshowbase(ios); } { // negative, showbase - std::wstring v = L"\xFFE5""-1,234,567.89"; + std::wstring v = w_currency_symbol + L"-1,234,567.89"; std::showbase(ios); typedef cpp17_input_iterator I; long double ex; @@ -638,7 +650,7 @@ assert(ex == 0); } { // zero, showbase - std::wstring v = L"CNY 0.00"; + std::wstring v = w_currency_name + L"0.00"; std::showbase(ios); typedef cpp17_input_iterator I; long double ex; @@ -651,7 +663,7 @@ std::noshowbase(ios); } { // negative one, showbase - std::wstring v = L"CNY -0.01"; + std::wstring v = w_currency_name + L"-0.01"; typedef cpp17_input_iterator I; long double ex; std::ios_base::iostate err = std::ios_base::goodbit; @@ -662,7 +674,7 @@ assert(ex == -1); } { // negative one, showbase - std::wstring v = L"CNY -0.01"; + std::wstring v = w_currency_name + L"-0.01"; std::showbase(ios); typedef cpp17_input_iterator I; long double ex; @@ -675,7 +687,7 @@ std::noshowbase(ios); } { // positive, showbase - std::wstring v = L"CNY 1,234,567.89"; + std::wstring v = w_currency_name + L"1,234,567.89"; typedef cpp17_input_iterator I; long double ex; std::ios_base::iostate err = std::ios_base::goodbit; @@ -686,7 +698,7 @@ assert(ex == 123456789); } { // positive, showbase - std::wstring v = L"CNY 1,234,567.89"; + std::wstring v = w_currency_name + L"1,234,567.89"; std::showbase(ios); typedef cpp17_input_iterator I; long double ex; @@ -699,7 +711,7 @@ std::noshowbase(ios); } { // negative, showbase - std::wstring v = L"CNY -1,234,567.89"; + std::wstring v = w_currency_name + L"-1,234,567.89"; std::showbase(ios); typedef cpp17_input_iterator I; long double ex; @@ -712,7 +724,7 @@ std::noshowbase(ios); } { // negative, showbase - std::wstring v = L"\xFFE5""-1,234,567.89"; + std::wstring v = w_currency_symbol + L"-1,234,567.89"; std::showbase(ios); typedef cpp17_input_iterator I; long double ex; @@ -724,7 +736,7 @@ std::noshowbase(ios); } { // negative, showbase - std::wstring v = L"\xFFE5""-1,234,567.89"; + std::wstring v = w_currency_symbol + L"-1,234,567.89"; typedef cpp17_input_iterator I; long double ex; std::ios_base::iostate err = std::ios_base::goodbit; diff --git a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp --- a/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp +++ b/libcxx/test/std/localization/locale.categories/category.monetary/locale.money.put/locale.money.put.members/put_long_double_zh_CN.pass.cpp @@ -9,7 +9,6 @@ // NetBSD does not support LC_MONETARY at the moment // XFAIL: netbsd -// XFAIL: LIBCXX-WINDOWS-FIXME // XFAIL: LIBCXX-AIX-FIXME // REQUIRES: locale.zh_CN.UTF-8 @@ -31,6 +30,7 @@ #include "test_macros.h" #include "test_iterators.h" +#include "locale_helpers.h" #include "platform_support.h" // locale name macros typedef std::money_put > Fn; @@ -71,6 +71,14 @@ #endif { const my_facet f(1); +#ifdef _WIN32 + std::string currency_name = "CNY"; +#else + std::string currency_name = "CNY "; +#endif + std::string currency_name_padding(7 - currency_name.size(), ' '); + std::string currency_symbol(LocaleHelpers::currency_symbol_zh_CN()); + std::string currency_symbol_padding(7 - currency_symbol.size(), ' '); // char, national { // zero long double v = 0; @@ -106,7 +114,7 @@ char str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), false, ios, '*', v); std::string ex(str, base(iter)); - assert(ex == "\xEF\xBF\xA5""0.00"); + assert(ex == currency_symbol + "0.00"); } { // negative one, showbase long double v = -1; @@ -114,7 +122,7 @@ char str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), false, ios, '*', v); std::string ex(str, base(iter)); - assert(ex == "\xEF\xBF\xA5""-0.01"); + assert(ex == currency_symbol + "-0.01"); } { // positive, showbase long double v = 123456789; @@ -122,7 +130,7 @@ char str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), false, ios, '*', v); std::string ex(str, base(iter)); - assert(ex == "\xEF\xBF\xA5""1,234,567.89"); + assert(ex == currency_symbol + "1,234,567.89"); } { // negative, showbase long double v = -123456789; @@ -130,7 +138,7 @@ char str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), false, ios, '*', v); std::string ex(str, base(iter)); - assert(ex == "\xEF\xBF\xA5""-1,234,567.89"); + assert(ex == currency_symbol + "-1,234,567.89"); } { // negative, showbase, left long double v = -123456789; @@ -140,7 +148,7 @@ char str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), false, ios, ' ', v); std::string ex(str, base(iter)); - assert(ex == "\xEF\xBF\xA5""-1,234,567.89 "); + assert(ex == currency_symbol + "-1,234,567.89" + currency_symbol_padding); assert(ios.width() == 0); } { // negative, showbase, internal @@ -151,7 +159,7 @@ char str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), false, ios, ' ', v); std::string ex(str, base(iter)); - assert(ex == "\xEF\xBF\xA5""- 1,234,567.89"); + assert(ex == currency_symbol + "-" + currency_symbol_padding + "1,234,567.89"); assert(ios.width() == 0); } { // negative, showbase, right @@ -162,7 +170,7 @@ char str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), false, ios, ' ', v); std::string ex(str, base(iter)); - assert(ex == " \xEF\xBF\xA5""-1,234,567.89"); + assert(ex == currency_symbol_padding + currency_symbol + "-1,234,567.89"); assert(ios.width() == 0); } @@ -203,7 +211,7 @@ char str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), true, ios, '*', v); std::string ex(str, base(iter)); - assert(ex == "CNY 0.00"); + assert(ex == currency_name + "0.00"); } { // negative one, showbase long double v = -1; @@ -211,7 +219,7 @@ char str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), true, ios, '*', v); std::string ex(str, base(iter)); - assert(ex == "CNY -0.01"); + assert(ex == currency_name + "-0.01"); } { // positive, showbase long double v = 123456789; @@ -219,7 +227,7 @@ char str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), true, ios, '*', v); std::string ex(str, base(iter)); - assert(ex == "CNY 1,234,567.89"); + assert(ex == currency_name + "1,234,567.89"); } { // negative, showbase long double v = -123456789; @@ -227,7 +235,7 @@ char str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), true, ios, '*', v); std::string ex(str, base(iter)); - assert(ex == "CNY -1,234,567.89"); + assert(ex == currency_name + "-1,234,567.89"); } { // negative, showbase, left long double v = -123456789; @@ -237,7 +245,7 @@ char str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), true, ios, ' ', v); std::string ex(str, base(iter)); - assert(ex == "CNY -1,234,567.89 "); + assert(ex == currency_name + "-1,234,567.89" + currency_name_padding); assert(ios.width() == 0); } { // negative, showbase, internal @@ -248,7 +256,7 @@ char str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), true, ios, ' ', v); std::string ex(str, base(iter)); - assert(ex == "CNY - 1,234,567.89"); + assert(ex == currency_name + "-" + currency_name_padding + "1,234,567.89"); assert(ios.width() == 0); } { // negative, showbase, right @@ -259,12 +267,19 @@ char str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), true, ios, ' ', v); std::string ex(str, base(iter)); - assert(ex == " CNY -1,234,567.89"); + assert(ex == currency_name_padding + currency_name + "-1,234,567.89"); assert(ios.width() == 0); } } #ifndef TEST_HAS_NO_WIDE_CHARACTERS { +#ifdef _WIN32 + std::wstring currency_name = L"CNY"; +#else + std::wstring currency_name = L"CNY "; +#endif + std::wstring currency_name_padding(7 - currency_name.size(), ' '); + std::wstring currency_symbol(LocaleHelpers::currency_symbol_zh_CN()); const my_facetw f(1); // wchar_t, national std::noshowbase(ios); @@ -303,7 +318,7 @@ wchar_t str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), false, ios, '*', v); std::wstring ex(str, base(iter)); - assert(ex == L"\xFFE5""0.00"); + assert(ex == currency_symbol + L"0.00"); } { // negative one, showbase long double v = -1; @@ -311,7 +326,7 @@ wchar_t str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), false, ios, '*', v); std::wstring ex(str, base(iter)); - assert(ex == L"\xFFE5""-0.01"); + assert(ex == currency_symbol + L"-0.01"); } { // positive, showbase long double v = 123456789; @@ -319,7 +334,7 @@ wchar_t str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), false, ios, '*', v); std::wstring ex(str, base(iter)); - assert(ex == L"\xFFE5""1,234,567.89"); + assert(ex == currency_symbol + L"1,234,567.89"); } { // negative, showbase long double v = -123456789; @@ -327,7 +342,7 @@ wchar_t str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), false, ios, '*', v); std::wstring ex(str, base(iter)); - assert(ex == L"\xFFE5""-1,234,567.89"); + assert(ex == currency_symbol + L"-1,234,567.89"); } { // negative, showbase, left long double v = -123456789; @@ -337,7 +352,7 @@ wchar_t str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), false, ios, ' ', v); std::wstring ex(str, base(iter)); - assert(ex == L"\xFFE5""-1,234,567.89 "); + assert(ex == currency_symbol + L"-1,234,567.89 "); assert(ios.width() == 0); } { // negative, showbase, internal @@ -348,7 +363,7 @@ wchar_t str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), false, ios, ' ', v); std::wstring ex(str, base(iter)); - assert(ex == L"\xFFE5""- 1,234,567.89"); + assert(ex == currency_symbol + L"- 1,234,567.89"); assert(ios.width() == 0); } { // negative, showbase, right @@ -359,7 +374,7 @@ wchar_t str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), false, ios, ' ', v); std::wstring ex(str, base(iter)); - assert(ex == L" \xFFE5""-1,234,567.89"); + assert(ex == L" " + currency_symbol + L"-1,234,567.89"); assert(ios.width() == 0); } @@ -400,7 +415,7 @@ wchar_t str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), true, ios, '*', v); std::wstring ex(str, base(iter)); - assert(ex == L"CNY 0.00"); + assert(ex == currency_name + L"0.00"); } { // negative one, showbase long double v = -1; @@ -408,7 +423,7 @@ wchar_t str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), true, ios, '*', v); std::wstring ex(str, base(iter)); - assert(ex == L"CNY -0.01"); + assert(ex == currency_name + L"-0.01"); } { // positive, showbase long double v = 123456789; @@ -416,7 +431,7 @@ wchar_t str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), true, ios, '*', v); std::wstring ex(str, base(iter)); - assert(ex == L"CNY 1,234,567.89"); + assert(ex == currency_name + L"1,234,567.89"); } { // negative, showbase long double v = -123456789; @@ -424,7 +439,7 @@ wchar_t str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), true, ios, '*', v); std::wstring ex(str, base(iter)); - assert(ex == L"CNY -1,234,567.89"); + assert(ex == currency_name + L"-1,234,567.89"); } { // negative, showbase, left long double v = -123456789; @@ -434,7 +449,7 @@ wchar_t str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), true, ios, ' ', v); std::wstring ex(str, base(iter)); - assert(ex == L"CNY -1,234,567.89 "); + assert(ex == currency_name + L"-1,234,567.89" + currency_name_padding); assert(ios.width() == 0); } { // negative, showbase, internal @@ -445,7 +460,7 @@ wchar_t str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), true, ios, ' ', v); std::wstring ex(str, base(iter)); - assert(ex == L"CNY - 1,234,567.89"); + assert(ex == currency_name + L"-" + currency_name_padding + L"1,234,567.89"); assert(ios.width() == 0); } { // negative, showbase, right @@ -456,7 +471,7 @@ wchar_t str[100]; cpp17_output_iterator iter = f.put(cpp17_output_iterator(str), true, ios, ' ', v); std::wstring ex(str, base(iter)); - assert(ex == L" CNY -1,234,567.89"); + assert(ex == currency_name_padding + currency_name + L"-1,234,567.89"); assert(ios.width() == 0); } } diff --git a/libcxx/test/support/locale_helpers.h b/libcxx/test/support/locale_helpers.h --- a/libcxx/test/support/locale_helpers.h +++ b/libcxx/test/support/locale_helpers.h @@ -86,6 +86,14 @@ #endif } +MultiStringType currency_symbol_zh_CN() { +#if defined(_WIN32) + return MKSTR("\u00A5"); // U+00A5 YEN SIGN +#else + return MKSTR("\uFFE5"); // U+FFE5 FULLWIDTH YEN SIGN +#endif +} + } // namespace LocaleHelpers #endif // LIBCXX_TEST_SUPPORT_LOCALE_HELPERS_H