Commit 960b7ee4 authored by wiebel's avatar wiebel
Browse files

made a separated module for utils and added some tests for it

parent 27e78da0
......@@ -62,6 +62,7 @@ ADD_SUBDIRECTORY( dataHandler )
ADD_SUBDIRECTORY( graphicsEngine )
ADD_SUBDIRECTORY( gui )
ADD_SUBDIRECTORY( plugins )
ADD_SUBDIRECTORY( utils )
ADD_EXECUTABLE( walnut OpenWalnut.cpp utils/WOptionHandler.cpp )
TARGET_LINK_LIBRARIES( walnut guiqt4 ${Boost_LIBRARIES} )
......
FILE(GLOB UTILS_SRC "*.cpp")
ADD_LIBRARY( utils SHARED ${UTILS_SRC} )
# Unit tests
IF( CXXTEST_FOUND )
CXXTEST_ADD_TEST( unittest_WOptionHandler WOptionHandler_test.cc ${CMAKE_CURRENT_SOURCE_DIR}/test/WOptionHandler_test.h )
TARGET_LINK_LIBRARIES( unittest_WOptionHandler utils guiqt4 ${Boost_LIBRARIES} )
ENDIF( CXXTEST_FOUND )
......@@ -36,6 +36,8 @@ namespace po = boost::program_options;
*/
class WOptionHandler
{
friend class WOptionHandlerTest;
public:
/**
* Initiate the handling of the commandline parameter given via argc and
......
//---------------------------------------------------------------------------
//
// Project: OpenWalnut
//
// Copyright 2009 SomeCopyrightowner
//
// 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 WOPTIONHANDLER_TEST_H
#define WOPTIONHANDLER_TEST_H
#include <cxxtest/TestSuite.h>
#include "../WOptionHandler.h"
class WOptionHandlerTest : public CxxTest::TestSuite
{
public:
void testInstanziation( void )
{
const int argc = 2;
char* arg[argc];
arg[1] = const_cast<char *>( "--thisoptiondoesnotexist" );
WOptionHandler th( argc, arg );
}
void testParsing( void )
{
const int argc = 2;
char* arg[argc];
arg[1] = const_cast<char *>( "--thisoptiondoesnotexist" );
bool exceptionCaught = false;
WOptionHandler th( argc, arg );
try
{
th.parseOptions();
}
catch( po::error )
{
exceptionCaught = true;
}
TS_ASSERT( exceptionCaught );
}
};
#endif // WOPTIONHANDLER_TEST_H
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