Commit 5d3cd57f authored by daniel.bub's avatar daniel.bub
Browse files

[REFAC #83] refactor unittest of WCsvConverter

parent 63b770da
......@@ -45,6 +45,6 @@ GET_FILENAME_COMPONENT( MODULE_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME )
# module.
SETUP_MODULE( ${MODULE_NAME} # name of the module
"${CMAKE_CURRENT_SOURCE_DIR}" # where to find the source ${CMAKE_CURRENT_SOURCE_DIR} is a good idea here mostly
"transferFunctionColorBar" # does your module need additional libs to compile?
"transferFunctionColorBar;data" # does your module need additional libs to compile?
"" # do you want to exclude files from stylechecking? (externals for example)
)
\ No newline at end of file
......@@ -27,22 +27,6 @@
#include "WCsvConverter.h"
WCsvConverter::WCsvConverter( WProtonData::SPtr protonData, boost::shared_ptr< WPropertyStatus > propertyStatus )
{
if( protonData == nullptr || propertyStatus == nullptr )
{
throw WException( "Could not convert CSV data! Proton data or property status are missing!" );
}
m_protonData = protonData;
m_propertyStatus = propertyStatus;
m_vectors = WConverterVectors::SPtr( new WConverterVectors() );
m_indexes = WConverterIndexes::SPtr( new WConverterIndexes() );
setOutputFromCSV( );
}
WCsvConverter::WCsvConverter( WProtonData::SPtr protonData, boost::shared_ptr< WPropertyStatus > propertyStatus,
WModule::SPtr colorBar )
{
......
......@@ -54,14 +54,6 @@
class WCsvConverter
{
public:
/**
* Initializes the vectors and indexes.
* Calls setOutputFromCSV.
* \param protonData The protondata to use.
* \param propertyStatus The status of the properties.
*/
WCsvConverter( WProtonData::SPtr protonData, boost::shared_ptr< WPropertyStatus > propertyStatus );
/**
* Initializes the vectors, indices and transfer function color bar
* Calls setOutputFromCSV.
......
......@@ -61,7 +61,7 @@ class WMFilterProtonData : public WModuleContainer
/**
* Only test classes may be friend
*/
friend class WMCsvConverterTest;
friend class WCsvConverterTest;
public:
/**
* represents a boost::shared_ptr to a vector containing a vector of floats.
......
......@@ -31,7 +31,9 @@
#include "core/kernel/WModuleFactory.h"
#include "../WCsvConverter.h"
#include "../WMFilterProtonData.h"
#include "../../transferFunctionColorBar/WMTransferFunctionColorBar.h"
#include "../../data/io/WReaderCSV.h"
/**
* Test class of WCsvConverter class
......@@ -43,56 +45,41 @@ public:
/**
* Test the constructors of WCsvConverter, so no exception is thrown, when input parameters are correct
*/
static void testConstructorsNoThrow()
static void testConstructorThrowNullptr()
{
auto emptyStringVector = new std::vector< std::string >( 1, "" );
WReaderCSV csvReader( W_FIXTURE_PATH + "../data/CSVs/valid.csv" );
WDataSetCSV::ContentSPtr emptyHeader( new WDataSetCSV::Content() );
emptyHeader->push_back( *emptyStringVector );
boost::shared_ptr< WDataSetCSV > csvDataSet = csvReader.read();
WDataSetCSV::ContentSPtr emptyData( new WDataSetCSV::Content() );
emptyHeader->push_back( *emptyStringVector );
WProtonData protonData( csvDataSet->getHeader(), csvDataSet->getData() );
WModule::SPtr emptyColorBar = WModule::SPtr( new WMTransferFunctionColorBar() );
WModule::SPtr tmpColorBar( new WMTransferFunctionColorBar() );
WProtonData::SPtr tmpProtonData = WProtonData::SPtr( new WProtonData( emptyHeader, emptyData ) );
boost::shared_ptr< WPropertyStatus > tmpPropertyStatus( new WPropertyStatus() );
TS_ASSERT_THROWS_NOTHING( WCsvConverter( tmpProtonData, tmpPropertyStatus ) );
TS_ASSERT_THROWS_NOTHING( WCsvConverter( tmpProtonData, tmpPropertyStatus, emptyColorBar ) );
}
/**
* Test the constructor of WCsvConverter, so no exception is thrown, when input parameters are correct
*/
static void testConstructorWithoutColorThrowNullptrParameter()
{
/*
auto emptyStringVector = new std::vector< std::string >( 1, "" );
WDataSetCSV::ContentSPtr emptyHeader( new WDataSetCSV::Content() );
emptyHeader->push_back( *emptyStringVector );
WDataSetCSV::ContentSPtr emptyData( new WDataSetCSV::Content() );
emptyHeader->push_back( *emptyStringVector );
WProtonData::SPtr tmpProtonData = WProtonData::SPtr( new WProtonData( emptyHeader, emptyData ) );
boost::shared_ptr< WPropertyStatus > tmpPropertyStatus( new WPropertyStatus() );
TS_ASSERT_THROWS_NOTHING( WCsvConverter( tmpProtonData, tmpPropertyStatus ) );
*/
/*
WDataSetCSV::ContentSPtr emptyHeader( new WDataSetCSV::Content() );
emptyHeader->push_back( *emptyStringVector );
WDataSetCSV::ContentSPtr emptyData( new WDataSetCSV::Content() );
emptyHeader->push_back( *emptyStringVector );
tmpProtonData = WProtonData::SPtr( new WProtonData( emptyHeader, emptyData ) );
tmpPropertyStatus = nullptr;
TS_ASSERT_THROWS( WCsvConverter( tmpProtonData, tmpPropertyStatus ), WException &e );
*/
WColumnPropertyHandler tmpColumnPropertyHandler( NULL, NULL, NULL );
tmpPropertyStatus->setColumnPropertyHandler(
boost::make_shared< WColumnPropertyHandler>( tmpColumnPropertyHandler )
);
WEventIDLimitationPropertyHandler tmpEventIDLimitationPropertyHandler( NULL, NULL, NULL );
tmpPropertyStatus->setEventIDLimitationPropertyHandler(
boost::make_shared< WEventIDLimitationPropertyHandler>( tmpEventIDLimitationPropertyHandler )
);
WFilterPropertyHandler tmpFilterPropertyHandler( NULL, NULL, NULL );
tmpPropertyStatus->setFilterPropertyHandler(
boost::make_shared< WFilterPropertyHandler>( tmpFilterPropertyHandler )
);
WVisualizationPropertyHandler tmpVisualizationPropertyHandler( NULL, NULL, NULL );
tmpPropertyStatus->setVisualizationPropertyHandler(
boost::make_shared< WVisualizationPropertyHandler>( tmpVisualizationPropertyHandler )
);
TS_ASSERT_THROWS_ANYTHING( WCsvConverter( boost::make_shared< WProtonData >( protonData ),
tmpPropertyStatus,
tmpColorBar )
);
}
};
......
......@@ -26,11 +26,8 @@
#define WMFILTERPROTONDATA_TEST_H
#include <cxxtest/TestSuite.h>
#include <boost/shared_ptr.hpp>
#include "../WMFilterProtonData.h"
#include "../WReaderCSV.h"
/**
* test class of the protonData class
......
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