blob: 515ae16aa54e7d2c107f82b06a306839bca19147 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
|
include(FetchContent)
if(CMAKE_BUILD_TYPE STREQUAL "Debug" OR CMAKE_BUILD_TYPE STREQUAL "RelWithDebInfo")
set(CVG_FLAGS -Wno-long-long -fprofile-arcs -ftest-coverage)
else()
endif()
if(FUD_SAN)
set(CVG_FLAGS ${CVG_FLAGS} -fsanitize=address -fsanitize=undefined)
endif()
set(gtest_URL https://github.com/google/googletest.git)
set(gtest_TAG v1.14.0)
FetchContent_Declare(
googletest
GIT_REPOSITORY ${gtest_URL}
GIT_TAG ${gtest_TAG}
)
FetchContent_MakeAvailable(googletest)
include(GoogleTest)
enable_testing()
set(CMAKE_THREAD_LIBS_INIT "-lpthread")
set(CMAKE_HAVE_THREADS_LIBRARY 1)
set(CMAKE_USE_WIN32_THREADS_INIT 0)
set(CMAKE_USE_PTHREADS_INIT 1)
set(THREADS_PREFER_PTHREAD_FLAG ON)
function(fud_add_test test_name)
set(options NO_OPTIONS)
set(oneValueArgs NO_ONE_VALUE_ARGS)
set(multiValueArgs SOURCES)
cmake_parse_arguments(FUD_ADD_TEST "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
add_executable(${test_name} test_common.cpp ${FUD_ADD_TEST_SOURCES})
target_include_directories(${test_name} PUBLIC $<TARGET_PROPERTY:fud>)
target_link_libraries(${test_name} PUBLIC GTest::gtest_main fud)
target_include_directories(${test_name} PRIVATE ${CMAKE_CURRENT_BINARY_DIR}/../include)
target_compile_options(${test_name} PRIVATE ${CVG_FLAGS})
target_link_options(${test_name} PRIVATE ${CVG_FLAGS})
set_target_properties(
${test_name} PROPERTIES
CXX_STANDARD 20
C_STANDARD 23
CXX_EXTENSIONS OFF
C_EXTENSIONS OFF
CXX_STANDARD_REQUIRED ON)
gtest_discover_tests(${test_name})
endfunction()
fud_add_test(test_fud SOURCES test_fud.cpp)
fud_add_test(test_allocator SOURCES test_allocator.cpp)
fud_add_test(test_assert SOURCES test_assert.cpp)
# fud_add_test(test_c_file SOURCES test_c_file.cpp)
fud_add_test(test_directory SOURCES test_directory.cpp)
fud_add_test(test_format SOURCES test_format.cpp)
fud_add_test(test_option SOURCES test_option.cpp)
fud_add_test(test_result SOURCES test_result.cpp)
fud_add_test(test_span SOURCES test_span.cpp)
fud_add_test(test_sqlite SOURCES test_sqlite.cpp)
fud_add_test(test_string SOURCES test_string.cpp)
fud_add_test(test_utf8 SOURCES test_utf8.cpp)
fud_add_test(test_vector SOURCES test_vector.cpp)
# fud_add_test(test_deserialize_number SOURCES test_deserialize_number.cpp)
# fud_add_test(test_ext_algorithm SOURCES test_algorithm.cpp)
# fud_add_test(test_ext_array SOURCES
# test_ext_array.cpp
# test_ext_unique_array.cpp)
|