Commit dab9d7f7 authored by Oliver Schmidts's avatar Oliver Schmidts

ready for boost.test and also first boost testcase

parent 7dc1c609
......@@ -138,6 +138,7 @@ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
# test all cpp-files in Utest
if(BUILD_TESTING)
find_package(Boost COMPONENTS unit_test_framework REQUIRED)
file(GLOB test_files "${CMAKE_TEST_DIR}/*.cpp")
# file(GLOB test_py_files "${CMAKE_TEST_DIR}/*/runtest*.py")
file(GLOB_RECURSE test_py_files "${CMAKE_TEST_DIR}/*runtest_*.py")
......@@ -411,11 +412,11 @@ if(BUILD_TESTING)
--build-project JPScore
--test-command jpscore --ini=${CMAKE_SOURCE_DIR}/inputfiles/Default/ini.xml
)
link_directories(${Boost_LIBRARY_DIRS})
foreach (test_src ${test_files})
GET_FILENAME_COMPONENT(test ${test_src} NAME_WE)
add_executable( ${test} ${test_src})
target_link_libraries (${test} core)
target_link_libraries (${test} core ${Boost_LIBRARIES})
add_test(NAME ${test} COMMAND ${test})
endforeach(test_src ${test_files})
......
#define BOOST_TEST_MODULE PointTest
#define BOOST_TEST_DYN_LINK
#include <boost/test/unit_test.hpp>
#include "../geometry/Point.h"
BOOST_AUTO_TEST_SUITE(PointTest)
BOOST_AUTO_TEST_CASE(Point_Constructor_Test)
{
BOOST_TEST_MESSAGE("Starting Point ctor test");
Point p;
BOOST_REQUIRE(p.GetX() == 0 && p.GetY() == 0);
Point p2(1, 1);
BOOST_REQUIRE(p2.GetX() == 1 && p2.GetY() == 1);
Point p3(p2);
BOOST_REQUIRE(p3.GetX() == 1 && p3.GetY() == 1);
BOOST_TEST_MESSAGE("Leaving ctor test");
BOOST_MESSAGE("Starting setter test");
p2.SetX(0.5);
p2.SetY(-232.2);
BOOST_REQUIRE(p2.GetX() == 0.5 && p2.GetY() == -232.2);
BOOST_TEST_MESSAGE("Leaving setter test");
}
BOOST_AUTO_TEST_CASE(Point_Norm_Tests)
{
BOOST_TEST_MESSAGE("Starting norm test");
Point p1(0,0);
BOOST_CHECK(p1.Norm() == 0);
p1.SetX(1);
BOOST_CHECK(p1.Norm() == 1);
p1.SetX(-1);
BOOST_CHECK(p1.Norm() == 1);
p1.SetX(3);
BOOST_CHECK(p1.Norm() == 3);
p1.SetX(0);
p1.SetY(1);
BOOST_CHECK(p1.Norm() == 1);
p1.SetY(-1);
BOOST_CHECK(p1.Norm() == 1);
p1.SetY(3);
BOOST_CHECK(p1.Norm() == 3);
p1.SetX(3);
p1.SetY(4);
BOOST_CHECK(p1.Norm() == 5);
BOOST_TEST_MESSAGE("Leaving norm test");
}
BOOST_AUTO_TEST_SUITE_END()
\ No newline at end of file
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