forked from OSchip/llvm-project
[NFC][libc++] Fixes some tests on Linux.
The tests are adapted to the output produced on Linux. Reviewed By: #libc, philnik, ldionne Differential Revision: https://reviews.llvm.org/D124331
This commit is contained in:
parent
257b39fbc7
commit
0289c90d70
|
@ -20,9 +20,6 @@
|
|||
// iter_type get(iter_type b, iter_type e, bool intl, ios_base& iob,
|
||||
// ios_base::iostate& err, long double& v) const;
|
||||
|
||||
// TODO For zh_CN GLIBC puts the negative sign after the currency symbol.
|
||||
// XFAIL: target={{.*}}-linux-gnu{{.*}}
|
||||
|
||||
#include <locale>
|
||||
#include <ios>
|
||||
#include <streambuf>
|
||||
|
@ -324,7 +321,11 @@ int main(int, char**)
|
|||
std::noshowbase(ios);
|
||||
}
|
||||
{ // negative one, showbase
|
||||
#ifdef TEST_HAS_GLIBC
|
||||
std::string v = "-" + currency_name + "0.01";
|
||||
#else
|
||||
std::string v = currency_name + "-0.01";
|
||||
#endif
|
||||
typedef cpp17_input_iterator<const char*> I;
|
||||
long double ex;
|
||||
std::ios_base::iostate err = std::ios_base::goodbit;
|
||||
|
@ -335,7 +336,11 @@ int main(int, char**)
|
|||
assert(ex == -1);
|
||||
}
|
||||
{ // negative one, showbase
|
||||
#ifdef TEST_HAS_GLIBC
|
||||
std::string v = "-" + currency_name + "0.01";
|
||||
#else
|
||||
std::string v = currency_name + "-0.01";
|
||||
#endif
|
||||
std::showbase(ios);
|
||||
typedef cpp17_input_iterator<const char*> I;
|
||||
long double ex;
|
||||
|
@ -372,7 +377,11 @@ int main(int, char**)
|
|||
std::noshowbase(ios);
|
||||
}
|
||||
{ // negative, showbase
|
||||
#ifdef TEST_HAS_GLIBC
|
||||
std::string v = "-" + currency_name + "1,234,567.89";
|
||||
#else
|
||||
std::string v = currency_name + "-1,234,567.89";
|
||||
#endif
|
||||
std::showbase(ios);
|
||||
typedef cpp17_input_iterator<const char*> I;
|
||||
long double ex;
|
||||
|
@ -663,7 +672,11 @@ int main(int, char**)
|
|||
std::noshowbase(ios);
|
||||
}
|
||||
{ // negative one, showbase
|
||||
#ifdef TEST_HAS_GLIBC
|
||||
std::wstring v = L"-" + w_currency_name + L"0.01";
|
||||
#else
|
||||
std::wstring v = w_currency_name + L"-0.01";
|
||||
#endif
|
||||
typedef cpp17_input_iterator<const wchar_t*> I;
|
||||
long double ex;
|
||||
std::ios_base::iostate err = std::ios_base::goodbit;
|
||||
|
@ -674,7 +687,11 @@ int main(int, char**)
|
|||
assert(ex == -1);
|
||||
}
|
||||
{ // negative one, showbase
|
||||
#ifdef TEST_HAS_GLIBC
|
||||
std::wstring v = L"-" + w_currency_name + L"0.01";
|
||||
#else
|
||||
std::wstring v = w_currency_name + L"-0.01";
|
||||
#endif
|
||||
std::showbase(ios);
|
||||
typedef cpp17_input_iterator<const wchar_t*> I;
|
||||
long double ex;
|
||||
|
@ -711,7 +728,11 @@ int main(int, char**)
|
|||
std::noshowbase(ios);
|
||||
}
|
||||
{ // negative, showbase
|
||||
#ifdef TEST_HAS_GLIBC
|
||||
std::wstring v = L"-" + w_currency_name + L"1,234,567.89";
|
||||
#else
|
||||
std::wstring v = w_currency_name + L"-1,234,567.89";
|
||||
#endif
|
||||
std::showbase(ios);
|
||||
typedef cpp17_input_iterator<const wchar_t*> I;
|
||||
long double ex;
|
||||
|
|
|
@ -20,9 +20,6 @@
|
|||
// iter_type put(iter_type s, bool intl, ios_base& f, char_type fill,
|
||||
// long double units) const;
|
||||
|
||||
// TODO For zh_CN GLIBC puts the negative sign after the currency symbol.
|
||||
// XFAIL: target={{.*}}-linux-gnu{{.*}}
|
||||
|
||||
#include <locale>
|
||||
#include <ios>
|
||||
#include <streambuf>
|
||||
|
@ -219,7 +216,11 @@ int main(int, char**)
|
|||
char str[100];
|
||||
cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(str), true, ios, '*', v);
|
||||
std::string ex(str, base(iter));
|
||||
#ifdef TEST_HAS_GLIBC
|
||||
assert(ex == "-" + currency_name + "0.01");
|
||||
#else
|
||||
assert(ex == currency_name + "-0.01");
|
||||
#endif
|
||||
}
|
||||
{ // positive, showbase
|
||||
long double v = 123456789;
|
||||
|
@ -235,7 +236,11 @@ int main(int, char**)
|
|||
char str[100];
|
||||
cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(str), true, ios, '*', v);
|
||||
std::string ex(str, base(iter));
|
||||
#ifdef TEST_HAS_GLIBC
|
||||
assert(ex == "-" + currency_name + "1,234,567.89");
|
||||
#else
|
||||
assert(ex == currency_name + "-1,234,567.89");
|
||||
#endif
|
||||
}
|
||||
{ // negative, showbase, left
|
||||
long double v = -123456789;
|
||||
|
@ -245,7 +250,11 @@ int main(int, char**)
|
|||
char str[100];
|
||||
cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(str), true, ios, ' ', v);
|
||||
std::string ex(str, base(iter));
|
||||
#ifdef TEST_HAS_GLIBC
|
||||
assert(ex == "-" + currency_name + "1,234,567.89" + currency_name_padding);
|
||||
#else
|
||||
assert(ex == currency_name + "-1,234,567.89" + currency_name_padding);
|
||||
#endif
|
||||
assert(ios.width() == 0);
|
||||
}
|
||||
{ // negative, showbase, internal
|
||||
|
@ -256,7 +265,11 @@ int main(int, char**)
|
|||
char str[100];
|
||||
cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(str), true, ios, ' ', v);
|
||||
std::string ex(str, base(iter));
|
||||
#ifdef TEST_HAS_GLIBC
|
||||
assert(ex == "-" + currency_name + currency_name_padding + "1,234,567.89");
|
||||
#else
|
||||
assert(ex == currency_name + "-" + currency_name_padding + "1,234,567.89");
|
||||
#endif
|
||||
assert(ios.width() == 0);
|
||||
}
|
||||
{ // negative, showbase, right
|
||||
|
@ -267,7 +280,11 @@ int main(int, char**)
|
|||
char str[100];
|
||||
cpp17_output_iterator<char*> iter = f.put(cpp17_output_iterator<char*>(str), true, ios, ' ', v);
|
||||
std::string ex(str, base(iter));
|
||||
#ifdef TEST_HAS_GLIBC
|
||||
assert(ex == currency_name_padding + "-" + currency_name + "1,234,567.89");
|
||||
#else
|
||||
assert(ex == currency_name_padding + currency_name + "-1,234,567.89");
|
||||
#endif
|
||||
assert(ios.width() == 0);
|
||||
}
|
||||
}
|
||||
|
@ -423,7 +440,11 @@ int main(int, char**)
|
|||
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));
|
||||
#ifdef TEST_HAS_GLIBC
|
||||
assert(ex == L"-" + currency_name + L"0.01");
|
||||
#else
|
||||
assert(ex == currency_name + L"-0.01");
|
||||
#endif
|
||||
}
|
||||
{ // positive, showbase
|
||||
long double v = 123456789;
|
||||
|
@ -439,7 +460,11 @@ int main(int, char**)
|
|||
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));
|
||||
#ifdef TEST_HAS_GLIBC
|
||||
assert(ex == L"-" + currency_name + L"1,234,567.89");
|
||||
#else
|
||||
assert(ex == currency_name + L"-1,234,567.89");
|
||||
#endif
|
||||
}
|
||||
{ // negative, showbase, left
|
||||
long double v = -123456789;
|
||||
|
@ -449,7 +474,11 @@ int main(int, char**)
|
|||
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));
|
||||
#ifdef TEST_HAS_GLIBC
|
||||
assert(ex == L"-" + currency_name + L"1,234,567.89" + currency_name_padding);
|
||||
#else
|
||||
assert(ex == currency_name + L"-1,234,567.89" + currency_name_padding);
|
||||
#endif
|
||||
assert(ios.width() == 0);
|
||||
}
|
||||
{ // negative, showbase, internal
|
||||
|
@ -460,7 +489,11 @@ int main(int, char**)
|
|||
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));
|
||||
#ifdef TEST_HAS_GLIBC
|
||||
assert(ex == L"-" + currency_name + currency_name_padding + L"1,234,567.89");
|
||||
#else
|
||||
assert(ex == currency_name + L"-" + currency_name_padding + L"1,234,567.89");
|
||||
#endif
|
||||
assert(ios.width() == 0);
|
||||
}
|
||||
{ // negative, showbase, right
|
||||
|
@ -471,7 +504,11 @@ int main(int, char**)
|
|||
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));
|
||||
#ifdef TEST_HAS_GLIBC
|
||||
assert(ex == currency_name_padding + L"-" + currency_name + L"1,234,567.89");
|
||||
#else
|
||||
assert(ex == currency_name_padding + currency_name + L"-1,234,567.89");
|
||||
#endif
|
||||
assert(ios.width() == 0);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -15,9 +15,6 @@
|
|||
// REQUIRES: locale.ru_RU.UTF-8
|
||||
// REQUIRES: locale.zh_CN.UTF-8
|
||||
|
||||
// GLIBC fails on the zh_CN test.
|
||||
// XFAIL: linux
|
||||
|
||||
// <locale>
|
||||
|
||||
// class time_get_byname<charT, InputIterator>
|
||||
|
@ -90,10 +87,14 @@ int main(int, char**)
|
|||
assert(t.tm_year == 109);
|
||||
assert(err == std::ios_base::eofbit);
|
||||
}
|
||||
|
||||
{
|
||||
const my_facet f(LOCALE_zh_CN_UTF_8, 1);
|
||||
#ifdef TEST_HAS_GLIBC
|
||||
// There's no separator between month and day.
|
||||
const char in[] = "2009\u5e740610";
|
||||
#else
|
||||
const char in[] = "2009/06/10";
|
||||
#endif
|
||||
err = std::ios_base::goodbit;
|
||||
t = std::tm();
|
||||
I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
|
||||
|
@ -103,6 +104,5 @@ int main(int, char**)
|
|||
assert(t.tm_year == 109);
|
||||
assert(err == std::ios_base::eofbit);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -17,9 +17,6 @@
|
|||
// REQUIRES: locale.ru_RU.UTF-8
|
||||
// REQUIRES: locale.zh_CN.UTF-8
|
||||
|
||||
// GLIBC fails on the zh_CN test.
|
||||
// XFAIL: linux
|
||||
|
||||
// <locale>
|
||||
|
||||
// class time_get_byname<charT, InputIterator>
|
||||
|
@ -94,7 +91,12 @@ int main(int, char**)
|
|||
}
|
||||
{
|
||||
const my_facet f(LOCALE_zh_CN_UTF_8, 1);
|
||||
#ifdef TEST_HAS_GLIBC
|
||||
// There's no separator between month and day.
|
||||
const wchar_t in[] = L"2009\u5e740610";
|
||||
#else
|
||||
const wchar_t in[] = L"2009/06/10";
|
||||
#endif
|
||||
err = std::ios_base::goodbit;
|
||||
t = std::tm();
|
||||
I i = f.get_date(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
|
||||
|
@ -104,6 +106,5 @@ int main(int, char**)
|
|||
assert(t.tm_year == 109);
|
||||
assert(err == std::ios_base::eofbit);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -21,9 +21,6 @@
|
|||
// get_weekday(iter_type s, iter_type end, ios_base& str,
|
||||
// ios_base::iostate& err, tm* t) const;
|
||||
|
||||
// TODO: investigation needed
|
||||
// XFAIL: target={{.*}}-linux-gnu{{.*}}
|
||||
|
||||
#include <locale>
|
||||
#include <cassert>
|
||||
#include "test_macros.h"
|
||||
|
@ -70,7 +67,11 @@ int main(int, char**)
|
|||
}
|
||||
{
|
||||
const my_facet f(LOCALE_ru_RU_UTF_8, 1);
|
||||
#if defined(TEST_HAS_GLIBC)
|
||||
const wchar_t in[] = L"\x41F\x43E\x43D\x435\x434\x435\x43B\x44C\x43D\x438\x43A";
|
||||
#else
|
||||
const wchar_t in[] = L"\x43F\x43E\x43D\x435\x434\x435\x43B\x44C\x43D\x438\x43A";
|
||||
#endif
|
||||
err = std::ios_base::goodbit;
|
||||
t = std::tm();
|
||||
I i = f.get_weekday(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t);
|
||||
|
|
Loading…
Reference in New Issue