1 //===----------------------------------------------------------------------===//
3 // The LLVM Compiler Infrastructure
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
12 // long double stold(const string& str, size_t *idx = 0);
13 // long double stold(const wstring& str, size_t *idx = 0);
23 assert(std::stold("0") == 0);
24 assert(std::stold(L
"0") == 0);
25 assert(std::stold("-0") == 0);
26 assert(std::stold(L
"-0") == 0);
27 assert(std::stold("-10") == -10);
28 assert(std::stold(L
"-10.5") == -10.5);
29 assert(std::stold(" 10") == 10);
30 assert(std::stold(L
" 10") == 10);
32 assert(std::stold("10g", &idx
) == 10);
35 assert(std::stold(L
"10g", &idx
) == 10);
39 assert(std::stold("1.e60", &idx
) == 1.e60L
);
42 catch (const std::out_of_range
&)
48 assert(std::stold(L
"1.e60", &idx
) == 1.e60L
);
51 catch (const std::out_of_range
&)
58 assert(std::stold("1.e6000", &idx
) == INFINITY
);
61 catch (const std::out_of_range
&)
67 assert(std::stold(L
"1.e6000", &idx
) == INFINITY
);
70 catch (const std::out_of_range
&)
76 assert(std::stold("INF", &idx
) == INFINITY
);
79 catch (const std::out_of_range
&)
86 assert(std::stold(L
"INF", &idx
) == INFINITY
);
89 catch (const std::out_of_range
&)
96 assert(std::isnan(std::stold("NAN", &idx
)));
99 catch (const std::out_of_range
&)
106 assert(std::isnan(std::stold(L
"NAN", &idx
)));
109 catch (const std::out_of_range
&)
116 std::stold("", &idx
);
119 catch (const std::invalid_argument
&)
125 std::stold(L
"", &idx
);
128 catch (const std::invalid_argument
&)
134 std::stold(" - 8", &idx
);
137 catch (const std::invalid_argument
&)
143 std::stold(L
" - 8", &idx
);
146 catch (const std::invalid_argument
&)
152 std::stold("a1", &idx
);
155 catch (const std::invalid_argument
&)
161 std::stold(L
"a1", &idx
);
164 catch (const std::invalid_argument
&)