From c578cf582160f8ac17a2bd41d66d249c70e09349 Mon Sep 17 00:00:00 2001 From: dnkpp Date: Tue, 4 Mar 2025 14:45:36 +0100 Subject: [PATCH 01/15] feat: add MIMICPP_ASSERT macro --- include/mimic++/config/Config.hpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/include/mimic++/config/Config.hpp b/include/mimic++/config/Config.hpp index 8b83cb13b..7a923782d 100644 --- a/include/mimic++/config/Config.hpp +++ b/include/mimic++/config/Config.hpp @@ -39,4 +39,8 @@ #endif #endif +#ifndef MIMICPP_ASSERT + #define MIMICPP_ASSERT(condition, msg) (void(0)) +#endif + #endif From 4d867eab13f63dcbd08803f35155e9f35f97f292 Mon Sep 17 00:00:00 2001 From: dnkpp Date: Tue, 4 Mar 2025 14:54:58 +0100 Subject: [PATCH 02/15] deps: add eremy-rifkin/libassert v2.1.5 --- cmake/Findlibassert.cmake | 8 ++++++++ test/unit-tests/CMakeLists.txt | 9 +++++++++ 2 files changed, 17 insertions(+) create mode 100644 cmake/Findlibassert.cmake diff --git a/cmake/Findlibassert.cmake b/cmake/Findlibassert.cmake new file mode 100644 index 000000000..46298e76a --- /dev/null +++ b/cmake/Findlibassert.cmake @@ -0,0 +1,8 @@ +# Copyright Dominic (DNKpp) Koepke 2024 - 2025. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +include(get_cpm) + +CPMAddPackage("gh:jeremy-rifkin/libassert@2.1.5") diff --git a/test/unit-tests/CMakeLists.txt b/test/unit-tests/CMakeLists.txt index 4f91c9a01..fec65a652 100644 --- a/test/unit-tests/CMakeLists.txt +++ b/test/unit-tests/CMakeLists.txt @@ -39,6 +39,12 @@ target_compile_options(${TARGET_NAME} # some test files exceed some limits # see: https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/fatal-error-c1128?view=msvc-170 "$<$:/bigobj>" + "$<$:/Zc:__cplusplus>" +) + +target_compile_definitions(${TARGET_NAME} + PUBLIC + "LIBASSERT_BREAK_ON_FAIL" ) include(EnableAdditionalTestFlags) @@ -46,6 +52,7 @@ include(EnableWarnings) include(LinkStdStacktrace) find_package(Catch2 REQUIRED) find_package(trompeloeil REQUIRED) +find_package(libassert REQUIRED) target_link_libraries(${TARGET_NAME} PRIVATE mimicpp::mimicpp @@ -54,10 +61,12 @@ target_link_libraries(${TARGET_NAME} mimicpp::internal::link-std-stacktrace Catch2::Catch2WithMain trompeloeil::trompeloeil + libassert::assert ) target_precompile_headers(${TARGET_NAME} PRIVATE + "../TestAssert.hpp" ) From 39da6e58434e18e14a3b526462a399eb20c0c068 Mon Sep 17 00:00:00 2001 From: dnkpp Date: Tue, 4 Mar 2025 14:55:30 +0100 Subject: [PATCH 03/15] chore: add special MIMICPP_ASSERT definition for testing --- test/TestAssert.hpp | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 test/TestAssert.hpp diff --git a/test/TestAssert.hpp b/test/TestAssert.hpp new file mode 100644 index 000000000..1dda104d2 --- /dev/null +++ b/test/TestAssert.hpp @@ -0,0 +1,10 @@ +// Copyright Dominic (DNKpp) Koepke 2024 - 2025. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#pragma once + +#include + +#define MIMICPP_ASSERT(condition, msg) ASSERT(condition, msg) From 28b0ab710238acc41d9a5f9d166c007145f4d98d Mon Sep 17 00:00:00 2001 From: dnkpp Date: Tue, 4 Mar 2025 15:15:51 +0100 Subject: [PATCH 04/15] refactor: replace assert usages with MIMICPP_ASSERT --- include/mimic++/Expectation.hpp | 17 ++++++------ include/mimic++/ExpectationBuilder.hpp | 4 ++- include/mimic++/Mock.hpp | 3 ++- include/mimic++/Sequence.hpp | 26 +++++++++---------- include/mimic++/Stacktrace.hpp | 4 +-- include/mimic++/policies/ControlPolicies.hpp | 4 +-- include/mimic++/policies/GeneralPolicies.hpp | 6 ++--- .../mimic++/printing/type/PostProcessing.hpp | 25 +++++++++--------- include/mimic++/printing/type/Templated.hpp | 3 ++- include/mimic++/reporting/DefaultReporter.hpp | 5 ++-- .../mimic++/reporting/StringifyReports.hpp | 14 +++++----- include/mimic++/reporting/TypeReport.hpp | 4 +-- include/mimic++/utilities/Algorithm.hpp | 7 ++--- include/mimic++/utilities/C++23Backports.hpp | 3 +-- 14 files changed, 63 insertions(+), 62 deletions(-) diff --git a/include/mimic++/Expectation.hpp b/include/mimic++/Expectation.hpp index 55621aed0..38d1d5981 100644 --- a/include/mimic++/Expectation.hpp +++ b/include/mimic++/Expectation.hpp @@ -9,8 +9,10 @@ #pragma once #include "mimic++/Call.hpp" +#include "mimic++/Fwd.hpp" #include "mimic++/Sequence.hpp" #include "mimic++/TypeTraits.hpp" +#include "mimic++/config/Config.hpp" #include "mimic++/reporting/CallReport.hpp" #include "mimic++/reporting/ExpectationReport.hpp" #include "mimic++/reporting/GlobalReporter.hpp" @@ -18,7 +20,6 @@ #include "mimic++/utilities/SourceLocation.hpp" #include -#include #include #include #include @@ -307,9 +308,7 @@ namespace mimicpp { const std::scoped_lock lock{m_ExpectationsMx}; - assert( - std::ranges::find(m_Expectations, expectation) == std::ranges::end(m_Expectations) - && "Expectation already belongs to this storage."); + MIMICPP_ASSERT(std::ranges::find(m_Expectations, expectation) == std::ranges::end(m_Expectations), "Expectation already belongs to this storage."); m_Expectations.emplace_back(std::move(expectation)); } @@ -326,7 +325,7 @@ namespace mimicpp const std::scoped_lock lock{m_ExpectationsMx}; auto iter = std::ranges::find(m_Expectations, expectation); - assert(iter != std::ranges::end(m_Expectations) && "Expectation does not belong to this storage."); + MIMICPP_ASSERT(iter != std::ranges::end(m_Expectations), "Expectation does not belong to this storage."); m_Expectations.erase(iter); if (!expectation->is_satisfied()) @@ -359,9 +358,9 @@ namespace mimicpp if (!std::ranges::empty(matches)) { std::vector reports = detail::gather_expectation_reports(matches); - assert(matches.size() == reports.size() && "Size mismatch."); + MIMICPP_ASSERT(matches.size() == reports.size(), "Size mismatch."); auto const bestIndex = detail::find_best_match(reports); - assert(0 <= bestIndex && bestIndex < std::ssize(reports) && "Invalid index."); + MIMICPP_ASSERT(0 <= bestIndex && bestIndex < std::ssize(reports), "Invalid index."); auto& report = reports[bestIndex]; auto& expectation = *matches[bestIndex]; @@ -679,8 +678,8 @@ namespace mimicpp : m_Storage{std::move(storage)}, m_Expectation{std::move(expectation)} { - assert(m_Storage && "Storage is nullptr."); - assert(m_Expectation && "Expectation is nullptr."); + MIMICPP_ASSERT(m_Storage, "Storage is nullptr."); + MIMICPP_ASSERT(m_Expectation, "Expectation is nullptr."); m_Storage->push(m_Expectation); } diff --git a/include/mimic++/ExpectationBuilder.hpp b/include/mimic++/ExpectationBuilder.hpp index dd58e051f..6c36ac60c 100644 --- a/include/mimic++/ExpectationBuilder.hpp +++ b/include/mimic++/ExpectationBuilder.hpp @@ -9,7 +9,9 @@ #pragma once #include "mimic++/Expectation.hpp" +#include "mimic++/Fwd.hpp" #include "mimic++/Sequence.hpp" +#include "mimic++/config/Config.hpp" #include "mimic++/matchers/Common.hpp" #include "mimic++/matchers/GeneralMatchers.hpp" #include "mimic++/matchers/StringMatchers.hpp" @@ -55,7 +57,7 @@ namespace mimicpp m_FinalizePolicy{std::forward(finalizePolicyArg)}, m_ExpectationPolicies{std::forward(policyListArg)} { - assert(m_Storage && "Storage is nullptr."); + MIMICPP_ASSERT(m_Storage, "Storage is nullptr."); } BasicExpectationBuilder(const BasicExpectationBuilder&) = delete; diff --git a/include/mimic++/Mock.hpp b/include/mimic++/Mock.hpp index 5df978c8b..5a837efcc 100644 --- a/include/mimic++/Mock.hpp +++ b/include/mimic++/Mock.hpp @@ -14,6 +14,7 @@ #include "mimic++/Fwd.hpp" #include "mimic++/Stacktrace.hpp" #include "mimic++/TypeTraits.hpp" +#include "mimic++/config/Config.hpp" #include "mimic++/policies/GeneralPolicies.hpp" #include "mimic++/printing/TypePrinter.hpp" #include "mimic++/reporting/TargetReport.hpp" @@ -317,7 +318,7 @@ namespace mimicpp::detail : m_Expectations{std::move(collection)}, m_Settings{std::move(settings)} { - assert(m_Settings.name && "Empty mock-name."); + MIMICPP_ASSERT(m_Settings.name, "Empty mock-name."); m_Settings.stacktraceSkip += 2u; // skips the operator() and the handle_call from the stacktrace } diff --git a/include/mimic++/Sequence.hpp b/include/mimic++/Sequence.hpp index c53d37fb0..5d9dc7632 100644 --- a/include/mimic++/Sequence.hpp +++ b/include/mimic++/Sequence.hpp @@ -9,13 +9,13 @@ #pragma once #include "mimic++/Fwd.hpp" +#include "mimic++/config/Config.hpp" #include "mimic++/printing/Format.hpp" #include "mimic++/reporting/GlobalReporter.hpp" #include "mimic++/utilities/C++23Backports.hpp" #include #include -#include #include #include #include @@ -118,7 +118,7 @@ namespace mimicpp::sequence [[nodiscard]] constexpr std::optional priority_of(const IdT id) const noexcept { - assert(is_valid(id)); + MIMICPP_ASSERT(is_valid(id), "Invalid id given."); if (is_consumable(id)) { @@ -133,31 +133,29 @@ namespace mimicpp::sequence constexpr void set_satisfied(const IdT id) noexcept { - assert(is_valid(id)); - assert(m_Cursor <= util::to_underlying(id)); + MIMICPP_ASSERT(is_valid(id), "Invalid id given."); + MIMICPP_ASSERT(m_Cursor <= util::to_underlying(id), "Invalid state."); auto& element = m_Entries[util::to_underlying(id)]; - assert(element == State::unsatisfied); + MIMICPP_ASSERT(element == State::unsatisfied, "Element is in unexpected state."); element = State::satisfied; } constexpr void set_saturated(const IdT id) noexcept { - assert(is_valid(id)); + MIMICPP_ASSERT(is_valid(id), "Invalid id given."); const auto index = util::to_underlying(id); - assert(m_Cursor <= index); + MIMICPP_ASSERT(m_Cursor <= index, "Invalid state."); auto& element = m_Entries[index]; - assert( - element == State::unsatisfied - || element == State::satisfied); + MIMICPP_ASSERT(element == State::unsatisfied || element == State::satisfied, "Element is in unexpected state."); element = State::saturated; } [[nodiscard]] constexpr bool is_consumable(const IdT id) const noexcept { - assert(is_valid(id)); + MIMICPP_ASSERT(is_valid(id), "Invalid id given."); const int index = util::to_underlying(id); const auto state = m_Entries[index]; @@ -175,7 +173,7 @@ namespace mimicpp::sequence constexpr void consume(const IdT id) noexcept { - assert(is_consumable(id)); + MIMICPP_ASSERT(is_consumable(id), "Sequence is not in consumable state."); m_Cursor = util::to_underlying(id); } @@ -227,7 +225,7 @@ namespace mimicpp::sequence constexpr int operator()(const auto id, const int cursor) const noexcept { const auto index = util::to_underlying(id); - assert(std::cmp_less_equal(cursor, index)); + MIMICPP_ASSERT(std::cmp_less_equal(cursor, index), "Invalid state."); return std::numeric_limits::max() - (static_cast(index) - cursor); @@ -241,7 +239,7 @@ namespace mimicpp::sequence constexpr int operator()(const auto id, const int cursor) const noexcept { const auto index = util::to_underlying(id); - assert(std::cmp_less_equal(cursor, index)); + MIMICPP_ASSERT(std::cmp_less_equal(cursor, index), "Invalid state."); return static_cast(index) - cursor; } diff --git a/include/mimic++/Stacktrace.hpp b/include/mimic++/Stacktrace.hpp index d1c78c4fd..b2ab3d04e 100644 --- a/include/mimic++/Stacktrace.hpp +++ b/include/mimic++/Stacktrace.hpp @@ -9,6 +9,7 @@ #pragma once #include "mimic++/Fwd.hpp" +#include "mimic++/config/Config.hpp" #include "mimic++/printing/PathPrinter.hpp" #include "mimic++/printing/StatePrinter.hpp" #include "mimic++/utilities/AlwaysFalse.hpp" @@ -16,7 +17,6 @@ #include #include -#include // ReSharper disable once CppUnusedIncludeDirective #include // std::invoke #include @@ -381,7 +381,7 @@ namespace mimicpp::stacktrace::detail template OutIter print_entry(OutIter out, Stacktrace const& stacktrace, std::size_t const index) { - assert(index < stacktrace.size() && "Index out of bounds."); + MIMICPP_ASSERT(index < stacktrace.size(), "Index out of bounds."); out = format::format_to(std::move(out), "`"); out = print_path(std::move(out), stacktrace.source_file(index)); diff --git a/include/mimic++/policies/ControlPolicies.hpp b/include/mimic++/policies/ControlPolicies.hpp index 4568467e0..b4b47656b 100644 --- a/include/mimic++/policies/ControlPolicies.hpp +++ b/include/mimic++/policies/ControlPolicies.hpp @@ -10,9 +10,9 @@ #include "mimic++/Fwd.hpp" #include "mimic++/Sequence.hpp" +#include "mimic++/config/Config.hpp" #include "mimic++/reporting/ExpectationReport.hpp" -#include #include #include #include @@ -195,7 +195,7 @@ namespace mimicpp constexpr void consume() noexcept { - assert(is_applicable()); + MIMICPP_ASSERT(is_applicable(), "Policy is inapplicable."); std::apply( [](auto&... entries) noexcept { diff --git a/include/mimic++/policies/GeneralPolicies.hpp b/include/mimic++/policies/GeneralPolicies.hpp index 072a99afb..03225474e 100644 --- a/include/mimic++/policies/GeneralPolicies.hpp +++ b/include/mimic++/policies/GeneralPolicies.hpp @@ -9,9 +9,9 @@ #pragma once #include "mimic++/Fwd.hpp" +#include "mimic++/config/Config.hpp" #include "mimic++/printing/StatePrinter.hpp" -#include #include namespace mimicpp::detail @@ -58,7 +58,7 @@ namespace mimicpp::expectation_policies template static constexpr void consume([[maybe_unused]] const call::Info& info) noexcept { - assert(mimicpp::detail::is_matching(info.fromCategory, expected) && "Call does not match."); + MIMICPP_ASSERT(mimicpp::detail::is_matching(info.fromCategory, expected), "Call does not match."); } [[nodiscard]] @@ -91,7 +91,7 @@ namespace mimicpp::expectation_policies template static constexpr void consume([[maybe_unused]] const call::Info& info) noexcept { - assert(mimicpp::detail::is_matching(info.fromConstness, constness) && "Call does not match."); + MIMICPP_ASSERT(mimicpp::detail::is_matching(info.fromConstness, constness), "Call does not match."); } [[nodiscard]] diff --git a/include/mimic++/printing/type/PostProcessing.hpp b/include/mimic++/printing/type/PostProcessing.hpp index 4f1b910d0..c096fe732 100644 --- a/include/mimic++/printing/type/PostProcessing.hpp +++ b/include/mimic++/printing/type/PostProcessing.hpp @@ -14,7 +14,6 @@ #include "mimic++/utilities/Algorithm.hpp" #include -#include #include #include #include @@ -80,8 +79,8 @@ namespace mimicpp::printing::type::detail auto const& prefixMatches, auto const& suffixMatches) { - assert(prefixMatches.size() == 2 && "Regex out-of-sync."); - assert(suffixMatches.size() == 1 && "Regex out-of-sync."); + MIMICPP_ASSERT(prefixMatches.size() == 2, "Regex out-of-sync."); + MIMICPP_ASSERT(suffixMatches.size() == 1, "Regex out-of-sync."); StringViewT const functionName{prefixMatches[1].first, prefixMatches[1].second}; StringViewT const prefix{prefixMatches[0].first, prefixMatches[0].second}; @@ -103,7 +102,7 @@ namespace mimicpp::printing::type::detail | std::views::reverse | std::views::drop(templateScopeSuffix.size()); auto const iter = util::find_closing_token(reversedName, '>', '<'); - assert(iter != reversedName.end() && "No template begin found."); + MIMICPP_ASSERT(iter != reversedName.end(), "No template begin found."); out = format::format_to( std::move(out), "{}::", @@ -125,17 +124,17 @@ namespace mimicpp::printing::type::detail StringViewT const prefix, StringViewT const scope) { - assert(scope.data() == prefix.data() && "Prefix and scope must be aligned."); + MIMICPP_ASSERT(scope.data() == prefix.data(), "Prefix and scope must be aligned."); StringViewT rest{prefix.data() + prefix.size(), scope.data() + scope.size()}; auto const closingIter = util::find_closing_token(rest, '(', ')'); - assert(closingIter != rest.cend() && "No corresponding closing-token found."); + MIMICPP_ASSERT(closingIter != rest.cend(), "No corresponding closing-token found."); SVMatchT suffixMatches{}; rest = StringViewT{closingIter, rest.cend()}; std::regex_search(rest.cbegin(), rest.cend(), suffixMatches, suffixRegex); - assert(!suffixMatches.empty() && "No function suffix found."); - assert(suffixMatches.size() == 2 && "Regex out-of-sync."); + MIMICPP_ASSERT(!suffixMatches.empty(), "No function suffix found."); + MIMICPP_ASSERT(suffixMatches.size() == 2, "Regex out-of-sync."); StringViewT const suffix{suffixMatches[0].first, suffixMatches[0].second}; out = std::ranges::copy(StringViewT{"lambda#"}, std::move(out)).out; @@ -229,7 +228,7 @@ namespace mimicpp::printing::type::detail StringViewT const rest{scope.cbegin(), matches[0].first}; SVMatchT prefixMatches{}; std::regex_search(rest.cbegin(), rest.cend(), prefixMatches, functionScopePrefix); - assert(!prefixMatches.empty() && "No corresponding function prefix found."); + MIMICPP_ASSERT(!prefixMatches.empty(), "No corresponding function prefix found."); std::size_t count{}; std::tie(out, count) = prettify_function_scope( @@ -337,7 +336,7 @@ namespace mimicpp::printing::type::detail StringViewT const rest{scope.cbegin(), matches[0].first}; SVMatchT prefixMatches{}; std::regex_search(rest.cbegin(), rest.cend(), prefixMatches, functionScopePrefix); - assert(!prefixMatches.empty() && "No corresponding function prefix found."); + MIMICPP_ASSERT(!prefixMatches.empty(), "No corresponding function prefix found."); std::size_t count{}; std::tie(out, count) = prettify_function_scope( @@ -449,7 +448,7 @@ namespace mimicpp::printing::type::detail | std::views::reverse | std::views::drop(1); auto const iter = util::find_closing_token(reversedName, '>', '<'); - assert(iter != reversedName.end() && "No template begin found."); + MIMICPP_ASSERT(iter != reversedName.end(), "No template begin found."); std::tuple info{ "<", StringT{iter.base(), name.end() - 1}, @@ -473,7 +472,7 @@ namespace mimicpp::printing::type::detail | std::views::reverse | std::views::drop(matches[0].length()); auto const iter = util::find_closing_token(reversedName, '}', '{'); - assert(iter != reversedName.end() && "No lambda begin found."); + MIMICPP_ASSERT(iter != reversedName.end(), "No lambda begin found."); std::tuple info{ format::format("lambda#{}", StringViewT{matches[1].first, matches[1].second}), @@ -501,7 +500,7 @@ namespace mimicpp::printing::type::detail | std::views::reverse | std::views::drop(matches[0].length()); auto const iter = util::find_closing_token(reversedName, ')', '('); - assert(iter != reversedName.end() && "No function begin found."); + MIMICPP_ASSERT(iter != reversedName.end(), "No function begin found."); StringViewT const argList{iter.base(), name.end() - matches[0].length()}; std::tuple info{ diff --git a/include/mimic++/printing/type/Templated.hpp b/include/mimic++/printing/type/Templated.hpp index eac9bcfa2..d93349fe0 100644 --- a/include/mimic++/printing/type/Templated.hpp +++ b/include/mimic++/printing/type/Templated.hpp @@ -9,6 +9,7 @@ #pragma once #include "mimic++/Fwd.hpp" +#include "mimic++/config/Config.hpp" #include "mimic++/printing/Format.hpp" #include "mimic++/printing/Fwd.hpp" #include "mimic++/printing/type/PrintType.hpp" @@ -31,7 +32,7 @@ namespace mimicpp::printing::type::detail { StringT name = type_name(); auto const iter = std::ranges::find(name, '<'); - assert(iter != name.cend() && "Given name is not a template."); + MIMICPP_ASSERT(iter != name.cend(), "Given name is not a template."); name.erase(iter, name.end()); return type::prettify_identifier(std::move(out), std::move(name)); diff --git a/include/mimic++/reporting/DefaultReporter.hpp b/include/mimic++/reporting/DefaultReporter.hpp index ee9e7b516..8da95ea05 100644 --- a/include/mimic++/reporting/DefaultReporter.hpp +++ b/include/mimic++/reporting/DefaultReporter.hpp @@ -8,13 +8,14 @@ #pragma once +#include "mimic++/Fwd.hpp" +#include "mimic++/config/Config.hpp" #include "mimic++/reporting/CallReport.hpp" #include "mimic++/reporting/ExpectationReport.hpp" #include "mimic++/reporting/IReporter.hpp" #include "mimic++/reporting/NoMatchReport.hpp" #include "mimic++/reporting/StringifyReports.hpp" -#include #include #include #include @@ -111,7 +112,7 @@ namespace mimicpp::reporting [[maybe_unused]] CallReport const call, [[maybe_unused]] ExpectationReport const expectationReport) noexcept override { - assert(std::holds_alternative(expectationReport.controlReport) && "Report denotes inapplicable expectation."); + MIMICPP_ASSERT(std::holds_alternative(expectationReport.controlReport), "Report denotes inapplicable expectation."); } void report_unfulfilled_expectation(ExpectationReport expectationReport) override diff --git a/include/mimic++/reporting/StringifyReports.hpp b/include/mimic++/reporting/StringifyReports.hpp index 369f7c183..e2b2d4e63 100644 --- a/include/mimic++/reporting/StringifyReports.hpp +++ b/include/mimic++/reporting/StringifyReports.hpp @@ -10,6 +10,7 @@ #include "mimic++/Fwd.hpp" #include "mimic++/Stacktrace.hpp" +#include "mimic++/config/Config.hpp" #include "mimic++/printing/Format.hpp" #include "mimic++/reporting/CallReport.hpp" #include "mimic++/reporting/ExpectationReport.hpp" @@ -19,7 +20,6 @@ #include "mimic++/utilities/C++23Backports.hpp" #include -#include #include #include #include @@ -183,7 +183,7 @@ namespace mimicpp::reporting::detail std::span const> const descriptions, StringViewT const linePrefix) { - assert(!descriptions.empty()); + MIMICPP_ASSERT(!descriptions.empty(), "Zero requirements can never be violated."); out = std::ranges::copy(linePrefix, std::move(out)).out; out = format::format_to(std::move(out), "Due to Violation(s):\n"); @@ -250,7 +250,7 @@ namespace mimicpp::reporting::detail static OutIter stringify_times_state(OutIter out, int const current, int const min, int const max) { const auto verbalizeValue = [](OutIter o, int const value) { - assert(0 < value && "Invalid value."); + MIMICPP_ASSERT(0 < value, "Invalid value."); switch (value) { @@ -260,7 +260,7 @@ namespace mimicpp::reporting::detail } }; - assert(current < min && "State doesn't denote an unsatisfied state."); + MIMICPP_ASSERT(current < min, "State doesn't denote an unsatisfied state."); out = format::format_to(std::move(out), "matching "); @@ -298,7 +298,7 @@ namespace mimicpp::reporting [[nodiscard]] inline StringT stringify_full_match(CallReport const& call, ExpectationReport expectation) { - assert(std::holds_alternative(expectation.controlReport) && "Report denotes inapplicable expectation."); + MIMICPP_ASSERT(std::holds_alternative(expectation.controlReport), "Report denotes inapplicable expectation."); StringStreamT ss{}; ss << "Matched "; @@ -332,7 +332,7 @@ namespace mimicpp::reporting [[nodiscard]] inline StringT stringify_inapplicable_matches(CallReport const& call, std::span expectations) { - assert(!expectations.empty() && "No expectations given."); + MIMICPP_ASSERT(!expectations.empty(), "No expectations given."); StringStreamT ss{}; @@ -397,7 +397,7 @@ namespace mimicpp::reporting expReport.requirementDescriptions, outcomes.outcomes, std::bind_front(std::equal_to{}, true)); - assert(!violations.empty() && "Zero violations do not denote a no-match."); + MIMICPP_ASSERT(!violations.empty(), "Zero violations do not denote a no-match."); std::ranges::sort(violations); detail::stringify_expectation_report_requirement_violations( std::ostreambuf_iterator{ss}, diff --git a/include/mimic++/reporting/TypeReport.hpp b/include/mimic++/reporting/TypeReport.hpp index eedf1b5c5..586a49056 100644 --- a/include/mimic++/reporting/TypeReport.hpp +++ b/include/mimic++/reporting/TypeReport.hpp @@ -9,9 +9,9 @@ #pragma once #include "mimic++/Fwd.hpp" +#include "mimic++/config/Config.hpp" #include "mimic++/printing/TypePrinter.hpp" -#include #include namespace mimicpp::reporting @@ -54,7 +54,7 @@ namespace mimicpp::reporting explicit constexpr TypeReport(make_name_fn const makeFn) noexcept : m_MakeNameFn{makeFn} { - assert(m_MakeNameFn && "Null make-function is not allowed."); + MIMICPP_ASSERT(m_MakeNameFn, "Null make-function is not allowed."); } }; } diff --git a/include/mimic++/utilities/Algorithm.hpp b/include/mimic++/utilities/Algorithm.hpp index 8aa173e25..afd1ad77c 100644 --- a/include/mimic++/utilities/Algorithm.hpp +++ b/include/mimic++/utilities/Algorithm.hpp @@ -8,8 +8,9 @@ #pragma once +#include "mimic++/config/Config.hpp" + #include -#include #include #include #include @@ -57,7 +58,7 @@ namespace mimicpp::util Predicate predicate, Projection projection = {}) { - assert(std::ranges::size(targetRange) == std::ranges::size(controlRange) && "Size mismatch."); + MIMICPP_ASSERT(std::ranges::size(targetRange) == std::ranges::size(controlRange), "Size mismatch."); auto const targetBegin = std::ranges::begin(targetRange); auto const controlBegin = std::ranges::begin(controlRange); @@ -153,7 +154,7 @@ namespace mimicpp::util std::ranges::subrange const part{pending.begin(), match.begin()}; openScopes += countAllOf(part, opening) - countAllOf(part, closing); - assert(0 <= openScopes && "More scopes closed than opened."); + MIMICPP_ASSERT(0 <= openScopes, "More scopes closed than opened."); if (0 == openScopes) { return match; diff --git a/include/mimic++/utilities/C++23Backports.hpp b/include/mimic++/utilities/C++23Backports.hpp index bb3e04ac4..0be257ad2 100644 --- a/include/mimic++/utilities/C++23Backports.hpp +++ b/include/mimic++/utilities/C++23Backports.hpp @@ -10,7 +10,6 @@ #include "mimic++/config/Config.hpp" -#include #include #include @@ -36,7 +35,7 @@ namespace mimicpp::util [[noreturn]] inline void unreachable() { - assert(false); + MIMICPP_ASSERT(false, "Reached the unreachable."); // Uses compiler specific extensions if possible. // Even if no extension is used, undefined behavior is still raised by From 95fd84e077a5a1382614a8277659f84a411578a0 Mon Sep 17 00:00:00 2001 From: dnkpp Date: Tue, 4 Mar 2025 15:18:05 +0100 Subject: [PATCH 05/15] chore: exclude MIMICPP_ASSERT from coverage --- .github/workflows/coverage.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml index ae37a7060..7a585bed9 100644 --- a/.github/workflows/coverage.yml +++ b/.github/workflows/coverage.yml @@ -70,7 +70,7 @@ jobs: git config --global --add safe.directory ${GITHUB_WORKSPACE} gcovr -j4 -v \ --filter "include/mimic++" \ - --exclude-lines-by-pattern "(\s*assert\(|\s*unreachable\(\);)" \ + --exclude-lines-by-pattern "\s*(MIMICPP_ASSERT|assert|unreachable)\(" \ --exclude-unreachable-branches \ --exclude-function-lines \ --exclude-noncode-lines \ From a932b217a51e04ee155b77d5ff4933225f83144f Mon Sep 17 00:00:00 2001 From: dnkpp Date: Tue, 4 Mar 2025 17:09:28 +0100 Subject: [PATCH 06/15] chore: add mimicpp-test-basics helper target --- test/CMakeLists.txt | 1 + test/test-basics/CMakeLists.txt | 40 +++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 test/test-basics/CMakeLists.txt diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e52d94b64..b49ff44c3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -3,6 +3,7 @@ # (See accompanying file LICENSE_1_0.txt or copy at # https://www.boost.org/LICENSE_1_0.txt) +add_subdirectory("test-basics") add_subdirectory("unit-tests") add_subdirectory("custom-stacktrace-tests") diff --git a/test/test-basics/CMakeLists.txt b/test/test-basics/CMakeLists.txt new file mode 100644 index 000000000..48f018776 --- /dev/null +++ b/test/test-basics/CMakeLists.txt @@ -0,0 +1,40 @@ +# Copyright Dominic (DNKpp) Koepke 2024 - 2025. +# Distributed under the Boost Software License, Version 1.0. +# (See accompanying file LICENSE_1_0.txt or copy at +# https://www.boost.org/LICENSE_1_0.txt) + +set(TARGET_NAME mimicpp-test-basics) + +add_library(${TARGET_NAME} INTERFACE +) +add_library(mimicpp::test::basics ALIAS ${TARGET_NAME}) + +target_include_directories(${TARGET_NAME} + INTERFACE + "$" +) + +target_compile_options(${TARGET_NAME} + INTERFACE + # some test files exceed some limits + # see: https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/fatal-error-c1128?view=msvc-170 + "$<$:/bigobj>" + "$<$:/Zc:__cplusplus>" +) + +target_compile_definitions(${TARGET_NAME} + INTERFACE + "LIBASSERT_BREAK_ON_FAIL" +) + +include(EnableAdditionalTestFlags) +include(EnableWarnings) +include(LinkStdStacktrace) +find_package(libassert REQUIRED) +target_link_libraries(${TARGET_NAME} + INTERFACE + mimicpp::internal::additional-test-flags + mimicpp::internal::warnings + mimicpp::internal::link-std-stacktrace + libassert::assert +) From 43a7440cde7d0eb4d31973a148b84867b53c1e94 Mon Sep 17 00:00:00 2001 From: dnkpp Date: Tue, 4 Mar 2025 17:10:14 +0100 Subject: [PATCH 07/15] chore: move TestAssert.hpp into mimicpp-test-basics --- test/{ => test-basics}/TestAssert.hpp | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) rename test/{ => test-basics}/TestAssert.hpp (97%) diff --git a/test/TestAssert.hpp b/test/test-basics/TestAssert.hpp similarity index 97% rename from test/TestAssert.hpp rename to test/test-basics/TestAssert.hpp index 1dda104d2..1145a3488 100644 --- a/test/TestAssert.hpp +++ b/test/test-basics/TestAssert.hpp @@ -1,10 +1,10 @@ -// Copyright Dominic (DNKpp) Koepke 2024 - 2025. -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// https://www.boost.org/LICENSE_1_0.txt) - -#pragma once - -#include - -#define MIMICPP_ASSERT(condition, msg) ASSERT(condition, msg) +// Copyright Dominic (DNKpp) Koepke 2024 - 2025. +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +#pragma once + +#include + +#define MIMICPP_ASSERT(condition, msg) ASSERT(condition, msg) From 9caaf542f3eaa136e85f283172e8b0650a09cdd9 Mon Sep 17 00:00:00 2001 From: dnkpp Date: Tue, 4 Mar 2025 17:10:39 +0100 Subject: [PATCH 08/15] chore: unit-tests utilize test-basics --- test/unit-tests/CMakeLists.txt | 23 ++--------------------- 1 file changed, 2 insertions(+), 21 deletions(-) diff --git a/test/unit-tests/CMakeLists.txt b/test/unit-tests/CMakeLists.txt index fec65a652..59e4c7d78 100644 --- a/test/unit-tests/CMakeLists.txt +++ b/test/unit-tests/CMakeLists.txt @@ -34,39 +34,20 @@ target_include_directories(${TARGET_NAME} include(EnableSanitizers) enable_sanitizers(${TARGET_NAME}) -target_compile_options(${TARGET_NAME} - PRIVATE - # some test files exceed some limits - # see: https://learn.microsoft.com/en-us/cpp/error-messages/compiler-errors-1/fatal-error-c1128?view=msvc-170 - "$<$:/bigobj>" - "$<$:/Zc:__cplusplus>" -) - -target_compile_definitions(${TARGET_NAME} - PUBLIC - "LIBASSERT_BREAK_ON_FAIL" -) - -include(EnableAdditionalTestFlags) -include(EnableWarnings) -include(LinkStdStacktrace) find_package(Catch2 REQUIRED) find_package(trompeloeil REQUIRED) find_package(libassert REQUIRED) target_link_libraries(${TARGET_NAME} PRIVATE mimicpp::mimicpp - mimicpp::internal::additional-test-flags - mimicpp::internal::warnings - mimicpp::internal::link-std-stacktrace + mimicpp::test::basics Catch2::Catch2WithMain trompeloeil::trompeloeil - libassert::assert ) target_precompile_headers(${TARGET_NAME} PRIVATE - "../TestAssert.hpp" + ) From aacfad13171e82d0d290ccc143ff5cf876e0f57b Mon Sep 17 00:00:00 2001 From: dnkpp Date: Tue, 4 Mar 2025 17:11:00 +0100 Subject: [PATCH 09/15] chore: examples utilizes test-basics --- examples/CMakeLists.txt | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index a004eb954..26fba009c 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -32,17 +32,20 @@ endif () include(EnableSanitizers) enable_sanitizers(${TARGET_NAME}) -include(EnableAdditionalTestFlags) -include(EnableWarnings) -include(LinkStdStacktrace) find_package(Catch2 REQUIRED) +find_package(trompeloeil REQUIRED) +find_package(libassert REQUIRED) target_link_libraries(${TARGET_NAME} PRIVATE mimicpp::mimicpp - mimicpp::internal::additional-test-flags - mimicpp::internal::warnings - mimicpp::internal::link-std-stacktrace + mimicpp::test::basics Catch2::Catch2WithMain ) +target_precompile_headers(${TARGET_NAME} + PRIVATE + + +) + catch_discover_tests(${TARGET_NAME}) From 66acf89832a9191218c36c9349810275621a17d8 Mon Sep 17 00:00:00 2001 From: dnkpp Date: Tue, 4 Mar 2025 17:14:38 +0100 Subject: [PATCH 10/15] chore: remove explicit catch includes from examples --- examples/CustomPrinter.cpp | 3 --- examples/CustomString.cpp | 2 -- examples/Finalizers.cpp | 2 -- examples/InterfaceMock.cpp | 2 -- examples/Mock.cpp | 2 -- examples/RegisterCallConvention.cpp | 2 -- examples/Requirements.cpp | 2 -- examples/Sequences.cpp | 2 -- examples/SideEffects.cpp | 2 -- examples/Times.cpp | 2 -- examples/VariadicMocks.cpp | 2 -- examples/Watcher.cpp | 2 -- 12 files changed, 25 deletions(-) diff --git a/examples/CustomPrinter.cpp b/examples/CustomPrinter.cpp index 077d67dee..a1ffc1805 100644 --- a/examples/CustomPrinter.cpp +++ b/examples/CustomPrinter.cpp @@ -5,9 +5,6 @@ #include "mimic++/Printing.hpp" -#include -#include - namespace { //! [my_type] diff --git a/examples/CustomString.cpp b/examples/CustomString.cpp index cd9fde757..00a4310e4 100644 --- a/examples/CustomString.cpp +++ b/examples/CustomString.cpp @@ -6,8 +6,6 @@ #include "mimic++/Mock.hpp" #include "mimic++/String.hpp" -#include - namespace { //! [MyString] diff --git a/examples/Finalizers.cpp b/examples/Finalizers.cpp index 1e2c8861a..da712ea69 100644 --- a/examples/Finalizers.cpp +++ b/examples/Finalizers.cpp @@ -6,8 +6,6 @@ #include "mimic++/Mock.hpp" #include "mimic++/policies/FinalizerPolicies.hpp" -#include - #include TEST_CASE( diff --git a/examples/InterfaceMock.cpp b/examples/InterfaceMock.cpp index 611912394..ca9183ba5 100644 --- a/examples/InterfaceMock.cpp +++ b/examples/InterfaceMock.cpp @@ -6,8 +6,6 @@ #include "mimic++/InterfaceMock.hpp" #include "mimic++/policies/FinalizerPolicies.hpp" -#include - TEST_CASE( "Mocking interface methods by hand.", "[example][example::mock][example::mock::interface]") diff --git a/examples/Mock.cpp b/examples/Mock.cpp index fa0ccbaff..f3691e587 100644 --- a/examples/Mock.cpp +++ b/examples/Mock.cpp @@ -6,8 +6,6 @@ #include "mimic++/Mock.hpp" #include "mimic++/policies/FinalizerPolicies.hpp" -#include - namespace { //! [stack concept] diff --git a/examples/RegisterCallConvention.cpp b/examples/RegisterCallConvention.cpp index 5dad05963..fee14b265 100644 --- a/examples/RegisterCallConvention.cpp +++ b/examples/RegisterCallConvention.cpp @@ -6,8 +6,6 @@ #include "mimic++/CallConvention.hpp" #include "mimic++/InterfaceMock.hpp" -#include - //! [register __stdcall] MIMICPP_REGISTER_CALL_CONVENTION(__stdcall, detail::stdcall_convention); diff --git a/examples/Requirements.cpp b/examples/Requirements.cpp index 43997e8b0..29d1eef1e 100644 --- a/examples/Requirements.cpp +++ b/examples/Requirements.cpp @@ -6,8 +6,6 @@ #include "mimic++/Mock.hpp" #include "mimic++/matchers/RangeMatchers.hpp" -#include - #include TEST_CASE( diff --git a/examples/Sequences.cpp b/examples/Sequences.cpp index 8967c16de..774e8f2e8 100644 --- a/examples/Sequences.cpp +++ b/examples/Sequences.cpp @@ -6,8 +6,6 @@ #include "mimic++/Mock.hpp" #include "mimic++/Sequence.hpp" -#include - TEST_CASE( "Sequences allow strong ordering between two or more expectations.", "[example][example::sequence]") diff --git a/examples/SideEffects.cpp b/examples/SideEffects.cpp index 90ae2642e..d5b2e7e88 100644 --- a/examples/SideEffects.cpp +++ b/examples/SideEffects.cpp @@ -6,8 +6,6 @@ #include "mimic++/Mock.hpp" #include "mimic++/policies/SideEffectPolicies.hpp" -#include - TEST_CASE( "Side-effects can execute arbitrary actions.", "[example][example::side-effect]") diff --git a/examples/Times.cpp b/examples/Times.cpp index 7a1107ae6..ce9bf23da 100644 --- a/examples/Times.cpp +++ b/examples/Times.cpp @@ -5,8 +5,6 @@ #include "mimic++/Mock.hpp" -#include - TEST_CASE( "once() requires the expectation to be matched exactly once.", "[example][example::times]") diff --git a/examples/VariadicMocks.cpp b/examples/VariadicMocks.cpp index 28b915c4b..f0c8785d8 100644 --- a/examples/VariadicMocks.cpp +++ b/examples/VariadicMocks.cpp @@ -8,8 +8,6 @@ #include "mimic++/matchers/RangeMatchers.hpp" #include "mimic++/policies/FinalizerPolicies.hpp" -#include - namespace { //! [variadic mock def] diff --git a/examples/Watcher.cpp b/examples/Watcher.cpp index 21210cd8e..524ff733f 100644 --- a/examples/Watcher.cpp +++ b/examples/Watcher.cpp @@ -7,8 +7,6 @@ #include "mimic++/ObjectWatcher.hpp" #include "mimic++/policies/SideEffectPolicies.hpp" -#include - TEST_CASE( "Watched reports violations during destruction.", "[example][example::watched][example::watched::life-time]") From 5d816eeca77b9137d111c1be004f8b5166e7c2d8 Mon Sep 17 00:00:00 2001 From: dnkpp Date: Tue, 4 Mar 2025 17:18:50 +0100 Subject: [PATCH 11/15] chore: mimicpp-custom-stacktrace-tests utilizes test-basics --- test/custom-stacktrace-tests/CMakeLists.txt | 15 +++++++++------ test/custom-stacktrace-tests/CustomStacktrace.cpp | 5 ----- test/custom-stacktrace-tests/CustomStacktrace.hpp | 6 ------ .../EqualityComparison.cpp | 5 ----- test/custom-stacktrace-tests/Printing.cpp | 4 ---- 5 files changed, 9 insertions(+), 26 deletions(-) diff --git a/test/custom-stacktrace-tests/CMakeLists.txt b/test/custom-stacktrace-tests/CMakeLists.txt index ef35067c9..79109d020 100644 --- a/test/custom-stacktrace-tests/CMakeLists.txt +++ b/test/custom-stacktrace-tests/CMakeLists.txt @@ -18,19 +18,22 @@ add_executable(${TARGET_NAME} include(EnableSanitizers) enable_sanitizers(${TARGET_NAME}) -include(EnableAdditionalTestFlags) -include(EnableWarnings) -include(LinkStdStacktrace) find_package(Catch2 REQUIRED) find_package(trompeloeil REQUIRED) +find_package(libassert REQUIRED) target_link_libraries(${TARGET_NAME} PRIVATE mimicpp::mimicpp - mimicpp::internal::additional-test-flags - mimicpp::internal::warnings - mimicpp::internal::link-std-stacktrace + mimicpp::test::basics Catch2::Catch2WithMain trompeloeil::trompeloeil ) +target_precompile_headers(${TARGET_NAME} + PRIVATE + + + +) + catch_discover_tests(${TARGET_NAME}) diff --git a/test/custom-stacktrace-tests/CustomStacktrace.cpp b/test/custom-stacktrace-tests/CustomStacktrace.cpp index 1ddca0203..c4aab1260 100644 --- a/test/custom-stacktrace-tests/CustomStacktrace.cpp +++ b/test/custom-stacktrace-tests/CustomStacktrace.cpp @@ -5,11 +5,6 @@ #include "CustomStacktrace.hpp" -#include -#include -#include -#include - using namespace mimicpp; TEST_CASE( diff --git a/test/custom-stacktrace-tests/CustomStacktrace.hpp b/test/custom-stacktrace-tests/CustomStacktrace.hpp index d77749f0e..350a3c1fa 100644 --- a/test/custom-stacktrace-tests/CustomStacktrace.hpp +++ b/test/custom-stacktrace-tests/CustomStacktrace.hpp @@ -10,12 +10,6 @@ #include "mimic++/Stacktrace.hpp" -// ReSharper disable CppUnusedIncludeDirective -#include -#include -#include -// ReSharper restore CppUnusedIncludeDirective - #include "../unit-tests/TestTypes.hpp" class CustomBackend diff --git a/test/custom-stacktrace-tests/EqualityComparison.cpp b/test/custom-stacktrace-tests/EqualityComparison.cpp index 5e8f175ae..59378251e 100644 --- a/test/custom-stacktrace-tests/EqualityComparison.cpp +++ b/test/custom-stacktrace-tests/EqualityComparison.cpp @@ -5,11 +5,6 @@ #include "CustomStacktrace.hpp" -#include -#include -#include -#include - using namespace mimicpp; using traits_t = stacktrace::backend_traits; diff --git a/test/custom-stacktrace-tests/Printing.cpp b/test/custom-stacktrace-tests/Printing.cpp index cede1e999..623916de8 100644 --- a/test/custom-stacktrace-tests/Printing.cpp +++ b/test/custom-stacktrace-tests/Printing.cpp @@ -5,10 +5,6 @@ #include "CustomStacktrace.hpp" -#include -#include -#include - using namespace mimicpp; TEST_CASE( From 04dc31f6565311fe871df8222cd50a4cdc10dbf6 Mon Sep 17 00:00:00 2001 From: dnkpp Date: Tue, 4 Mar 2025 17:22:27 +0100 Subject: [PATCH 12/15] chore: mimicpp-adapter-tests-boost-test utilizes test-basics --- test/adapter-tests/boost-test/CMakeLists.txt | 5 +---- test/adapter-tests/boost-test/main.cpp | 2 ++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/test/adapter-tests/boost-test/CMakeLists.txt b/test/adapter-tests/boost-test/CMakeLists.txt index 205392c8f..072644ecb 100644 --- a/test/adapter-tests/boost-test/CMakeLists.txt +++ b/test/adapter-tests/boost-test/CMakeLists.txt @@ -25,13 +25,10 @@ CPMAddPackage( SYSTEM YES ) -include(EnableAdditionalTestFlags) -include(EnableWarnings) target_link_libraries(${TARGET_NAME} PRIVATE mimicpp::mimicpp - mimicpp::internal::additional-test-flags - mimicpp::internal::warnings + mimicpp::test::basics Boost::unit_test_framework ) diff --git a/test/adapter-tests/boost-test/main.cpp b/test/adapter-tests/boost-test/main.cpp index 281fe68e2..4213796bd 100644 --- a/test/adapter-tests/boost-test/main.cpp +++ b/test/adapter-tests/boost-test/main.cpp @@ -3,6 +3,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // https://www.boost.org/LICENSE_1_0.txt) +#include + #include "../../unit-tests/SuppressionMacros.hpp" #include "mimic++/Mock.hpp" From 61df22914e139b367f5cb953d92c07bd00ecf6d0 Mon Sep 17 00:00:00 2001 From: dnkpp Date: Tue, 4 Mar 2025 17:24:55 +0100 Subject: [PATCH 13/15] chore: mimicpp-adapter-tests-catch2 utilizes test-basics --- test/adapter-tests/catch2/CMakeLists.txt | 5 +---- test/adapter-tests/catch2/main.cpp | 4 +++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/test/adapter-tests/catch2/CMakeLists.txt b/test/adapter-tests/catch2/CMakeLists.txt index d1d3409e5..b73461180 100644 --- a/test/adapter-tests/catch2/CMakeLists.txt +++ b/test/adapter-tests/catch2/CMakeLists.txt @@ -11,14 +11,11 @@ add_executable(${TARGET_NAME} include(EnableSanitizers) enable_sanitizers(${TARGET_NAME}) -include(EnableAdditionalTestFlags) -include(EnableWarnings) find_package(Catch2 REQUIRED) target_link_libraries(${TARGET_NAME} PRIVATE mimicpp::mimicpp - mimicpp::internal::additional-test-flags - mimicpp::internal::warnings + mimicpp::test::basics Catch2::Catch2WithMain ) diff --git a/test/adapter-tests/catch2/main.cpp b/test/adapter-tests/catch2/main.cpp index cfd8284bd..3563c4392 100644 --- a/test/adapter-tests/catch2/main.cpp +++ b/test/adapter-tests/catch2/main.cpp @@ -3,10 +3,12 @@ // (See accompanying file LICENSE_1_0.txt or copy at // https://www.boost.org/LICENSE_1_0.txt) -#include "catch2/catch_test_macros.hpp" +#include + #include "mimic++/Mock.hpp" #include "mimic++/adapters/Catch2.hpp" +#include #include #include #include From 445aa74f77c78e8a1ca5e8d640c1e29935daf201 Mon Sep 17 00:00:00 2001 From: dnkpp Date: Tue, 4 Mar 2025 17:26:19 +0100 Subject: [PATCH 14/15] chore: mimicpp-adapter-tests-doctest utilizes test-basics --- test/adapter-tests/doctest/CMakeLists.txt | 5 +---- test/adapter-tests/doctest/main.cpp | 2 ++ 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/test/adapter-tests/doctest/CMakeLists.txt b/test/adapter-tests/doctest/CMakeLists.txt index 4389052cc..a12c31950 100644 --- a/test/adapter-tests/doctest/CMakeLists.txt +++ b/test/adapter-tests/doctest/CMakeLists.txt @@ -11,14 +11,11 @@ add_executable(${TARGET_NAME} include(EnableSanitizers) enable_sanitizers(${TARGET_NAME}) -include(EnableAdditionalTestFlags) -include(EnableWarnings) CPMAddPackage("gh:doctest/doctest@2.4.11") target_link_libraries(${TARGET_NAME} PRIVATE mimicpp::mimicpp - mimicpp::internal::additional-test-flags - mimicpp::internal::warnings + mimicpp::test::basics doctest::doctest ) diff --git a/test/adapter-tests/doctest/main.cpp b/test/adapter-tests/doctest/main.cpp index 84d875cf4..9c5f3e8cd 100644 --- a/test/adapter-tests/doctest/main.cpp +++ b/test/adapter-tests/doctest/main.cpp @@ -3,6 +3,8 @@ // (See accompanying file LICENSE_1_0.txt or copy at // https://www.boost.org/LICENSE_1_0.txt) +#include + #define DOCTEST_CONFIG_IMPLEMENT_WITH_MAIN #include "mimic++/adapters/Doctest.hpp" From c60d8caa59345252884d13d84e22156185bf1aad Mon Sep 17 00:00:00 2001 From: dnkpp Date: Tue, 4 Mar 2025 17:29:05 +0100 Subject: [PATCH 15/15] chore: mimicpp-adapter-tests-gtest utilizes test-basics --- test/adapter-tests/gtest/CMakeLists.txt | 5 +---- test/adapter-tests/gtest/main.cpp | 4 +++- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/test/adapter-tests/gtest/CMakeLists.txt b/test/adapter-tests/gtest/CMakeLists.txt index 445c3820e..99c117c54 100644 --- a/test/adapter-tests/gtest/CMakeLists.txt +++ b/test/adapter-tests/gtest/CMakeLists.txt @@ -21,13 +21,10 @@ CPMAddPackage( "gtest_force_shared_crt ON" ) -include(EnableAdditionalTestFlags) -include(EnableWarnings) target_link_libraries(${TARGET_NAME} PRIVATE mimicpp::mimicpp - mimicpp::internal::additional-test-flags - mimicpp::internal::warnings + mimicpp::test::basics GTest::gtest_main ) diff --git a/test/adapter-tests/gtest/main.cpp b/test/adapter-tests/gtest/main.cpp index b4e41445f..fffecf17b 100644 --- a/test/adapter-tests/gtest/main.cpp +++ b/test/adapter-tests/gtest/main.cpp @@ -3,10 +3,12 @@ // (See accompanying file LICENSE_1_0.txt or copy at // https://www.boost.org/LICENSE_1_0.txt) +#include + #include "mimic++/Mock.hpp" #include "mimic++/adapters/gtest.hpp" -#include "gtest/gtest-spi.h" +#include namespace {