Added more tests for numeric conversion error handing; Refs LWG issue 2009

git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@188282 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Marshall Clow 2013-08-13 15:52:51 +00:00
parent 6b229e1ad1
commit 8634fc5494
4 changed files with 66 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}

View File

@ -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);
}
}