Commit aed1535c authored by Mathias Goldau's avatar Mathias Goldau
Browse files

[ADD]

 * some unit tests and disabled unit_test warnings from cmake for those where no test are neccesarry
 * fixed some style violations
parent 8dc4b6eb
......@@ -20,5 +20,6 @@ IF( CXXTEST_FOUND )
"WTransferable.cpp"
"WConditionSet.cpp"
"WPrototyped.cpp"
"WLimits.cpp" # there are only some definitions
)
ENDIF( CXXTEST_FOUND )
......@@ -203,3 +203,16 @@ std::istream& operator>>( std::istream& in, WColor& c )
return in;
}
bool WColor::operator==( const WColor &rhs ) const
{
return m_red == rhs.m_red &&
m_green == rhs.m_green &&
m_blue == rhs.m_blue &&
m_alpha == rhs.m_alpha;
}
bool WColor::operator!=( const WColor &rhs ) const
{
return !( *this == rhs );
}
......@@ -109,6 +109,25 @@ public:
*/
void setRGB( double r, double g, double b );
/**
* Compares two WColor instances on all four channels.
*
* \param rhs The other WColor instance
* \return True if they share the same values in all four channles:
* red, green, blue and alpha
*/
bool operator==( const WColor &rhs ) const;
/**
* Opposite of the operator==.
*
* \param rhs The other WColor instance
* \return True if they don't share the same values in all four channles:
* red, green, blue and alpha
*/
bool operator!=( const WColor &rhs ) const;
protected:
private:
float m_red; //!< Red channel
......
......@@ -25,12 +25,13 @@
#ifndef WCOLOR_TEST_H
#define WCOLOR_TEST_H
#include <string>
#include <sstream>
#include <string>
#include <cxxtest/TestSuite.h>
#include "../WColor.h"
#include "WColorTraits.h"
/**
* Unit tests the WColor class
......@@ -40,7 +41,7 @@ class WColorTest : public CxxTest::TestSuite
public:
/**
* To write a WColor object to an output stream we must ensure that every
* component (red, green, blue and alpha) are written to that stream and
* component (red, green, blue and alpha) are written to that stream and
* that we have a special delimiter char.
*/
void testOutputOperator( void )
......@@ -93,6 +94,18 @@ public:
TS_ASSERT_DELTA( c.getGreen(), 0.3, 0.0001 );
TS_ASSERT_DELTA( c.getBlue(), 0.2099, 0.0001 );
}
/**
* Two colors are equal if they share the same value in all four channels.
*/
void testEquality( void )
{
WColor foo( 0.1, 0.2, 0.3, 0.4 );
WColor bar( 0.10001, 0.2, 0.3, 0.4 );
TS_ASSERT_DIFFERS( foo, bar );
WColor pansen( 0.1, 0.2, 0.3, 0.4 );
TS_ASSERT_EQUALS( foo, pansen );
}
};
#endif // WCOLOR_TEST_H
......@@ -5,5 +5,12 @@ FILE( GLOB DATAHANDLER_IO_SRC "*.cpp" )
# Unit tests
IF( CXXTEST_FOUND )
CXXTEST_ADD_TESTS_FROM_LIST( "${DATAHANDLER_IO_SRC}" "dataHandler;niftiio;biosig" )
CXXTEST_ADD_TESTS_FROM_LIST( "${DATAHANDLER_IO_SRC}"
"dataHandler;niftiio;biosig"
"WWriter.cpp" # too simple to test
"WReader.cpp" # too simple to test
"WWriterLookUpTableVTK.cpp" # there is only one member function which is not trivial, but its more an integration test
"WReaderLookUpTableVTK.cpp" # there is only one member function which is not trivial, but its more an integration test
"WWriterFiberVTK.cpp" # there is only one member function which is not trivial, but its more an integration test
)
ENDIF( CXXTEST_FOUND )
......@@ -14,5 +14,6 @@ TARGET_LINK_LIBRARIES( gui common )
IF( CXXTEST_FOUND )
CXXTEST_ADD_TESTS_FROM_LIST( "${GUI_SRC}"
"common;utils"
"WGUI.cpp"
)
ENDIF( CXXTEST_FOUND )
......@@ -24,14 +24,14 @@
#include "../common/WConditionOneShot.h"
#include "../common/WFlag.h"
#include "WGUI.h"
WGUI::WGUI( int argc, char** argv ): boost::enable_shared_from_this< WGUI >(),
m_isInitialized( new WConditionOneShot(), false )
WGUI::WGUI( int argc, char** argv )
: boost::enable_shared_from_this< WGUI >(),
m_isInitialized( new WConditionOneShot(), false ),
m_argc( argc ),
m_argv( argv )
{
this->argc = argc;
this->argv = argv;
}
WGUI::~WGUI()
......
......@@ -121,12 +121,12 @@ protected:
/**
* Number of command line arguments given.
*/
int argc;
int m_argc;
/**
* Command line arguments given.
*/
char** argv;
char** m_argv;
};
#endif // WGUI_H
......
......@@ -41,8 +41,8 @@
#include "WCreateCustomDockWidgetEvent.h"
#include "WQt4Gui.h"
WQt4Gui::WQt4Gui( int argc, char** argv ):
WGUI( argc, argv )
WQt4Gui::WQt4Gui( int argc, char** argv )
: WGUI( argc, argv )
{
}
......@@ -56,7 +56,7 @@ WQt4Gui::~WQt4Gui()
const unsigned int boost::program_options::options_description::m_default_line_length = 2048;
#endif
bool WQt4Gui::parseOptions( int argc, char** argv )
bool WQt4Gui::parseOptions()
{
namespace po = boost::program_options; // since the namespace is far to big we use a shortcut here
po::options_description desc( "Allowed options" );
......@@ -73,7 +73,7 @@ bool WQt4Gui::parseOptions( int argc, char** argv )
try
{
po::store( po::command_line_parser( argc, argv ).options( desc ).positional( p ).run(), m_optionsMap );
po::store( po::command_line_parser( m_argc, m_argv ).options( desc ).positional( p ).run(), m_optionsMap );
}
catch( const po::error &e )
{
......@@ -129,8 +129,7 @@ bool WQt4Gui::parseOptions( int argc, char** argv )
int WQt4Gui::run()
{
bool parsingSuccessful = false;
parsingSuccessful = parseOptions( argc, argv );
bool parsingSuccessful = parseOptions();
if( !parsingSuccessful )
{
......@@ -146,7 +145,7 @@ int WQt4Gui::run()
WLogger::getLogger()->run();
WLogger::getLogger()->addLogMessage( "Bringing up GUI", "GUI", LL_INFO );
QApplication appl( argc, argv, true );
QApplication appl( m_argc, m_argv, true );
// startup graphics engine
m_ge = WGraphicsEngine::getGraphicsEngine();
......
......@@ -140,10 +140,8 @@ private:
* At the moment it seems reasonable that different GUIs might have
* different command line options, thus we implement their parsing
* in the GUI implemntation itself, i.e. here.
* \param argc number of arguments given on command line.
* \param argv arguments given on command line.
*/
bool parseOptions( int argc, char** argv );
bool parseOptions();
};
#endif // WQT4GUI_H
......
//---------------------------------------------------------------------------
//
// 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 WGUI_TEST_H
#define WGUI_TEST_H
#include <cxxtest/TestSuite.h>
#include "../WGUI.h"
/**
* Tests for WGUI: Since WGUI is abstrac no test are here to define
*/
class WGUITest : public CxxTest::TestSuite
{
public:
// Since WGUI is abstrac no test are here to define
void testInstantiation( void )
{
TS_ASSERT( true );
}
};
#endif // WGUI_TEST_H
......@@ -13,5 +13,6 @@ ENDIF()
IF( CXXTEST_FOUND )
CXXTEST_ADD_TESTS_FROM_LIST( "${MATH_SRC}"
"math;common;utils"
)
"WMath.cpp" # this declares only a namespace
)
ENDIF( CXXTEST_FOUND )
......@@ -314,10 +314,28 @@ void WMFiberClustering::connectors()
void WMFiberClustering::properties()
{
m_properties->addString( "Fibers Display Module", "Display fibers" );
// this bool is hidden
// this bool is hidden and used for hiding the osgNode
m_properties->addBool( "active", true, true )->connect( boost::bind( &WMFiberClustering::slotPropertyChanged, this, _1 ) );
m_properties->addDouble( "Threshold", 6.5 )->connect( boost::bind( &WMFiberClustering::slotPropertyChanged, this, _1 ) );
m_properties->addDouble( "max distance threshold",
m_maxDistance_t,
false,
"Maximum distance of two fibers in one cluster."
)->connect( boost::bind( &WMFiberClustering::slotPropertyChanged, this, _1 ) );
m_properties->addDouble( "max distance threshold",
m_proximity_t,
false,
"defines the minimum distance between two fibers which should be considered in distance measure."
)->connect( boost::bind( &WMFiberClustering::slotPropertyChanged, this, _1 ) );
m_properties->addInt( "min cluster size",
m_minClusterSize,
false,
"All clusters up to this size will be discarded."
)->connect( boost::bind( &WMFiberClustering::slotPropertyChanged, this, _1 ) );
m_properties->addBool( "separate primitives",
m_separatePrimitives,
false,
"If true each cluster has its own OSG node"
)->connect( boost::bind( &WMFiberClustering::slotPropertyChanged, this, _1 ) );
}
void WMFiberClustering::slotPropertyChanged( std::string propertyName )
......@@ -333,7 +351,7 @@ void WMFiberClustering::slotPropertyChanged( std::string propertyName )
m_osgNode->setNodeMask( 0x0 );
}
}
else if( propertyName == "Threshold" )
else if( propertyName == "max distance threshold" )
{
m_maxDistance_t = m_properties->getValue< double >( propertyName );
update();
......
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