From 914993df0b9927057c0981c83dd679e7307d6b27 Mon Sep 17 00:00:00 2001 From: Marshall Clow Date: Tue, 13 Aug 2013 15:52:51 +0000 Subject: [PATCH] Added more tests for numeric conversion error handing; Refs LWG issue 2009 llvm-svn: 188282 --- .../strings/string.conversions/stol.pass.cpp | 19 +++++++++++++++++++ .../strings/string.conversions/stoll.pass.cpp | 9 +++++++++ .../strings/string.conversions/stoul.pass.cpp | 19 +++++++++++++++++++ .../string.conversions/stoull.pass.cpp | 19 +++++++++++++++++++ 4 files changed, 66 insertions(+) diff --git a/libcxx/test/strings/string.conversions/stol.pass.cpp b/libcxx/test/strings/string.conversions/stol.pass.cpp index 521c8592f245..bcc5c72fd27f 100644 --- a/libcxx/test/strings/string.conversions/stol.pass.cpp +++ b/libcxx/test/strings/string.conversions/stol.pass.cpp @@ -86,4 +86,23 @@ int main() { assert(idx == 0); } +// LWG issue #2009 + try + { + std::stol("9999999999999999999999999999999999999999999999999", &idx); + assert(false); + } + catch (const std::out_of_range&) + { + assert(idx == 0); + } + try + { + std::stol(L"9999999999999999999999999999999999999999999999999", &idx); + assert(false); + } + catch (const std::out_of_range&) + { + assert(idx == 0); + } } diff --git a/libcxx/test/strings/string.conversions/stoll.pass.cpp b/libcxx/test/strings/string.conversions/stoll.pass.cpp index a4ba6a3bcbce..11f15e1fd0f2 100644 --- a/libcxx/test/strings/string.conversions/stoll.pass.cpp +++ b/libcxx/test/strings/string.conversions/stoll.pass.cpp @@ -98,4 +98,13 @@ int main() { assert(idx == 0); } + try + { + std::stoll(L"99999999999999999999999999", &idx); + assert(false); + } + catch (const std::out_of_range&) + { + assert(idx == 0); + } } diff --git a/libcxx/test/strings/string.conversions/stoul.pass.cpp b/libcxx/test/strings/string.conversions/stoul.pass.cpp index 8cf37ebf9f79..41d11010783a 100644 --- a/libcxx/test/strings/string.conversions/stoul.pass.cpp +++ b/libcxx/test/strings/string.conversions/stoul.pass.cpp @@ -84,4 +84,23 @@ int main() { assert(idx == 0); } +// LWG issue #2009 + try + { + std::stoul("9999999999999999999999999999999999999999999999999", &idx); + assert(false); + } + catch (const std::out_of_range&) + { + assert(idx == 0); + } + try + { + std::stoul(L"9999999999999999999999999999999999999999999999999", &idx); + assert(false); + } + catch (const std::out_of_range&) + { + assert(idx == 0); + } } diff --git a/libcxx/test/strings/string.conversions/stoull.pass.cpp b/libcxx/test/strings/string.conversions/stoull.pass.cpp index ba1e538deeb8..760c087234cc 100644 --- a/libcxx/test/strings/string.conversions/stoull.pass.cpp +++ b/libcxx/test/strings/string.conversions/stoull.pass.cpp @@ -85,4 +85,23 @@ int main() { assert(idx == 0); } +// LWG issue #2009 + try + { + std::stoull("9999999999999999999999999999999999999999999999999", &idx); + assert(false); + } + catch (const std::out_of_range&) + { + assert(idx == 0); + } + try + { + std::stoull(L"9999999999999999999999999999999999999999999999999", &idx); + assert(false); + } + catch (const std::out_of_range&) + { + assert(idx == 0); + } }