Commit 70a50946 authored by ibanez's avatar ibanez
Browse files

ENH: Moving TestingMacros.h to the top directoy in order to make it available...

ENH: Moving TestingMacros.h to the top directoy in order to make it available to other Testing subdirectories.
     Also adding a TEST_SET_GET_STRING() macro to perform extensive testing in Set/Get String methods.


git-svn-id: http://svn.slicer.org/Slicer4/trunk@11383 3bd1e089-480b-0410-8dfb-8563597acbee
parent 39d66853
......@@ -379,7 +379,10 @@ ENDIF(Slicer3_USE_QT)
# --------------------------------------------------------------------------
# Configure and install headers
include_directories("${CMAKE_CURRENT_BINARY_DIR}")
include_directories(
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}"
)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/vtkSlicerConfigure.h.in
......
......@@ -16,6 +16,17 @@
#include "vtkDebugLeaks.h"
#include "vtkSmartPointer.h"
#define EXERCISE_BASIC_OBJECT_METHODS( object ) \
{ \
if ( object == NULL ) \
{ \
std::cerr << "EXERCISE_BASIC_OBJECT_METHODS( with NULL object )" << std::endl; \
return EXIT_FAILURE; \
} \
object->Print( std::cout ); \
std::cout << "Name of Class = " << object->GetClassName() << std::endl; \
std::cout << "Name of Superclass = " << object->Superclass::GetClassName() << std::endl; \
}
#define TRY_EXPECT_ITK_EXCEPTION( command ) \
try \
......@@ -64,10 +75,64 @@
return EXIT_FAILURE; \
}
#define CHECK_FOR_VTK_MEMORY_LEAKS() \
if( vtkDebugLeaks::PrintCurrentLeaks() > 3 ) \
{ \
result = EXIT_FAILURE; \
#define TEST_SET_GET_BOOLEAN( object, variable ) \
object->Set##variable( false ); \
object->Set##variable( true ); \
if( object->Get##variable() != true ) \
{ \
std::cerr << "Error in Set/Get"#variable << std::endl; \
return EXIT_FAILURE; \
} \
object->Set##variable( false ); \
if( object->Get##variable() != false ) \
{ \
std::cerr << "Error in Set/Get"#variable << std::endl; \
return EXIT_FAILURE; \
} \
object->variable##On(); \
if( object->Get##variable() != true ) \
{ \
std::cerr << "Error in On/Get"#variable << std::endl; \
return EXIT_FAILURE; \
} \
object->variable##Off(); \
if( object->Get##variable() != false ) \
{ \
std::cerr << "Error in Off/Get"#variable << std::endl; \
return EXIT_FAILURE; \
}
#define TEST_SET_GET_STRING( object, variable ) \
{ \
const char * originalStringPointer = object->Get##variable(); \
std::string originalString; \
if( originalStringPointer != NULL ) \
{ \
originalString = originalStringPointer; \
} \
std::string string1 = "testingIsGood"; \
object->Set##variable( string1.c_str() ); \
if( object->Get##variable() != string1 ) \
{ \
std::cerr << "Error in Set/Get"#variable << std::endl; \
return EXIT_FAILURE; \
} \
std::string string2 = "moreTestingIsBetter"; \
object->Set##variable( string2.c_str() ); \
if( object->Get##variable() != string2 ) \
{ \
std::cerr << "Error in Set/Get"#variable << std::endl; \
return EXIT_FAILURE; \
} \
if( originalStringPointer != NULL ) \
{ \
object->SetDescription( originalString.c_str() ); \
} \
else \
{ \
object->SetDescription( NULL ); \
} \
}
#endif
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment