Skip to content

Commit

Permalink
tests with double
Browse files Browse the repository at this point in the history
  • Loading branch information
thinks committed Aug 11, 2024
1 parent 176afdf commit 82976ed
Show file tree
Hide file tree
Showing 4 changed files with 340 additions and 340 deletions.
3 changes: 1 addition & 2 deletions include/thinks/tph_poisson.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
* TODOS:
* - Move implementation macros to implementation section??
* - Build and run tests with sanitizers!!
* - Tests with TPH_POISSON_REAL_TYPE == double!!
*/

#include <stddef.h>// size_t, ptrdiff_t, NULL
Expand Down Expand Up @@ -1110,7 +1109,7 @@ const tph_poisson_real *tph_poisson_get_samples(tph_poisson_sampling *s)
The input domain is (-FLT_MAX, FLT_MAX] (for floats)
The api consists of these functions:
The API consists of these functions:
int tph_poisson_create(tph_poisson_sampling *sampling,
const tph_poisson_args *args,
Expand Down
43 changes: 30 additions & 13 deletions test/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,8 @@ set_target_properties(tph_poisson_d PROPERTIES
)
add_library(thinks::tph_poisson_d ALIAS tph_poisson_d)

# Fetch rpmalloc repo, source files are included directly in our test build, since the
# project does not have a CMake build system.
FetchContent_Declare(rpmalloc
GIT_REPOSITORY https://github.com/mjansson/rpmalloc.git
GIT_TAG 1.4.5
Expand All @@ -108,10 +110,11 @@ if(NOT rpmalloc_POPULATED)
FetchContent_Populate(rpmalloc)
endif()

# float
add_executable(tph_poisson_test
"test.cpp"
${rpmalloc_SOURCE_DIR}/rpmalloc/rpmalloc.c)
target_link_libraries(tph_poisson_test PRIVATE thinks::tph_poisson_f thinks::tph_poisson_d)
"${rpmalloc_SOURCE_DIR}/rpmalloc/rpmalloc.c")
target_link_libraries(tph_poisson_test PRIVATE thinks::tph_poisson_f)
target_include_directories(tph_poisson_test PRIVATE ${rpmalloc_SOURCE_DIR})
set_target_properties(tph_poisson_test PROPERTIES
CXX_STANDARD ${_cxx_standard}
Expand All @@ -120,18 +123,32 @@ set_target_properties(tph_poisson_test PROPERTIES
)
add_test(NAME tph_poisson_test COMMAND tph_poisson_test)

add_executable(tph_poisson_vec_test
"tph_poisson_vec_test.c")
target_link_libraries(tph_poisson_vec_test PRIVATE thinks::tph_poisson)
if(NOT MSVC)
target_link_libraries(tph_poisson_vec_test PRIVATE m)
endif()
set_target_properties(tph_poisson_vec_test PROPERTIES
C_STANDARD ${_c_standard}
C_STANDARD_REQUIRED ON
C_EXTENSIONS OFF
# double
add_executable(tph_poisson_test_d
"test.cpp"
"${rpmalloc_SOURCE_DIR}/rpmalloc/rpmalloc.c")
target_link_libraries(tph_poisson_test_d PRIVATE thinks::tph_poisson_d)
target_include_directories(tph_poisson_test_d PRIVATE ${rpmalloc_SOURCE_DIR})
target_compile_definitions(tph_poisson_test_d PRIVATE TPH_POISSON_TEST_USE_DOUBLE)
set_target_properties(tph_poisson_test_d PROPERTIES
CXX_STANDARD ${_cxx_standard}
CXX_STANDARD_REQUIRED ON
CXX_EXTENSIONS OFF
)
add_test(NAME tph_poisson_vec_test COMMAND tph_poisson_vec_test)
add_test(NAME tph_poisson_test_d COMMAND tph_poisson_test_d)

# add_executable(tph_poisson_vec_test
# "tph_poisson_vec_test.c")
# target_link_libraries(tph_poisson_vec_test PRIVATE thinks::tph_poisson)
# if(NOT MSVC)
# target_link_libraries(tph_poisson_vec_test PRIVATE m)
# endif()
# set_target_properties(tph_poisson_vec_test PROPERTIES
# C_STANDARD ${_c_standard}
# C_STANDARD_REQUIRED ON
# C_EXTENSIONS OFF
# )
# add_test(NAME tph_poisson_vec_test COMMAND tph_poisson_vec_test)

unset(_cxx_standard)
unset(_c_standard)
Expand Down
Loading

0 comments on commit 82976ed

Please sign in to comment.