Compare commits

...

27 commits
v2.0.0 ... main

Author SHA1 Message Date
Alexander Grund
2a9438ea7e
Merge pull request #132 from Farmer-Markus/android
Added boost source build support
2025-08-24 12:21:17 +02:00
Farmer_Markus
bfd964961e Added boost source build support 2025-08-15 19:38:06 +02:00
Alexander Grund
ad456c684b
Merge pull request #131 from Flamefire/gha-windows
Add Windows runners to GHA CI
2025-06-15 11:08:45 +02:00
Alexander Grund
f974db3b08 Increase verbosity of Boost tests in Appveyor 2025-06-13 15:40:37 +02:00
Alexander Grund
68e66eefb4 Workaround file-too-big error on MinGW CI 2025-06-12 09:28:40 +02:00
Alexander Grund
2f02e9c870 Use MinGW generator for GCC on Windows 2025-06-12 09:18:11 +02:00
Alexander Grund
d8809dca2a Improve check for std::uncaught_exceptions
GCC 8 on MinGW still warns about that.
Check the version of the feature macro and add parens to ensure correct
evaluation.
2025-06-11 15:16:36 +02:00
Alexander Grund
3980cc97e1
Fix CMake parallel flag for MSVC 2025-06-09 18:27:33 +02:00
Alexander Grund
66bfbe115c
Set stage dir as boost root 2025-06-09 14:18:33 +02:00
Alexander Grund
6683b829c3
CI: Add Boost debug output to CMake search 2025-06-09 14:18:33 +02:00
Alexander Grund
0d4a9f1e33
Remove std::bind1st test for C++17 2025-06-09 14:18:33 +02:00
Alexander Grund
29c7e2d067
GHA: Separate out doc and inspect builds
Don't run doc build on Windows due to missing dependencies.
Use separate steps for different builds to easier differentiate them.
2025-06-09 14:18:32 +02:00
Alexander Grund
1d2fb3f3df
GHA: Add Windows builds 2025-06-09 14:18:32 +02:00
Alexander Grund
8151fe20c7
Merge pull request #130 from Flamefire/appveyor-cxx
Enhance CI
2025-05-02 12:37:41 +02:00
Alexander Grund
a334c4fb3b Split appveyor jobs to fit time limit 2025-04-30 15:40:17 +02:00
Alexander Grund
78a4fbe129 Fix test in C++17 and up 2025-04-30 12:36:56 +02:00
Alexander Grund
c34cbb56ab Add MOCK_CXX_VERSION macro 2025-04-30 12:32:02 +02:00
Alexander Grund
f18da714f2 Make inspect target explicit 2025-04-30 09:28:18 +02:00
Alexander Grund
2e2a6525ba Appveyor: Add VS 2022 builds 2025-04-30 09:28:18 +02:00
Alexander Grund
3555de3c89 Appveyor: Update Boost version for VS 2019 2025-04-30 09:11:20 +02:00
Flamefire
d7c80fbf28 GHA: Fix ownership of repo in container
Avoid:
> fatal: detected dubious ownership in repository at '/__w/turtle/turtle'

by adding that path to the git `safe.path`.
This is caused by the command(s) running inside the container but the
folder being created outside the container so the owner inside the container is not what is expected by git.
2025-04-30 09:11:20 +02:00
Alexander Grund
20dafe08a6 Remove some detail macros and rename parameters for readability 2025-04-21 11:58:18 +02:00
Alexander Grund
cd6f5ea70d Fix GHA CI
Move Ubuntu 20.04 tests to containers as that runner image has been removed.
2025-04-21 11:21:25 +02:00
Alexander Grund
26583bebf3
GHA: Fix doc build
Use Boost 1.87 to include fix for libxslt 1.1.35:  https://github.com/boostorg/boostbook/issues/14
2025-04-05 18:38:43 +02:00
Alexander Grund
d675a05d95
Require CMake 3.16
With CMake 4 compatibility with CMake 3.5 was dropped and 3.10 deprecated.
Use a reasonably new lower bound based on Ubuntu 20
2025-04-05 18:27:25 +02:00
Mathieu Champlon
d8808f56e9
Merge pull request #125 from mat007/prepare-release
Prepare v2.0.0
2024-10-02 13:33:51 +02:00
Mathieu Champlon
e9f6716aa8 Bump version to 2.0.0 2024-09-29 20:42:36 +02:00
13 changed files with 219 additions and 116 deletions

View file

@ -1,4 +1,4 @@
# Copyright 2022 Alexander Grund # Copyright 2022-2025 Alexander Grund
# #
# Distributed under the Boost Software License, Version 1.0. # Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
@ -32,7 +32,7 @@ jobs:
with: with:
clangFormatVersion: 10 clangFormatVersion: 10
posix: Build:
defaults: defaults:
run: run:
shell: bash shell: bash
@ -42,7 +42,7 @@ jobs:
matrix: matrix:
include: include:
# Linux, gcc # Linux, gcc
- { compiler: gcc-7, cxxstd: '14,17', boostBranch: boost-1.86.0, os: ubuntu-20.04 } - { compiler: gcc-7, cxxstd: '14,17', boostBranch: boost-1.86.0, os: ubuntu-latest, container: 'ubuntu:20.04' }
- { compiler: gcc-10, cxxstd: '14,17,20', boostBranch: boost-1.86.0, os: ubuntu-22.04 } - { compiler: gcc-10, cxxstd: '14,17,20', boostBranch: boost-1.86.0, os: ubuntu-22.04 }
- { compiler: gcc-12, cxxstd: '14,17,20', boostBranch: master, os: ubuntu-22.04 } - { compiler: gcc-12, cxxstd: '14,17,20', boostBranch: master, os: ubuntu-22.04 }
- { compiler: gcc-14, cxxstd: '14,17,20', boostBranch: boost-1.86.0, os: ubuntu-24.04 } - { compiler: gcc-14, cxxstd: '14,17,20', boostBranch: boost-1.86.0, os: ubuntu-24.04 }
@ -53,8 +53,13 @@ jobs:
- { compiler: clang-18, cxxstd: '14,17,20', boostBranch: boost-1.86.0, os: ubuntu-24.04 } - { compiler: clang-18, cxxstd: '14,17,20', boostBranch: boost-1.86.0, os: ubuntu-24.04 }
- { compiler: clang-18, cxxstd: '14,17,20', boostBranch: master, os: ubuntu-24.04 } - { compiler: clang-18, cxxstd: '14,17,20', boostBranch: master, os: ubuntu-24.04 }
# Windows
- { toolset: msvc-14.2, os: windows-2019, cxxstd: 14, generator: 'Visual Studio 16 2019' }
- { toolset: gcc, os: windows-2019, cxxstd: 17, generator: 'MinGW Makefiles' }
- { toolset: msvc-14.3, os: windows-2022, cxxstd: 20, generator: 'Visual Studio 17 2022' }
- { name: Collect coverage, coverage: yes, - { name: Collect coverage, coverage: yes,
compiler: gcc-8, cxxstd: '14', boostBranch: boost-1.86.0, os: ubuntu-20.04 } compiler: gcc-8, cxxstd: '14', boostBranch: boost-1.86.0, os: ubuntu-latest, container: 'ubuntu:20.04' }
timeout-minutes: 120 timeout-minutes: 120
runs-on: ${{matrix.os}} runs-on: ${{matrix.os}}
@ -75,6 +80,7 @@ jobs:
apt-get -o Acquire::Retries=$NET_RETRY_COUNT update apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y g++ git cmake apt-get -o Acquire::Retries=$NET_RETRY_COUNT install -y g++ git cmake
git config --global pack.threads 0 git config --global pack.threads 0
git config --global --add safe.directory "$GITHUB_WORKSPACE" # Avoid ownership issues of repo in container
- uses: actions/checkout@v4 - uses: actions/checkout@v4
with: with:
@ -83,7 +89,7 @@ jobs:
# Checking out Boost and all its submodules takes ages... # Checking out Boost and all its submodules takes ages...
- name: Cache Boost - name: Cache Boost
uses: actions/cache@v3 uses: actions/cache@v4
with: with:
path: boost-root path: boost-root
key: boost-${{matrix.boostBranch}} key: boost-${{matrix.boostBranch}}
@ -98,6 +104,8 @@ jobs:
- name: Install packages and setup env - name: Install packages and setup env
run: | run: |
B2_TOOLSET=${{matrix.toolset}}
if [[ ! "${{matrix.os}}" == "windows-"* ]]; then
sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update sudo apt-get -o Acquire::Retries=$NET_RETRY_COUNT update
CXX=${{matrix.compiler}} CXX=${{matrix.compiler}}
CXX="${CXX/gcc-/g++-}" CXX="${CXX/gcc-/g++-}"
@ -107,19 +115,30 @@ jobs:
CXX="ccache ${CXX/clang-/clang++-}" CXX="ccache ${CXX/clang-/clang++-}"
echo "CXX=$CXX" >> $GITHUB_ENV echo "CXX=$CXX" >> $GITHUB_ENV
echo "CC=${{matrix.compiler}}" >> $GITHUB_ENV echo "CC=${{matrix.compiler}}" >> $GITHUB_ENV
if [[ -z $B2_TOOLSET ]]; then
if [[ "$CXX" =~ clang ]]; then if [[ "$CXX" =~ clang ]]; then
B2_TOOLSET=clang B2_TOOLSET=clang
else else
B2_TOOLSET=gcc B2_TOOLSET=gcc
fi fi
fi
[[ -z $CXX ]] || echo "using $B2_TOOLSET : : $CXX ;" > ~/user-config.jam
fi
echo "B2_TOOLSET=$B2_TOOLSET" >> $GITHUB_ENV echo "B2_TOOLSET=$B2_TOOLSET" >> $GITHUB_ENV
echo "using $B2_TOOLSET : : $CXX ;" > ~/user-config.jam
B2_FLAGS+=" --toolset=$B2_TOOLSET cxxstd=${{matrix.cxxstd}}"
if [[ "${{matrix.coverage}}" == "yes" ]]; then
B2_FLAGS+=" cxxflags=--coverage linkflags=--coverage"
fi
echo "B2_FLAGS=$B2_FLAGS" >> $GITHUB_ENV
# Move the Boost root to a sibling folder # Move the Boost root to a sibling folder
mv boost-root .. mv boost-root ..
echo "BOOST_ROOT=${{github.workspace}}/../boost-root" >> $GITHUB_ENV echo "BOOST_ROOT=${{github.workspace}}/../boost-root" >> $GITHUB_ENV
- name: Cache ccache - name: Cache ccache
uses: hendrikmuhs/ccache-action@v1 uses: hendrikmuhs/ccache-action@v1
if: startsWith(matrix.os, 'ubuntu')
with: with:
key: ${{matrix.os}}-${{matrix.compiler}}-${{matrix.boostBranch}} key: ${{matrix.os}}-${{matrix.compiler}}-${{matrix.boostBranch}}
@ -129,11 +148,17 @@ jobs:
- name: Boost build - name: Boost build
run: | run: |
B2_FLAGS="cxxstd=${{matrix.cxxstd}}" ./b2 "$GITHUB_WORKSPACE/test" -q $B2_FLAGS -j3
if [[ "${{matrix.coverage}}" == "yes" ]]; then ./b2 "$GITHUB_WORKSPACE/doc//mock_examples" -q $B2_FLAGS "$@"
B2_FLAGS="$B2_FLAGS cxxflags=--coverage linkflags=--coverage" working-directory: ${{env.BOOST_ROOT}}
fi
scripts/build.sh --toolset=$B2_TOOLSET $B2_FLAGS -j3 - name: Run inspect check
run: ./b2 "$GITHUB_WORKSPACE/test//inspect" -q $B2_FLAGS
working-directory: ${{env.BOOST_ROOT}}
- name: Build doc
if: startsWith(matrix.os, 'ubuntu')
run: scripts/build_doc.sh $B2_FLAGS -j3
- name: Collect coverage - name: Collect coverage
if: matrix.coverage if: matrix.coverage
@ -164,9 +189,21 @@ jobs:
run: | run: |
mkdir build && cd build mkdir build && cd build
CXX_STANDARD="${{matrix.cxxstd}}" CXX_STANDARD="${{matrix.cxxstd}}"
cmake .. -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_FLAGS="-std=c++${CXX_STANDARD##*,}" -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_VERBOSE_MAKEFILE=ON if [[ "${{matrix.os}}" == "windows-"* ]]; then
cmake --build . --config Debug -- -j3 extra_args=()
ctest --output-on-failure --build-config Debug -j3 else
extra_args=(-DCMAKE_CXX_COMPILER_LAUNCHER=ccache)
fi
if [[ -n "${{matrix.generator}}" ]]; then
extra_args+=(-G "${{matrix.generator}}")
fi
if [[ "${{matrix.generator}}" == "MinGW"* ]]; then
extra_args+=(-DCMAKE_CXX_FLAGS="-Wa,-mbig-obj")
fi
echo "Using extra args: ${extra_args[*]}"
cmake .. -DCMAKE_BUILD_TYPE=Debug -DBoost_ROOT="$BOOST_ROOT/stage" -DCMAKE_CXX_STANDARD="${CXX_STANDARD##*,}" "${extra_args[@]}" -DCMAKE_VERBOSE_MAKEFILE=ON -DBoost_DEBUG=ON -DBoost_VERBOSE=ON
cmake --build . --config Debug --parallel 3
ctest --output-on-failure --build-config Debug
- name: Cleanup Boost folder to reduce cache usage - name: Cleanup Boost folder to reduce cache usage
if: ${{ always() }} if: ${{ always() }}

View file

@ -1,4 +1,4 @@
# Copyright 2020 Alexander Grund # Copyright 2020-2025 Alexander Grund
# Distributed under the Boost Software License, Version 1.0. # Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt) # (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
@ -14,7 +14,7 @@ jobs:
name: Create Release name: Create Release
runs-on: ubuntu-latest runs-on: ubuntu-latest
env: env:
BOOST_VERSION: 1.71.0 BOOST_VERSION: 1.87.0
BOOST_ROOT: ${{github.workspace}}/dependencies/boost BOOST_ROOT: ${{github.workspace}}/dependencies/boost
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4

View file

@ -1,9 +1,9 @@
# Copyright 2019 Alexander Grund # Copyright 2019-2025 Alexander Grund
# Distributed under the Boost Software License, Version 1.0. # Distributed under the Boost Software License, Version 1.0.
# See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt # See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt
cmake_minimum_required(VERSION 3.8) cmake_minimum_required(VERSION 3.16..3.20)
project(turtle VERSION 1.3.2 LANGUAGES CXX) project(turtle VERSION 2.0.0 LANGUAGES CXX)
if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR) if(CMAKE_SOURCE_DIR STREQUAL CMAKE_CURRENT_SOURCE_DIR)
set(IS_ROOT_PROJECT ON) set(IS_ROOT_PROJECT ON)
@ -18,7 +18,11 @@ option(TURTLE_INSTALL "Enable to add install target" ${IS_ROOT_PROJECT})
if(WIN32 AND NOT DEFINED Boost_USE_STATIC_LIBS) if(WIN32 AND NOT DEFINED Boost_USE_STATIC_LIBS)
set(Boost_USE_STATIC_LIBS ON) set(Boost_USE_STATIC_LIBS ON)
endif() endif()
find_package(Boost 1.58 REQUIRED)
# Allows boost to be build by parent project
if(NOT TARGET Boost::boost)
find_package(Boost 1.58 REQUIRED)
endif()
set(MOCK_VERSION "\"${PROJECT_VERSION}\"") set(MOCK_VERSION "\"${PROJECT_VERSION}\"")
set(_turtleVersionFile ${CMAKE_CURRENT_BINARY_DIR}/include/turtle/version.hpp) set(_turtleVersionFile ${CMAKE_CURRENT_BINARY_DIR}/include/turtle/version.hpp)
@ -67,14 +71,7 @@ if(TURTLE_INSTALL)
INSTALL_DESTINATION ${configInstallDestination} INSTALL_DESTINATION ${configInstallDestination}
) )
if(NOT CMAKE_VERSION VERSION_LESS 3.14)
write_basic_package_version_file(${versionFile} COMPATIBILITY SameMajorVersion ARCH_INDEPENDENT) write_basic_package_version_file(${versionFile} COMPATIBILITY SameMajorVersion ARCH_INDEPENDENT)
else()
set(OLD_CMAKE_SIZEOF_VOID_P ${CMAKE_SIZEOF_VOID_P})
set(CMAKE_SIZEOF_VOID_P "")
write_basic_package_version_file(${versionFile} COMPATIBILITY SameMajorVersion)
set(CMAKE_SIZEOF_VOID_P ${OLD_CMAKE_SIZEOF_VOID_P})
endif()
install(FILES ${configFile} ${versionFile} DESTINATION ${configInstallDestination}) install(FILES ${configFile} ${versionFile} DESTINATION ${configInstallDestination})

View file

@ -2,8 +2,8 @@
# subject to the Boost Software License, Version 1.0. (See accompanying # subject to the Boost Software License, Version 1.0. (See accompanying
# file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) # file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
# #
# Copyright Mathieu Champlon 2015. # Copyright 2015 Mathieu Champlon
# Copyright Alexander Grund 2020. # Copyright 2020-2025 Alexander Grund
skip_branch_with_pr: true skip_branch_with_pr: true
@ -12,6 +12,10 @@ branches:
- main - main
environment: environment:
global:
ADDRESS_MODEL: 32,64
VARIANT: debug,release
matrix: matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
BOOST: 1_65_1 BOOST: 1_65_1
@ -19,17 +23,38 @@ environment:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
BOOST: 1_65_1 BOOST: 1_65_1
TOOLSET: msvc-14.1 TOOLSET: msvc-14.1
CXX_STANDARD: 14
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
BOOST: 1_67_0 BOOST: 1_69_0
TOOLSET: msvc-14.1 TOOLSET: msvc-14.1
CXX_STANDARD: 14 CXX_STANDARD: 14,17
# CXX_STANDARD: 17 ADDRESS_MODEL: 64
VARIANT: debug
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
BOOST: 1_83_0
TOOLSET: msvc-14.3
CXX_STANDARD: 14,17,20
ADDRESS_MODEL: 64
VARIANT: debug
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
BOOST: 1_86_0
TOOLSET: msvc-14.3
CXX_STANDARD: 14,17
ADDRESS_MODEL: 64
VARIANT: debug
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
BOOST: 1_86_0
TOOLSET: msvc-14.3
CXX_STANDARD: 20
# CMake builds
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
BOOST: 1_65_1 BOOST: 1_65_1
CMAKE: true CMAKE: true
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019 - APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
BOOST: 1_77_0 BOOST: 1_83_0
CMAKE: true
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2022
BOOST: 1_86_0
CMAKE: true CMAKE: true
install: install:
@ -55,8 +80,9 @@ build_script:
- cd %BOOST_ROOT% - cd %BOOST_ROOT%
- call bootstrap.bat - call bootstrap.bat
- cd %APPVEYOR_BUILD_FOLDER% - cd %APPVEYOR_BUILD_FOLDER%
- if NOT "%CXX_STANDARD%"=="" set CXX_FLAGS=cxxflags=/std:c++%CXX_STANDARD% - if NOT "%CXX_STANDARD%"=="" set CXX_FLAGS=cxxstd=%CXX_STANDARD%
- set BUILD_ARGS=address-model=32,64 variant=debug,release - set BUILD_ARGS=address-model=%ADDRESS_MODEL% variant=%VARIANT%
- set BOOST_TEST_LOG_LEVEL=all
- call scripts\build.bat --toolset=%TOOLSET% %CXX_FLAGS% -j3 - call scripts\build.bat --toolset=%TOOLSET% %CXX_FLAGS% -j3
for: for:

View file

@ -544,6 +544,7 @@ bool custom_constraint(int expected, int actual)
return expected == actual; return expected == actual;
} }
#if MOCK_CXX_VERSION < 201703L
BOOST_AUTO_TEST_CASE(demonstrates_adding_a_custom_constraint_with_a_standard_library_functor) BOOST_AUTO_TEST_CASE(demonstrates_adding_a_custom_constraint_with_a_standard_library_functor)
{ {
mock_class c; mock_class c;
@ -551,6 +552,7 @@ BOOST_AUTO_TEST_CASE(demonstrates_adding_a_custom_constraint_with_a_standard_lib
std::bind1st(std::ptr_fun(&custom_constraint), 42)); // std::ptr_fun creates an std::unary_function std::bind1st(std::ptr_fun(&custom_constraint), 42)); // std::ptr_fun creates an std::unary_function
c.method(42); c.method(42);
} }
#endif
//] //]
} // namespace constraints_example_3 } // namespace constraints_example_3

View file

@ -1,6 +1,7 @@
// http://turtle.sourceforge.net // http://turtle.sourceforge.net
// //
// Copyright Mathieu Champlon 2009 // Copyright Mathieu Champlon 2009
// Copyright 2020-2025 Alexander Grund
// //
// Distributed under the Boost Software License, Version 1.0. // Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at // (See accompanying file LICENSE_1_0.txt or copy at
@ -24,10 +25,24 @@
# endif # endif
#endif #endif
#if defined(__cpp_lib_uncaught_exceptions) || defined(_MSC_VER) && (_MSC_VER >= 1900) #ifndef MOCK_NO_UNCAUGHT_EXCEPTIONS
# ifndef MOCK_NO_UNCAUGHT_EXCEPTIONS # if(defined(__cpp_lib_uncaught_exceptions) && __cpp_lib_uncaught_exceptions >= 201411) || \
(defined(_MSC_VER) && _MSC_VER >= 1900)
# define MOCK_UNCAUGHT_EXCEPTIONS # define MOCK_UNCAUGHT_EXCEPTIONS
# endif # endif
#endif #endif
#if BOOST_VERSION >= 107700
# define MOCK_CXX_VERSION BOOST_CXX_VERSION
#elif defined(_MSC_VER)
# ifdef _MSVC_LANG
# define MOCK_CXX_VERSION _MSVC_LANG
# elif defined(_HAS_CXX17)
# define MOCK_CXX_VERSION 201703L
# endif
#endif
#ifndef MOCK_CXX_VERSION
# define MOCK_CXX_VERSION __cplusplus
#endif
#endif // MOCK_CONFIG_HPP_INCLUDED #endif // MOCK_CONFIG_HPP_INCLUDED

View file

@ -1,6 +1,7 @@
// http://turtle.sourceforge.net // http://turtle.sourceforge.net
// //
// Copyright Mathieu Champlon 2008 // Copyright Mathieu Champlon 2008
// Copyright 2020-2025 Alexander Grund
// //
// Distributed under the Boost Software License, Version 1.0. // Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at // (See accompanying file LICENSE_1_0.txt or copy at
@ -17,6 +18,7 @@
#include <boost/preprocessor/repetition/enum.hpp> #include <boost/preprocessor/repetition/enum.hpp>
#include <boost/preprocessor/repetition/enum_binary_params.hpp> #include <boost/preprocessor/repetition/enum_binary_params.hpp>
#include <boost/preprocessor/repetition/enum_params.hpp> #include <boost/preprocessor/repetition/enum_params.hpp>
#include <boost/preprocessor/repetition/repeat.hpp>
#include <boost/preprocessor/stringize.hpp> #include <boost/preprocessor/stringize.hpp>
#include <boost/preprocessor/variadic/size.hpp> #include <boost/preprocessor/variadic/size.hpp>
#include <functional> #include <functional>

View file

@ -1,6 +1,7 @@
// http://turtle.sourceforge.net // http://turtle.sourceforge.net
// //
// Copyright Mathieu Champlon 2012 // Copyright 2012 Mathieu Champlon
// Copyright 2025 Alexander Grund
// //
// Distributed under the Boost Software License, Version 1.0. // Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at // (See accompanying file LICENSE_1_0.txt or copy at
@ -80,7 +81,7 @@ namespace mock { namespace detail {
typedef safe_error<R, MOCK_ERROR_POLICY<R>> error_type; typedef safe_error<R, MOCK_ERROR_POLICY<R>> error_type;
public: public:
function_impl() : context_(0), valid_(true), exceptions_(exceptions()), mutex_(std::make_shared<mutex>()) {} function_impl() : exceptions_(exceptions()), mutex_(std::make_shared<mutex>()) {}
virtual ~function_impl() virtual ~function_impl()
{ {
if(valid_ && exceptions_ >= exceptions()) if(valid_ && exceptions_ >= exceptions())
@ -314,8 +315,8 @@ namespace mock { namespace detail {
}; };
std::list<expectation_type> expectations_; std::list<expectation_type> expectations_;
context* context_; context* context_ = nullptr;
mutable bool valid_; mutable bool valid_ = true;
const int exceptions_; const int exceptions_;
const std::shared_ptr<mutex> mutex_; const std::shared_ptr<mutex> mutex_;
}; };

View file

@ -1,6 +1,7 @@
// http://turtle.sourceforge.net // http://turtle.sourceforge.net
// //
// Copyright Mathieu Champlon 2008 // Copyright Mathieu Champlon 2008
// Copyright 2022-2025 Alexander Grund
// //
// Distributed under the Boost Software License, Version 1.0. // Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at // (See accompanying file LICENSE_1_0.txt or copy at
@ -14,7 +15,7 @@
#include "signature.hpp" #include "signature.hpp"
#include "signature_traits.hpp" #include "signature_traits.hpp"
#include "type_name.hpp" #include "type_name.hpp"
#include <boost/preprocessor/repetition/repeat.hpp> #include <boost/preprocessor/repetition/enum.hpp>
#include <boost/preprocessor/stringize.hpp> #include <boost/preprocessor/stringize.hpp>
#include <type_traits> #include <type_traits>
@ -49,47 +50,47 @@ namespace mock { namespace detail {
return t##_mock_; \ return t##_mock_; \
} }
#define MOCK_PARAM(S) mock::detail::parameter_t < S #define MOCK_PARAM(S, n) mock::detail::parameter_t<S, n>
#define MOCK_DECL_PARAM(z, n, d) BOOST_PP_COMMA_IF(n) d, n > p##n
#define MOCK_DECL_PARAMS(n, S) BOOST_PP_REPEAT(n, MOCK_DECL_PARAM, MOCK_PARAM(S))
#define MOCK_DECL(M, n, S, c) mock::detail::result_type_t<S> M(MOCK_DECL_PARAMS(n, S)) c
#define MOCK_FORWARD_PARAM(z, n, d) BOOST_PP_COMMA_IF(n) d, n >> (p##n) #define MOCK_DECL_PARAM(z, n, S) MOCK_PARAM(S, n) p##n
#define MOCK_FORWARD_PARAMS(n, S) BOOST_PP_REPEAT(n, MOCK_FORWARD_PARAM, std::forward < MOCK_PARAM(S)) #define MOCK_DECL_PARAMS(n, S) BOOST_PP_ENUM(n, MOCK_DECL_PARAM, S)
#define MOCK_METHOD_AUX(M, n, S, t, c) \ #define MOCK_DECL(name, arity, signature, qualifier) \
static_assert(n == mock::detail::function_arity_t<S>::value, "Arity mismatch"); \ mock::detail::result_type_t<signature> name(MOCK_DECL_PARAMS(arity, signature)) qualifier
MOCK_DECL(M, n, S, c) { return MOCK_ANONYMOUS_HELPER(t)(MOCK_FORWARD_PARAMS(n, S)); }
#define MOCK_METHOD_EXT(M, n, S, t) \ #define MOCK_FORWARD_PARAM(z, n, S) std::forward<MOCK_PARAM(S, n)>(p##n)
MOCK_METHOD_AUX(M, n, S, t, ) \ #define MOCK_FORWARD_PARAMS(n, S) BOOST_PP_ENUM(n, MOCK_FORWARD_PARAM, S)
MOCK_METHOD_AUX(M, n, S, t, const) \ #define MOCK_METHOD_AUX(name, arity, signature, identifier, qualifier) \
MOCK_METHOD_HELPER(S, t) MOCK_DECL(name, arity, signature, qualifier) \
#define MOCK_CONST_METHOD_EXT(M, n, S, t) \
MOCK_METHOD_AUX(M, n, S, t, const) \
MOCK_METHOD_HELPER(S, t)
#define MOCK_NON_CONST_METHOD_EXT(M, n, S, t) \
MOCK_METHOD_AUX(M, n, S, t, ) \
MOCK_METHOD_HELPER(S, t)
#define MOCK_FUNCTION_HELPER(S, t, s) \
s mock::detail::function<S>& t##_mock(mock::detail::context& context, boost::unit_test::const_string instance) \
{ \ { \
static mock::detail::function<S> f; \ return MOCK_ANONYMOUS_HELPER(identifier)(MOCK_FORWARD_PARAMS(arity, signature)); \
}
#define MOCK_METHOD_EXT(name, arity, signature, identifier) \
MOCK_METHOD_AUX(name, arity, signature, identifier, ) \
MOCK_METHOD_AUX(name, arity, signature, identifier, const) \
MOCK_METHOD_HELPER(signature, identifier)
#define MOCK_CONST_METHOD_EXT(name, arity, signature, identifier) \
MOCK_METHOD_AUX(name, arity, signature, identifier, const) \
MOCK_METHOD_HELPER(signature, identifier)
#define MOCK_NON_CONST_METHOD_EXT(name, arity, signature, identifier) \
MOCK_METHOD_AUX(name, arity, signature, identifier, ) \
MOCK_METHOD_HELPER(signature, identifier)
#define MOCK_FUNCTION_HELPER(signature, identifier, prefix) \
prefix mock::detail::function<signature>& identifier##_mock(mock::detail::context& context, \
boost::unit_test::const_string instance) \
{ \
static mock::detail::function<signature> f; \
return f(context, instance); \ return f(context, instance); \
} }
#define MOCK_CONSTRUCTOR_AUX(T, n, A, t) \ #define MOCK_FUNCTION_AUX(name, arity, signature, identifier, prefix) \
T(MOCK_DECL_PARAMS(n, void A)) { MOCK_HELPER(t)(MOCK_FORWARD_PARAMS(n, void A)); } \ MOCK_FUNCTION_HELPER(signature, identifier, prefix) \
MOCK_FUNCTION_HELPER(void A, t, static) static_assert(arity == mock::detail::function_arity_t<signature>::value, "Arity mismatch"); \
prefix MOCK_DECL(name, arity, signature, ) \
#define MOCK_FUNCTION_AUX(F, n, S, t, s) \ { \
MOCK_FUNCTION_HELPER(S, t, s) \ return MOCK_HELPER(identifier)(MOCK_FORWARD_PARAMS(arity, signature)); \
static_assert(n == mock::detail::function_arity_t<S>::value, "Arity mismatch"); \ }
s MOCK_DECL(F, n, S, ) { return MOCK_HELPER(t)(MOCK_FORWARD_PARAMS(n, S)); }
#define MOCK_VARIADIC_ELEM_0(e0, ...) e0
#define MOCK_VARIADIC_ELEM_1(e0, e1, ...) e1
#define MOCK_VARIADIC_ELEM_2(e0, e1, e2, ...) e2
#define MOCK_REPLACED_MACRO_ERROR(oldName, newName) static_assert(false, #oldName " has been replaced by " #newName) #define MOCK_REPLACED_MACRO_ERROR(oldName, newName) static_assert(false, #oldName " has been replaced by " #newName)
// Replaced macros // Replaced macros

View file

@ -1,6 +1,7 @@
// http://turtle.sourceforge.net // http://turtle.sourceforge.net
// //
// Copyright Mathieu Champlon 2008 // Copyright Mathieu Champlon 2008
// Copyright 2022-2025 Alexander Grund
// //
// Distributed under the Boost Software License, Version 1.0. // Distributed under the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at // (See accompanying file LICENSE_1_0.txt or copy at
@ -15,6 +16,7 @@
#include "object.hpp" #include "object.hpp"
#include "reset.hpp" #include "reset.hpp"
#include "verify.hpp" #include "verify.hpp"
#include <boost/preprocessor/variadic/elem.hpp>
/// MOCK_CLASS( name ) /// MOCK_CLASS( name )
/// Define a class /// Define a class
@ -51,7 +53,12 @@
/// MOCK_CONSTRUCTOR( [calling convention] name, arity, parameters, identifier ) /// MOCK_CONSTRUCTOR( [calling convention] name, arity, parameters, identifier )
/// As constructors do not have a return type, the usual signature gets restricted here to just the parameters. /// As constructors do not have a return type, the usual signature gets restricted here to just the parameters.
#define MOCK_CONSTRUCTOR(T, arity, parameters, identifier) MOCK_CONSTRUCTOR_AUX(T, arity, parameters, identifier) #define MOCK_CONSTRUCTOR(T, arity, parameters, identifier) \
T(MOCK_DECL_PARAMS(arity, void parameters)) \
{ \
MOCK_HELPER(identifier)(MOCK_FORWARD_PARAMS(arity, void parameters)); \
} \
MOCK_FUNCTION_HELPER(void parameters, identifier, static)
/// MOCK_DESTRUCTOR( [calling convention] ~name, identifier ) /// MOCK_DESTRUCTOR( [calling convention] ~name, identifier )
#define MOCK_DESTRUCTOR(T, identifier) \ #define MOCK_DESTRUCTOR(T, identifier) \
@ -71,37 +78,39 @@
/// if 'identifier' is omitted it will default to 'name' /// if 'identifier' is omitted it will default to 'name'
#define MOCK_METHOD(M, ...) \ #define MOCK_METHOD(M, ...) \
MOCK_METHOD_EXT(M, \ MOCK_METHOD_EXT(M, \
MOCK_VARIADIC_ELEM_0(__VA_ARGS__, ), \ BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__, ), \
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, MOCK_SIGNATURE(M), ), \ BOOST_PP_VARIADIC_ELEM(1, __VA_ARGS__, MOCK_SIGNATURE(M), ), \
MOCK_VARIADIC_ELEM_2(__VA_ARGS__, M, M, )) BOOST_PP_VARIADIC_ELEM(2, __VA_ARGS__, M, M, ))
/// MOCK_CONST_METHOD( [calling convention] name, arity[, signature[, identifier]] ) /// MOCK_CONST_METHOD( [calling convention] name, arity[, signature[, identifier]] )
/// generates only the const version of the method /// generates only the const version of the method
/// The 'signature' can be omitted if it can be uniquely identified from the base class /// The 'signature' can be omitted if it can be uniquely identified from the base class
/// if 'identifier' is omitted it will default to 'name' /// if 'identifier' is omitted it will default to 'name'
#define MOCK_CONST_METHOD(M, ...) \ #define MOCK_CONST_METHOD(M, ...) \
MOCK_CONST_METHOD_EXT(M, \ MOCK_CONST_METHOD_EXT(M, \
MOCK_VARIADIC_ELEM_0(__VA_ARGS__, ), \ BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__, ), \
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, MOCK_SIGNATURE(M), ), \ BOOST_PP_VARIADIC_ELEM(1, __VA_ARGS__, MOCK_SIGNATURE(M), ), \
MOCK_VARIADIC_ELEM_2(__VA_ARGS__, M, M, )) BOOST_PP_VARIADIC_ELEM(2, __VA_ARGS__, M, M, ))
/// MOCK_NON_CONST_METHOD( [calling convention] name, arity[, signature[, identifier]] ) /// MOCK_NON_CONST_METHOD( [calling convention] name, arity[, signature[, identifier]] )
/// generates only the non-const version of the method /// generates only the non-const version of the method
/// The 'signature' can be omitted if it can be uniquely identified from the base class /// The 'signature' can be omitted if it can be uniquely identified from the base class
/// if 'identifier' is omitted it will default to 'name' /// if 'identifier' is omitted it will default to 'name'
#define MOCK_NON_CONST_METHOD(M, ...) \ #define MOCK_NON_CONST_METHOD(M, ...) \
MOCK_NON_CONST_METHOD_EXT(M, \ MOCK_NON_CONST_METHOD_EXT(M, \
MOCK_VARIADIC_ELEM_0(__VA_ARGS__, ), \ BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__, ), \
MOCK_VARIADIC_ELEM_1(__VA_ARGS__, MOCK_SIGNATURE(M), ), \ BOOST_PP_VARIADIC_ELEM(1, __VA_ARGS__, MOCK_SIGNATURE(M), ), \
MOCK_VARIADIC_ELEM_2(__VA_ARGS__, M, M, )) BOOST_PP_VARIADIC_ELEM(2, __VA_ARGS__, M, M, ))
/// MOCK_FUNCTION( [calling convention] name, arity, signature[, identifier] ) /// MOCK_FUNCTION( [calling convention] name, arity, signature[, identifier] )
/// if 'identifier' is omitted it will default to 'name' /// if 'identifier' is omitted it will default to 'name'
#define MOCK_FUNCTION(F, arity, ...) \ #define MOCK_FUNCTION(F, arity, ...) \
MOCK_FUNCTION_AUX(F, arity, MOCK_VARIADIC_ELEM_0(__VA_ARGS__, ), MOCK_VARIADIC_ELEM_1(__VA_ARGS__, F, ), inline) MOCK_FUNCTION_AUX( \
F, arity, BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__, ), BOOST_PP_VARIADIC_ELEM(1, __VA_ARGS__, F, ), inline)
/// MOCK_STATIC_METHOD( [calling convention] name, arity, signature[, identifier] ) /// MOCK_STATIC_METHOD( [calling convention] name, arity, signature[, identifier] )
/// if 'identifier' is omitted it will default to 'name' /// if 'identifier' is omitted it will default to 'name'
#define MOCK_STATIC_METHOD(F, arity, ...) \ #define MOCK_STATIC_METHOD(F, arity, ...) \
MOCK_FUNCTION_AUX(F, arity, MOCK_VARIADIC_ELEM_0(__VA_ARGS__, ), MOCK_VARIADIC_ELEM_1(__VA_ARGS__, F, ), static) MOCK_FUNCTION_AUX( \
F, arity, BOOST_PP_VARIADIC_ELEM(0, __VA_ARGS__, ), BOOST_PP_VARIADIC_ELEM(1, __VA_ARGS__, F, ), static)
/// MOCK_EXPECT( identifier ) /// MOCK_EXPECT( identifier )
/// Begin setting up expectation for the identifier /// Begin setting up expectation for the identifier

View file

@ -1,6 +1,7 @@
#!/bin/sh #!/bin/sh
# Copyright (C) 2015 Mathieu Champlon # Copyright (C) 2015 Mathieu Champlon
# Copyright (C) 2025 Alexander Grund
# #
# Distributed under the Boost Software License, Version 1.0. # Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt) # (See accompanying file LICENSE_1_0.txt or http://www.boost.org/LICENSE_1_0.txt)
@ -18,3 +19,6 @@ scripts/build_doc.sh "$@"
cd "$BOOST_ROOT" cd "$BOOST_ROOT"
./b2 "$PROJECT_DIR/doc//mock_examples" -q "$@" ./b2 "$PROJECT_DIR/doc//mock_examples" -q "$@"
cd "$BOOST_ROOT"
./b2 "$PROJECT_DIR/test//inspect" -q "$@"

View file

@ -1,4 +1,5 @@
# Copyright Mathieu Champlon 2012 # Copyright 2012 Mathieu Champlon
# Copyright 2025 Alexander Grund
# #
# Distributed under the Boost Software License version 1.0. (See # Distributed under the Boost Software License version 1.0. (See
# accompanying file LICENSE_1_0.txt or copy at # accompanying file LICENSE_1_0.txt or copy at
@ -15,22 +16,27 @@ project
path-constant parent : .. ; path-constant parent : .. ;
alias mock_inspect : run /boost/tools/inspect//inspect/<variant>release : $(parent) -text -brief : : <test-info>always_show_run_output : inspect ;
[ run /boost/tools/inspect//inspect/<variant>release explicit inspect ;
: $(parent) -text -brief : : : inspect
]
;
rule run-test ( name ) rule run-test ( name : options * )
{ {
run $(name) defined_1.cpp defined_2.cpp undefined.cpp /boost//unit_test_framework : : : : $(name)_ ; run $(name) defined_1.cpp defined_2.cpp undefined.cpp /boost//unit_test_framework : : : $(options) : $(name)_ ;
run $(name) undefined.cpp /boost//unit_test_framework : : : <define>MOCK_USE_CONVERSIONS : $(name)_use_conversions ; run $(name) undefined.cpp /boost//unit_test_framework : : : $(options) <define>MOCK_USE_CONVERSIONS : $(name)_use_conversions ;
run $(name) undefined.cpp /boost//unit_test_framework /boost//thread : : : <define>MOCK_THREAD_SAFE <define>BOOST_THREAD_USES_MOVE <threading>multi : $(name)_thread_safe ; run $(name) undefined.cpp /boost//unit_test_framework /boost//thread : : : $(options) <define>MOCK_THREAD_SAFE <define>BOOST_THREAD_USES_MOVE <threading>multi : $(name)_thread_safe ;
} }
rule run-tests rule run-tests
{ {
for name in [ glob test_*.cpp detail/test_*.cpp ] { run-test $(name) ; } for name in [ glob test_*.cpp ] { run-test $(name) ; }
# Avoid object file getting to big on MinGW
run-test detail/test_function.cpp :
<toolset>gcc,<target-os>windows:<inlining>on
<toolset>gcc,<target-os>windows:<optimization>space ;
run-test detail/test_invocation.cpp ;
run-test detail/test_is_functor.cpp ;
run-test detail/test_signature.cpp ;
run-test detail/test_type_name.cpp ;
} }
alias mock_tests : [ run-tests ] ; alias mock_tests : [ run-tests ] ;

View file

@ -67,6 +67,8 @@ BOOST_AUTO_TEST_CASE(function_pointer_is_functor)
is_not_functor(&f2); is_not_functor(&f2);
} }
// ptr_fun, bin1st is removed in C++17
#if MOCK_CXX_VERSION < 201703L
BOOST_AUTO_TEST_CASE(std_ptr_fun_is_functor) BOOST_AUTO_TEST_CASE(std_ptr_fun_is_functor)
{ {
is_functor(std::ptr_fun(&f1)); is_functor(std::ptr_fun(&f1));
@ -77,6 +79,7 @@ BOOST_AUTO_TEST_CASE(std_bind_first_is_functor)
{ {
is_functor(std::bind1st(std::ptr_fun(&f2), "")); is_functor(std::bind1st(std::ptr_fun(&f2), ""));
} }
#endif
BOOST_AUTO_TEST_CASE(bind_is_functor) BOOST_AUTO_TEST_CASE(bind_is_functor)
{ {