Skip to content
Snippets Groups Projects
Commit 62b7a4bd authored by Kasper Marstal's avatar Kasper Marstal
Browse files

ENH: ELASTIX-1 Add Test data manager

parent de80fcb9
No related branches found
No related tags found
No related merge requests found
#---------------------------------------------------------------------
# ---------------------------------------------------------------------
# To add a test to the build system, append it to the list below.
# Any GoogleTests in these files are automatically added to CTest and
# the Kibana dashboard.
# the elastix dashboard.
set( ElastixUnitTestFilenames
elxExampleUnitTest.cxx
itkRegistration.cxx
)
#---------------------------------------------------------------------
# ---------------------------------------------------------------------
# Set data directories
set( ELASTIX_UNITTEST_INPUT_DATA_DIR ${CMAKE_CURRENT_BINARY_DIR}/Data/Input )
set( ELASTIX_UNITTEST_OUTPUT_DATA_DIR ${CMAKE_CURRENT_BINARY_DIR}/Data/Output )
set( ELASTIX_UNITTEST_BASELINE_DATA_DIR ${CMAKE_CURRENT_BINARY_DIR}/Data/Baseline )
if( NOT EXISTS ${ELASTIX_UNITTEST_OUTPUT_DATA_DIR} )
file( MAKE_DIRECTORY ${ELASTIX_UNITTEST_OUTPUT_DATA_DIR} )
endif()
if( NOT EXISTS ${ELASTIX_UNITTEST_OUTPUT_DATA_DIR} )
message( FATAL_ERROR
"Could not create directory for output data. Make sure elastix has permission to write to disk."
)
endif()
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/elxTestHarness.h.in
${CMAKE_CURRENT_BINARY_DIR}/elxTestHarness.h
${CMAKE_CURRENT_SOURCE_DIR}/elxDataDirectories.h.in
${CMAKE_CURRENT_SOURCE_DIR}/elxDataDirectories.h
ESCAPE_QUOTES
)
# Build tests
add_library( DataManager elxDataManager.cxx )
list( APPEND TEST_LIBRARIES
DataManager
)
foreach( ElastixUnitTestFilename ${ElastixUnitTestFilenames} )
# Build tests executables
string( REPLACE ".cxx" "" ElastixUnitTest ${ElastixUnitTestFilename} )
......
#ifndef __elxTestDataDirectories_h
#define __elxTestDataDirectories_h
#define ELASTIX_UNITTEST_INPUT_DATA_DIR "/Users/kasper/Development/build/SuperElastix/Elastix-build/Testing/Unit/Data/Input"
#define ELASTIX_UNITTEST_OUTPUT_DATA_DIR "/Users/kasper/Development/build/SuperElastix/Elastix-build/Testing/Unit/Data/Output"
#define ELASTIX_UNITTEST_BASELINE_DATA_DIR "/Users/kasper/Development/build/SuperElastix/Elastix-build/Testing/Unit/Data/Baseline"
#endif // __elxTestDataDirectories_h
#ifndef __elxTestDataDirectories_h
#define __elxTestDataDirectories_h
#define ELASTIX_UNITTEST_INPUT_DATA_DIR "@ELASTIX_UNITTEST_INPUT_DATA_DIR@"
#define ELASTIX_UNITTEST_OUTPUT_DATA_DIR "@ELASTIX_UNITTEST_OUTPUT_DATA_DIR@"
#define ELASTIX_UNITTEST_BASELINE_DATA_DIR "@ELASTIX_UNITTEST_BASELINE_DATA_DIR@"
#endif // __elxTestDataDirectories_h
\ No newline at end of file
#ifndef __DataManager_cxx
#define __DataManager_cxx
#include "elxDataManager.h"
std::string
DataManager
::GetInput( const std::string filename ) const
{
const std::string path = this->GetInputDirectory() + this->GetPathSeparator() + filename;
return path;
}
std::string
DataManager
::GetOutput( const std::string filename ) const
{
const std::string path = this->GetOutputDirectory() + this->GetPathSeparator() + filename;
return path;
}
std::string
DataManager
::GetBaseline( const std::string filename ) const
{
const std::string path = this->GetBaselineDirectory() + this->GetPathSeparator() + filename;
return path;
}
#endif // __elxTestData_cxx
\ No newline at end of file
#ifndef __DataManager_h
#define __DataManager_h
#include <string>
#include "itkMacro.h"
#include "itkProcessObject.h"
#include "elxDataDirectories.h"
class DataManager
{
public:
DataManager()
{
this->m_InputDirectory = ELASTIX_UNITTEST_INPUT_DATA_DIR;
this->m_OutputDirectory = ELASTIX_UNITTEST_OUTPUT_DATA_DIR;
this->m_BaselineDirectory = ELASTIX_UNITTEST_BASELINE_DATA_DIR;
}
std::string GetInputDirectory( void ) const { return this->m_InputDirectory; };
std::string GetOutputDirectory( void ) const { return this->m_InputDirectory; };
std::string GetBaselineDirectory( void ) const { return this->m_InputDirectory; };
std::string GetInput( const std::string filename ) const;
std::string GetOutput( const std::string filename ) const;
std::string GetBaseline( const std::string filename ) const;
std::string GetPathSeparator () const
{
#ifdef WIN32
return ";";
#else
return ":";
#endif
}
private:
std::string m_InputDirectory;
std::string m_BaselineDirectory;
std::string m_OutputDirectory;
};
#endif // #define __DataManager_h
\ No newline at end of file
......@@ -17,24 +17,25 @@ TEST( GoogleTest, Example0 )
TEST( GoogleTest, Example1 )
{
// Record random number between 0 and 9
int MetricValue = rand() % 10;
RecordProperty("MetricValue", MetricValue);
ASSERT_TRUE( true );
// Record random number between 0 and 9
int MetricValue = rand() % 10;
RecordProperty("MetricValue", MetricValue);
ASSERT_TRUE( true );
}
TEST( GoogleTest, Example2 )
{
// Record random number between 10 and 19
int MetricValue = rand() % 10 + 10;
RecordProperty("MetricValue", MetricValue);
ASSERT_TRUE( true );
// Record random number between 10 and 19
int MetricValue = rand() % 10 + 10;
RecordProperty("MetricValue", MetricValue);
RecordProperty("OverlapCoefficient", 1);
ASSERT_TRUE( true );
}
TEST( GoogleTest, Example3 )
{
// Record random number between 20 and 29
int MetricValue = rand() % 10 + 20;
RecordProperty("MetricValue", MetricValue);
ASSERT_TRUE( true );
}
\ No newline at end of file
// Record random number between 20 and 29
int MetricValue = rand() % 10 + 20;
RecordProperty("MetricValue", MetricValue);
ASSERT_TRUE( true );
}
#ifndef __ElastixTestHarness_h
#define __ElastixTestHarness_h
#define ELASTIX_UNITTEST_INPUT_DATA_DIR "@ELASTIX_UNITTEST_INPUT_DATA_DIR@"
#define ELASTIX_INITTEST_BASELINE_DATA_DIR "@ELASTIX_UNITTEST_BASELINE_DATA_DIR@"
#endif // __ElastixTestHarness_h
\ No newline at end of file
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