Skip to content

Commit

Permalink
Merge pull request #216 from carstene1ns/doctest
Browse files Browse the repository at this point in the history
Use `doctest` for unit tests
  • Loading branch information
Ghabry authored Oct 13, 2017
2 parents 69bd43d + 68b5b42 commit 4d258c5
Show file tree
Hide file tree
Showing 6 changed files with 5,696 additions and 63 deletions.
8 changes: 2 additions & 6 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
/builds/autoconf/
!/builds/autoconf/m4/m4_ax_pkg_check_modules.m4
/liblcf-*/
/tests/*.log
/tests/*.trs
/time_stamp*
/test_runner*
.deps/
.libs/
.dirstamp
Expand All @@ -20,7 +18,6 @@ configure
liblcf-*.tar.gz
libtool
stamp-h1
test-suite.log
*.la
*.lo

Expand Down Expand Up @@ -57,5 +54,4 @@ Makefile
*.pc

# tests
/tests/time_stamp*
!/tests/time_stamp.cpp
/tests/test_runner*
18 changes: 11 additions & 7 deletions Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -193,18 +193,22 @@ pkginclude_HEADERS = \
src/generated/rpg_trooppage.h \
src/generated/rpg_variable.h

check_PROGRAMS = time_stamp
TESTS = time_stamp
time_stamp_SOURCES = tests/time_stamp.cpp
time_stamp_CPPFLAGS = \
check_PROGRAMS = test_runner
test_runner_SOURCES = \
tests/time_stamp.cpp \
tests/test_main.cpp
test_runner_CPPFLAGS = \
-I$(srcdir)/src \
-I$(srcdir)/src/generated
time_stamp_CXXFLAGS = \
test_runner_CXXFLAGS = \
-std=c++11 \
$(EXPAT_CXXFLAGS) \
$(ICU_CXXFLAGS)
time_stamp_LDADD = \
test_runner_LDADD = \
liblcf.la \
$(EXPAT_LIBS) \
$(ICU_LIBS)
time_stamp_LDFLAGS = -no-install
test_runner_LDFLAGS = -no-install

check-local:
$(AM_V_at)./test_runner
20 changes: 4 additions & 16 deletions builds/cmake/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,22 +83,10 @@ install(FILES ${CMAKE_BINARY_DIR}/liblcf.pc
DESTINATION ${LIB_INSTALL_DIR}/pkgconfig)

# test
enable_testing()

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/../../src)

function(CXX_TEST target libs)
get_filename_component(name ${target} NAME_WE)
add_executable(test_${name} ${target})
target_link_libraries(test_${name} ${PROJECT_NAME} ${libs})
add_test(
NAME test_${name}
WORKING_DIRECTORY ${EXECUTABLE_OUTPUT_PATH}
COMMAND ${EXECUTABLE_OUTPUT_PATH}/test_${name})
add_dependencies(test_${name} ${PROJECT_NAME})
endfunction()

file(GLOB TEST_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../../tests/*.cpp)
foreach(i ${TEST_FILES})
cxx_test(${i} ${ICU_LIBRARIES} ${EXPAT_LIBRARY})
endforeach()
add_executable(test_runner EXCLUDE_FROM_ALL ${TEST_FILES})
target_link_libraries(test_runner ${PROJECT_NAME} ${ICU_LIBRARIES} ${EXPAT_LIBRARY})
add_custom_target(check COMMAND ${EXECUTABLE_OUTPUT_PATH}/test_runner)
add_dependencies(check test_runner)
Loading

0 comments on commit 4d258c5

Please sign in to comment.