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 // double stod(const string& str, size_t *idx = 0);
13 // double stod(const wstring& str, size_t *idx = 0);
21 assert(std::stod("0") == 0);
22 assert(std::stod(L
"0") == 0);
23 assert(std::stod("-0") == 0);
24 assert(std::stod(L
"-0") == 0);
25 assert(std::stod("-10") == -10);
26 assert(std::stod(L
"-10.5") == -10.5);
27 assert(std::stod(" 10") == 10);
28 assert(std::stod(L
" 10") == 10);
30 assert(std::stod("10g", &idx
) == 10);
33 assert(std::stod(L
"10g", &idx
) == 10);
37 assert(std::stod("1.e60", &idx
) == 1.e60
);
40 catch (const std::out_of_range
&)
46 assert(std::stod(L
"1.e60", &idx
) == 1.e60
);
49 catch (const std::out_of_range
&)
56 assert(std::stod("1.e360", &idx
) == INFINITY
);
59 catch (const std::out_of_range
&)
65 assert(std::stod(L
"1.e360", &idx
) == INFINITY
);
68 catch (const std::out_of_range
&)
74 assert(std::stod("INF", &idx
) == INFINITY
);
77 catch (const std::out_of_range
&)
84 assert(std::stod(L
"INF", &idx
) == INFINITY
);
87 catch (const std::out_of_range
&)
94 assert(std::isnan(std::stod("NAN", &idx
)));
97 catch (const std::out_of_range
&)
104 assert(std::isnan(std::stod(L
"NAN", &idx
)));
107 catch (const std::out_of_range
&)
117 catch (const std::invalid_argument
&)
123 std::stod(L
"", &idx
);
126 catch (const std::invalid_argument
&)
132 std::stod(" - 8", &idx
);
135 catch (const std::invalid_argument
&)
141 std::stod(L
" - 8", &idx
);
144 catch (const std::invalid_argument
&)
150 std::stod("a1", &idx
);
153 catch (const std::invalid_argument
&)
159 std::stod(L
"a1", &idx
);
162 catch (const std::invalid_argument
&)