From d7306fb85ae44e7e5a66003ca81541c1721b5197 Mon Sep 17 00:00:00 2001 From: Roger Ferrer Ibanez Date: Tue, 29 Nov 2016 16:31:40 +0000 Subject: [PATCH] Protect locale tests under noexceptions Skip tests that expect exceptions be thrown. Differential Revision: https://reviews.llvm.org/D27096 llvm-svn: 288156 --- .../conversions/conversions.string/ctor_err_string.pass.cpp | 5 ++++- .../localization/locales/locale.global.templates/use_facet.pass.cpp | 5 ++++- .../localization/locales/locale/locale.cons/char_pointer.pass.cpp | 5 ++++- .../std/localization/locales/locale/locale.members/combine.pass.cpp | 5 ++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp b/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp index 307311d..70204c2 100644 --- a/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp +++ b/libcxx/test/std/localization/locales/locale.convenience/conversions/conversions.string/ctor_err_string.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // wstring_convert @@ -29,6 +28,7 @@ int main() static_assert(!std::is_convertible::value, ""); static_assert( std::is_constructible::value, ""); #endif +#ifndef TEST_HAS_NO_EXCEPTIONS { Myconv myconv; try @@ -48,10 +48,12 @@ int main() { } } +#endif { Myconv myconv("byte error"); std::string bs = myconv.to_bytes(L"\xDA83"); assert(bs == "byte error"); +#ifndef TEST_HAS_NO_EXCEPTIONS try { myconv.from_bytes('\xA5'); @@ -60,6 +62,7 @@ int main() catch (const std::range_error&) { } +#endif } { Myconv myconv("byte error", L"wide error"); diff --git a/libcxx/test/std/localization/locales/locale.global.templates/use_facet.pass.cpp b/libcxx/test/std/localization/locales/locale.global.templates/use_facet.pass.cpp index fec8ecc..2dba4b6 100644 --- a/libcxx/test/std/localization/locales/locale.global.templates/use_facet.pass.cpp +++ b/libcxx/test/std/localization/locales/locale.global.templates/use_facet.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // template const Facet& use_facet(const locale& loc); @@ -15,6 +14,8 @@ #include #include +#include "test_macros.h" + int facet_count = 0; struct my_facet @@ -32,6 +33,7 @@ std::locale::id my_facet::id; int main() { +#ifndef TEST_HAS_NO_EXCEPTIONS try { const my_facet& f = std::use_facet(std::locale()); @@ -41,6 +43,7 @@ int main() catch (std::bad_cast&) { } +#endif const my_facet* fp = 0; { std::locale loc(std::locale(), new my_facet); diff --git a/libcxx/test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp b/libcxx/test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp index c7021df..aef2ea9 100644 --- a/libcxx/test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp +++ b/libcxx/test/std/localization/locales/locale/locale.cons/char_pointer.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // REQUIRES: locale.ru_RU.UTF-8 // REQUIRES: locale.zh_CN.UTF-8 @@ -22,6 +21,8 @@ #include "count_new.hpp" #include "platform_support.h" // locale name macros +#include "test_macros.h" + void check(const std::locale& loc) { @@ -70,6 +71,7 @@ int main() check(loc3); assert(!(loc == loc3)); assert(loc != loc3); +#ifndef TEST_HAS_NO_EXCEPTIONS try { std::locale((const char*)0); @@ -86,6 +88,7 @@ int main() catch (std::runtime_error&) { } +#endif std::locale ok(""); } assert(globalMemCounter.checkOutstandingNewEq(0)); diff --git a/libcxx/test/std/localization/locales/locale/locale.members/combine.pass.cpp b/libcxx/test/std/localization/locales/locale/locale.members/combine.pass.cpp index 26a760f..a9919f6 100644 --- a/libcxx/test/std/localization/locales/locale/locale.members/combine.pass.cpp +++ b/libcxx/test/std/localization/locales/locale/locale.members/combine.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // template locale combine(const locale& other) const; @@ -18,6 +17,8 @@ #include "count_new.hpp" +#include "test_macros.h" + void check(const std::locale& loc) { assert(std::has_facet >(loc)); @@ -78,6 +79,7 @@ int main() } assert(globalMemCounter.checkOutstandingNewEq(0)); } +#ifndef TEST_HAS_NO_EXCEPTIONS { { std::locale loc; @@ -93,4 +95,5 @@ int main() } assert(globalMemCounter.checkOutstandingNewEq(0)); } +#endif } -- 2.7.4