diff options
author | Howard Hinnant <hhinnant@apple.com> | 2013-01-14 18:59:43 +0000 |
---|---|---|
committer | Howard Hinnant <hhinnant@apple.com> | 2013-01-14 18:59:43 +0000 |
commit | 1afbabab32278fac416a8d3115dbad9d573bf142 (patch) | |
tree | e0c7ed81f51839358b4e73cecc36203185f069fa /libcxx/test/strings/string.conversions | |
parent | 269894ca23dd29e3cca3985cc72ca5481cc8b804 (diff) | |
download | bcm5719-llvm-1afbabab32278fac416a8d3115dbad9d573bf142.tar.gz bcm5719-llvm-1afbabab32278fac416a8d3115dbad9d573bf142.zip |
Fix string conversions functions to throw out_of_range properly. Fixes http://llvm.org/bugs/show_bug.cgi?id=14919.
llvm-svn: 172447
Diffstat (limited to 'libcxx/test/strings/string.conversions')
-rw-r--r-- | libcxx/test/strings/string.conversions/stof.pass.cpp | 9 | ||||
-rw-r--r-- | libcxx/test/strings/string.conversions/stoll.pass.cpp | 9 |
2 files changed, 14 insertions, 4 deletions
diff --git a/libcxx/test/strings/string.conversions/stof.pass.cpp b/libcxx/test/strings/string.conversions/stof.pass.cpp index 749d8672e5c..444a69518c6 100644 --- a/libcxx/test/strings/string.conversions/stof.pass.cpp +++ b/libcxx/test/strings/string.conversions/stof.pass.cpp @@ -32,23 +32,24 @@ int main() idx = 0; assert(std::stof(L"10g", &idx) == 10); assert(idx == 2); + idx = 0; try { assert(std::stof("1.e60", &idx) == INFINITY); - assert(idx == 5); + assert(false); } catch (const std::out_of_range&) { - assert(false); + assert(idx == 0); } try { assert(std::stof(L"1.e60", &idx) == INFINITY); - assert(idx == 5); + assert(false); } catch (const std::out_of_range&) { - assert(false); + assert(idx == 0); } idx = 0; try diff --git a/libcxx/test/strings/string.conversions/stoll.pass.cpp b/libcxx/test/strings/string.conversions/stoll.pass.cpp index 217f00d0430..3887b7d2870 100644 --- a/libcxx/test/strings/string.conversions/stoll.pass.cpp +++ b/libcxx/test/strings/string.conversions/stoll.pass.cpp @@ -86,4 +86,13 @@ int main() { assert(idx == 0); } + try + { + std::stoll("99999999999999999999999999", &idx); + assert(false); + } + catch (const std::out_of_range&) + { + assert(idx == 0); + } } |