Skip to content

Commit

Permalink
update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
yomichi committed Sep 19, 2021
1 parent a5e0822 commit f6583c0
Show file tree
Hide file tree
Showing 15 changed files with 6,686 additions and 132 deletions.
28 changes: 28 additions & 0 deletions cmake/EnableGtests.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#
# enables testing with google test
# provides add_gtest(test) and add_gtest_release(test) commands
#

# check xml output
option(TestXMLOutput "Output tests to xml" OFF)

# custom function to add gtest with xml output
# arg0 - test (assume the source is ${test}.cpp
function(add_gtest test)
if (TestXMLOutput)
set (test_xml_output --gtest_output=xml:${test}.xml)
endif(TestXMLOutput)

if(${ARGC} EQUAL 2)
set(source "${ARGV1}/${test}")
set(gtest_src "${ARGV1}/gtest_main.cc;${ARGV1}/gtest-all.cc")
else(${ARGC} EQUAL 2)
set(source "${test}")
set(gtest_src "gtest_main.cc;gtest-all.cc")
endif(${ARGC} EQUAL 2)

add_executable(${test} ${source} ${gtest_src})
target_link_libraries(${test} ${LINK_ALL})
add_test(NAME ${test} COMMAND ${test} ${test_xml_output})
endfunction(add_gtest)

24 changes: 7 additions & 17 deletions test/c++/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,31 +1,21 @@
cmake_minimum_required(VERSION 2.8.12)

function(add_gtest test)
set(source "${ARGV1}/${test}.cpp")
set(gtest_src "${ARGV1}/gtest_main.cc;${ARGV1}/gtest-all.cc")

add_executable(${test} ${source} ${gtest_src} ${header_files})
target_link_libraries(${test} pthread gf)
target_include_directories(${test} PRIVATE ${HDF5_INCLUDE_DIR})
add_test(NAME ${test} COMMAND ${test} ${test_xml_output})
endfunction(add_gtest)

#find_package(GTest REQUIRED)
#include_directories(BEFORE ${GTEST_INCLUDE_DIRS})
include(EnableGtests) #defined in ./cmake
include_directories(../../c++/include)

# test for SPM library


# test for GF library
set(unittest_src_gf
test_fft
test_pade
test_fft_fermion
test_fft_boson
test_pade_fermion
test_pade_boson
)

foreach(test_c++ ${unittest_src_gf})
add_gtest(${test_c++} ".")
#target_link_libraries(${test_c++} gf)
add_gtest(${test_c++})
target_link_libraries(${test_c++} gf)
endforeach(test_c++)

add_subdirectory(data)
Loading

0 comments on commit f6583c0

Please sign in to comment.