diff --git a/.gitmodules b/.gitmodules index 070d332..f6ea797 100644 --- a/.gitmodules +++ b/.gitmodules @@ -4,3 +4,6 @@ [submodule "lib/DeathHandler"] path = lib/DeathHandler url = https://github.com/vmarkovtsev/DeathHandler.git +[submodule "lib/Catch"] + path = lib/Catch + url = https://github.com/philsquared/Catch.git diff --git a/CMakeLists.txt b/CMakeLists.txt index b6cd827..afe2770 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,7 @@ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/include") include(TargetArch) include(FindPkgConfig) +include(CTest) set(common_gcc_flags "-Wall -Wextra -pedantic -Wconversion") set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${common_gcc_flags} -O0") @@ -119,3 +120,9 @@ target_compile_definitions(${PROJECT_NAME} ) configure_file(src/${PROJECT_NAME}Config.h.in ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}Config.h) + +if (BUILD_TESTING) + set(CATCH_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/lib/Catch") + set(MYCURRY_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/src") + add_subdirectory(test/unit) +endif() diff --git a/lib/Catch b/lib/Catch new file mode 160000 index 0000000..4d0cd60 --- /dev/null +++ b/lib/Catch @@ -0,0 +1 @@ +Subproject commit 4d0cd602e37197f1502a419142d8f0167d4a063a diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt new file mode 100644 index 0000000..548fe84 --- /dev/null +++ b/test/unit/CMakeLists.txt @@ -0,0 +1,28 @@ +project(mycurry_unit_test CXX) + +set(CMAKE_CXX_STANDARD 14) +set(CMAKE_CXX_STANDARD_REQUIRED ON) + +add_executable(${PROJECT_NAME} + main.cpp +) + +target_compile_definitions(${PROJECT_NAME} + PRIVATE VWR_WITH_IMPLICIT_CONVERSIONS=1 + PRIVATE VWR_EXTRA_ACCESSORS +) + +target_include_directories(${PROJECT_NAME} + PRIVATE ${CATCH_SOURCE_DIR}/single_include + PRIVATE ${MYCURRY_SOURCE_DIR} + PRIVATE ${CMAKE_SOURCE_DIR}/lib/vectorwrapper/include + PRIVATE ${CMAKE_SOURCE_DIR}/lib/tree-2.81/src +) + +add_test( + NAME CloonelJumpTest + WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} + COMMAND ${PROJECT_NAME} +) + + diff --git a/test/unit/main.cpp b/test/unit/main.cpp new file mode 100644 index 0000000..a35d71c --- /dev/null +++ b/test/unit/main.cpp @@ -0,0 +1,21 @@ +/* + Copyright 2016, 2017 Michele "King_DuckZ" Santullo + + This file is part of MyCurry. + + MyCurry is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + MyCurry 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 General Public License for more details. + + You should have received a copy of the GNU General Public License + along with MyCurry. If not, see . +*/ + +#define CATCH_CONFIG_MAIN +#include "catch.hpp"