summaryrefslogtreecommitdiffstats
path: root/libcxx/test
diff options
context:
space:
mode:
authorMarshall Clow <mclow.lists@gmail.com>2013-08-13 15:52:51 +0000
committerMarshall Clow <mclow.lists@gmail.com>2013-08-13 15:52:51 +0000
commit914993df0b9927057c0981c83dd679e7307d6b27 (patch)
tree68bc0bc7c7a7da2c13d1595d0465dfea91f16724 /libcxx/test
parentc14b59d1a1518caaeac83802c286558a4d1e12a3 (diff)
downloadbcm5719-llvm-914993df0b9927057c0981c83dd679e7307d6b27.tar.gz
bcm5719-llvm-914993df0b9927057c0981c83dd679e7307d6b27.zip
Added more tests for numeric conversion error handing; Refs LWG issue 2009
llvm-svn: 188282
Diffstat (limited to 'libcxx/test')
-rw-r--r--libcxx/test/strings/string.conversions/stol.pass.cpp19
-rw-r--r--libcxx/test/strings/string.conversions/stoll.pass.cpp9
-rw-r--r--libcxx/test/strings/string.conversions/stoul.pass.cpp19
-rw-r--r--libcxx/test/strings/string.conversions/stoull.pass.cpp19
4 files changed, 66 insertions, 0 deletions
diff --git a/libcxx/test/strings/string.conversions/stol.pass.cpp b/libcxx/test/strings/string.conversions/stol.pass.cpp
index 521c8592f24..bcc5c72fd27 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 a4ba6a3bcbc..11f15e1fd0f 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 8cf37ebf9f7..41d11010783 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 ba1e538deeb..760c087234c 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);
+ }
}
OpenPOWER on IntegriCloud