From 84c152a130ff95e52846dddd2cc6ad1c31648160 Mon Sep 17 00:00:00 2001 From: Roger Ferrer Ibanez Date: Mon, 14 Nov 2016 10:44:26 +0000 Subject: [PATCH] Update tests for strings conversions under libcpp-no-exceptions Differential Revision: https://reviews.llvm.org/D26139 llvm-svn: 286812 --- .../strings/string.conversions/stod.pass.cpp | 23 ++++++++++++++++- .../strings/string.conversions/stof.pass.cpp | 19 +++++++++++++- .../strings/string.conversions/stoi.pass.cpp | 5 +++- .../strings/string.conversions/stol.pass.cpp | 5 +++- .../strings/string.conversions/stold.pass.cpp | 25 ++++++++++++++++++- .../strings/string.conversions/stoll.pass.cpp | 5 +++- .../strings/string.conversions/stoul.pass.cpp | 5 +++- .../string.conversions/stoull.pass.cpp | 5 +++- 8 files changed, 84 insertions(+), 8 deletions(-) diff --git a/libcxx/test/std/strings/string.conversions/stod.pass.cpp b/libcxx/test/std/strings/string.conversions/stod.pass.cpp index 27d5e5cbd19b..3d5db63e0983 100644 --- a/libcxx/test/std/strings/string.conversions/stod.pass.cpp +++ b/libcxx/test/std/strings/string.conversions/stod.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // double stod(const string& str, size_t *idx = 0); @@ -17,6 +16,8 @@ #include #include +#include "test_macros.h" + int main() { assert(std::stod("0") == 0); @@ -33,20 +34,25 @@ int main() idx = 0; assert(std::stod(L"10g", &idx) == 10); assert(idx == 2); +#ifndef TEST_HAS_NO_EXCEPTIONS try +#endif { assert(std::stod("1.e60", &idx) == 1.e60); assert(idx == 5); } +#ifndef TEST_HAS_NO_EXCEPTIONS catch (const std::out_of_range&) { assert(false); } try +#endif { assert(std::stod(L"1.e60", &idx) == 1.e60); assert(idx == 5); } +#ifndef TEST_HAS_NO_EXCEPTIONS catch (const std::out_of_range&) { assert(false); @@ -71,40 +77,54 @@ int main() assert(idx == 0); } try +#endif { assert(std::stod("INF", &idx) == INFINITY); assert(idx == 3); } +#ifndef TEST_HAS_NO_EXCEPTIONS catch (const std::out_of_range&) { assert(false); } +#endif idx = 0; +#ifndef TEST_HAS_NO_EXCEPTIONS try +#endif { assert(std::stod(L"INF", &idx) == INFINITY); assert(idx == 3); } +#ifndef TEST_HAS_NO_EXCEPTIONS catch (const std::out_of_range&) { assert(false); } +#endif idx = 0; +#ifndef TEST_HAS_NO_EXCEPTIONS try +#endif { assert(std::isnan(std::stod("NAN", &idx))); assert(idx == 3); } +#ifndef TEST_HAS_NO_EXCEPTIONS catch (const std::out_of_range&) { assert(false); } +#endif idx = 0; +#ifndef TEST_HAS_NO_EXCEPTIONS try +#endif { assert(std::isnan(std::stod(L"NAN", &idx))); assert(idx == 3); } +#ifndef TEST_HAS_NO_EXCEPTIONS catch (const std::out_of_range&) { assert(false); @@ -164,4 +184,5 @@ int main() { assert(idx == 0); } +#endif } diff --git a/libcxx/test/std/strings/string.conversions/stof.pass.cpp b/libcxx/test/std/strings/string.conversions/stof.pass.cpp index 38519a2feba0..1e17e1d3abdd 100644 --- a/libcxx/test/std/strings/string.conversions/stof.pass.cpp +++ b/libcxx/test/std/strings/string.conversions/stof.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 @@ -20,6 +19,8 @@ #include #include +#include "test_macros.h" + int main() { assert(std::stof("0") == 0); @@ -36,6 +37,7 @@ int main() idx = 0; assert(std::stof(L"10g", &idx) == 10); assert(idx == 2); +#ifndef TEST_HAS_NO_EXCEPTIONS idx = 0; try { @@ -75,40 +77,54 @@ int main() assert(idx == 0); } try +#endif { assert(std::stof("INF", &idx) == INFINITY); assert(idx == 3); } +#ifndef TEST_HAS_NO_EXCEPTIONS catch (const std::out_of_range&) { assert(false); } +#endif idx = 0; +#ifndef TEST_HAS_NO_EXCEPTIONS try +#endif { assert(std::stof(L"INF", &idx) == INFINITY); assert(idx == 3); } +#ifndef TEST_HAS_NO_EXCEPTIONS catch (const std::out_of_range&) { assert(false); } +#endif idx = 0; +#ifndef TEST_HAS_NO_EXCEPTIONS try +#endif { assert(std::isnan(std::stof("NAN", &idx))); assert(idx == 3); } +#ifndef TEST_HAS_NO_EXCEPTIONS catch (const std::out_of_range&) { assert(false); } +#endif idx = 0; +#ifndef TEST_HAS_NO_EXCEPTIONS try +#endif { assert(std::isnan(std::stof(L"NAN", &idx))); assert(idx == 3); } +#ifndef TEST_HAS_NO_EXCEPTIONS catch (const std::out_of_range&) { assert(false); @@ -168,4 +184,5 @@ int main() { assert(idx == 0); } +#endif } diff --git a/libcxx/test/std/strings/string.conversions/stoi.pass.cpp b/libcxx/test/std/strings/string.conversions/stoi.pass.cpp index 238072740703..8852d47f0011 100644 --- a/libcxx/test/std/strings/string.conversions/stoi.pass.cpp +++ b/libcxx/test/std/strings/string.conversions/stoi.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // int stoi(const string& str, size_t *idx = 0, int base = 10); @@ -16,6 +15,8 @@ #include #include +#include "test_macros.h" + int main() { assert(std::stoi("0") == 0); @@ -32,6 +33,7 @@ int main() idx = 0; assert(std::stoi(L"10g", &idx, 16) == 16); assert(idx == 2); +#ifndef TEST_HAS_NO_EXCEPTIONS if (std::numeric_limits::max() > std::numeric_limits::max()) { try @@ -106,4 +108,5 @@ int main() { assert(idx == 0); } +#endif } diff --git a/libcxx/test/std/strings/string.conversions/stol.pass.cpp b/libcxx/test/std/strings/string.conversions/stol.pass.cpp index 2ca2c01cfb8c..457cf0a76997 100644 --- a/libcxx/test/std/strings/string.conversions/stol.pass.cpp +++ b/libcxx/test/std/strings/string.conversions/stol.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 @@ -19,6 +18,8 @@ #include #include +#include "test_macros.h" + int main() { assert(std::stol("0") == 0); @@ -35,6 +36,7 @@ int main() idx = 0; assert(std::stol(L"10g", &idx, 16) == 16); assert(idx == 2); +#ifndef TEST_HAS_NO_EXCEPTIONS idx = 0; try { @@ -109,4 +111,5 @@ int main() { assert(idx == 0); } +#endif } diff --git a/libcxx/test/std/strings/string.conversions/stold.pass.cpp b/libcxx/test/std/strings/string.conversions/stold.pass.cpp index f489df2f124d..9d9dc3832ba6 100644 --- a/libcxx/test/std/strings/string.conversions/stold.pass.cpp +++ b/libcxx/test/std/strings/string.conversions/stold.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // // long double stold(const string& str, size_t *idx = 0); @@ -19,6 +18,8 @@ #include #include +#include "test_macros.h" + int main() { assert(std::stold("0") == 0); @@ -35,25 +36,32 @@ int main() idx = 0; assert(std::stold(L"10g", &idx) == 10); assert(idx == 2); +#ifndef TEST_HAS_NO_EXCEPTIONS try +#endif { assert(std::stold("1.e60", &idx) == 1.e60L); assert(idx == 5); } +#ifndef TEST_HAS_NO_EXCEPTIONS catch (const std::out_of_range&) { assert(false); } try +#endif { assert(std::stold(L"1.e60", &idx) == 1.e60L); assert(idx == 5); } +#ifndef TEST_HAS_NO_EXCEPTIONS catch (const std::out_of_range&) { assert(false); } +#endif idx = 0; +#ifndef TEST_HAS_NO_EXCEPTIONS try { assert(std::stold("1.e6000", &idx) == INFINITY); @@ -73,40 +81,54 @@ int main() assert(idx == 0); } try +#endif { assert(std::stold("INF", &idx) == INFINITY); assert(idx == 3); } +#ifndef TEST_HAS_NO_EXCEPTIONS catch (const std::out_of_range&) { assert(false); } +#endif idx = 0; +#ifndef TEST_HAS_NO_EXCEPTIONS try +#endif { assert(std::stold(L"INF", &idx) == INFINITY); assert(idx == 3); } +#ifndef TEST_HAS_NO_EXCEPTIONS catch (const std::out_of_range&) { assert(false); } +#endif idx = 0; +#ifndef TEST_HAS_NO_EXCEPTIONS try +#endif { assert(std::isnan(std::stold("NAN", &idx))); assert(idx == 3); } +#ifndef TEST_HAS_NO_EXCEPTIONS catch (const std::out_of_range&) { assert(false); } +#endif idx = 0; +#ifndef TEST_HAS_NO_EXCEPTIONS try +#endif { assert(std::isnan(std::stold(L"NAN", &idx))); assert(idx == 3); } +#ifndef TEST_HAS_NO_EXCEPTIONS catch (const std::out_of_range&) { assert(false); @@ -166,4 +188,5 @@ int main() { assert(idx == 0); } +#endif } diff --git a/libcxx/test/std/strings/string.conversions/stoll.pass.cpp b/libcxx/test/std/strings/string.conversions/stoll.pass.cpp index d41db4284acd..ca8412aeb758 100644 --- a/libcxx/test/std/strings/string.conversions/stoll.pass.cpp +++ b/libcxx/test/std/strings/string.conversions/stoll.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 @@ -19,6 +18,8 @@ #include #include +#include "test_macros.h" + int main() { assert(std::stoll("0") == 0); @@ -35,6 +36,7 @@ int main() idx = 0; assert(std::stoll(L"10g", &idx, 16) == 16); assert(idx == 2); +#ifndef TEST_HAS_NO_EXCEPTIONS idx = 0; try { @@ -108,4 +110,5 @@ int main() { assert(idx == 0); } +#endif } diff --git a/libcxx/test/std/strings/string.conversions/stoul.pass.cpp b/libcxx/test/std/strings/string.conversions/stoul.pass.cpp index 9dbd952434a9..1acdf116458f 100644 --- a/libcxx/test/std/strings/string.conversions/stoul.pass.cpp +++ b/libcxx/test/std/strings/string.conversions/stoul.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 @@ -19,6 +18,8 @@ #include #include +#include "test_macros.h" + int main() { assert(std::stoul("0") == 0); @@ -33,6 +34,7 @@ int main() idx = 0; assert(std::stoul(L"10g", &idx, 16) == 16); assert(idx == 2); +#ifndef TEST_HAS_NO_EXCEPTIONS idx = 0; try { @@ -107,4 +109,5 @@ int main() { assert(idx == 0); } +#endif } diff --git a/libcxx/test/std/strings/string.conversions/stoull.pass.cpp b/libcxx/test/std/strings/string.conversions/stoull.pass.cpp index 837ca3120100..e63679eed2f4 100644 --- a/libcxx/test/std/strings/string.conversions/stoull.pass.cpp +++ b/libcxx/test/std/strings/string.conversions/stoull.pass.cpp @@ -7,7 +7,6 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: libcpp-no-exceptions // XFAIL: with_system_cxx_lib=x86_64-apple-darwin11 // XFAIL: with_system_cxx_lib=x86_64-apple-darwin12 @@ -19,6 +18,8 @@ #include #include +#include "test_macros.h" + int main() { assert(std::stoull("0") == 0); @@ -33,6 +34,7 @@ int main() idx = 0; assert(std::stoull(L"10g", &idx, 16) == 16); assert(idx == 2); +#ifndef TEST_HAS_NO_EXCEPTIONS idx = 0; try { @@ -108,4 +110,5 @@ int main() { assert(idx == 0); } +#endif }