#include "mitkCompressedImageContainer.h"
#include "mitkCoreObjectFactory.h"
#include "mitkDataNodeFactory.h"
#include "mitkImageDataItem.h"
#include "itkSmartPointerForwardReference.txx"
Go to the source code of this file.
Classes | |
class | mitkCompressedImageContainerTestClass |
Functions | |
int | mitkCompressedImageContainerTest (int argc, char *argv[]) |
ctest entry point |
int mitkCompressedImageContainerTest | ( | int | argc, |
char * | argv[] | ||
) |
ctest entry point
Definition at line 114 of file mitkCompressedImageContainerTest.cpp.
References EXIT_FAILURE, EXIT_SUCCESS, mitk::CompressedImageContainer::New(), mitk::DataNodeFactory::New(), and mitkCompressedImageContainerTestClass::Test().
{ // one big variable to tell if anything went wrong unsigned int numberFailed(0); // need one parameter (image filename) if(argc==0) { std::cerr<<"No file specified [FAILED]"<<std::endl; return EXIT_FAILURE; } // load the image mitk::Image::Pointer image = NULL; mitk::DataNodeFactory::Pointer factory = mitk::DataNodeFactory::New(); try { std::cout << "Testing with parameter '" << argv[1] << "'" << std::endl; factory->SetFileName( argv[1] ); factory->Update(); if(factory->GetNumberOfOutputs()<1) { std::cerr<<"File could not be loaded [FAILED]"<<std::endl; return EXIT_FAILURE; } mitk::DataNode::Pointer node = factory->GetOutput( 0 ); image = dynamic_cast<mitk::Image*>(node->GetData()); if(image.IsNull()) { std::cout<<"File not an image - test will not be applied [PASSED]"<<std::endl; std::cout<<"[TEST DONE]"<<std::endl; return EXIT_SUCCESS; } } catch ( itk::ExceptionObject & ex ) { ++numberFailed; std::cerr << "Exception: " << ex << "[FAILED]" << std::endl; return EXIT_FAILURE; } std::cout << " (II) Could load image." << std::endl; std::cout << "Testing instantiation" << std::endl; // instantiation mitk::CompressedImageContainer::Pointer container = mitk::CompressedImageContainer::New(); if (container.IsNotNull()) { std::cout << " (II) Instantiation works." << std::endl; } else { ++numberFailed; std::cout << "Test failed, and it's the ugliest one!" << std::endl; return EXIT_FAILURE; } // some real work mitkCompressedImageContainerTestClass::Test( container, image, numberFailed ); std::cout << "Testing destruction" << std::endl; // freeing container = NULL; std::cout << " (II) Freeing works." << std::endl; if (numberFailed > 0) { std::cerr << numberFailed << " tests failed." << std::endl; return EXIT_FAILURE; } else { std::cout << "PASSED all tests." << std::endl; return EXIT_SUCCESS; } }