| commit | 1afbabab32278fac416a8d3115dbad9d573bf142 | [log] [tgz] |
|---|---|---|
| author | Howard Hinnant <hhinnant@apple.com> | Mon Jan 14 18:59:43 2013 +0000 |
| committer | Howard Hinnant <hhinnant@apple.com> | Mon Jan 14 18:59:43 2013 +0000 |
| tree | e0c7ed81f51839358b4e73cecc36203185f069fa | |
| parent | 269894ca23dd29e3cca3985cc72ca5481cc8b804 [diff] |
Fix string conversions functions to throw out_of_range properly. Fixes http://llvm.org/bugs/show_bug.cgi?id=14919. llvm-svn: 172447
diff --git a/libcxx/test/strings/string.conversions/stof.pass.cpp b/libcxx/test/strings/string.conversions/stof.pass.cpp index 749d867..444a695 100644 --- a/libcxx/test/strings/string.conversions/stof.pass.cpp +++ b/libcxx/test/strings/string.conversions/stof.pass.cpp
@@ -32,23 +32,24 @@ 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 217f00d..3887b7d 100644 --- a/libcxx/test/strings/string.conversions/stoll.pass.cpp +++ b/libcxx/test/strings/string.conversions/stoll.pass.cpp
@@ -86,4 +86,13 @@ { assert(idx == 0); } + try + { + std::stoll("99999999999999999999999999", &idx); + assert(false); + } + catch (const std::out_of_range&) + { + assert(idx == 0); + } }