Update tests for strings conversions under libcpp-no-exceptions

Differential Revision: https://reviews.llvm.org/D26139

llvm-svn: 286812
This commit is contained in:
Roger Ferrer Ibanez 2016-11-14 10:44:26 +00:00
parent 3d8482a88d
commit 84c152a130
8 changed files with 84 additions and 8 deletions

View File

@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//
// XFAIL: libcpp-no-exceptions
// <string>
// double stod(const string& str, size_t *idx = 0);
@ -17,6 +16,8 @@
#include <cmath>
#include <cassert>
#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
}

View File

@ -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 <cmath>
#include <cassert>
#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
}

View File

@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//
// XFAIL: libcpp-no-exceptions
// <string>
// int stoi(const string& str, size_t *idx = 0, int base = 10);
@ -16,6 +15,8 @@
#include <string>
#include <cassert>
#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<long>::max() > std::numeric_limits<int>::max())
{
try
@ -106,4 +108,5 @@ int main()
{
assert(idx == 0);
}
#endif
}

View File

@ -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 <string>
#include <cassert>
#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
}

View File

@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//
// XFAIL: libcpp-no-exceptions
// <string>
// long double stold(const string& str, size_t *idx = 0);
@ -19,6 +18,8 @@
#include <cmath>
#include <cassert>
#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
}

View File

@ -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 <string>
#include <cassert>
#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
}

View File

@ -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 <string>
#include <cassert>
#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
}

View File

@ -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 <string>
#include <cassert>
#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
}