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

llvm-svn: 188282
This commit is contained in:
Marshall Clow 2013-08-13 15:52:51 +00:00
parent c14b59d1a1
commit 914993df0b
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);
}
}