Skip to content

Commit 1aa3088

Browse files
committed
Include and patch boost UT with FetchContent
1 parent 4d6e195 commit 1aa3088

File tree

4 files changed

+258
-11
lines changed

4 files changed

+258
-11
lines changed

oup.sublime-project

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@
5757
"name": "oup_runtime_tests_run",
5858
"shell_cmd": "make -j12 oup_runtime_tests_run",
5959
},
60+
{
61+
"name": "style",
62+
"shell_cmd": "make -j12 style",
63+
},
6064
{
6165
"name": "oup_runtime_tests",
6266
"shell_cmd": "make -j12 oup_runtime_tests",
@@ -69,10 +73,6 @@
6973
"name": "oup_speed_benchmark",
7074
"shell_cmd": "make -j12 oup_speed_benchmark",
7175
},
72-
{
73-
"name": "snatch",
74-
"shell_cmd": "make -j12 snatch",
75-
},
7676
],
7777
"working_dir": "$folder/build",
7878
}

tests/CMakeLists.txt

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,12 @@ endfunction()
3131

3232
include(FetchContent)
3333

34-
FetchContent_Declare(snatch
35-
GIT_REPOSITORY https://github.com/cschreib/snatch.git
36-
GIT_TAG v0.1.3)
37-
FetchContent_MakeAvailable(snatch)
34+
FetchContent_Declare(boost_ut
35+
GIT_REPOSITORY https://github.com/boost-ext/ut.git
36+
GIT_TAG v1.1.9
37+
UPDATE_COMMAND git checkout .
38+
PATCH_COMMAND git apply ${PROJECT_SOURCE_DIR}/tests/boost_ut_fix.patch)
39+
FetchContent_MakeAvailable(boost_ut)
3840

3941
set(RUNTIME_TEST_FILES
4042
${PROJECT_SOURCE_DIR}/tests/testing.cpp
@@ -62,8 +64,7 @@ set(RUNTIME_TEST_FILES
6264

6365
add_executable(oup_runtime_tests ${RUNTIME_TEST_FILES})
6466
target_link_libraries(oup_runtime_tests PRIVATE oup::oup)
65-
# target_link_libraries(oup_runtime_tests PRIVATE snatch::snatch)
66-
target_include_directories(oup_runtime_tests PRIVATE "/home/cschreib/programming/ut/include")
67+
target_link_libraries(oup_runtime_tests PRIVATE Boost::ut)
6768
add_platform_definitions(oup_runtime_tests)
6869

6970
add_custom_target(oup_runtime_tests_run

tests/boost_ut_fix.patch

Lines changed: 247 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,247 @@
1+
diff --git a/CMakeLists.txt b/CMakeLists.txt
2+
index b9e94ab..bd6bb6a 100644
3+
--- a/CMakeLists.txt
4+
+++ b/CMakeLists.txt
5+
@@ -61,61 +61,61 @@ else()
6+
target_compile_features(ut INTERFACE cxx_std_17)
7+
endif()
8+
9+
-if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
10+
- if(WIN32) # clang-cl
11+
- # FIXME: we should not export this pedantic options! CK
12+
- target_compile_options(
13+
- ut
14+
- INTERFACE -Wall
15+
- -Wextra
16+
- # FIXME -Werror
17+
- -Wno-c++98-c++11-c++14-c++17-compat-pedantic
18+
- -Wno-c++98-c++11-compat
19+
- -Wno-c++98-compat
20+
- -Wno-c++98-compat-pedantic
21+
- -Wno-c99-extensions
22+
- -Wno-pedantic
23+
- )
24+
- else()
25+
- add_compile_options(-Wall -Wextra -Wpedantic -Werror)
26+
- endif()
27+
-elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
28+
- # FIXME: we should not export this pedantic options! CK
29+
- target_compile_options(
30+
- ut
31+
- INTERFACE -Wall
32+
- -Wextra
33+
- # TODO: why not simpply -Wpedantic
34+
- -Werror
35+
- -Wcast-align
36+
- #-Wcast-align=strict
37+
- -Wcast-qual
38+
- -Wdouble-promotion
39+
- -Wduplicated-branches
40+
- -Wduplicated-cond
41+
- -Wlogical-op
42+
- -Wmissing-declarations
43+
- -Wmissing-include-dirs
44+
- -Wnull-dereference
45+
- -Wold-style-cast
46+
- -Wpointer-arith
47+
- -Wredundant-decls
48+
- -Wsign-conversion
49+
- -Wswitch-enum
50+
- -Wtrampolines
51+
- -Wunused-but-set-variable
52+
- -Wunused-result
53+
- -Wuseless-cast
54+
- -Wzero-as-null-pointer-constant
55+
- # FIXME
56+
- -Wno-undef
57+
- -Wno-missing-declarations
58+
- -Wno-sign-conversion
59+
- -Wno-float-equal
60+
- )
61+
-elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
62+
- add_compile_options(/W4 /WX)
63+
-endif()
64+
+# if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang")
65+
+# if(WIN32) # clang-cl
66+
+# # FIXME: we should not export this pedantic options! CK
67+
+# target_compile_options(
68+
+# ut
69+
+# INTERFACE -Wall
70+
+# -Wextra
71+
+# # FIXME -Werror
72+
+# -Wno-c++98-c++11-c++14-c++17-compat-pedantic
73+
+# -Wno-c++98-c++11-compat
74+
+# -Wno-c++98-compat
75+
+# -Wno-c++98-compat-pedantic
76+
+# -Wno-c99-extensions
77+
+# -Wno-pedantic
78+
+# )
79+
+# else()
80+
+# add_compile_options(-Wall -Wextra -Wpedantic -Werror)
81+
+# endif()
82+
+# elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU")
83+
+# # FIXME: we should not export this pedantic options! CK
84+
+# target_compile_options(
85+
+# ut
86+
+# INTERFACE -Wall
87+
+# -Wextra
88+
+# # TODO: why not simpply -Wpedantic
89+
+# -Werror
90+
+# -Wcast-align
91+
+# #-Wcast-align=strict
92+
+# -Wcast-qual
93+
+# -Wdouble-promotion
94+
+# -Wduplicated-branches
95+
+# -Wduplicated-cond
96+
+# -Wlogical-op
97+
+# -Wmissing-declarations
98+
+# -Wmissing-include-dirs
99+
+# -Wnull-dereference
100+
+# -Wold-style-cast
101+
+# -Wpointer-arith
102+
+# -Wredundant-decls
103+
+# -Wsign-conversion
104+
+# -Wswitch-enum
105+
+# -Wtrampolines
106+
+# -Wunused-but-set-variable
107+
+# -Wunused-result
108+
+# -Wuseless-cast
109+
+# -Wzero-as-null-pointer-constant
110+
+# # FIXME
111+
+# -Wno-undef
112+
+# -Wno-missing-declarations
113+
+# -Wno-sign-conversion
114+
+# -Wno-float-equal
115+
+# )
116+
+# elseif("${CMAKE_CXX_COMPILER_ID}" STREQUAL "MSVC")
117+
+# add_compile_options(/W4 /WX)
118+
+# endif()
119+
120+
add_custom_target(style)
121+
add_custom_command(
122+
diff --git a/include/boost/ut.hpp b/include/boost/ut.hpp
123+
index 47faa56..5abb44c 100644
124+
--- a/include/boost/ut.hpp
125+
+++ b/include/boost/ut.hpp
126+
@@ -671,8 +671,8 @@ struct eq_ : op {
127+
[[nodiscard]] constexpr auto lhs() const { return get(lhs_); }
128+
[[nodiscard]] constexpr auto rhs() const { return get(rhs_); }
129+
130+
- const TLhs lhs_{};
131+
- const TRhs rhs_{};
132+
+ const TLhs& lhs_{};
133+
+ const TRhs& rhs_{};
134+
const bool value_{};
135+
};
136+
137+
@@ -704,8 +704,8 @@ struct neq_ : op {
138+
[[nodiscard]] constexpr auto lhs() const { return get(lhs_); }
139+
[[nodiscard]] constexpr auto rhs() const { return get(rhs_); }
140+
141+
- const TLhs lhs_{};
142+
- const TRhs rhs_{};
143+
+ const TLhs& lhs_{};
144+
+ const TRhs& rhs_{};
145+
const bool value_{};
146+
};
147+
148+
@@ -727,8 +727,8 @@ struct gt_ : op {
149+
[[nodiscard]] constexpr auto lhs() const { return get(lhs_); }
150+
[[nodiscard]] constexpr auto rhs() const { return get(rhs_); }
151+
152+
- const TLhs lhs_{};
153+
- const TRhs rhs_{};
154+
+ const TLhs& lhs_{};
155+
+ const TRhs& rhs_{};
156+
const bool value_{};
157+
};
158+
159+
@@ -750,8 +750,8 @@ struct ge_ : op {
160+
[[nodiscard]] constexpr auto lhs() const { return get(lhs_); }
161+
[[nodiscard]] constexpr auto rhs() const { return get(rhs_); }
162+
163+
- const TLhs lhs_{};
164+
- const TRhs rhs_{};
165+
+ const TLhs& lhs_{};
166+
+ const TRhs& rhs_{};
167+
const bool value_{};
168+
};
169+
170+
@@ -774,8 +774,8 @@ struct lt_ : op {
171+
[[nodiscard]] constexpr auto rhs() const { return get(rhs_); }
172+
173+
private:
174+
- const TLhs lhs_{};
175+
- const TRhs rhs_{};
176+
+ const TLhs& lhs_{};
177+
+ const TRhs& rhs_{};
178+
const bool value_{};
179+
};
180+
181+
@@ -797,8 +797,8 @@ struct le_ : op {
182+
[[nodiscard]] constexpr auto lhs() const { return get(lhs_); }
183+
[[nodiscard]] constexpr auto rhs() const { return get(rhs_); }
184+
185+
- const TLhs lhs_{};
186+
- const TRhs rhs_{};
187+
+ const TLhs& lhs_{};
188+
+ const TRhs& rhs_{};
189+
const bool value_{};
190+
};
191+
192+
@@ -813,8 +813,8 @@ struct and_ : op {
193+
[[nodiscard]] constexpr auto lhs() const { return get(lhs_); }
194+
[[nodiscard]] constexpr auto rhs() const { return get(rhs_); }
195+
196+
- const TLhs lhs_{};
197+
- const TRhs rhs_{};
198+
+ const TLhs& lhs_{};
199+
+ const TRhs& rhs_{};
200+
const bool value_{};
201+
};
202+
203+
@@ -829,8 +829,8 @@ struct or_ : op {
204+
[[nodiscard]] constexpr auto lhs() const { return get(lhs_); }
205+
[[nodiscard]] constexpr auto rhs() const { return get(rhs_); }
206+
207+
- const TLhs lhs_{};
208+
- const TRhs rhs_{};
209+
+ const TLhs& lhs_{};
210+
+ const TRhs& rhs_{};
211+
const bool value_{};
212+
};
213+
214+
@@ -1532,7 +1532,7 @@ struct that_ {
215+
return static_cast<bool>(t_);
216+
}
217+
218+
- const T t_{};
219+
+ const T& t_{};
220+
};
221+
222+
template <class T>
223+
@@ -1846,19 +1846,19 @@ template <class F, class T,
224+
template <
225+
class F, template <class...> class T, class... Ts,
226+
type_traits::requires_t<not type_traits::is_container_v<T<Ts...>>> = 0>
227+
-[[nodiscard]] constexpr auto operator|(const F& f, const T<Ts...>& t) {
228+
- return [f, t](const auto name) {
229+
+[[nodiscard]] constexpr auto operator|(const F& f, T<Ts...>&& t) {
230+
+ return [f, &t](const auto name) {
231+
apply(
232+
- [f, name](const auto&... args) {
233+
+ [f, name](auto&&... args) {
234+
(detail::on<F>(events::test<F, Ts>{.type = "test",
235+
.name = name,
236+
.tag = {},
237+
.location = {},
238+
- .arg = args,
239+
+ .arg = std::move(args),
240+
.run = f}),
241+
...);
242+
},
243+
- t);
244+
+ std::move(t));
245+
};
246+
}
247+

tests/testing.hpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// #include "snatch/snatch.hpp"
21
#include "boost/ut.hpp"
32

43
using namespace boost::ut;

0 commit comments

Comments
 (0)