Commit 99036f45 authored by Daniel Bub's avatar Daniel Bub
Browse files

Merge branch 'top2021s5/#83_unittest_WMCsvConverter' into 'sprint_5'

[MERGE #83] Top2021s5/#83 unittest wm csv converter

See merge request top/21s/sivert-vis/sivert-vis-project!83
parents 93226e81 5d3cd57f
#---------------------------------------------------------------------------
#
# Project: OpenWalnut ( http://www.openwalnut.org )
#
# Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
# For more information see http:#www.openwalnut.org/copying
#
# This file is part of OpenWalnut.
#
# OpenWalnut is free software: you can redistribute it and/or modify
# it under the terms of the GNU Lesser General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# OpenWalnut is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with OpenWalnut. If not, see <http:#www.gnu.org/licenses/>.
#
#---------------------------------------------------------------------------
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Some common setup
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# we use the directory name as module name
GET_FILENAME_COMPONENT( MODULE_NAME ${CMAKE_CURRENT_SOURCE_DIR} NAME )
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Search own dependencies
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# 1: FindPackage( LibYouNeed )
# 2: INCLUDE_DIRECTORIES( ${LIBYOUNEED_INCLUDE_DIR} )
# 3: LINK_DIRECTORIES( ${LIBYOUNEED_LIBRARY_DIRS} )
# 4: Add ${LIBYOUNEED_LIBRARY} as _MODULE_DEPENDENCIES parameter to SETUP_MODULE
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Setup for compilation
# ---------------------------------------------------------------------------------------------------------------------------------------------------
# Let this function do the job. It sets up tests and copies shaders automatically. It additionally configures the stylecheck mechanism for this
# 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;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,28 +27,20 @@
#include "WCsvConverter.h"
WCsvConverter::WCsvConverter( WProtonData::SPtr protonData, boost::shared_ptr< WPropertyStatus > propertyStatus )
{
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,
WCsvConverter::WCsvConverter( WProtonData::SPtr protonData, boost::shared_ptr< WPropertyStatus > propertyStatus,
WModule::SPtr colorBar )
{
if( protonData == nullptr || propertyStatus == nullptr || colorBar == nullptr )
{
throw WException( "Could not convert CSV data! Proton data, property status or color bar are missing!" );
}
m_protonData = protonData;
m_propertyStatus = propertyStatus;
m_vectors = WConverterVectors::SPtr( new WConverterVectors() );
m_indexes = WConverterIndexes::SPtr( new WConverterIndexes() );
m_colorBar = colorBar;
setOutputFromCSV( );
}
......
......@@ -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.
......
......@@ -58,6 +58,10 @@
*/
class WMFilterProtonData : public WModuleContainer
{
/**
* Only test classes may be friend
*/
friend class WCsvConverterTest;
public:
/**
* represents a boost::shared_ptr to a vector containing a vector of floats.
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut ( http://www.openwalnut.org )
//
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
// For more information see http://www.openwalnut.org/copying
//
// This file is part of OpenWalnut.
//
// OpenWalnut is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// OpenWalnut is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
//
//---------------------------------------------------------------------------
#ifndef WCSVCONVERTER_TEST_H
#define WCSVCONVERTER_TEST_H
#include <vector>
#include <string>
#include <cxxtest/TestSuite.h>
#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
*/
class WCsvConverterTest : public CxxTest::TestSuite
{
public:
/**
* Test the constructors of WCsvConverter, so no exception is thrown, when input parameters are correct
*/
static void testConstructorThrowNullptr()
{
WReaderCSV csvReader( W_FIXTURE_PATH + "../data/CSVs/valid.csv" );
boost::shared_ptr< WDataSetCSV > csvDataSet = csvReader.read();
WProtonData protonData( csvDataSet->getHeader(), csvDataSet->getData() );
WModule::SPtr tmpColorBar( new WMTransferFunctionColorBar() );
boost::shared_ptr< WPropertyStatus > tmpPropertyStatus( new WPropertyStatus() );
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 )
);
}
};
#endif // WCSVCONVERTER_TEST_H
......@@ -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