diff options
Diffstat (limited to 'test/std/localization')
30 files changed, 156 insertions, 491 deletions
diff --git a/test/std/localization/c.locales/clocale.pass.cpp b/test/std/localization/c.locales/clocale.pass.cpp index a90725bfa367..534213495cd9 100644 --- a/test/std/localization/c.locales/clocale.pass.cpp +++ b/test/std/localization/c.locales/clocale.pass.cpp @@ -47,6 +47,7 @@ int main() { std::lconv lc; + ((void)lc); // Prevent unused warning #ifndef _LIBCPP_HAS_NO_THREAD_UNSAFE_C_FUNCTIONS static_assert((std::is_same<decltype(std::setlocale(0, "")), char*>::value), ""); #endif diff --git a/test/std/localization/locale.categories/__scan_keyword.pass.cpp b/test/std/localization/locale.categories/__scan_keyword.pass.cpp deleted file mode 100644 index b33aab9a730a..000000000000 --- a/test/std/localization/locale.categories/__scan_keyword.pass.cpp +++ /dev/null @@ -1,118 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <locale> - -// Not a portable test - -// __scan_keyword -// Scans [__b, __e) until a match is found in the basic_strings range -// [__kb, __ke) or until it can be shown that there is no match in [__kb, __ke). -// __b will be incremented (visibly), consuming CharT until a match is found -// or proved to not exist. A keyword may be "", in which will match anything. -// If one keyword is a prefix of another, and the next CharT in the input -// might match another keyword, the algorithm will attempt to find the longest -// matching keyword. If the longer matching keyword ends up not matching, then -// no keyword match is found. If no keyword match is found, __ke is returned. -// Else an iterator pointing to the matching keyword is found. If more than -// one keyword matches, an iterator to the first matching keyword is returned. -// If on exit __b == __e, eofbit is set in __err. If __case_sensitive is false, -// __ct is used to force to lower case before comparing characters. -// Examples: -// Keywords: "a", "abb" -// If the input is "a", the first keyword matches and eofbit is set. -// If the input is "abc", no match is found and "ab" are consumed. -// -// template <class _InputIterator, class _ForwardIterator, class _Ctype> -// _ForwardIterator -// __scan_keyword(_InputIterator& __b, _InputIterator __e, -// _ForwardIterator __kb, _ForwardIterator __ke, -// const _Ctype& __ct, ios_base::iostate& __err, -// bool __case_sensitive = true); - -#include <locale> -#include <cassert> - -int main() -{ - const std::ctype<char>& ct = std::use_facet<std::ctype<char> >(std::locale::classic()); - std::ios_base::iostate err = std::ios_base::goodbit; - { - const char input[] = "a"; - const char* in = input; - std::string keys[] = {"a", "abb"}; - err = std::ios_base::goodbit; - std::string* k = std::__scan_keyword(in, input+sizeof(input)-1, - keys, keys+sizeof(keys)/sizeof(keys[0]), - ct, err); - assert(k - keys == 0); - assert(in == input+1); - assert(err == std::ios_base::eofbit); - } - { - const char input[] = "abc"; - const char* in = input; - std::string keys[] = {"a", "abb"}; - err = std::ios_base::goodbit; - std::string* k = std::__scan_keyword(in, input+sizeof(input)-1, - keys, keys+sizeof(keys)/sizeof(keys[0]), - ct, err); - assert(k - keys == 2); - assert(in == input+2); - assert(err == std::ios_base::failbit); - } - { - const char input[] = "abb"; - const char* in = input; - std::string keys[] = {"a", "abb"}; - err = std::ios_base::goodbit; - std::string* k = std::__scan_keyword(in, input+sizeof(input)-1, - keys, keys+sizeof(keys)/sizeof(keys[0]), - ct, err); - assert(k - keys == 1); - assert(in == input+3); - assert(err == std::ios_base::eofbit); - } - { - const char input[] = "Tue "; - const char* in = input; - std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"}; - err = std::ios_base::goodbit; - std::string* k = std::__scan_keyword(in, input+sizeof(input)-1, - keys, keys+sizeof(keys)/sizeof(keys[0]), - ct, err); - assert(k - keys == 2); - assert(in == input+3); - assert(err == std::ios_base::goodbit); - } - { - const char input[] = "tue "; - const char* in = input; - std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"}; - err = std::ios_base::goodbit; - std::string* k = std::__scan_keyword(in, input+sizeof(input)-1, - keys, keys+sizeof(keys)/sizeof(keys[0]), - ct, err); - assert(k - keys == 4); - assert(in == input+0); - assert(err == std::ios_base::failbit); - } - { - const char input[] = "tue "; - const char* in = input; - std::string keys[] = {"Mon", "Monday", "Tue", "Tuesday"}; - err = std::ios_base::goodbit; - std::string* k = std::__scan_keyword(in, input+sizeof(input)-1, - keys, keys+sizeof(keys)/sizeof(keys[0]), - ct, err, false); - assert(k - keys == 2); - assert(in == input+3); - assert(err == std::ios_base::goodbit); - } -} diff --git a/test/std/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp b/test/std/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp index 09009ceaaae2..dfbdeaea954b 100644 --- a/test/std/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp +++ b/test/std/localization/locale.categories/category.collate/locale.collate.byname/compare.pass.cpp @@ -53,23 +53,6 @@ int main() } } { - std::locale l(""); - { - const std::collate<char>& f = std::use_facet<std::collate<char> >(l); - std::string s2("aaaaaaA"); - std::string s3("BaaaaaA"); - assert(f.compare(s2.data(), s2.data() + s2.size(), - s3.data(), s3.data() + s3.size()) == 1); - } - { - const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l); - std::wstring s2(L"aaaaaaA"); - std::wstring s3(L"BaaaaaA"); - assert(f.compare(s2.data(), s2.data() + s2.size(), - s3.data(), s3.data() + s3.size()) == 1); - } - } - { std::locale l("C"); { const std::collate<char>& f = std::use_facet<std::collate<char> >(l); diff --git a/test/std/localization/locale.categories/category.collate/locale.collate.byname/transform.pass.cpp b/test/std/localization/locale.categories/category.collate/locale.collate.byname/transform.pass.cpp index d31705e5ad1b..b39e9ad74dc4 100644 --- a/test/std/localization/locale.categories/category.collate/locale.collate.byname/transform.pass.cpp +++ b/test/std/localization/locale.categories/category.collate/locale.collate.byname/transform.pass.cpp @@ -25,8 +25,6 @@ int main() { - // Ensure that the default locale is not C. If it is, the second tests will fail. - putenv(const_cast<char*>("LC_ALL=" LOCALE_en_US_UTF_8)); { std::locale l(LOCALE_en_US_UTF_8); { @@ -41,19 +39,6 @@ int main() } } { - std::locale l(""); - { - std::string x("1234"); - const std::collate<char>& f = std::use_facet<std::collate<char> >(l); - assert(f.transform(x.data(), x.data() + x.size()) != x); - } - { - std::wstring x(L"1234"); - const std::collate<wchar_t>& f = std::use_facet<std::collate<wchar_t> >(l); - assert(f.transform(x.data(), x.data() + x.size()) != x); - } - } - { std::locale l("C"); { std::string x("1234"); diff --git a/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/classic_table.pass.cpp b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/classic_table.pass.cpp index b5690e3c6b26..f7b0e5b71567 100644 --- a/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/classic_table.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/facet.ctype.special/facet.ctype.char.statics/classic_table.pass.cpp @@ -30,7 +30,7 @@ int main() for ( size_t i = 0; i < 128; ++i ) // values above 128 are not consistent { mask set = 0; - + if ( i < 32 || i > 126 ) set |= F::cntrl; if ( i >= 32 && i <= 126 ) set |= F::print; @@ -51,9 +51,9 @@ int main() if ( i >= 58 && i <= 64 ) set |= F::punct; // ':' .. '@' if ( i >= 91 && i <= 96 ) set |= F::punct; // '[' .. '`' if ( i >= 123 && i <= 126 ) set |= F::punct; // '{' .. '~' } - + assert(( p[i] & set) == set); // all the right bits set assert(((p[i] & ~set) & defined) == 0); // no extra ones } - + } diff --git a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/types.pass.cpp b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/types.pass.cpp index fdfab5769043..0e9909720c0b 100644 --- a/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/types.pass.cpp +++ b/test/std/localization/locale.categories/category.ctype/locale.ctype.byname/types.pass.cpp @@ -45,19 +45,6 @@ int main() } } { - std::locale l(""); - { - assert(std::has_facet<std::ctype_byname<char> >(l)); - assert(&std::use_facet<std::ctype<char> >(l) - == &std::use_facet<std::ctype_byname<char> >(l)); - } - { - assert(std::has_facet<std::ctype_byname<wchar_t> >(l)); - assert(&std::use_facet<std::ctype<wchar_t> >(l) - == &std::use_facet<std::ctype_byname<wchar_t> >(l)); - } - } - { std::locale l("C"); { assert(std::has_facet<std::ctype_byname<char> >(l)); diff --git a/test/std/localization/locale.categories/category.monetary/locale.moneypunct/money_base.pass.cpp b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/money_base.pass.cpp index beabe0cae660..a0c17dcae7d0 100644 --- a/test/std/localization/locale.categories/category.monetary/locale.moneypunct/money_base.pass.cpp +++ b/test/std/localization/locale.categories/category.monetary/locale.moneypunct/money_base.pass.cpp @@ -21,13 +21,13 @@ int main() { - std::money_base mb; - assert(mb.none == 0); - assert(mb.space == 1); - assert(mb.symbol == 2); - assert(mb.sign == 3); - assert(mb.value == 4); - assert(sizeof(std::money_base::pattern) == 4); + std::money_base mb; ((void)mb); + static_assert(std::money_base::none == 0, ""); + static_assert(std::money_base::space == 1, ""); + static_assert(std::money_base::symbol == 2, ""); + static_assert(std::money_base::sign == 3, ""); + static_assert(std::money_base::value == 4, ""); + static_assert(sizeof(std::money_base::pattern) == 4, ""); std::money_base::pattern p; p.field[0] = std::money_base::none; } diff --git a/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpp index a54b37314e87..596f8f80f04e 100644 --- a/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpp +++ b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_double.pass.cpp @@ -13,6 +13,9 @@ // iter_type put(iter_type s, ios_base& iob, char_type fill, double v) const; +// TODO(EricWF): This test takes 40+ minutes to build with Clang 3.8 under ASAN or MSAN. +// UNSUPPORTED: asan, msan + #include <locale> #include <ios> #include <cassert> diff --git a/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp index 935961257ef2..cf9339341abb 100644 --- a/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp +++ b/test/std/localization/locale.categories/category.numeric/locale.nm.put/facet.num.put.members/put_long_double.pass.cpp @@ -13,6 +13,9 @@ // iter_type put(iter_type s, ios_base& iob, char_type fill, long double v) const; +// TODO(EricWF): This test takes 40+ minutes to build with Clang 3.8 under ASAN or MSAN. +// UNSUPPORTED: asan, msan + // TODO GLIBC uses a different string for positive and negative NAN numbers. // XFAIL: linux-gnu @@ -24412,14 +24415,14 @@ void test11() void test12() { - char str[200]; output_iterator<char*> iter; std::locale lc = std::locale::classic(); std::locale lg(lc, new my_numpunct); #ifdef __APPLE__ // This test is failing on FreeBSD, possibly due to different representations -// of the floating point numbers. +// of the floating point numbers. const my_facet f(1); + char str[200]; { long double v = 1234567890.125; std::ios ios(0); @@ -26218,7 +26221,6 @@ int main() test10(); test11(); test12(); - char str[200]; output_iterator<char*> iter; std::locale lc = std::locale::classic(); std::locale lg(lc, new my_numpunct); diff --git a/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp index f5c7c1277c31..6d7f506bb2d4 100644 --- a/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp +++ b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_double.pass.cpp @@ -207,6 +207,30 @@ int main() assert(err == ios.goodbit); assert(v == 2); } + { + v = -1; + const char str[] = "1.79779e+309"; // unrepresentable + std::ios_base::iostate err = ios.goodbit; + input_iterator<const char*> iter = + f.get(input_iterator<const char*>(str), + input_iterator<const char*>(str+sizeof(str)), + ios, err, v); + assert(iter.base() == str+sizeof(str)-1); + assert(err == ios.failbit); + assert(v == HUGE_VAL); + } + { + v = -1; + const char str[] = "-1.79779e+308"; // unrepresentable + std::ios_base::iostate err = ios.goodbit; + input_iterator<const char*> iter = + f.get(input_iterator<const char*>(str), + input_iterator<const char*>(str+sizeof(str)), + ios, err, v); + assert(iter.base() == str+sizeof(str)-1); + assert(err == ios.failbit); + assert(v == -HUGE_VAL); + } ios.imbue(std::locale(std::locale(), new my_numpunct)); { v = -1; diff --git a/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_float.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_float.pass.cpp index 9138894784ed..d01f63d5920d 100644 --- a/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_float.pass.cpp +++ b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_float.pass.cpp @@ -32,6 +32,7 @@ public: : F(refs) {} }; + int main() { const my_facet f(1); @@ -168,4 +169,29 @@ int main() assert(err == ios.goodbit); assert(std::isnan(v)); } + { + v = -1; + const char str[] = "3.40283e+39"; // unrepresentable + std::ios_base::iostate err = ios.goodbit; + input_iterator<const char*> iter = + f.get(input_iterator<const char*>(str), + input_iterator<const char*>(str+sizeof(str)), + ios, err, v); + assert(iter.base() == str+sizeof(str)-1); + assert(err == ios.failbit); + assert(v == HUGE_VALF); + } + { + v = -1; + const char str[] = "-3.40283e+38"; // unrepresentable + std::ios_base::iostate err = ios.goodbit; + input_iterator<const char*> iter = + f.get(input_iterator<const char*>(str), + input_iterator<const char*>(str+sizeof(str)), + ios, err, v); + assert(iter.base() == str+sizeof(str)-1); + assert(err == ios.failbit); + assert(v == -HUGE_VALF); + + } } diff --git a/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_double.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_double.pass.cpp index 8e89ebc470cf..b79650b0199b 100644 --- a/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_double.pass.cpp +++ b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/get_long_double.pass.cpp @@ -32,6 +32,7 @@ public: : F(refs) {} }; + int main() { const my_facet f(1); @@ -228,4 +229,28 @@ int main() assert(err != ios.failbit); assert(v == 304888344611713860501504000000.0L); } + { + v = -1; + const char str[] = "1.19973e+4933"; // unrepresentable + std::ios_base::iostate err = ios.goodbit; + input_iterator<const char*> iter = + f.get(input_iterator<const char*>(str), + input_iterator<const char*>(str+sizeof(str)), + ios, err, v); + assert(iter.base() == str+sizeof(str)-1); + assert(err == ios.failbit); + assert(v == HUGE_VALL); + } + { + v = -1; + const char str[] = "-1.18974e+4932"; // unrepresentable + std::ios_base::iostate err = ios.goodbit; + input_iterator<const char*> iter = + f.get(input_iterator<const char*>(str), + input_iterator<const char*>(str+sizeof(str)), + ios, err, v); + assert(iter.base() == str+sizeof(str)-1); + assert(err == ios.failbit); + assert(v == -HUGE_VALL); + } } diff --git a/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/test_min_max.pass.cpp b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/test_min_max.pass.cpp index e474eca2f5b2..6ba5a89e61e4 100644 --- a/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/test_min_max.pass.cpp +++ b/test/std/localization/locale.categories/category.numeric/locale.num.get/facet.num.get.members/test_min_max.pass.cpp @@ -25,14 +25,14 @@ void check_limits() assert(miniss << minv); assert(maxiss << maxv); std::string mins = miniss.str(); - std::string maxs = maxiss.str(); + std::string maxs = maxiss.str(); istringstream maxoss(maxs), minoss(mins); T new_minv, new_maxv; assert(maxoss >> new_maxv); assert(minoss >> new_minv); - + assert(new_minv == minv); assert(new_maxv == maxv); @@ -40,11 +40,11 @@ void check_limits() mins = "-1"; else mins[mins.size() - 1]++; - + maxs[maxs.size() - 1]++; istringstream maxoss2(maxs), minoss2(mins); - + assert(! (maxoss2 >> new_maxv)); assert(! (minoss2 >> new_minv)); } diff --git a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp index 7ad431652a89..931ab5d40964 100644 --- a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp +++ b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname.pass.cpp @@ -9,15 +9,8 @@ // REQUIRES: locale.en_US.UTF-8 // REQUIRES: locale.fr_FR.UTF-8 -// REQUIRES: locale.ru_RU.UTF-8 // REQUIRES: locale.zh_CN.UTF-8 -// NOTE: debian and opensuse use old locale data for ru_RU.UTF-8 abbreviated -// months. This locale data was changed in glibc 2.14. -// Debian uses glibc 2.13 as of 20/11/2014 -// OpenSuse uses glibc 2.19 with old locale data as of 20/11/2014 -// XFAIL: debian, opensuse - // <locale> // class time_get_byname<charT, InputIterator> @@ -70,16 +63,6 @@ int main() assert(err == std::ios_base::eofbit); } { - const my_facet f(LOCALE_ru_RU_UTF_8, 1); - const char in[] = "\xD0\xB8\xD1\x8E\xD0\xBD\xD1\x8F"; - err = std::ios_base::goodbit; - t = std::tm(); - I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t); - assert(i.base() == in+sizeof(in)/sizeof(in[0])-1); - assert(t.tm_mon == 5); - assert(err == std::ios_base::eofbit); - } - { const my_facet f(LOCALE_zh_CN_UTF_8, 1); const char in[] = "\xE5\x85\xAD\xE6\x9C\x88"; err = std::ios_base::goodbit; diff --git a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp index 631a6de03d82..551f298b0419 100644 --- a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp +++ b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_monthname_wide.pass.cpp @@ -9,15 +9,8 @@ // REQUIRES: locale.en_US.UTF-8 // REQUIRES: locale.fr_FR.UTF-8 -// REQUIRES: locale.ru_RU.UTF-8 // REQUIRES: locale.zh_CN.UTF-8 -// NOTE: debian and opensuse use bad locale data for ru_RU.UTF-8 abbreviated -// months. This locale data was fixed in glibc 2.14. -// Debian uses glibc 2.13 as of 20/11/2014 -// OpenSuse uses glibc 2.19 with old locale data as of 20/11/2014 -// XFAIL: debian, opensuse - // <locale> // class time_get_byname<charT, InputIterator> @@ -79,16 +72,6 @@ int main() assert(err == std::ios_base::eofbit); } { - const my_facet f(LOCALE_ru_RU_UTF_8, 1); - const wchar_t in[] = L"\x438\x44E\x43D\x44F"; - err = std::ios_base::goodbit; - t = std::tm(); - I i = f.get_monthname(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t); - assert(i.base() == in+sizeof(in)/sizeof(in[0])-1); - assert(t.tm_mon == 5); - assert(err == std::ios_base::eofbit); - } - { const my_facet f(LOCALE_zh_CN_UTF_8, 1); const wchar_t in[] = L"\x516D\x6708"; err = std::ios_base::goodbit; diff --git a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp index ae8bce22445a..4a2b3819b507 100644 --- a/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp +++ b/test/std/localization/locale.categories/category.time/locale.time.get.byname/get_one_wide.pass.cpp @@ -75,7 +75,7 @@ int main() } { const my_facet f(LOCALE_fr_FR_UTF_8, 1); - const wchar_t in[] = L"Sam 31 d""\xE9""c 23:55:59 2061"; + const wchar_t in[] = L"Sam 31 d" L"\xE9" L"c 23:55:59 2061"; err = std::ios_base::goodbit; t = std::tm(); I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c'); @@ -105,11 +105,11 @@ int main() { const my_facet f("ru_RU", 1); const wchar_t in[] = L"\x441\x443\x431\x431\x43E\x442\x430" - ", 31 " - "\x434\x435\x43A\x430\x431\x440\x44F" - " 2061 " - "\x433" - ". 23:55:59"; + L", 31 " + L"\x434\x435\x43A\x430\x431\x440\x44F" + L" 2061 " + L"\x433" + L". 23:55:59"; err = std::ios_base::goodbit; t = std::tm(); I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c'); @@ -140,7 +140,7 @@ int main() { const my_facet f("zh_CN", 1); const wchar_t in[] = L"\x516D" - " 12/31 23:55:59 2061"; + L" 12/31 23:55:59 2061"; err = std::ios_base::goodbit; t = std::tm(); I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'c'); @@ -157,7 +157,7 @@ int main() #endif { const my_facet f(LOCALE_zh_CN_UTF_8, 1); - const wchar_t in[] = L"23""\x65F6""55""\x5206""59""\x79D2"; + const wchar_t in[] = L"23" L"\x65F6" L"55" L"\x5206" L"59" L"\x79D2"; err = std::ios_base::goodbit; t = std::tm(); I i = f.get(I(in), I(in+sizeof(in)/sizeof(in[0])-1), ios, err, &t, 'X'); diff --git a/test/std/localization/locale.stdcvt/version.pass.cpp b/test/std/localization/locale.stdcvt/version.pass.cpp deleted file mode 100644 index 3885380854cc..000000000000 --- a/test/std/localization/locale.stdcvt/version.pass.cpp +++ /dev/null @@ -1,20 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <codecvt> - -#include <codecvt> - -#ifndef _LIBCPP_VERSION -#error _LIBCPP_VERSION not defined -#endif - -int main() -{ -} diff --git a/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_copy.pass.cpp b/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_copy.pass.cpp new file mode 100644 index 000000000000..72e79dfb1e7f --- /dev/null +++ b/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_copy.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// These constructors are still unavailable in C++03, but this test depends +// on access control SFINAE and fails without it. +// UNSUPPORTED: c++98, c++03 + +// <locale> + +// wstring_convert<Codecvt, Elem, Wide_alloc, Byte_alloc> + +// wstring_convert(wstring_convert const&) = delete; +// wstring_convert& operator=(wstring_convert const&) = delete; + +#include <locale> +#include <codecvt> +#include <cassert> + +int main() +{ + typedef std::codecvt_utf8<wchar_t> Codecvt; + typedef std::wstring_convert<Codecvt> Myconv; + static_assert(!std::is_copy_constructible<Myconv>::value, ""); + static_assert(!std::is_copy_assignable<Myconv>::value, ""); +} diff --git a/test/std/localization/locales/locale/locale.cons/assign.pass.cpp b/test/std/localization/locales/locale/locale.cons/assign.pass.cpp index 80afe1e46aad..8b31a8f97498 100644 --- a/test/std/localization/locales/locale/locale.cons/assign.pass.cpp +++ b/test/std/localization/locales/locale/locale.cons/assign.pass.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // REQUIRES: locale.ru_RU.UTF-8 -// UNSUPPORTED: sanitizer-new-delete // <locale> @@ -18,21 +17,10 @@ #include <cassert> #include <new> -#include "platform_support.h" // locale name macros - -int new_called = 0; +#include "count_new.hpp" -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - return std::malloc(s); -} +#include "platform_support.h" // locale name macros -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} void check(const std::locale& loc) { @@ -79,5 +67,5 @@ int main() check(loc); check(loc2); } - assert(new_called == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); } diff --git a/test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp b/test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp index b808a7650c47..c7021df8f577 100644 --- a/test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp +++ b/test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp @@ -10,7 +10,6 @@ // XFAIL: libcpp-no-exceptions // REQUIRES: locale.ru_RU.UTF-8 // REQUIRES: locale.zh_CN.UTF-8 -// UNSUPPORTED: sanitizer-new-delete // <locale> @@ -20,21 +19,9 @@ #include <new> #include <cassert> +#include "count_new.hpp" #include "platform_support.h" // locale name macros -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} void check(const std::locale& loc) { @@ -101,5 +88,5 @@ int main() } std::locale ok(""); } - assert(new_called == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); } diff --git a/test/std/localization/locales/locale/locale.cons/copy.pass.cpp b/test/std/localization/locales/locale/locale.cons/copy.pass.cpp index 0760cc46cdd8..9e446e440851 100644 --- a/test/std/localization/locales/locale/locale.cons/copy.pass.cpp +++ b/test/std/localization/locales/locale/locale.cons/copy.pass.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // REQUIRES: locale.fr_FR.UTF-8 -// UNSUPPORTED: sanitizer-new-delete // <locale> @@ -18,22 +17,9 @@ #include <cassert> #include <new> +#include "count_new.hpp" #include "platform_support.h" // locale name macros -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} - void check(const std::locale& loc) { assert(std::has_facet<std::collate<char> >(loc)); @@ -78,5 +64,5 @@ int main() check(loc); check(loc2); } - assert(new_called == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); } diff --git a/test/std/localization/locales/locale/locale.cons/locale_char_pointer_cat.pass.cpp b/test/std/localization/locales/locale/locale.cons/locale_char_pointer_cat.pass.cpp index 2a9e20fcf98d..eb381f9a580d 100644 --- a/test/std/localization/locales/locale/locale.cons/locale_char_pointer_cat.pass.cpp +++ b/test/std/localization/locales/locale/locale.cons/locale_char_pointer_cat.pass.cpp @@ -9,7 +9,6 @@ // REQUIRES: locale.en_US.UTF-8 // REQUIRES: locale.ru_RU.UTF-8 -// UNSUPPORTED: sanitizer-new-delete // <locale> @@ -19,22 +18,9 @@ #include <new> #include <cassert> +#include "count_new.hpp" #include "platform_support.h" // locale name macros -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} - void check(const std::locale& loc) { assert(std::has_facet<std::collate<char> >(loc)); @@ -78,5 +64,5 @@ int main() std::locale loc2(loc, LOCALE_en_US_UTF_8, std::locale::monetary); check(loc2); } - assert(new_called == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); } diff --git a/test/std/localization/locales/locale/locale.cons/locale_facetptr.pass.cpp b/test/std/localization/locales/locale/locale.cons/locale_facetptr.pass.cpp index fb6e39e5742f..1144931e3d2c 100644 --- a/test/std/localization/locales/locale/locale.cons/locale_facetptr.pass.cpp +++ b/test/std/localization/locales/locale/locale.cons/locale_facetptr.pass.cpp @@ -8,7 +8,6 @@ //===----------------------------------------------------------------------===// // REQUIRES: locale.ru_RU.UTF-8 -// UNSUPPORTED: sanitizer-new-delete // <locale> @@ -18,21 +17,9 @@ #include <new> #include <cassert> +#include "count_new.hpp" #include "platform_support.h" // locale name macros -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} void check(const std::locale& loc) { @@ -81,7 +68,6 @@ std::locale::id my_facet::id; int main() { -{ { std::locale loc(LOCALE_ru_RU_UTF_8); check(loc); @@ -91,9 +77,7 @@ int main() const my_facet& f = std::use_facet<my_facet>(loc2); assert(f.test() == 5); } - assert(new_called == 0); -} -{ + assert(globalMemCounter.checkOutstandingNewEq(0)); { std::locale loc; check(loc); @@ -101,6 +85,5 @@ int main() check(loc2); assert(loc == loc2); } - assert(new_called == 0); -} + assert(globalMemCounter.checkOutstandingNewEq(0)); } diff --git a/test/std/localization/locales/locale/locale.cons/locale_locale_cat.pass.cpp b/test/std/localization/locales/locale/locale.cons/locale_locale_cat.pass.cpp index fa87eb20e9af..f1afff66580e 100644 --- a/test/std/localization/locales/locale/locale.cons/locale_locale_cat.pass.cpp +++ b/test/std/localization/locales/locale/locale.cons/locale_locale_cat.pass.cpp @@ -9,7 +9,6 @@ // REQUIRES: locale.en_US.UTF-8 // REQUIRES: locale.ru_RU.UTF-8 -// UNSUPPORTED: sanitizer-new-delete // <locale> @@ -19,22 +18,9 @@ #include <new> #include <cassert> +#include "count_new.hpp" #include "platform_support.h" // locale name macros -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} - void check(const std::locale& loc) { assert(std::has_facet<std::collate<char> >(loc)); @@ -78,5 +64,5 @@ int main() std::locale loc2(loc, std::locale(LOCALE_en_US_UTF_8), std::locale::monetary); check(loc2); } - assert(new_called == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); } diff --git a/test/std/localization/locales/locale/locale.cons/locale_string_cat.pass.cpp b/test/std/localization/locales/locale/locale.cons/locale_string_cat.pass.cpp index 59fbc59b90da..eb63cd03b663 100644 --- a/test/std/localization/locales/locale/locale.cons/locale_string_cat.pass.cpp +++ b/test/std/localization/locales/locale/locale.cons/locale_string_cat.pass.cpp @@ -6,10 +6,9 @@ // Source Licenses. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// - + // REQUIRES: locale.en_US.UTF-8 // REQUIRES: locale.ru_RU.UTF-8 -// UNSUPPORTED: sanitizer-new-delete // <locale> @@ -19,21 +18,9 @@ #include <new> #include <cassert> +#include "count_new.hpp" #include "platform_support.h" // locale name macros -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} void check(const std::locale& loc) { @@ -78,5 +65,5 @@ int main() std::locale loc2(loc, std::string(LOCALE_en_US_UTF_8), std::locale::monetary); check(loc2); } - assert(new_called == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); } diff --git a/test/std/localization/locales/locale/locale.cons/string.pass.cpp b/test/std/localization/locales/locale/locale.cons/string.pass.cpp index c9f944196e73..6fc0808b2728 100644 --- a/test/std/localization/locales/locale/locale.cons/string.pass.cpp +++ b/test/std/localization/locales/locale/locale.cons/string.pass.cpp @@ -9,7 +9,6 @@ // REQUIRES: locale.ru_RU.UTF-8 // REQUIRES: locale.zh_CN.UTF-8 -// UNSUPPORTED: sanitizer-new-delete // <locale> @@ -19,22 +18,9 @@ #include <new> #include <cassert> +#include "count_new.hpp" #include "platform_support.h" // locale name macros -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} - void check(const std::locale& loc) { assert(std::has_facet<std::collate<char> >(loc)); @@ -83,5 +69,5 @@ int main() assert(!(loc == loc3)); assert(loc != loc3); } - assert(new_called == 0); + assert(globalMemCounter.checkOutstandingNewEq(0)); } diff --git a/test/std/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp b/test/std/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp deleted file mode 100644 index 4a7f77ad5d9a..000000000000 --- a/test/std/localization/locales/locale/locale.types/locale.facet/facet.pass.cpp +++ /dev/null @@ -1,53 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <locale> - -// class locale::facet -// { -// protected: -// explicit facet(size_t refs = 0); -// virtual ~facet(); -// facet(const facet&) = delete; -// void operator=(const facet&) = delete; -// }; - -// This test isn't portable - -#include <locale> -#include <cassert> - -struct my_facet - : public std::locale::facet -{ - static int count; - my_facet(unsigned refs = 0) - : std::locale::facet(refs) - {++count;} - - ~my_facet() {--count;} -}; - -int my_facet::count = 0; - -int main() -{ - my_facet* f = new my_facet; - f->__add_shared(); - assert(my_facet::count == 1); - f->__release_shared(); - assert(my_facet::count == 0); - f = new my_facet(1); - f->__add_shared(); - assert(my_facet::count == 1); - f->__release_shared(); - assert(my_facet::count == 1); - f->__release_shared(); - assert(my_facet::count == 0); -} diff --git a/test/std/localization/version.pass.cpp b/test/std/localization/locales/locale/locale.types/locale.facet/tested_elsewhere.pass.cpp index a64534c9f58b..b58f5c55b643 100644 --- a/test/std/localization/version.pass.cpp +++ b/test/std/localization/locales/locale/locale.types/locale.facet/tested_elsewhere.pass.cpp @@ -7,14 +7,6 @@ // //===----------------------------------------------------------------------===// -// <locale> - -#include <locale> - -#ifndef _LIBCPP_VERSION -#error _LIBCPP_VERSION not defined -#endif - int main() { } diff --git a/test/std/localization/locales/locale/locale.types/locale.id/id.pass.cpp b/test/std/localization/locales/locale/locale.types/locale.id/id.pass.cpp deleted file mode 100644 index 3233624d87b4..000000000000 --- a/test/std/localization/locales/locale/locale.types/locale.id/id.pass.cpp +++ /dev/null @@ -1,50 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// <locale> - -// class locale::id -// { -// public: -// id(); -// void operator=(const id&) = delete; -// id(const id&) = delete; -// }; - -// This test isn't portable - -#include <locale> -#include <cassert> - -std::locale::id id0; -std::locale::id id2; -std::locale::id id1; - -int main() -{ - long id = id0.__get(); - assert(id0.__get() == id+0); - assert(id0.__get() == id+0); - assert(id0.__get() == id+0); - assert(id1.__get() == id+1); - assert(id1.__get() == id+1); - assert(id1.__get() == id+1); - assert(id2.__get() == id+2); - assert(id2.__get() == id+2); - assert(id2.__get() == id+2); - assert(id0.__get() == id+0); - assert(id0.__get() == id+0); - assert(id0.__get() == id+0); - assert(id1.__get() == id+1); - assert(id1.__get() == id+1); - assert(id1.__get() == id+1); - assert(id2.__get() == id+2); - assert(id2.__get() == id+2); - assert(id2.__get() == id+2); -} diff --git a/test/std/localization/c.locales/version.pass.cpp b/test/std/localization/locales/locale/locale.types/locale.id/tested_elsewhere.pass.cpp index 0fce59e2b0b8..b58f5c55b643 100644 --- a/test/std/localization/c.locales/version.pass.cpp +++ b/test/std/localization/locales/locale/locale.types/locale.id/tested_elsewhere.pass.cpp @@ -7,14 +7,6 @@ // //===----------------------------------------------------------------------===// -// <clocale> - -#include <clocale> - -#ifndef _LIBCPP_VERSION -#error _LIBCPP_VERSION not defined -#endif - int main() { } |