Skip to content
Snippets Groups Projects
Commit 494b0625 authored by Patrick Imbo's avatar Patrick Imbo
Browse files

ENH: Testing if exception rised

parent c7cd5cc2
No related branches found
No related tags found
No related merge requests found
...@@ -29,6 +29,10 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[]) ...@@ -29,6 +29,10 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[])
ObjectType::Pointer obj = ObjectType::New(); ObjectType::Pointer obj = ObjectType::New();
bool hasRisedException;
hasRisedException = false;
try try
{ {
std::cout << obj->GetPhysicalBias() << std::endl; std::cout << obj->GetPhysicalBias() << std::endl;
...@@ -37,8 +41,18 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[]) ...@@ -37,8 +41,18 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[])
{ {
std::cout << "ExceptionObject caught for GetPhysicalBias() !" << std::endl; std::cout << "ExceptionObject caught for GetPhysicalBias() !" << std::endl;
std::cout << err << std::endl; std::cout << err << std::endl;
hasRisedException =true;
}
if(!hasRisedException)
{
std::cerr << " Should has raise an exception !"<< std::endl;
return EXIT_FAILURE;
} }
hasRisedException = false;
try try
{ {
std::cout << obj->GetPhysicalGain() << std::endl; std::cout << obj->GetPhysicalGain() << std::endl;
...@@ -47,8 +61,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[]) ...@@ -47,8 +61,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[])
{ {
std::cout << "ExceptionObject caught for GetPhysicalGain() !" << std::endl; std::cout << "ExceptionObject caught for GetPhysicalGain() !" << std::endl;
std::cout << err << std::endl; std::cout << err << std::endl;
hasRisedException =true;
}
if(!hasRisedException)
{
std::cerr << " Should has raise an exception !"<< std::endl;
return EXIT_FAILURE;
} }
hasRisedException = false;
try try
{ {
std::cout << obj->GetSolarIrradiance() << std::endl; std::cout << obj->GetSolarIrradiance() << std::endl;
...@@ -57,8 +80,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[]) ...@@ -57,8 +80,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[])
{ {
std::cout << "ExceptionObject caught for GetSolarIrradiance() !" << std::endl; std::cout << "ExceptionObject caught for GetSolarIrradiance() !" << std::endl;
std::cout << err << std::endl; std::cout << err << std::endl;
hasRisedException =true;
}
if(!hasRisedException)
{
std::cerr << " Should has raise an exception !"<< std::endl;
return EXIT_FAILURE;
} }
hasRisedException = false;
try try
{ {
std::cout << obj->GetDay() << std::endl; std::cout << obj->GetDay() << std::endl;
...@@ -67,8 +99,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[]) ...@@ -67,8 +99,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[])
{ {
std::cout << "ExceptionObject caught for GetDay() !" << std::endl; std::cout << "ExceptionObject caught for GetDay() !" << std::endl;
std::cout << err << std::endl; std::cout << err << std::endl;
hasRisedException =true;
}
if(!hasRisedException)
{
std::cerr << " Should has raise an exception !"<< std::endl;
return EXIT_FAILURE;
} }
hasRisedException = false;
try try
{ {
std::cout << obj->GetMonth() << std::endl; std::cout << obj->GetMonth() << std::endl;
...@@ -77,8 +118,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[]) ...@@ -77,8 +118,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[])
{ {
std::cout << "ExceptionObject caught for GetMonth() !" << std::endl; std::cout << "ExceptionObject caught for GetMonth() !" << std::endl;
std::cout << err << std::endl; std::cout << err << std::endl;
hasRisedException =true;
} }
if(!hasRisedException)
{
std::cerr << " Should has raise an exception !"<< std::endl;
return EXIT_FAILURE;
}
hasRisedException = false;
try try
{ {
std::cout << obj->GetYear() << std::endl; std::cout << obj->GetYear() << std::endl;
...@@ -87,8 +137,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[]) ...@@ -87,8 +137,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[])
{ {
std::cout << "ExceptionObject caught for GetYear() !" << std::endl; std::cout << "ExceptionObject caught for GetYear() !" << std::endl;
std::cout << err << std::endl; std::cout << err << std::endl;
hasRisedException =true;
} }
if(!hasRisedException)
{
std::cerr << " Should has raise an exception !"<< std::endl;
return EXIT_FAILURE;
}
hasRisedException = false;
try try
{ {
std::cout << obj->GetHour() << std::endl; std::cout << obj->GetHour() << std::endl;
...@@ -97,8 +156,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[]) ...@@ -97,8 +156,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[])
{ {
std::cout << "ExceptionObject caught for GetHour() !" << std::endl; std::cout << "ExceptionObject caught for GetHour() !" << std::endl;
std::cout << err << std::endl; std::cout << err << std::endl;
hasRisedException =true;
} }
if(!hasRisedException)
{
std::cerr << " Should has raise an exception !"<< std::endl;
return EXIT_FAILURE;
}
hasRisedException = false;
try try
{ {
std::cout << obj->GetMinute() << std::endl; std::cout << obj->GetMinute() << std::endl;
...@@ -107,8 +175,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[]) ...@@ -107,8 +175,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[])
{ {
std::cout << "ExceptionObject caught for GetMinute() !" << std::endl; std::cout << "ExceptionObject caught for GetMinute() !" << std::endl;
std::cout << err << std::endl; std::cout << err << std::endl;
hasRisedException =true;
} }
if(!hasRisedException)
{
std::cerr << " Should has raise an exception !"<< std::endl;
return EXIT_FAILURE;
}
hasRisedException = false;
try try
{ {
std::cout << obj->GetProductionDay() << std::endl; std::cout << obj->GetProductionDay() << std::endl;
...@@ -117,8 +194,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[]) ...@@ -117,8 +194,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[])
{ {
std::cout << "ExceptionObject caught for GetProductionDay() !" << std::endl; std::cout << "ExceptionObject caught for GetProductionDay() !" << std::endl;
std::cout << err << std::endl; std::cout << err << std::endl;
hasRisedException =true;
} }
if(!hasRisedException)
{
std::cerr << " Should has raise an exception !"<< std::endl;
return EXIT_FAILURE;
}
hasRisedException = false;
try try
{ {
std::cout << obj->GetProductionMonth() << std::endl; std::cout << obj->GetProductionMonth() << std::endl;
...@@ -127,8 +213,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[]) ...@@ -127,8 +213,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[])
{ {
std::cout << "ExceptionObject caught for GetProductionMonth() !" << std::endl; std::cout << "ExceptionObject caught for GetProductionMonth() !" << std::endl;
std::cout << err << std::endl; std::cout << err << std::endl;
hasRisedException =true;
} }
if(!hasRisedException)
{
std::cerr << " Should has raise an exception !"<< std::endl;
return EXIT_FAILURE;
}
hasRisedException = false;
try try
{ {
std::cout << obj->GetProductionYear() << std::endl; std::cout << obj->GetProductionYear() << std::endl;
...@@ -137,8 +232,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[]) ...@@ -137,8 +232,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[])
{ {
std::cout << "ExceptionObject caught for GetProductionYear() !" << std::endl; std::cout << "ExceptionObject caught for GetProductionYear() !" << std::endl;
std::cout << err << std::endl; std::cout << err << std::endl;
hasRisedException =true;
}
if(!hasRisedException)
{
std::cerr << " Should has raise an exception !"<< std::endl;
return EXIT_FAILURE;
} }
hasRisedException = false;
try try
{ {
std::cout << obj->GetSatElevation() << std::endl; std::cout << obj->GetSatElevation() << std::endl;
...@@ -147,8 +251,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[]) ...@@ -147,8 +251,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[])
{ {
std::cout << "ExceptionObject caught for GetSatElevation() !" << std::endl; std::cout << "ExceptionObject caught for GetSatElevation() !" << std::endl;
std::cout << err << std::endl; std::cout << err << std::endl;
hasRisedException =true;
}
if(!hasRisedException)
{
std::cerr << " Should has raise an exception !"<< std::endl;
return EXIT_FAILURE;
} }
hasRisedException = false;
try try
{ {
std::cout << obj->GetSatAzimuth() << std::endl; std::cout << obj->GetSatAzimuth() << std::endl;
...@@ -157,8 +270,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[]) ...@@ -157,8 +270,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[])
{ {
std::cout << "ExceptionObject caught for GetSatAzimuth() !" << std::endl; std::cout << "ExceptionObject caught for GetSatAzimuth() !" << std::endl;
std::cout << err << std::endl; std::cout << err << std::endl;
hasRisedException =true;
}
if(!hasRisedException)
{
std::cerr << " Should has raise an exception !"<< std::endl;
return EXIT_FAILURE;
} }
hasRisedException = false;
try try
{ {
std::cout << obj->GetFirstWavelengths() << std::endl; std::cout << obj->GetFirstWavelengths() << std::endl;
...@@ -167,8 +289,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[]) ...@@ -167,8 +289,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[])
{ {
std::cout << "ExceptionObject caught for GetFirstWavelengths() !" << std::endl; std::cout << "ExceptionObject caught for GetFirstWavelengths() !" << std::endl;
std::cout << err << std::endl; std::cout << err << std::endl;
hasRisedException =true;
} }
if(!hasRisedException)
{
std::cerr << " Should has raise an exception !"<< std::endl;
return EXIT_FAILURE;
}
hasRisedException = false;
try try
{ {
std::cout << obj->GetLastWavelengths() << std::endl; std::cout << obj->GetLastWavelengths() << std::endl;
...@@ -177,8 +308,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[]) ...@@ -177,8 +308,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[])
{ {
std::cout << "ExceptionObject caught for GetLastWavelengths() !" << std::endl; std::cout << "ExceptionObject caught for GetLastWavelengths() !" << std::endl;
std::cout << err << std::endl; std::cout << err << std::endl;
hasRisedException =true;
} }
if(!hasRisedException)
{
std::cerr << " Should has raise an exception !"<< std::endl;
return EXIT_FAILURE;
}
hasRisedException = false;
try try
{ {
if( obj->CanRead() != true) if( obj->CanRead() != true)
...@@ -191,8 +331,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[]) ...@@ -191,8 +331,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[])
{ {
std::cout << "ExceptionObject caught for CanRead() !" << std::endl; std::cout << "ExceptionObject caught for CanRead() !" << std::endl;
std::cout << err << std::endl; std::cout << err << std::endl;
hasRisedException =true;
} }
if(!hasRisedException)
{
std::cerr << " Should has raise an exception !"<< std::endl;
return EXIT_FAILURE;
}
hasRisedException = false;
try try
{ {
std::vector<unsigned int> rgb(3); std::vector<unsigned int> rgb(3);
...@@ -208,8 +357,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[]) ...@@ -208,8 +357,17 @@ int otbDefaultImageMetadataInterface(int argc, char* argv[])
{ {
std::cout << "ExceptionObject caught for GetDefaultDisplay() !" << std::endl; std::cout << "ExceptionObject caught for GetDefaultDisplay() !" << std::endl;
std::cout << err << std::endl; std::cout << err << std::endl;
hasRisedException =true;
} }
if(!hasRisedException)
{
std::cerr << " Should has raise an exception !"<< std::endl;
return EXIT_FAILURE;
}
hasRisedException = false;
return EXIT_SUCCESS; return EXIT_SUCCESS;
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment