Skip to content

Commit 70870b3

Browse files
authored
remove code coverage from cmake (#4)
1 parent 2273e03 commit 70870b3

File tree

2 files changed

+46
-4
lines changed

2 files changed

+46
-4
lines changed

test/CMakeLists.txt

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,23 @@ set(CMAKE_CXX_STANDARD 17)
66
add_executable(tests test_meta.cpp test_builder_meta.cpp test_callback.cpp test_nexus.cpp)
77

88
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
9-
target_compile_options(tests PRIVATE -ftemplate-backtrace-limit=0 -ferror-limit=2)
9+
target_compile_options(tests
10+
PRIVATE
11+
-ftemplate-backtrace-limit=0
12+
-ferror-limit=2
13+
)
14+
1015
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
11-
target_compile_options(tests PRIVATE -ftemplate-backtrace-limit=0 -fmax-errors=2)
16+
target_compile_options(tests
17+
PRIVATE
18+
-ftemplate-backtrace-limit=0
19+
-fmax-errors=2
20+
)
1221
endif()
1322

1423
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain Cib)
1524

1625
list(APPEND CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/lib/Catch2/extras)
1726
include(CTest)
1827
include(Catch)
19-
catch_discover_tests(tests)
28+
catch_discover_tests(tests)

test/test_nexus.cpp

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ TEST_CASE("an empty configuration should compile and initialize") {
1414
}
1515

1616

17+
1718
template<int Id>
1819
static bool is_callback_invoked = false;
1920

@@ -223,7 +224,7 @@ TEST_CASE("configuration with conditional features") {
223224
is_callback_invoked<1> = false;
224225
is_callback_invoked<2> = false;
225226

226-
SECTION("services can be invoked directly from nexus") {
227+
SECTION("component 0 is enabled") {
227228
cib::nexus<ConditionalConfig<0>> nexus{};
228229

229230
REQUIRE_FALSE(is_callback_invoked<0>);
@@ -238,4 +239,36 @@ TEST_CASE("configuration with conditional features") {
238239
nexus.builder<TestCallback<2>>();
239240
REQUIRE_FALSE(is_callback_invoked<2>);
240241
}
242+
243+
SECTION("component 1 is enabled") {
244+
cib::nexus<ConditionalConfig<1>> nexus{};
245+
246+
REQUIRE_FALSE(is_callback_invoked<0>);
247+
nexus.builder<TestCallback<0>>();
248+
REQUIRE_FALSE(is_callback_invoked<0>);
249+
250+
REQUIRE_FALSE(is_callback_invoked<1>);
251+
nexus.builder<TestCallback<1>>();
252+
REQUIRE(is_callback_invoked<1>);
253+
254+
REQUIRE_FALSE(is_callback_invoked<2>);
255+
nexus.builder<TestCallback<2>>();
256+
REQUIRE_FALSE(is_callback_invoked<2>);
257+
}
258+
259+
SECTION("component 2 is enabled") {
260+
cib::nexus<ConditionalConfig<2>> nexus{};
261+
262+
REQUIRE_FALSE(is_callback_invoked<0>);
263+
nexus.builder<TestCallback<0>>();
264+
REQUIRE_FALSE(is_callback_invoked<0>);
265+
266+
REQUIRE_FALSE(is_callback_invoked<1>);
267+
nexus.builder<TestCallback<1>>();
268+
REQUIRE_FALSE(is_callback_invoked<1>);
269+
270+
REQUIRE_FALSE(is_callback_invoked<2>);
271+
nexus.builder<TestCallback<2>>();
272+
REQUIRE(is_callback_invoked<2>);
273+
}
241274
}

0 commit comments

Comments
 (0)