Update tests for strings conversions under libcpp-no-exceptions
Differential Revision: https://reviews.llvm.org/D26139 git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@286812 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user