From: Michael Andreen Date: Thu, 14 Jun 2007 13:55:06 +0000 (+0000) Subject: some more changes X-Git-Tag: v0.1~83 X-Git-Url: https://ruin.nu/git/?p=germs.git;a=commitdiff_plain;h=7ec029d28e715c3c8826b1aea0b1a3afe53de603 some more changes --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 102a11b..ce189d8 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -5,6 +5,9 @@ SET(CMAKE_VERBOSE_MAKEFILE OFF) ADD_DEFINITIONS(-Wall -O2) INCLUDE_DIRECTORIES(.) -ADD_EXECUTABLE(../bin/genesort main.cpp geneorder.cpp) +ADD_LIBRARY(GeneSort geneorder) +ADD_EXECUTABLE(../bin/genesort main.cpp) -TARGET_LINK_LIBRARIES(../bin/genesort doublefann) +TARGET_LINK_LIBRARIES(../bin/genesort doublefann GeneSort) + +SUBDIRS(test) diff --git a/src/test/CMakeLists.txt b/src/test/CMakeLists.txt new file mode 100644 index 0000000..fa36e96 --- /dev/null +++ b/src/test/CMakeLists.txt @@ -0,0 +1,20 @@ +PROJECT(GeneSort) + +SET(CMAKE_VERBOSE_MAKEFILE OFF) + +ADD_DEFINITIONS(-Wall -O2) + +find_package(Qt3 REQUIRED) + +INCLUDE_DIRECTORIES(${QT_INCLUDE_DIR}) +link_directories(${QT_LIB_DIR}) +add_definitions(${QT_DEFINITIONS}) + +SET(TESTSRC geneordertest) + +ADD_EXECUTABLE(tester main ${TESTSRC}) + +ADD_EXECUTABLE(qttester qtmain ${TESTSRC}) + +TARGET_LINK_LIBRARIES(tester GeneSort cppunit) +TARGET_LINK_LIBRARIES(qttester GeneSort cppunit qttestrunnerd ${QT_LIBRARIES}) diff --git a/src/test/exampletest.cpp b/src/test/exampletest.cpp new file mode 100644 index 0000000..32ad2a3 --- /dev/null +++ b/src/test/exampletest.cpp @@ -0,0 +1,75 @@ +#ifndef __GENEORDERTEST_H__ +#define __GENEORDERTEST_H__ + +#include +#include + +/* + * A test case that is designed to produce + * example errors and failures. + * + */ + +#define TESTNAME ExampleTest + + +class TESTNAME : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE( TESTNAME ); + CPPUNIT_TEST( example ); + CPPUNIT_TEST( anotherExample ); + CPPUNIT_TEST( testAdd ); + CPPUNIT_TEST( testEquals ); + CPPUNIT_TEST_SUITE_END(); + +protected: + + double m_value1; + double m_value2; +public: + + void setUp (){ + m_value1 = 2.0; + m_value2 = 3.0; + } + +protected: + + void example () + { + CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, 1.1, 0.05); + CPPUNIT_ASSERT (1 == 0); + CPPUNIT_ASSERT (1 == 1); + } + + void anotherExample () + { + CPPUNIT_ASSERT (1 == 2); + } + + void testAdd () + { + double result = m_value1 + m_value2; + CPPUNIT_ASSERT (result == 6.0); + } + + void testEquals () + { + std::auto_ptr l1 (new long (12)); + std::auto_ptr l2 (new long (12)); + + CPPUNIT_ASSERT_EQUAL (12, 12); + CPPUNIT_ASSERT_EQUAL (12L, 12L); + CPPUNIT_ASSERT_EQUAL (*l1, *l2); + + CPPUNIT_ASSERT (12L == 12L); + CPPUNIT_ASSERT_EQUAL (12, 13); + CPPUNIT_ASSERT_DOUBLES_EQUAL (12.0, 11.99, 0.5); + } +}; + +CPPUNIT_TEST_SUITE_REGISTRATION( TESTNAME ); + +#undef TESTNAME + +#endif diff --git a/src/test/geneordertest.cpp b/src/test/geneordertest.cpp new file mode 100644 index 0000000..cc29694 --- /dev/null +++ b/src/test/geneordertest.cpp @@ -0,0 +1,39 @@ +#include +#include + +#include + +/* + * A test case that is designed to produce + * example errors and failures. + * + */ + +#define TESTNAME GeneOrderTest + + +class TESTNAME : public CPPUNIT_NS::TestFixture +{ + CPPUNIT_TEST_SUITE( TESTNAME ); + CPPUNIT_TEST( testCreate ); + CPPUNIT_TEST_SUITE_END(); + +protected: + + double m_value1; + double m_value2; +public: + + void setUp (){ + } + +protected: + + void testCreate (){ + CPPUNIT_ASSERT (1 == 0); + } +}; + +CPPUNIT_TEST_SUITE_REGISTRATION( TESTNAME ); + +#undef TESTNAME diff --git a/src/test/main.cpp b/src/test/main.cpp new file mode 100644 index 0000000..4eca9d0 --- /dev/null +++ b/src/test/main.cpp @@ -0,0 +1,34 @@ +#include +#include +#include +#include +#include +#include + + +int +main( int argc, char* argv[] ) +{ + // Create the event manager and test controller + CPPUNIT_NS::TestResult controller; + + // Add a listener that colllects test result + CPPUNIT_NS::TestResultCollector result; + controller.addListener( &result ); + + // Add a listener that print dots as test run. + CPPUNIT_NS::BriefTestProgressListener progress; + controller.addListener( &progress ); + + // Add the top suite to the test runner + CPPUNIT_NS::TestRunner runner; + runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() ); + runner.run( controller ); + + // Print test in a compiler compatible format. + CPPUNIT_NS::CompilerOutputter outputter( &result, CPPUNIT_NS::stdCOut() ); + outputter.write(); + + return result.wasSuccessful() ? 0 : 1; +} + diff --git a/src/test/qtmain.cpp b/src/test/qtmain.cpp new file mode 100644 index 0000000..e650040 --- /dev/null +++ b/src/test/qtmain.cpp @@ -0,0 +1,19 @@ +#include +#include +#include + + +int main( int argc, char** argv ) +{ + QApplication app( argc, argv ); + + //CPPUNIT_NS::QtUi::TestRunner runner; + + CPPUNIT_NS::QtTestRunner runner; + + runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() ); + runner.run( true ); + + return 0; +} + diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt deleted file mode 100644 index 0810962..0000000 --- a/test/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -PROJECT(GeneSort) - -SET(CMAKE_VERBOSE_MAKEFILE OFF) - -ADD_DEFINITIONS(-Wall -O2) - -find_package(Qt3 REQUIRED) - -INCLUDE_DIRECTORIES(. ../src ${QT_INCLUDE_DIR}) -link_directories(${QT_LIB_DIR}) -add_definitions(${QT_DEFINITIONS}) - -SET(TESTSRC geneordertest) - -ADD_EXECUTABLE(tester main ${TESTSRC}) - -ADD_EXECUTABLE(qttester qtmain ${TESTSRC}) - -TARGET_LINK_LIBRARIES(tester cppunit) -TARGET_LINK_LIBRARIES(qttester cppunit qttestrunnerd ${QT_LIBRARIES}) diff --git a/test/exampletest.cpp b/test/exampletest.cpp deleted file mode 100644 index 32ad2a3..0000000 --- a/test/exampletest.cpp +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef __GENEORDERTEST_H__ -#define __GENEORDERTEST_H__ - -#include -#include - -/* - * A test case that is designed to produce - * example errors and failures. - * - */ - -#define TESTNAME ExampleTest - - -class TESTNAME : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TESTNAME ); - CPPUNIT_TEST( example ); - CPPUNIT_TEST( anotherExample ); - CPPUNIT_TEST( testAdd ); - CPPUNIT_TEST( testEquals ); - CPPUNIT_TEST_SUITE_END(); - -protected: - - double m_value1; - double m_value2; -public: - - void setUp (){ - m_value1 = 2.0; - m_value2 = 3.0; - } - -protected: - - void example () - { - CPPUNIT_ASSERT_DOUBLES_EQUAL (1.0, 1.1, 0.05); - CPPUNIT_ASSERT (1 == 0); - CPPUNIT_ASSERT (1 == 1); - } - - void anotherExample () - { - CPPUNIT_ASSERT (1 == 2); - } - - void testAdd () - { - double result = m_value1 + m_value2; - CPPUNIT_ASSERT (result == 6.0); - } - - void testEquals () - { - std::auto_ptr l1 (new long (12)); - std::auto_ptr l2 (new long (12)); - - CPPUNIT_ASSERT_EQUAL (12, 12); - CPPUNIT_ASSERT_EQUAL (12L, 12L); - CPPUNIT_ASSERT_EQUAL (*l1, *l2); - - CPPUNIT_ASSERT (12L == 12L); - CPPUNIT_ASSERT_EQUAL (12, 13); - CPPUNIT_ASSERT_DOUBLES_EQUAL (12.0, 11.99, 0.5); - } -}; - -CPPUNIT_TEST_SUITE_REGISTRATION( TESTNAME ); - -#undef TESTNAME - -#endif diff --git a/test/geneordertest.cpp b/test/geneordertest.cpp deleted file mode 100644 index cc29694..0000000 --- a/test/geneordertest.cpp +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include - -#include - -/* - * A test case that is designed to produce - * example errors and failures. - * - */ - -#define TESTNAME GeneOrderTest - - -class TESTNAME : public CPPUNIT_NS::TestFixture -{ - CPPUNIT_TEST_SUITE( TESTNAME ); - CPPUNIT_TEST( testCreate ); - CPPUNIT_TEST_SUITE_END(); - -protected: - - double m_value1; - double m_value2; -public: - - void setUp (){ - } - -protected: - - void testCreate (){ - CPPUNIT_ASSERT (1 == 0); - } -}; - -CPPUNIT_TEST_SUITE_REGISTRATION( TESTNAME ); - -#undef TESTNAME diff --git a/test/main.cpp b/test/main.cpp deleted file mode 100644 index 4eca9d0..0000000 --- a/test/main.cpp +++ /dev/null @@ -1,34 +0,0 @@ -#include -#include -#include -#include -#include -#include - - -int -main( int argc, char* argv[] ) -{ - // Create the event manager and test controller - CPPUNIT_NS::TestResult controller; - - // Add a listener that colllects test result - CPPUNIT_NS::TestResultCollector result; - controller.addListener( &result ); - - // Add a listener that print dots as test run. - CPPUNIT_NS::BriefTestProgressListener progress; - controller.addListener( &progress ); - - // Add the top suite to the test runner - CPPUNIT_NS::TestRunner runner; - runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() ); - runner.run( controller ); - - // Print test in a compiler compatible format. - CPPUNIT_NS::CompilerOutputter outputter( &result, CPPUNIT_NS::stdCOut() ); - outputter.write(); - - return result.wasSuccessful() ? 0 : 1; -} - diff --git a/test/qtmain.cpp b/test/qtmain.cpp deleted file mode 100644 index e650040..0000000 --- a/test/qtmain.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include -#include -#include - - -int main( int argc, char** argv ) -{ - QApplication app( argc, argv ); - - //CPPUNIT_NS::QtUi::TestRunner runner; - - CPPUNIT_NS::QtTestRunner runner; - - runner.addTest( CPPUNIT_NS::TestFactoryRegistry::getRegistry().makeTest() ); - runner.run( true ); - - return 0; -} -