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 //===----------------------------------------------------------------------===//
10 // XFAIL: with_system_lib=x86_64-apple-darwin11
11 // XFAIL: with_system_lib=x86_64-apple-darwin12
15 // float stof(const string& str, size_t *idx = 0);
16 // float stof(const wstring& str, size_t *idx = 0);
24 assert(std::stof("0") == 0);
25 assert(std::stof(L
"0") == 0);
26 assert(std::stof("-0") == 0);
27 assert(std::stof(L
"-0") == 0);
28 assert(std::stof("-10") == -10);
29 assert(std::stof(L
"-10.5") == -10.5);
30 assert(std::stof(" 10") == 10);
31 assert(std::stof(L
" 10") == 10);
33 assert(std::stof("10g", &idx
) == 10);
36 assert(std::stof(L
"10g", &idx
) == 10);
41 assert(std::stof("1.e60", &idx
) == INFINITY
);
44 catch (const std::out_of_range
&)
50 assert(std::stof(L
"1.e60", &idx
) == INFINITY
);
53 catch (const std::out_of_range
&)
60 assert(std::stof("1.e360", &idx
) == INFINITY
);
63 catch (const std::out_of_range
&)
69 assert(std::stof(L
"1.e360", &idx
) == INFINITY
);
72 catch (const std::out_of_range
&)
78 assert(std::stof("INF", &idx
) == INFINITY
);
81 catch (const std::out_of_range
&)
88 assert(std::stof(L
"INF", &idx
) == INFINITY
);
91 catch (const std::out_of_range
&)
98 assert(std::isnan(std::stof("NAN", &idx
)));
101 catch (const std::out_of_range
&)
108 assert(std::isnan(std::stof(L
"NAN", &idx
)));
111 catch (const std::out_of_range
&)
121 catch (const std::invalid_argument
&)
127 std::stof(L
"", &idx
);
130 catch (const std::invalid_argument
&)
136 std::stof(" - 8", &idx
);
139 catch (const std::invalid_argument
&)
145 std::stof(L
" - 8", &idx
);
148 catch (const std::invalid_argument
&)
154 std::stof("a1", &idx
);
157 catch (const std::invalid_argument
&)
163 std::stof(L
"a1", &idx
);
166 catch (const std::invalid_argument
&)