Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,35 @@ jobs:
cxx_standard: ${{ fromJSON(needs.generate-base-matrix.outputs.cxx_versions) }}
config:
# clang
- prefix: "Ubuntu"
os: "ubuntu-latest"
container:
image: "ghcr.io/dnkpp/clang:22"
compiler:
name: "clang"
version: "22"
asan: true
cxx20_modules: true

- prefix: "Ubuntu"
suffix: "/libc++"
os: "ubuntu-latest"
container:
image: "ghcr.io/dnkpp/clang:22"
compiler:
name: "clang"
version: "22"
only_cpptrace: true
libcxx: true
cxx20_modules: false

- prefix: "Ubuntu"
os: "ubuntu-latest"
container:
image: "ghcr.io/dnkpp/clang:21"
compiler:
name: "clang"
version: "21"
asan: true
cxx20_modules: true

- prefix: "Ubuntu"
Expand Down Expand Up @@ -209,14 +230,23 @@ jobs:
only_cpptrace: true

# gcc
- prefix: "Ubuntu"
os: "ubuntu-latest"
container:
image: "ghcr.io/dnkpp/gcc:16"
compiler:
name: "gcc"
version: "16"
asan: true
cxx20_modules: true

- prefix: "Ubuntu"
os: "ubuntu-latest"
container:
image: "ghcr.io/dnkpp/gcc:15"
compiler:
name: "gcc"
version: "15"
asan: true
cxx20_modules: false # in theory, it should work but in practice it does not.

- prefix: "Ubuntu"
Expand Down
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -548,8 +548,8 @@ For more details, please refer to the reporting section in the documentation.
The following official adapters exist and can be included from the `mimic++_ext/adapters` include directory:

* [Boost.Test](https://github.com/boostorg/test) (tested with v1.89.0)
* [Catch2](https://github.com/catchorg) (tested with v3.10.0)
* [Doctest](https://github.com/doctest/doctest) (tested with v2.4.12)
* [Catch2](https://github.com/catchorg) (tested with v3.15.0)
* [Doctest](https://github.com/doctest/doctest) (tested with v2.5.2)
* [GTest](https://github.com/google/googletest) (tested with v1.15.2)

<a name="documentation"></a>
Expand All @@ -576,7 +576,8 @@ The results of these test cases are consistently tracked by an extensive CI syst
test case outcomes,
and coverage across dozens of different operating systems, compilers, and build configurations.

For the test builds, the flags `-Wall -Wextra -Wpedantic -Werror` (or `/W4 /WX /permissive-` on MSVC) are set.
For the test builds, the flags `-Wall -Wextra -Werror -pedantic -pedantic-errors`
(or `/W4 /WX /permissive-` on MSVC) are set.
This ensures that `mimic++` won't flood your build output with endless warnings - or, even worse, break your builds —
if you enable these flags in your own projects.

Expand Down Expand Up @@ -629,13 +630,15 @@ version.
| clang-19 | x | x | x | x | x | x | std/fmt | std*/cpptrace/boost |
| clang-20 | x | x | x | x | x | x | std/fmt | std*/cpptrace/boost |
| clang-21 | x | x | x | x | x | x | std/fmt | std*/cpptrace/boost |
| clang-22 | x | x | x | x | x | x | std/fmt | std*/cpptrace/boost |
| gcc-10 | * | * | * | ? | * | * | fmt | cpptrace/boost |
| gcc-10.2 | * | * | * | ? | * | * | fmt | cpptrace/boost |
| gcc-11 | x | x | x | ? | x | x | fmt | cpptrace/boost |
| gcc-12 | x | x | x | ? | x | x | fmt | cpptrace/boost |
| gcc-13 | x | x | x | ? | x | x | std/fmt | std*/cpptrace/boost |
| gcc-14 | x | x | x | ? | x | x | std/fmt | std*/cpptrace/boost |
| gcc-15 | x | x | x | ? | x | x | std/fmt | std*/cpptrace/boost |
| gcc-16 | x | x | x | ? | x | x | std/fmt | std*/cpptrace/boost |

Note:

Expand Down
4 changes: 2 additions & 2 deletions cmake/get_cpm.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
#
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors

set(CPM_DOWNLOAD_VERSION 0.42.0)
set(CPM_HASH_SUM "2020b4fc42dba44817983e06342e682ecfc3d2f484a581f11cc5731fbe4dce8a")
set(CPM_DOWNLOAD_VERSION 0.42.3)
set(CPM_HASH_SUM "a609e875fd532b067174250f6abbc3dac22fe2d64869783fb1e80bda1625c844")

if(CPM_SOURCE_CACHE)
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
Expand Down
32 changes: 31 additions & 1 deletion include/mimic++/macros/Common.hpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Copyright Dominic (DNKpp) Koepke 2024 - 2025.
// Copyright Dominic (DNKpp) Koepke 2024-2026.
// 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)
Expand Down Expand Up @@ -179,4 +179,34 @@ namespace mimicpp
*/
#define MIMICPP_DETAIL_STRINGIFY(...) MIMICPP_DETAIL_STRINGIFY_IMPL(__VA_ARGS__)

/**
* \brief General-purpose counter
* \ingroup MACRO_DETAIL
* \details
* This macro generates unique integer values within the current translation unit.
* Although this mechanism is widely supported, it is not yet part of the official standard.
* However, a proposal to standardize it has already been accepted, so it is expected to become part of future C and C++ standards.
* \see https://www.open-std.org/jtc1/sc22/wg14/www/docs/n3457.htm
*
* Recent versions of Clang (e.g., Clang 22) may emit the following warning:
* > error: '__COUNTER__' is a C2y extension [-Werror,-Wc2y-extensions]
*
* Since this macro is currently only used to generate unique names for scoped-expectations,
* falling back to `__LINE__` should generally be safe in such cases.
*
* \note As a last-resort mechanism, users can override this macro by defining it themselves before including this header.
*/
#ifndef MIMICPP_DETAIL_COUNTER
#if (!defined(__clang__) || __clang_major__ < 22)
#if defined(__COUNTER__) \
&& (__COUNTER__ + 1 == __COUNTER__ + 0)
#define MIMICPP_DETAIL_COUNTER __COUNTER__
#endif
#endif

#ifndef MIMICPP_DETAIL_COUNTER
#define MIMICPP_DETAIL_COUNTER __LINE__
#endif
#endif

#endif
8 changes: 4 additions & 4 deletions include/mimic++/macros/ScopedExpectation.hpp
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
// Copyright Dominic (DNKpp) Koepke 2024 - 2025.
// Copyright Dominic (DNKpp) Koepke 2024-2026.
// 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)

#ifndef MIMICPP_MACROS_SCOPED_EXPECTATION_HPP
#define MIMICPP_MACROS_SCOPED_EXPECTATION_HPP

#include "mimic++/macros/Common.hpp"

#define MIMICPP_DETAIL_UNIQUE_NAME(prefix, counter) prefix##counter
#define MIMICPP_DETAIL_SCOPED_EXPECTATION_IMPL(counter) \
[[maybe_unused]] \
Expand All @@ -15,16 +17,14 @@
* \brief Convenience macro, which creates a ScopedExpectation with a unique name.
* \ingroup MOCK
*/
#define MIMICPP_SCOPED_EXPECTATION MIMICPP_DETAIL_SCOPED_EXPECTATION_IMPL(__COUNTER__)
#define MIMICPP_SCOPED_EXPECTATION MIMICPP_DETAIL_SCOPED_EXPECTATION_IMPL(MIMICPP_DETAIL_COUNTER)

#ifndef MIMICPP_CONFIG_ONLY_PREFIXED_MACROS

/**
* \brief Shorthand variant of \ref MIMICPP_SCOPED_EXPECTATION.
* \ingroup MOCK
*/
#define SCOPED_EXP MIMICPP_SCOPED_EXPECTATION

#endif

#endif
16 changes: 8 additions & 8 deletions include/mimic++/printing/type/Parser.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
#include <variant>
#endif

namespace mimicpp::printing::type::parsing::v2
namespace mimicpp::printing::type::parsing
{
class Transaction;

Expand Down Expand Up @@ -1356,11 +1356,11 @@ namespace mimicpp::printing::type::parsing::v2

namespace mimicpp::printing::type
{
MIMICPP_DETAIL_CONSTEXPR_PRETTY_TYPES std::optional<parsing::v2::state::TypeId> parse_type(std::string_view const text)
MIMICPP_DETAIL_CONSTEXPR_PRETTY_TYPES std::optional<parsing::state::TypeId> parse_type(std::string_view const text)
{
lexing::NameLexer lexer{text};
parsing::v2::TokenStream stream{lexer};
if (std::optional typeId = parsing::v2::parse_type_id(stream);
parsing::TokenStream stream{lexer};
if (std::optional typeId = parsing::parse_type_id(stream);
typeId
&& stream.is_eof())
{
Expand All @@ -1370,16 +1370,16 @@ namespace mimicpp::printing::type
return std::nullopt;
}

MIMICPP_DETAIL_CONSTEXPR_PRETTY_TYPES std::optional<parsing::v2::state::FunctionId> parse_function(std::string_view const text)
MIMICPP_DETAIL_CONSTEXPR_PRETTY_TYPES std::optional<parsing::state::FunctionId> parse_function(std::string_view const text)
{
lexing::NameLexer lexer{text};
parsing::v2::TokenStream stream{lexer};
if (std::optional functionId = parsing::v2::parse_function(stream))
parsing::TokenStream stream{lexer};
if (std::optional functionId = parsing::parse_function(stream))
{
if (stream.is_eof()
// Sometimes certain template details are added in separate square-brackets
|| (text.ends_with(']')
&& parsing::v2::expect(stream, lexing::operator_or_punctuator{"["})))
&& parsing::expect(stream, lexing::operator_or_punctuator{"["})))
{
return functionId;
}
Expand Down
2 changes: 1 addition & 1 deletion include/mimic++/printing/type/ParserState.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#include <vector>
#endif

namespace mimicpp::printing::type::parsing::v2::state
namespace mimicpp::printing::type::parsing::state
{
struct TypeId;

Expand Down
4 changes: 2 additions & 2 deletions include/mimic++/printing/type/PrintType.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ namespace mimicpp::printing::type
{
if (std::optional const typeId = parse_type(name))
{
parsing::v2::PrintVisitor<OutIter> visitor{std::move(out)};
parsing::PrintVisitor<OutIter> visitor{std::move(out)};
visitor.visit(*typeId);

return visitor.out();
Expand All @@ -145,7 +145,7 @@ namespace mimicpp::printing::type
{
if (std::optional const functionId = parse_function(name))
{
parsing::v2::PrintVisitor<OutIter> visitor{std::move(out)};
parsing::PrintVisitor<OutIter> visitor{std::move(out)};
visitor.visit(*functionId);

return visitor.out();
Expand Down
2 changes: 1 addition & 1 deletion include/mimic++/printing/type/PrintVisitor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include <variant>
#endif

namespace mimicpp::printing::type::parsing::v2
namespace mimicpp::printing::type::parsing
{
template <print_iterator OutIter>
class PrintVisitor
Expand Down
16 changes: 15 additions & 1 deletion test/adapter-tests/boost-test/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright Dominic (DNKpp) Koepke 2024 - 2025.
# Copyright Dominic (DNKpp) Koepke 2024-2026.
# 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)
Expand All @@ -18,6 +18,20 @@ target_link_libraries(${TARGET_NAME} PRIVATE
Boost::unit_test_framework
)

# @formatter:off
string(CONCAT DISABLE_C2Y_EXTENSION_WARNING
"$<"
"$<AND:"
"$<CXX_COMPILER_ID:Clang>,"
"$<VERSION_GREATER_EQUAL:$<CXX_COMPILER_VERSION>,22>>"
":-Wno-c2y-extensions>"
)
# @formatter:on

target_compile_options(${TARGET_NAME} PRIVATE
${DISABLE_C2Y_EXTENSION_WARNING}
)

target_precompile_headers(${TARGET_NAME} PRIVATE
<TestAssert.hpp>
)
Expand Down
8 changes: 2 additions & 6 deletions test/adapter-tests/doctest/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright Dominic (DNKpp) Koepke 2024 - 2025.
# Copyright Dominic (DNKpp) Koepke 2024-2026.
# 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)
Expand All @@ -11,17 +11,13 @@ add_executable(${TARGET_NAME}
include(Mimic++-EnableSanitizers)
enable_sanitizers(${TARGET_NAME})

CPMAddPackage("gh:doctest/doctest@2.4.12")
CPMAddPackage("gh:doctest/doctest@2.5.2")
target_link_libraries(${TARGET_NAME} PRIVATE
mimicpp::header-only
mimicpp::test::basics
doctest::doctest
)

target_compile_options(${TARGET_NAME} PRIVATE
"$<$<CXX_COMPILER_ID:Clang>:-Wno-#warnings>"
)

target_precompile_headers(${TARGET_NAME} PRIVATE
<TestAssert.hpp>
)
Expand Down
2 changes: 1 addition & 1 deletion test/cmake/FindCatch2.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ include(get_cpm)
# fixes reporting in clion
set(CATCH_CONFIG_CONSOLE_WIDTH 800 CACHE STRING "")

CPMAddPackage("gh:catchorg/Catch2@3.14.0")
CPMAddPackage("gh:catchorg/Catch2@3.15.0")

if (Catch2_ADDED)
include("${Catch2_SOURCE_DIR}/extras/Catch.cmake")
Expand Down
7 changes: 3 additions & 4 deletions test/cmake/Mimic++-EnableWarnings.cmake
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright Dominic (DNKpp) Koepke 2024 - 2025.
# Copyright Dominic (DNKpp) Koepke 2024-2026.
# 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)
Expand All @@ -13,21 +13,20 @@ if (NOT TARGET enable-warnings)
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang"
AND CMAKE_CXX_COMPILER_FRONTEND_VARIANT STREQUAL "MSVC")

set(WARNING_FLAGS /W4 -Wextra -Wpedantic -Werror -Wno-unknown-attributes)
set(WARNING_FLAGS /W4 -Wextra -Werror -Wpedantic -Wno-unknown-attributes)
else ()
# @formatter:off
string(CONCAT WARNING_FLAGS
"$<IF:"
"$<CXX_COMPILER_ID:MSVC>,"
"/W4;/WX;/permissive-,"
"-Wall;-Wextra;-Wpedantic;-Werror"
"-Wall;-Wextra;-Werror;-pedantic;-pedantic-errors"
">"
)
# @formatter:on
endif ()

target_compile_options(enable-warnings INTERFACE

${WARNING_FLAGS}
)

Expand Down
11 changes: 8 additions & 3 deletions test/type-name-print-tests/FunctionIdentifiers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,11 +100,16 @@ namespace
};
}

#if !MIMICPP_DETAIL_HAS_SOURCE_LOCATION
// The `__builtin_FUNCTION` function generates more unreliable names.
#ifdef MIMICPP_DETAIL_HAS_SOURCE_LOCATION
#define PRETTIFY_FUNCTION_SOURCE_LOCATION_FUNCTION_SHOULDFAIL
#else
#define PRETTIFY_FUNCTION_SOURCE_LOCATION_FUNCTION_SHOULDFAIL "[!shouldfail]"
#elif MIMICPP_DETAIL_IS_CLANG \
&& __clang_major__ == 22
// clang-22 changed the lambda synthetic-identifiers
// see https://github.com/llvm/llvm-project/issues/199259
#define PRETTIFY_FUNCTION_SOURCE_LOCATION_FUNCTION_SHOULDFAIL "[!shouldfail]"
#else
#define PRETTIFY_FUNCTION_SOURCE_LOCATION_FUNCTION_SHOULDFAIL
#endif

TEST_CASE(
Expand Down
2 changes: 1 addition & 1 deletion test/unit-tests/printing/parser/BuiltinTypes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

using mimicpp::printing::type::parse_type;
namespace lexing = mimicpp::printing::type::lexing;
namespace state = mimicpp::printing::type::parsing::v2::state;
namespace state = mimicpp::printing::type::parsing::state;

namespace
{
Expand Down
2 changes: 1 addition & 1 deletion test/unit-tests/printing/parser/ConversionFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

using mimicpp::printing::type::parse_type;
namespace lexing = mimicpp::printing::type::lexing;
namespace state = mimicpp::printing::type::parsing::v2::state;
namespace state = mimicpp::printing::type::parsing::state;

namespace
{
Expand Down
Loading
Loading