Skip to content

Commit 4330159

Browse files
author
Hana Dusíková
committed
added selftests in cmake
1 parent 3bcaf24 commit 4330159

13 files changed

+42
-1
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,5 @@ mtent12.txt
1515
*.zip
1616
tests/benchmark-range/*
1717
!tests/benchmark-range/*.cpp
18-
!tests/benchmark-range/*.hpp
18+
!tests/benchmark-range/*.hpp
19+
build

CMakeLists.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,9 @@ install(
2727
DESTINATION lib/cmake/ctre)
2828
install(DIRECTORY include/ DESTINATION include
2929
FILES_MATCHING PATTERN *.hpp)
30+
31+
option(ENABLE_CTRE_SELF_TEST "build self tests" OFF)
32+
33+
if(ENABLE_CTRE_SELF_TEST)
34+
add_subdirectory(tests)
35+
endif()

tests/CMakeLists.txt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
file(GLOB ctre_self_tests *.cpp)
2+
3+
add_custom_target(ctre_self_test)
4+
5+
foreach(ctre_self_test_file ${ctre_self_tests})
6+
get_filename_component(ctre_self_test_name ${ctre_self_test_file} NAME)
7+
message(STATUS ${ctre_self_test_name})
8+
9+
add_library(ctre_self_test_${ctre_self_test_name} STATIC ${ctre_self_test_name})
10+
target_link_libraries(ctre_self_test_${ctre_self_test_name} ctre)
11+
target_compile_features(ctre_self_test_${ctre_self_test_name} PRIVATE cxx_std_17)
12+
13+
add_dependencies(ctre_self_test ctre_self_test_${ctre_self_test_name})
14+
endforeach()

tests/_fixed-string.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include <ctll/fixed_string.hpp>
22

3+
void empty_symbol() { }
4+
35
static constexpr auto Pattern = ctll::basic_fixed_string{ LR"(^\s*(\d+)\s+:(\S):$(\S+?)$(\S+?)$(\S+))" };
46

57
static_assert(Pattern.size() == 38);

tests/_unicode.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include <ctre.hpp>
22
#include <string_view>
33

4+
void empty_symbol() { }
5+
46
template <typename T> struct identify;
57
template <size_t N> struct number_id;
68

tests/generating.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#include <ctre.hpp>
22

3+
void empty_symbol() { }
4+
35
template <typename... T> struct id_type;
46

57
using namespace ctre::test_literals;

tests/many-of-same-proto.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include <ctre.hpp>
22
using namespace ctre::test_literals;
33

4+
void empty_symbol() { }
5+
46
#if !__cpp_nontype_template_parameter_class
57
#define CTRE_TEST(pattern) static_assert(pattern ## _ctre_test)
68
#else

tests/matching.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include <ctre.hpp>
22
#include <string_view>
33

4+
void empty_symbol() { }
5+
46
template <typename Pattern> constexpr bool match(std::string_view input, Pattern pattern) {
57
return bool(ctre::match_re(input.begin(), input.end(), pattern));
68
}

tests/matching2-msvc-greedy.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
#include <ctre.hpp>
44
#include <string_view>
55

6+
void empty_symbol() { }
7+
68
#if !__cpp_nontype_template_parameter_class
79
#define CTRE_CREATE(pattern) (pattern ## _ctre)
810
#define CTRE_SYNTAX(pattern) (pattern ## _ctre_syntax)

tests/matching2.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#include <ctre.hpp>
22
#include <string_view>
33

4+
void empty_symbol() { }
5+
46
#if !__cpp_nontype_template_parameter_class
57
#define CTRE_CREATE(pattern) (pattern ## _ctre)
68
#define CTRE_SYNTAX(pattern) (pattern ## _ctre_syntax)

0 commit comments

Comments
 (0)