Uncaught exception fix

This commit is contained in:
Markus Gans 2017-09-20 06:50:29 +02:00
parent f5a5ba3528
commit c97511a6cc
1 changed files with 45 additions and 48 deletions

View File

@ -88,52 +88,19 @@ int main (int, char**)
std::cout << " stream in: " << streamer9 << std::endl; std::cout << " stream in: " << streamer9 << std::endl;
// ...from long double // ...from long double
try FString streamer10;
{ streamer10 << lDouble(0.333333333333333333L);
FString streamer10; std::cout << " stream in: " << streamer10 << std::endl;
streamer10 << lDouble(0.333333333333333333L);
std::cout << " stream in: " << streamer10 << std::endl;
}
catch (const std::invalid_argument& ex)
{
std::cerr << "Invalid argument: " << ex.what() << std::endl;
}
catch (const std::exception& ex)
{
std::cerr << "Arithmetic error: " << ex.what() << std::endl;
}
// ...from double // ...from double
try FString streamer11;
{ streamer11 << double(0.11111111111);
FString streamer11; std::cout << " stream in: " << streamer11 << std::endl;
streamer11 << double(0.11111111111);
std::cout << " stream in: " << streamer11 << std::endl;
}
catch (const std::invalid_argument& ex)
{
std::cerr << "Invalid argument: " << ex.what() << std::endl;
}
catch (const std::exception& ex)
{
std::cerr << "Arithmetic error: " << ex.what() << std::endl;
}
// ...from float // ...from float
try FString streamer12;
{ streamer12 << float(0.22222222);
FString streamer12; std::cout << " stream in: " << streamer12 << std::endl;
streamer12 << float(0.22222222);
std::cout << " stream in: " << streamer12 << std::endl;
}
catch (const std::invalid_argument& ex)
{
std::cerr << "Invalid argument: " << ex.what() << std::endl;
}
catch (const std::exception& ex)
{
std::cerr << "Arithmetic error: " << ex.what() << std::endl;
}
// Test: Streaming from a FString (operator >>)... // Test: Streaming from a FString (operator >>)...
@ -158,14 +125,44 @@ int main (int, char**)
std::cout << "stream out: " << stream_char << std::endl; std::cout << "stream out: " << stream_char << std::endl;
// ...to interger // ...to interger
int stream_int; try
FString("-321") >> stream_int; {
std::cout << "stream out: " << stream_int << std::endl; int stream_int;
FString("-321") >> stream_int;
std::cout << "stream out: " << stream_int << std::endl;
}
catch (const std::invalid_argument& ex)
{
std::cerr << "Invalid argument: " << ex.what() << std::endl;
}
catch (const std::overflow_error& ex)
{
std::cerr << "overflow: " << ex.what() << std::endl;
}
catch (const std::exception& ex)
{
std::cerr << "Arithmetic error: " << ex.what() << std::endl;
}
// ...to unsigned interger // ...to unsigned interger
uInt stream_uint; try
FString("123") >> stream_uint; {
std::cout << "stream out: " << stream_uint << std::endl; uInt stream_uint;
FString("123") >> stream_uint;
std::cout << "stream out: " << stream_uint << std::endl;
}
catch (const std::invalid_argument& ex)
{
std::cerr << "Invalid argument: " << ex.what() << std::endl;
}
catch (const std::overflow_error& ex)
{
std::cerr << "overflow: " << ex.what() << std::endl;
}
catch (const std::exception& ex)
{
std::cerr << "Arithmetic error: " << ex.what() << std::endl;
}
// ...to double // ...to double
try try