// 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
#include "test_macros.h"
#include "test_iterators.h"
+#include "locale_helpers.h"
#include "platform_support.h" // locale name macros
typedef std::money_get<char, cpp17_input_iterator<const char*> > Fn;
ios.imbue(std::locale(ios.getloc(),
new std::moneypunct_byname<wchar_t, true>(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
assert(ex == -123456789);
}
{ // zero, showbase
- std::string v = "\xEF\xBF\xA5""0.00";
+ std::string v = currency_symbol + "0.00";
typedef cpp17_input_iterator<const char*> I;
long double ex;
std::ios_base::iostate err = std::ios_base::goodbit;
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<const char*> I;
long double ex;
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<const char*> I;
long double ex;
std::ios_base::iostate err = std::ios_base::goodbit;
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<const char*> I;
long double ex;
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<const char*> I;
long double ex;
std::ios_base::iostate err = std::ios_base::goodbit;
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<const char*> I;
long double ex;
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<const char*> I;
long double ex;
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<const char*> I;
long double ex;
std::noshowbase(ios);
}
{ // negative one, showbase
- std::string v = "CNY -0.01";
+ std::string v = currency_name + "-0.01";
typedef cpp17_input_iterator<const char*> I;
long double ex;
std::ios_base::iostate err = std::ios_base::goodbit;
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<const char*> I;
long double ex;
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<const char*> I;
long double ex;
std::ios_base::iostate err = std::ios_base::goodbit;
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<const char*> I;
long double ex;
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<const char*> I;
long double ex;
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<const char*> I;
long double ex;
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<const char*> I;
long double ex;
std::ios_base::iostate err = std::ios_base::goodbit;
}
}
#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
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<const wchar_t*> I;
long double ex;
std::ios_base::iostate err = std::ios_base::goodbit;
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<const wchar_t*> I;
long double ex;
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<const wchar_t*> I;
long double ex;
std::ios_base::iostate err = std::ios_base::goodbit;
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<const wchar_t*> I;
long double ex;
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<const wchar_t*> I;
long double ex;
std::ios_base::iostate err = std::ios_base::goodbit;
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<const wchar_t*> I;
long double ex;
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<const wchar_t*> I;
long double ex;
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<const wchar_t*> I;
long double ex;
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<const wchar_t*> I;
long double ex;
std::ios_base::iostate err = std::ios_base::goodbit;
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<const wchar_t*> I;
long double ex;
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<const wchar_t*> I;
long double ex;
std::ios_base::iostate err = std::ios_base::goodbit;
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<const wchar_t*> I;
long double ex;
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<const wchar_t*> I;
long double ex;
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<const wchar_t*> I;
long double ex;
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<const wchar_t*> I;
long double ex;
std::ios_base::iostate err = std::ios_base::goodbit;
// 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
#include "test_macros.h"
#include "test_iterators.h"
+#include "locale_helpers.h"
#include "platform_support.h" // locale name macros
typedef std::money_put<char, cpp17_output_iterator<char*> > Fn;
#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;
char str[100];
cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(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;
char str[100];
cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(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;
char str[100];
cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(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;
char str[100];
cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(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;
char str[100];
cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(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
char str[100];
cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(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
char str[100];
cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(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);
}
char str[100];
cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(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;
char str[100];
cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(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;
char str[100];
cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(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;
char str[100];
cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(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;
char str[100];
cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(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
char str[100];
cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(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
char str[100];
cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(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);
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(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;
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(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;
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(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;
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(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;
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(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
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(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
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(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);
}
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(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;
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(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;
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(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;
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(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;
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(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
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(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
wchar_t str[100];
cpp17_output_iterator<wchar_t*> iter = f.put(cpp17_output_iterator<wchar_t*>(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);
}
}