diff --git a/.gitignore b/.gitignore
index 1b6052fea7..066d2a6b01 100644
--- a/.gitignore
+++ b/.gitignore
@@ -7,6 +7,7 @@ libnnpdf/REAMDE.md
libnnpdf/scripts/nnpdf.pc
libnnpdf/src/NNPDF/common.h
libnnpdf/src/NNPDF/config.h
+evolven3fit/evolven3fit.cc
# Created by https://www.gitignore.io/api/macos
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 663b5892f2..2dd7b4e4ea 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -28,6 +28,7 @@ set(VERSION "\"4.0\"")
set(nnpdfcpp_VERSION 4.0)
# check for dependencies
+find_package(PythonInterp 3 REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_search_module(LIBARCHIVE REQUIRED libarchive)
pkg_search_module(SQLITE3 REQUIRED sqlite3)
@@ -35,11 +36,6 @@ pkg_search_module(GSL REQUIRED gsl)
pkg_search_module(YAML REQUIRED yaml-cpp)
-option(ENABLE_OPENMP "Enable openmp parallelism." OFF)
-option(ENABLE_OPENMPI "Enable openMPI parallelism." OFF)
-option(ENABLE_TESTS "Enable unit test" OFF)
-option(ENABLE_ASAN "Enable ASAN" OFF)
-option(ENABLE_DEAD_STRIP "Enable use of flag `-dead_strip-dylibs`" OFF)
option(NNPDF_DEV "n3fit and validphys in developer mode" ON)
set(PROFILE_PREFIX "" CACHE STRING "Where you store the 'data' folder. Default empty uses CMAKE_INSTALL_PREFIX/share/NNPDF.")
@@ -49,19 +45,6 @@ else (PROFILE_PREFIX)
set(PROFILE_PREFIX "${CMAKE_INSTALL_PREFIX}/share/NNPDF")
endif()
-if (ENABLE_OPENMPI)
- set(LIBNNPDF_HAVE_MPI "#define OPENMPI")
-endif()
-
-set(LIBNNPDF_HAVE_SSE "#define SSE_CONV")
-
-
-if(ENABLE_OPENMP)
- find_package(OpenMP REQUIRED)
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
-endif(ENABLE_OPENMP)
-
# LHAPDF
find_program(LHAPDF_CONFIG lhapdf-config REQUIRED)
if (LHAPDF_CONFIG)
@@ -99,7 +82,7 @@ if (APFEL_CONFIG)
set(APFEL_LIBRARIES ${APFEL_LIBRARIES} CACHE STRING INTERNAL)
endif(APFEL_CONFIG)
-set(DEFAULT_CXX_OPTIONS "-Wall -Wextra -march=nocona -mtune=haswell -fvisibility-inlines-hidden -fmessage-length=0 -ftree-vectorize -fPIC -fstack-protector-strong -O2 -pipe")
+set(DEFAULT_CXX_OPTIONS "-Wall -Wextra -fvisibility-inlines-hidden -fmessage-length=0 -ftree-vectorize -fPIC -fstack-protector-strong -O2 -pipe")
#strip linker flags to avoid duplication of asan flags
string(REPLACE "-fsanitize=address" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
@@ -107,44 +90,17 @@ string(REPLACE "-fsanitize=address" "" CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE
set(CMAKE_ALL_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${CMAKE_MODULE_LINKER_FLAGS} ${CMAKE_SHARED_LINKER_FLAGS}")
-#dead_strip_dylibs can cause issues, warn if we remove it
-if(ENABLE_DEAD_STRIP)
- if(NOT ${CMAKE_ALL_LINKER_FLAGS} MATCHES "-Wl,-dead_strip_dylibs")
- message(WARNING "ENABLE_DEAD_STRIP was set true but there were no occurences of the flag `dead_strip_dylibs` found")
- endif(NOT ${CMAKE_ALL_LINKER_FLAGS} MATCHES "-Wl,-dead_strip_dylibs")
-else(ENABLE_DEAD_STRIP)
- if(CMAKE_ALL_LINKER_FLAGS MATCHES "-Wl,-dead_strip_dylibs")
- message(WARNING "removing all occurence of flag: `dead_strip_dylibs` (default behaviour). If you are sure this flag is required then ENABLE_DEAD_STRIP")
- string(REPLACE "-Wl,-dead_strip_dylibs" "" CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}")
- string(REPLACE "-Wl,-dead_strip_dylibs" "" CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}")
- string(REPLACE "-Wl,-dead_strip_dylibs" "" CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
- #executable linker flags get set later
- set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS}" CACHE STRING "Flags used by the linker during the creation of modules during all build types" FORCE)
- set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS}" CACHE STRING "Flags used by the linker during the creation of shared libraries during all build types" FORCE)
- endif(CMAKE_ALL_LINKER_FLAGS MATCHES "-Wl,-dead_strip_dylibs")
-endif(ENABLE_DEAD_STRIP)
-
-# Flags for ASAN
-if(ENABLE_ASAN)
- set(CMAKE_CXX_FLAGS "-fsanitize=address ${DEFAULT_CXX_OPTIONS} ${LHAPDF_CXX_FLAGS} ${APFEL_CXX_FLAGS} ${YAML_CFLAGS} ${SQLITE3_CFLAGS} ${GSL_CFLAGS} ${LIBARCHIVE_CFLAGS}" CACHE STRING "compile flags" FORCE)
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g" CACHE STRING "debug compile flags" FORCE)
- set(CMAKE_EXE_LINKER_FLAGS "-fsanitize=address ${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "linker flags" FORCE)
- set(CMAKE_EXE_LINKER_FLAGS_DEBUG "-fsanitize=address ${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING "debug linker flags" FORCE)
-else(ENABLE_ASAN)
- set(CMAKE_CXX_FLAGS "${DEFAULT_CXX_OPTIONS} ${LHAPDF_CXX_FLAGS} ${APFEL_CXX_FLAGS} ${YAML_CFLAGS} ${SQLITE3_CFLAGS} ${GSL_CFLAGS} ${LIBARCHIVE_CFLAGS}" CACHE STRING "compile flags" FORCE)
- set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g" CACHE STRING "debug compile flags" FORCE)
- set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "linker flags" FORCE)
- set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING "debug linker flags" FORCE)
-endif(ENABLE_ASAN)
+set(CMAKE_CXX_FLAGS "${DEFAULT_CXX_OPTIONS} ${LHAPDF_CXX_FLAGS} ${APFEL_CXX_FLAGS} ${YAML_CFLAGS} ${SQLITE3_CFLAGS} ${GSL_CFLAGS} ${LIBARCHIVE_CFLAGS}" CACHE STRING "compile flags" FORCE)
+set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS} -g" CACHE STRING "debug compile flags" FORCE)
+set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS}" CACHE STRING "linker flags" FORCE)
+set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG}" CACHE STRING "debug linker flags" FORCE)
# libnnpdf configuration
add_subdirectory(libnnpdf)
-# nnpdfcpp configuration
-add_subdirectory(nnpdfcpp)
-
# evolven3fit
-add_subdirectory(n3fit/evolven3fit)
+add_subdirectory(evolven3fit)
+install(FILES ${PROJECT_SOURCE_DIR}/validphys2/src/validphys/datafiles/theory.db DESTINATION ${PROFILE_PREFIX}/)
if(NNPDF_DEV)
install(CODE "execute_process(COMMAND ${PYTHON_EXECUTABLE} -m pip install --no-deps -e ${PROJECT_SOURCE_DIR})")
diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml
index c3e0fe5804..877431f21d 100644
--- a/conda-recipe/meta.yaml
+++ b/conda-recipe/meta.yaml
@@ -52,10 +52,10 @@ requirements:
- recommonmark
- sphinx_rtd_theme >0.5
- sphinxcontrib-bibtex
- - curio >=1.0
- pineappl >=0.6.2
- eko >=0.14.1
- fiatlux
+ - curio >=1.0 # reportengine uses it but it's not in its dependencies
test:
requires:
@@ -63,12 +63,6 @@ test:
- pytest
- coverage
- pytest-mpl
- #Build dependencies for catch tests
- - {{ compiler("cxx") }}
- - {{ compiler("c") }}
- - sysroot_linux-64==2.17 # [linux]
- - swig ==3.0.10
- - cmake
source_files:
- "*"
diff --git a/doc/sphinx/source/get-started/installation.rst b/doc/sphinx/source/get-started/installation.rst
index 51845fc4c6..a2be8fd015 100644
--- a/doc/sphinx/source/get-started/installation.rst
+++ b/doc/sphinx/source/get-started/installation.rst
@@ -244,8 +244,9 @@ explained above, if the user has not already done so.
Installation from source on M1/M2 Macs
--------------------------------------
-Installation on M1/M2 Macs is not directly supported, so everything needs to be
-built manually. The following steps are required:
+Installation on M1/M2 Macs directly with cmake is not directly supported.
+If you install following this tutorial PDFs will need to be evolved with ``evolven3fit_new``.
+Make sure you have a valid installation of ``pandoc`` available in your system:
1. Clone the repositories
@@ -255,153 +256,47 @@ built manually. The following steps are required:
cd nnpdfgit
git clone git@github.com:NNPDF/nnpdf.git
git clone git@github.com:NNPDF/binary-bootstrap.git
- git clone https://github.com/scarrazza/apfel.git
-2. Execute binary bootstrap to set the channels in ``.condarc``
+2. Execute binary bootstrap to set the channels in ``.condarc`` and install miniconda.
+Note: if you want to install some specific version of `miniconda`_ instead it should work just the same.
.. code::
./binary-bootstrap/bootstrap.sh
-3. Setup conda environment using python 3.9
+3. Setup conda environment using python (we use in this example 3.10) and, if you don't have them yet, install ``lhapdf``, ``pandoc`` and ``sccache`` (for rust).
.. code::
- conda create -n nnpdf-dev python=3.9
+ conda create -n nnpdf-dev python=3.10
conda activate nnpdf-dev
+ conda install lhapdf pandoc sccache
-4. Install ARM compiler
+ Test that everything is ok:
.. code::
- conda install clangxx_osx-arm64
-
-5. LHAPDF
-
- Download version 6.4.0 and decompress
-
- .. code::
-
- wget -O LHAPDF-6.4.0.tar.gz https://lhapdf.hepforge.org/downloads/?f=LHAPDF-6.4.0.tar.gz
- tar -xzvf LHAPDF-6.4.0.tar.gz
- rm LHAPDF-6.4.0.tar.gz
- cd LHAPDF-6.4.0
-
- Regenerate the configuration files, configure the build with python disabled, compile and
- install. You may need to `brew install automake` first:
-
- .. code::
-
- autoreconf -f -i
- ./configure --prefix=$CONDA_PREFIX --disable-python
- make -j
- make install
-
- Install the python wrapper
-
- .. code::
-
- cd wrappers/python
- pip install -e .
-
- Test
-
- .. code::
-
- lhapdf install CT18NNLO
+ lhapdf install NNPDF40_nnlo_as_01180
python -c "import lhapdf"
-6. Apfel
-
-
- First, we need to install some dependencies:
+4. Note for tensorflow
- .. code::
-
- conda install pkg-config swig cmake
-
- Then build it
+ At the time of writing, it is necessary to follow this extra step in order to install ``tensorflow`` which works only for python < 3.12.
+ Other versions of ``tensorflow-macos`` and ``tensorflow-metal`` might also work, but these are the ones we tested.
.. code::
- cd ../../../apfel
- autoreconf -f -i
- PYTHON=$(which python) ./configure --prefix=$CONDA_PREFIX
- make clean
- make -j
- make install
-
-7. validphys
+ conda install -c apple tensorflow-deps
+ pip install tensorflow-macos==2.9.2
+ pip install tensorflow-metal==0.5.0
- First install reportengine and validobj, then validphys itself:
+5. Install NNPDF packages (``validphys``, ``n3fit`` and ``evolven3fit_new``) and its dependencies
.. code::
- pip install reportengine validobj
- cd ../nnpdf/validphys2
pip install -e .
-8. nnpdf
-
- Install other dependencies
-
- .. code::
-
- conda install libarchive sqlite gsl yaml-cpp
-
- Run cmake in nnpdf/build directory:
-
- .. code::
-
- cd ..
- mkdir build
- cd build
- cmake .. -DCMAKE_INSTALL_PREFIX=$CONDA_PREFIX
-
- Edit the file ``nnpdfgit/nnpdf/CMakeLists.txt`` :
-
- - on line 8 change the option to true, so it says:
-
- .. code::
-
- SET(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
-
- - comment out line 58 (:code:`set(LIBNNPDF_HAVE_SSE "#define SSE_CONV")`)
-
- - line 104 should read:
-
- .. code::
-
- set(DEFAULT_CXX_OPTIONS "-Wall -Wextra -fvisibility-inlines-hidden -fmessage-length=0 -ftree-vectorize -fPIC -fstack-protector-strong -O2 -pipe")
-
- (so delete ``-march=nocona -mtune=haswell``).
-
- Then make:
-
- .. code::
-
- make -j
- make install
-
- Install remaining packages
-
- .. code::
-
- pip install seaborn prompt_toolkit scipy psutil hyperopt
-
-9. Install tensorflow
-
- Not specifying versions will install at the time of writing macos 2.12.0 and metal 0.8.0, which both work.
- They only give warnings on the optimizers, that the legacy versions are faster.
- If you want an older version, macos 2.9.2 and metal 0.5.0 are also tested to work.
-
- .. code::
-
- conda install -c apple tensorflow-deps
- pip install tensorflow-macos==2.9.2
- pip install tensorflow-metal==0.5.0
-
-10. Test
+6. Test
.. code::
diff --git a/n3fit/evolven3fit/CMakeLists.txt b/evolven3fit/CMakeLists.txt
similarity index 55%
rename from n3fit/evolven3fit/CMakeLists.txt
rename to evolven3fit/CMakeLists.txt
index 5a59287a15..f4e8d09787 100644
--- a/n3fit/evolven3fit/CMakeLists.txt
+++ b/evolven3fit/CMakeLists.txt
@@ -1,20 +1,17 @@
# Include files (should this information not be known at this point?)
-include_directories(${PROJECT_SOURCE_DIR}/nnpdfcpp/src/common/inc)
-include_directories(${PROJECT_SOURCE_DIR}/nnpdfcpp/src/nnfit/inc)
-include_directories(${PROJECT_SOURCE_DIR}/n3fit/evolven3fit)
+include_directories(${PROJECT_SOURCE_DIR}/evolven3fit)
include_directories(${PROJECT_SOURCE_DIR}/libnnpdf/src/)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/binaries)
configure_file(
- "${PROJECT_SOURCE_DIR}/libnnpdf/src/NNPDF/common.h.in"
- "${PROJECT_SOURCE_DIR}/libnnpdf/src/NNPDF/common.h"
- )
+ "${PROJECT_SOURCE_DIR}/evolven3fit/evolven3fit.cc.in"
+ "${PROJECT_SOURCE_DIR}/evolven3fit/evolven3fit.cc"
+)
# Add files to the make
-add_executable(evolven3fit ${PROJECT_SOURCE_DIR}/n3fit/evolven3fit/evolven3fit.cc
- ${PROJECT_SOURCE_DIR}/nnpdfcpp/src/common/src/md5.cc
- ${PROJECT_SOURCE_DIR}/nnpdfcpp/src/common/src/exportgrid.cc
- ${PROJECT_SOURCE_DIR}/nnpdfcpp/src/nnfit/src/evolgrid.cc )
+add_executable(evolven3fit ${PROJECT_SOURCE_DIR}/evolven3fit/evolven3fit.cc
+ ${PROJECT_SOURCE_DIR}/evolven3fit/exportgrid.cc
+ ${PROJECT_SOURCE_DIR}/evolven3fit/evolgrid.cc )
# Set all flags
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${NNPDF_LDFLAGS} ${GSL_LDFLAGS} ${APFEL_LIBRARIES} ${YAML_LDFLAGS}")
diff --git a/nnpdfcpp/src/nnfit/src/evolgrid.cc b/evolven3fit/evolgrid.cc
similarity index 100%
rename from nnpdfcpp/src/nnfit/src/evolgrid.cc
rename to evolven3fit/evolgrid.cc
diff --git a/nnpdfcpp/src/nnfit/inc/evolgrid.h b/evolven3fit/evolgrid.h
similarity index 100%
rename from nnpdfcpp/src/nnfit/inc/evolgrid.h
rename to evolven3fit/evolgrid.h
diff --git a/n3fit/evolven3fit/evolven3fit.cc b/evolven3fit/evolven3fit.cc.in
similarity index 97%
rename from n3fit/evolven3fit/evolven3fit.cc
rename to evolven3fit/evolven3fit.cc.in
index 5b29f2bd58..e01eee48d1 100644
--- a/n3fit/evolven3fit/evolven3fit.cc
+++ b/evolven3fit/evolven3fit.cc.in
@@ -13,7 +13,6 @@
#include
#include
#include
-#include
#include
#include "exportgrid.h"
@@ -27,6 +26,8 @@ using std::string;
using std::stringstream;
using std::stoi;
+#define DBPATH "@PROFILE_PREFIX@/theory.db"
+
// Check if folder exists
bool CheckConsistency(string const& folder, string const& exportfile)
{
@@ -96,7 +97,7 @@ int main(int argc, char **argv)
// load theory from db
std::map theory_map;
- NNPDF::IndexDB db(get_data_path() + "/theory.db", "theoryIndex");
+ NNPDF::IndexDB db(DBPATH, "theoryIndex");
auto keys = APFEL::kValues;
keys.push_back("EScaleVar");
db.ExtractMap(theory_id, keys, theory_map);
diff --git a/nnpdfcpp/src/common/src/exportgrid.cc b/evolven3fit/exportgrid.cc
similarity index 100%
rename from nnpdfcpp/src/common/src/exportgrid.cc
rename to evolven3fit/exportgrid.cc
diff --git a/nnpdfcpp/src/common/inc/exportgrid.h b/evolven3fit/exportgrid.h
similarity index 100%
rename from nnpdfcpp/src/common/inc/exportgrid.h
rename to evolven3fit/exportgrid.h
diff --git a/n3fit/evolven3fit/varflavors.py b/evolven3fit/varflavors.py
similarity index 100%
rename from n3fit/evolven3fit/varflavors.py
rename to evolven3fit/varflavors.py
diff --git a/libnnpdf/CMakeLists.txt b/libnnpdf/CMakeLists.txt
index 0147d12f26..9fbf64e4ee 100644
--- a/libnnpdf/CMakeLists.txt
+++ b/libnnpdf/CMakeLists.txt
@@ -3,11 +3,6 @@ set(exec_prefix "${prefix}")
set(includedir "${prefix}/include")
set(libdir "${prefix}/lib")
-configure_file(
- "${PROJECT_SOURCE_DIR}/libnnpdf/nnprofile.yaml.in"
- "${PROJECT_SOURCE_DIR}/libnnpdf/nnprofile.yaml"
- )
-
configure_file(
"${PROJECT_SOURCE_DIR}/libnnpdf/src/NNPDF/config.h.in"
"${PROJECT_SOURCE_DIR}/libnnpdf/src/NNPDF/config.h"
@@ -58,14 +53,6 @@ target_link_libraries(nnpdf ${LHAPDF_LIBRARIES} ${GSL_LDFLAGS} ${SQLITE3_LDFLAGS
install(FILES ${PROJECT_SOURCE_DIR}/libnnpdf/scripts/nnpdf.pc DESTINATION lib/pkgconfig)
install(DIRECTORY src/NNPDF DESTINATION include)
-
file(WRITE ${PROJECT_SOURCE_DIR}/libnnpdf/REAMDE.md "The share folder of NNPDF has been moved, see: https://github.com/NNPDF/nnpdf/pull/1861\n")
install(FILES ${PROJECT_SOURCE_DIR}/libnnpdf/REAMDE.md DESTINATION share/NNPDF)
-install(FILES ${PROJECT_SOURCE_DIR}/libnnpdf/nnprofile.yaml DESTINATION share/NNPDF)
install(TARGETS nnpdf DESTINATION lib)
-
-add_subdirectory(wrapper)
-
-if(ENABLE_TESTS)
- add_subdirectory(tests)
-endif()
diff --git a/libnnpdf/nnprofile.yaml.in b/libnnpdf/nnprofile.yaml.in
index 4765fbe5e9..e3f5486208 100644
--- a/libnnpdf/nnprofile.yaml.in
+++ b/libnnpdf/nnprofile.yaml.in
@@ -1,9 +1,5 @@
# Local resource locations
-data_path: '@PROFILE_PREFIX@/data/'
-results_path: '@PROFILE_PREFIX@/results/'
-hyperscan_path: '@PROFILE_PREFIX@/hyperscan_results/'
-validphys_cache_path: '@PROFILE_PREFIX@/vp-cache/'
-config_path: '@PROFILE_PREFIX@/config/'
+data_path: '@PROFILE_PREFIX@'
# Remote resource locations
fit_urls:
diff --git a/libnnpdf/tests/CMakeLists.txt b/libnnpdf/tests/CMakeLists.txt
deleted file mode 100644
index a4cb08bab1..0000000000
--- a/libnnpdf/tests/CMakeLists.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-add_executable(catch_test EXCLUDE_FROM_ALL main.cc experiment_test.cc test_utils.cc)
-target_link_libraries(catch_test nnpdf ${LibArchive_LIBRARIES})
diff --git a/libnnpdf/tests/catch.hpp b/libnnpdf/tests/catch.hpp
deleted file mode 100644
index f7681f49ea..0000000000
--- a/libnnpdf/tests/catch.hpp
+++ /dev/null
@@ -1,11545 +0,0 @@
-/*
- * Catch v1.9.6
- * Generated: 2017-06-27 12:19:54.557875
- * ----------------------------------------------------------
- * This file has been merged from multiple headers. Please don't edit it directly
- * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved.
- *
- * 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)
- */
-#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
-#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED
-
-#define TWOBLUECUBES_CATCH_HPP_INCLUDED
-
-#ifdef __clang__
-# pragma clang system_header
-#elif defined __GNUC__
-# pragma GCC system_header
-#endif
-
-// #included from: internal/catch_suppress_warnings.h
-
-#ifdef __clang__
-# ifdef __ICC // icpc defines the __clang__ macro
-# pragma warning(push)
-# pragma warning(disable: 161 1682)
-# else // __ICC
-# pragma clang diagnostic ignored "-Wglobal-constructors"
-# pragma clang diagnostic ignored "-Wvariadic-macros"
-# pragma clang diagnostic ignored "-Wc99-extensions"
-# pragma clang diagnostic ignored "-Wunused-variable"
-# pragma clang diagnostic push
-# pragma clang diagnostic ignored "-Wpadded"
-# pragma clang diagnostic ignored "-Wc++98-compat"
-# pragma clang diagnostic ignored "-Wc++98-compat-pedantic"
-# pragma clang diagnostic ignored "-Wswitch-enum"
-# pragma clang diagnostic ignored "-Wcovered-switch-default"
-# endif
-#elif defined __GNUC__
-# pragma GCC diagnostic ignored "-Wvariadic-macros"
-# pragma GCC diagnostic ignored "-Wunused-variable"
-# pragma GCC diagnostic ignored "-Wparentheses"
-
-# pragma GCC diagnostic push
-# pragma GCC diagnostic ignored "-Wpadded"
-#endif
-#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER)
-# define CATCH_IMPL
-#endif
-
-#ifdef CATCH_IMPL
-# ifndef CLARA_CONFIG_MAIN
-# define CLARA_CONFIG_MAIN_NOT_DEFINED
-# define CLARA_CONFIG_MAIN
-# endif
-#endif
-
-// #included from: internal/catch_notimplemented_exception.h
-#define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_H_INCLUDED
-
-// #included from: catch_common.h
-#define TWOBLUECUBES_CATCH_COMMON_H_INCLUDED
-
-// #included from: catch_compiler_capabilities.h
-#define TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED
-
-// Detect a number of compiler features - mostly C++11/14 conformance - by compiler
-// The following features are defined:
-//
-// CATCH_CONFIG_CPP11_NULLPTR : is nullptr supported?
-// CATCH_CONFIG_CPP11_NOEXCEPT : is noexcept supported?
-// CATCH_CONFIG_CPP11_GENERATED_METHODS : The delete and default keywords for compiler generated methods
-// CATCH_CONFIG_CPP11_IS_ENUM : std::is_enum is supported?
-// CATCH_CONFIG_CPP11_TUPLE : std::tuple is supported
-// CATCH_CONFIG_CPP11_LONG_LONG : is long long supported?
-// CATCH_CONFIG_CPP11_OVERRIDE : is override supported?
-// CATCH_CONFIG_CPP11_UNIQUE_PTR : is unique_ptr supported (otherwise use auto_ptr)
-// CATCH_CONFIG_CPP11_SHUFFLE : is std::shuffle supported?
-// CATCH_CONFIG_CPP11_TYPE_TRAITS : are type_traits and enable_if supported?
-
-// CATCH_CONFIG_CPP11_OR_GREATER : Is C++11 supported?
-
-// CATCH_CONFIG_VARIADIC_MACROS : are variadic macros supported?
-// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported?
-// CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported?
-// CATCH_CONFIG_POSIX_SIGNALS : are POSIX signals supported?
-// ****************
-// Note to maintainers: if new toggles are added please document them
-// in configuration.md, too
-// ****************
-
-// In general each macro has a _NO_ form
-// (e.g. CATCH_CONFIG_CPP11_NO_NULLPTR) which disables the feature.
-// Many features, at point of detection, define an _INTERNAL_ macro, so they
-// can be combined, en-mass, with the _NO_ forms later.
-
-// All the C++11 features can be disabled with CATCH_CONFIG_NO_CPP11
-
-#ifdef __cplusplus
-
-# if __cplusplus >= 201103L
-# define CATCH_CPP11_OR_GREATER
-# endif
-
-# if __cplusplus >= 201402L
-# define CATCH_CPP14_OR_GREATER
-# endif
-
-#endif
-
-#ifdef __clang__
-
-# if __has_feature(cxx_nullptr)
-# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
-# endif
-
-# if __has_feature(cxx_noexcept)
-# define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
-# endif
-
-# if defined(CATCH_CPP11_OR_GREATER)
-# define CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
- _Pragma( "clang diagnostic push" ) \
- _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" )
-# define CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
- _Pragma( "clang diagnostic pop" )
-
-# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \
- _Pragma( "clang diagnostic push" ) \
- _Pragma( "clang diagnostic ignored \"-Wparentheses\"" )
-# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \
- _Pragma( "clang diagnostic pop" )
-# endif
-
-#endif // __clang__
-
-////////////////////////////////////////////////////////////////////////////////
-// We know some environments not to support full POSIX signals
-#if defined(__CYGWIN__) || defined(__QNX__)
-
-# if !defined(CATCH_CONFIG_POSIX_SIGNALS)
-# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS
-# endif
-
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-// Cygwin
-#ifdef __CYGWIN__
-
-// Required for some versions of Cygwin to declare gettimeofday
-// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin
-# define _BSD_SOURCE
-
-#endif // __CYGWIN__
-
-////////////////////////////////////////////////////////////////////////////////
-// Borland
-#ifdef __BORLANDC__
-
-#endif // __BORLANDC__
-
-////////////////////////////////////////////////////////////////////////////////
-// EDG
-#ifdef __EDG_VERSION__
-
-#endif // __EDG_VERSION__
-
-////////////////////////////////////////////////////////////////////////////////
-// Digital Mars
-#ifdef __DMC__
-
-#endif // __DMC__
-
-////////////////////////////////////////////////////////////////////////////////
-// GCC
-#ifdef __GNUC__
-
-# if __GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__)
-# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
-# endif
-
-// - otherwise more recent versions define __cplusplus >= 201103L
-// and will get picked up below
-
-#endif // __GNUC__
-
-////////////////////////////////////////////////////////////////////////////////
-// Visual C++
-#ifdef _MSC_VER
-
-#define CATCH_INTERNAL_CONFIG_WINDOWS_SEH
-
-#if (_MSC_VER >= 1600)
-# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
-# define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR
-#endif
-
-#if (_MSC_VER >= 1900 ) // (VC++ 13 (VS2015))
-#define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
-#define CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
-#define CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE
-#define CATCH_INTERNAL_CONFIG_CPP11_TYPE_TRAITS
-#endif
-
-#endif // _MSC_VER
-
-////////////////////////////////////////////////////////////////////////////////
-
-// Use variadic macros if the compiler supports them
-#if ( defined _MSC_VER && _MSC_VER > 1400 && !defined __EDGE__) || \
- ( defined __WAVE__ && __WAVE_HAS_VARIADICS ) || \
- ( defined __GNUC__ && __GNUC__ >= 3 ) || \
- ( !defined __cplusplus && __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L )
-
-#define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
-
-#endif
-
-// Use __COUNTER__ if the compiler supports it
-#if ( defined _MSC_VER && _MSC_VER >= 1300 ) || \
- ( defined __GNUC__ && ( __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3 )) ) || \
- ( defined __clang__ && __clang_major__ >= 3 )
-
-#define CATCH_INTERNAL_CONFIG_COUNTER
-
-#endif
-
-////////////////////////////////////////////////////////////////////////////////
-// C++ language feature support
-
-// catch all support for C++11
-#if defined(CATCH_CPP11_OR_GREATER)
-
-# if !defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR)
-# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR
-# endif
-
-# ifndef CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
-# define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT
-# endif
-
-# ifndef CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
-# define CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS
-# endif
-
-# ifndef CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM
-# define CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM
-# endif
-
-# ifndef CATCH_INTERNAL_CONFIG_CPP11_TUPLE
-# define CATCH_INTERNAL_CONFIG_CPP11_TUPLE
-# endif
-
-# ifndef CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
-# define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS
-# endif
-
-# if !defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG)
-# define CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG
-# endif
-
-# if !defined(CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE)
-# define CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE
-# endif
-# if !defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR)
-# define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR
-# endif
-# if !defined(CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE)
-# define CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE
-# endif
-# if !defined(CATCH_INTERNAL_CONFIG_CPP11_TYPE_TRAITS)
-# define CATCH_INTERNAL_CONFIG_CPP11_TYPE_TRAITS
-# endif
-
-#endif // __cplusplus >= 201103L
-
-// Now set the actual defines based on the above + anything the user has configured
-#if defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR) && !defined(CATCH_CONFIG_CPP11_NO_NULLPTR) && !defined(CATCH_CONFIG_CPP11_NULLPTR) && !defined(CATCH_CONFIG_NO_CPP11)
-# define CATCH_CONFIG_CPP11_NULLPTR
-#endif
-#if defined(CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_CONFIG_CPP11_NO_NOEXCEPT) && !defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_CONFIG_NO_CPP11)
-# define CATCH_CONFIG_CPP11_NOEXCEPT
-#endif
-#if defined(CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS) && !defined(CATCH_CONFIG_CPP11_NO_GENERATED_METHODS) && !defined(CATCH_CONFIG_CPP11_GENERATED_METHODS) && !defined(CATCH_CONFIG_NO_CPP11)
-# define CATCH_CONFIG_CPP11_GENERATED_METHODS
-#endif
-#if defined(CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM) && !defined(CATCH_CONFIG_CPP11_NO_IS_ENUM) && !defined(CATCH_CONFIG_CPP11_IS_ENUM) && !defined(CATCH_CONFIG_NO_CPP11)
-# define CATCH_CONFIG_CPP11_IS_ENUM
-#endif
-#if defined(CATCH_INTERNAL_CONFIG_CPP11_TUPLE) && !defined(CATCH_CONFIG_CPP11_NO_TUPLE) && !defined(CATCH_CONFIG_CPP11_TUPLE) && !defined(CATCH_CONFIG_NO_CPP11)
-# define CATCH_CONFIG_CPP11_TUPLE
-#endif
-#if defined(CATCH_INTERNAL_CONFIG_VARIADIC_MACROS) && !defined(CATCH_CONFIG_NO_VARIADIC_MACROS) && !defined(CATCH_CONFIG_VARIADIC_MACROS)
-# define CATCH_CONFIG_VARIADIC_MACROS
-#endif
-#if defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_CPP11_NO_LONG_LONG) && !defined(CATCH_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_NO_CPP11)
-# define CATCH_CONFIG_CPP11_LONG_LONG
-#endif
-#if defined(CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE) && !defined(CATCH_CONFIG_CPP11_NO_OVERRIDE) && !defined(CATCH_CONFIG_CPP11_OVERRIDE) && !defined(CATCH_CONFIG_NO_CPP11)
-# define CATCH_CONFIG_CPP11_OVERRIDE
-#endif
-#if defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_NO_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_CPP11)
-# define CATCH_CONFIG_CPP11_UNIQUE_PTR
-#endif
-// Use of __COUNTER__ is suppressed if __JETBRAINS_IDE__ is #defined (meaning we're being parsed by a JetBrains IDE for
-// analytics) because, at time of writing, __COUNTER__ is not properly handled by it.
-// This does not affect compilation
-#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) && !defined(__JETBRAINS_IDE__)
-# define CATCH_CONFIG_COUNTER
-#endif
-#if defined(CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE) && !defined(CATCH_CONFIG_CPP11_NO_SHUFFLE) && !defined(CATCH_CONFIG_CPP11_SHUFFLE) && !defined(CATCH_CONFIG_NO_CPP11)
-# define CATCH_CONFIG_CPP11_SHUFFLE
-#endif
-# if defined(CATCH_INTERNAL_CONFIG_CPP11_TYPE_TRAITS) && !defined(CATCH_CONFIG_CPP11_NO_TYPE_TRAITS) && !defined(CATCH_CONFIG_CPP11_TYPE_TRAITS) && !defined(CATCH_CONFIG_NO_CPP11)
-# define CATCH_CONFIG_CPP11_TYPE_TRAITS
-# endif
-#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH)
-# define CATCH_CONFIG_WINDOWS_SEH
-#endif
-// This is set by default, because we assume that unix compilers are posix-signal-compatible by default.
-#if !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS)
-# define CATCH_CONFIG_POSIX_SIGNALS
-#endif
-
-#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS)
-# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS
-# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS
-#endif
-#if !defined(CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS)
-# define CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS
-# define CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
-#endif
-
-// noexcept support:
-#if defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_NOEXCEPT)
-# define CATCH_NOEXCEPT noexcept
-# define CATCH_NOEXCEPT_IS(x) noexcept(x)
-#else
-# define CATCH_NOEXCEPT throw()
-# define CATCH_NOEXCEPT_IS(x)
-#endif
-
-// nullptr support
-#ifdef CATCH_CONFIG_CPP11_NULLPTR
-# define CATCH_NULL nullptr
-#else
-# define CATCH_NULL NULL
-#endif
-
-// override support
-#ifdef CATCH_CONFIG_CPP11_OVERRIDE
-# define CATCH_OVERRIDE override
-#else
-# define CATCH_OVERRIDE
-#endif
-
-// unique_ptr support
-#ifdef CATCH_CONFIG_CPP11_UNIQUE_PTR
-# define CATCH_AUTO_PTR( T ) std::unique_ptr
-#else
-# define CATCH_AUTO_PTR( T ) std::auto_ptr
-#endif
-
-#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line
-#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )
-#ifdef CATCH_CONFIG_COUNTER
-# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ )
-#else
-# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )
-#endif
-
-#define INTERNAL_CATCH_STRINGIFY2( expr ) #expr
-#define INTERNAL_CATCH_STRINGIFY( expr ) INTERNAL_CATCH_STRINGIFY2( expr )
-
-#include
-#include
-
-namespace Catch {
-
- struct IConfig;
-
- struct CaseSensitive { enum Choice {
- Yes,
- No
- }; };
-
- class NonCopyable {
-#ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
- NonCopyable( NonCopyable const& ) = delete;
- NonCopyable( NonCopyable && ) = delete;
- NonCopyable& operator = ( NonCopyable const& ) = delete;
- NonCopyable& operator = ( NonCopyable && ) = delete;
-#else
- NonCopyable( NonCopyable const& info );
- NonCopyable& operator = ( NonCopyable const& );
-#endif
-
- protected:
- NonCopyable() {}
- virtual ~NonCopyable();
- };
-
- class SafeBool {
- public:
- typedef void (SafeBool::*type)() const;
-
- static type makeSafe( bool value ) {
- return value ? &SafeBool::trueValue : 0;
- }
- private:
- void trueValue() const {}
- };
-
- template
- inline void deleteAll( ContainerT& container ) {
- typename ContainerT::const_iterator it = container.begin();
- typename ContainerT::const_iterator itEnd = container.end();
- for(; it != itEnd; ++it )
- delete *it;
- }
- template
- inline void deleteAllValues( AssociativeContainerT& container ) {
- typename AssociativeContainerT::const_iterator it = container.begin();
- typename AssociativeContainerT::const_iterator itEnd = container.end();
- for(; it != itEnd; ++it )
- delete it->second;
- }
-
- bool startsWith( std::string const& s, std::string const& prefix );
- bool startsWith( std::string const& s, char prefix );
- bool endsWith( std::string const& s, std::string const& suffix );
- bool endsWith( std::string const& s, char suffix );
- bool contains( std::string const& s, std::string const& infix );
- void toLowerInPlace( std::string& s );
- std::string toLower( std::string const& s );
- std::string trim( std::string const& str );
- bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis );
-
- struct pluralise {
- pluralise( std::size_t count, std::string const& label );
-
- friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser );
-
- std::size_t m_count;
- std::string m_label;
- };
-
- struct SourceLineInfo {
-
- SourceLineInfo();
- SourceLineInfo( char const* _file, std::size_t _line );
-# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
- SourceLineInfo(SourceLineInfo const& other) = default;
- SourceLineInfo( SourceLineInfo && ) = default;
- SourceLineInfo& operator = ( SourceLineInfo const& ) = default;
- SourceLineInfo& operator = ( SourceLineInfo && ) = default;
-# endif
- bool empty() const;
- bool operator == ( SourceLineInfo const& other ) const;
- bool operator < ( SourceLineInfo const& other ) const;
-
- char const* file;
- std::size_t line;
- };
-
- std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info );
-
- // This is just here to avoid compiler warnings with macro constants and boolean literals
- inline bool isTrue( bool value ){ return value; }
- inline bool alwaysTrue() { return true; }
- inline bool alwaysFalse() { return false; }
-
- void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo );
-
- void seedRng( IConfig const& config );
- unsigned int rngSeed();
-
- // Use this in variadic streaming macros to allow
- // >> +StreamEndStop
- // as well as
- // >> stuff +StreamEndStop
- struct StreamEndStop {
- std::string operator+() {
- return std::string();
- }
- };
- template
- T const& operator + ( T const& value, StreamEndStop ) {
- return value;
- }
-}
-
-#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) )
-#define CATCH_INTERNAL_ERROR( msg ) ::Catch::throwLogicError( msg, CATCH_INTERNAL_LINEINFO );
-
-namespace Catch {
-
- class NotImplementedException : public std::exception
- {
- public:
- NotImplementedException( SourceLineInfo const& lineInfo );
- NotImplementedException( NotImplementedException const& ) {}
-
- virtual ~NotImplementedException() CATCH_NOEXCEPT {}
-
- virtual const char* what() const CATCH_NOEXCEPT;
-
- private:
- std::string m_what;
- SourceLineInfo m_lineInfo;
- };
-
-} // end namespace Catch
-
-///////////////////////////////////////////////////////////////////////////////
-#define CATCH_NOT_IMPLEMENTED throw Catch::NotImplementedException( CATCH_INTERNAL_LINEINFO )
-
-// #included from: internal/catch_context.h
-#define TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED
-
-// #included from: catch_interfaces_generators.h
-#define TWOBLUECUBES_CATCH_INTERFACES_GENERATORS_H_INCLUDED
-
-#include
-
-namespace Catch {
-
- struct IGeneratorInfo {
- virtual ~IGeneratorInfo();
- virtual bool moveNext() = 0;
- virtual std::size_t getCurrentIndex() const = 0;
- };
-
- struct IGeneratorsForTest {
- virtual ~IGeneratorsForTest();
-
- virtual IGeneratorInfo& getGeneratorInfo( std::string const& fileInfo, std::size_t size ) = 0;
- virtual bool moveNext() = 0;
- };
-
- IGeneratorsForTest* createGeneratorsForTest();
-
-} // end namespace Catch
-
-// #included from: catch_ptr.hpp
-#define TWOBLUECUBES_CATCH_PTR_HPP_INCLUDED
-
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wpadded"
-#endif
-
-namespace Catch {
-
- // An intrusive reference counting smart pointer.
- // T must implement addRef() and release() methods
- // typically implementing the IShared interface
- template
- class Ptr {
- public:
- Ptr() : m_p( CATCH_NULL ){}
- Ptr( T* p ) : m_p( p ){
- if( m_p )
- m_p->addRef();
- }
- Ptr( Ptr const& other ) : m_p( other.m_p ){
- if( m_p )
- m_p->addRef();
- }
- ~Ptr(){
- if( m_p )
- m_p->release();
- }
- void reset() {
- if( m_p )
- m_p->release();
- m_p = CATCH_NULL;
- }
- Ptr& operator = ( T* p ){
- Ptr temp( p );
- swap( temp );
- return *this;
- }
- Ptr& operator = ( Ptr const& other ){
- Ptr temp( other );
- swap( temp );
- return *this;
- }
- void swap( Ptr& other ) { std::swap( m_p, other.m_p ); }
- T* get() const{ return m_p; }
- T& operator*() const { return *m_p; }
- T* operator->() const { return m_p; }
- bool operator !() const { return m_p == CATCH_NULL; }
- operator SafeBool::type() const { return SafeBool::makeSafe( m_p != CATCH_NULL ); }
-
- private:
- T* m_p;
- };
-
- struct IShared : NonCopyable {
- virtual ~IShared();
- virtual void addRef() const = 0;
- virtual void release() const = 0;
- };
-
- template
- struct SharedImpl : T {
-
- SharedImpl() : m_rc( 0 ){}
-
- virtual void addRef() const {
- ++m_rc;
- }
- virtual void release() const {
- if( --m_rc == 0 )
- delete this;
- }
-
- mutable unsigned int m_rc;
- };
-
-} // end namespace Catch
-
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
-
-namespace Catch {
-
- class TestCase;
- class Stream;
- struct IResultCapture;
- struct IRunner;
- struct IGeneratorsForTest;
- struct IConfig;
-
- struct IContext
- {
- virtual ~IContext();
-
- virtual IResultCapture* getResultCapture() = 0;
- virtual IRunner* getRunner() = 0;
- virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) = 0;
- virtual bool advanceGeneratorsForCurrentTest() = 0;
- virtual Ptr getConfig() const = 0;
- };
-
- struct IMutableContext : IContext
- {
- virtual ~IMutableContext();
- virtual void setResultCapture( IResultCapture* resultCapture ) = 0;
- virtual void setRunner( IRunner* runner ) = 0;
- virtual void setConfig( Ptr const& config ) = 0;
- };
-
- IContext& getCurrentContext();
- IMutableContext& getCurrentMutableContext();
- void cleanUpContext();
- Stream createStream( std::string const& streamName );
-
-}
-
-// #included from: internal/catch_test_registry.hpp
-#define TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED
-
-// #included from: catch_interfaces_testcase.h
-#define TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED
-
-#include
-
-namespace Catch {
-
- class TestSpec;
-
- struct ITestCase : IShared {
- virtual void invoke () const = 0;
- protected:
- virtual ~ITestCase();
- };
-
- class TestCase;
- struct IConfig;
-
- struct ITestCaseRegistry {
- virtual ~ITestCaseRegistry();
- virtual std::vector const& getAllTests() const = 0;
- virtual std::vector const& getAllTestsSorted( IConfig const& config ) const = 0;
- };
-
- bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config );
- std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config );
- std::vector const& getAllTestCasesSorted( IConfig const& config );
-
-}
-
-namespace Catch {
-
-template
-class MethodTestCase : public SharedImpl {
-
-public:
- MethodTestCase( void (C::*method)() ) : m_method( method ) {}
-
- virtual void invoke() const {
- C obj;
- (obj.*m_method)();
- }
-
-private:
- virtual ~MethodTestCase() {}
-
- void (C::*m_method)();
-};
-
-typedef void(*TestFunction)();
-
-struct NameAndDesc {
- NameAndDesc( const char* _name = "", const char* _description= "" )
- : name( _name ), description( _description )
- {}
-
- const char* name;
- const char* description;
-};
-
-void registerTestCase
- ( ITestCase* testCase,
- char const* className,
- NameAndDesc const& nameAndDesc,
- SourceLineInfo const& lineInfo );
-
-struct AutoReg {
-
- AutoReg
- ( TestFunction function,
- SourceLineInfo const& lineInfo,
- NameAndDesc const& nameAndDesc );
-
- template
- AutoReg
- ( void (C::*method)(),
- char const* className,
- NameAndDesc const& nameAndDesc,
- SourceLineInfo const& lineInfo ) {
-
- registerTestCase
- ( new MethodTestCase( method ),
- className,
- nameAndDesc,
- lineInfo );
- }
-
- ~AutoReg();
-
-private:
- AutoReg( AutoReg const& );
- void operator= ( AutoReg const& );
-};
-
-void registerTestCaseFunction
- ( TestFunction function,
- SourceLineInfo const& lineInfo,
- NameAndDesc const& nameAndDesc );
-
-} // end namespace Catch
-
-#ifdef CATCH_CONFIG_VARIADIC_MACROS
- ///////////////////////////////////////////////////////////////////////////////
- #define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \
- static void TestName(); \
- CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
- namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); } \
- CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
- static void TestName()
- #define INTERNAL_CATCH_TESTCASE( ... ) \
- INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), __VA_ARGS__ )
-
- ///////////////////////////////////////////////////////////////////////////////
- #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \
- CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
- namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); } \
- CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
-
- ///////////////////////////////////////////////////////////////////////////////
- #define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\
- CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
- namespace{ \
- struct TestName : ClassName{ \
- void test(); \
- }; \
- Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestName::test, #ClassName, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); \
- } \
- CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
- void TestName::test()
- #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \
- INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, __VA_ARGS__ )
-
- ///////////////////////////////////////////////////////////////////////////////
- #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \
- CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
- Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); \
- CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
-
-#else
- ///////////////////////////////////////////////////////////////////////////////
- #define INTERNAL_CATCH_TESTCASE2( TestName, Name, Desc ) \
- static void TestName(); \
- CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
- namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); }\
- CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
- static void TestName()
- #define INTERNAL_CATCH_TESTCASE( Name, Desc ) \
- INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), Name, Desc )
-
- ///////////////////////////////////////////////////////////////////////////////
- #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \
- CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
- namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( Name, Desc ), CATCH_INTERNAL_LINEINFO ); } \
- CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
-
- ///////////////////////////////////////////////////////////////////////////////
- #define INTERNAL_CATCH_TEST_CASE_METHOD2( TestCaseName, ClassName, TestName, Desc )\
- CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
- namespace{ \
- struct TestCaseName : ClassName{ \
- void test(); \
- }; \
- Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestCaseName::test, #ClassName, Catch::NameAndDesc( TestName, Desc ), CATCH_INTERNAL_LINEINFO ); \
- } \
- CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \
- void TestCaseName::test()
- #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, TestName, Desc )\
- INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, TestName, Desc )
-
- ///////////////////////////////////////////////////////////////////////////////
- #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, Name, Desc ) \
- CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \
- Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); \
- CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS
-
-#endif
-
-// #included from: internal/catch_capture.hpp
-#define TWOBLUECUBES_CATCH_CAPTURE_HPP_INCLUDED
-
-// #included from: catch_result_builder.h
-#define TWOBLUECUBES_CATCH_RESULT_BUILDER_H_INCLUDED
-
-// #included from: catch_result_type.h
-#define TWOBLUECUBES_CATCH_RESULT_TYPE_H_INCLUDED
-
-namespace Catch {
-
- // ResultWas::OfType enum
- struct ResultWas { enum OfType {
- Unknown = -1,
- Ok = 0,
- Info = 1,
- Warning = 2,
-
- FailureBit = 0x10,
-
- ExpressionFailed = FailureBit | 1,
- ExplicitFailure = FailureBit | 2,
-
- Exception = 0x100 | FailureBit,
-
- ThrewException = Exception | 1,
- DidntThrowException = Exception | 2,
-
- FatalErrorCondition = 0x200 | FailureBit
-
- }; };
-
- inline bool isOk( ResultWas::OfType resultType ) {
- return ( resultType & ResultWas::FailureBit ) == 0;
- }
- inline bool isJustInfo( int flags ) {
- return flags == ResultWas::Info;
- }
-
- // ResultDisposition::Flags enum
- struct ResultDisposition { enum Flags {
- Normal = 0x01,
-
- ContinueOnFailure = 0x02, // Failures fail test, but execution continues
- FalseTest = 0x04, // Prefix expression with !
- SuppressFail = 0x08 // Failures are reported but do not fail the test
- }; };
-
- inline ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ) {
- return static_cast( static_cast( lhs ) | static_cast( rhs ) );
- }
-
- inline bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; }
- inline bool isFalseTest( int flags ) { return ( flags & ResultDisposition::FalseTest ) != 0; }
- inline bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; }
-
-} // end namespace Catch
-
-// #included from: catch_assertionresult.h
-#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_H_INCLUDED
-
-#include
-
-namespace Catch {
-
- struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison;
-
- struct DecomposedExpression
- {
- virtual ~DecomposedExpression() {}
- virtual bool isBinaryExpression() const {
- return false;
- }
- virtual void reconstructExpression( std::string& dest ) const = 0;
-
- // Only simple binary comparisons can be decomposed.
- // If more complex check is required then wrap sub-expressions in parentheses.
- template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator + ( T const& );
- template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator - ( T const& );
- template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator * ( T const& );
- template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator / ( T const& );
- template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator % ( T const& );
- template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator && ( T const& );
- template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator || ( T const& );
-
- private:
- DecomposedExpression& operator = (DecomposedExpression const&);
- };
-
- struct AssertionInfo
- {
- AssertionInfo() {}
- AssertionInfo( char const * _macroName,
- SourceLineInfo const& _lineInfo,
- char const * _capturedExpression,
- ResultDisposition::Flags _resultDisposition,
- char const * _secondArg = "");
-
- char const * macroName;
- SourceLineInfo lineInfo;
- char const * capturedExpression;
- ResultDisposition::Flags resultDisposition;
- char const * secondArg;
- };
-
- struct AssertionResultData
- {
- AssertionResultData() : decomposedExpression( CATCH_NULL )
- , resultType( ResultWas::Unknown )
- , negated( false )
- , parenthesized( false ) {}
-
- void negate( bool parenthesize ) {
- negated = !negated;
- parenthesized = parenthesize;
- if( resultType == ResultWas::Ok )
- resultType = ResultWas::ExpressionFailed;
- else if( resultType == ResultWas::ExpressionFailed )
- resultType = ResultWas::Ok;
- }
-
- std::string const& reconstructExpression() const {
- if( decomposedExpression != CATCH_NULL ) {
- decomposedExpression->reconstructExpression( reconstructedExpression );
- if( parenthesized ) {
- reconstructedExpression.insert( 0, 1, '(' );
- reconstructedExpression.append( 1, ')' );
- }
- if( negated ) {
- reconstructedExpression.insert( 0, 1, '!' );
- }
- decomposedExpression = CATCH_NULL;
- }
- return reconstructedExpression;
- }
-
- mutable DecomposedExpression const* decomposedExpression;
- mutable std::string reconstructedExpression;
- std::string message;
- ResultWas::OfType resultType;
- bool negated;
- bool parenthesized;
- };
-
- class AssertionResult {
- public:
- AssertionResult();
- AssertionResult( AssertionInfo const& info, AssertionResultData const& data );
- ~AssertionResult();
-# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS
- AssertionResult( AssertionResult const& ) = default;
- AssertionResult( AssertionResult && ) = default;
- AssertionResult& operator = ( AssertionResult const& ) = default;
- AssertionResult& operator = ( AssertionResult && ) = default;
-# endif
-
- bool isOk() const;
- bool succeeded() const;
- ResultWas::OfType getResultType() const;
- bool hasExpression() const;
- bool hasMessage() const;
- std::string getExpression() const;
- std::string getExpressionInMacro() const;
- bool hasExpandedExpression() const;
- std::string getExpandedExpression() const;
- std::string getMessage() const;
- SourceLineInfo getSourceInfo() const;
- std::string getTestMacroName() const;
- void discardDecomposedExpression() const;
- void expandDecomposedExpression() const;
-
- protected:
- AssertionInfo m_info;
- AssertionResultData m_resultData;
- };
-
-} // end namespace Catch
-
-// #included from: catch_matchers.hpp
-#define TWOBLUECUBES_CATCH_MATCHERS_HPP_INCLUDED
-
-namespace Catch {
-namespace Matchers {
- namespace Impl {
-
- template struct MatchAllOf;
- template struct MatchAnyOf;
- template struct MatchNotOf;
-
- class MatcherUntypedBase {
- public:
- std::string toString() const {
- if( m_cachedToString.empty() )
- m_cachedToString = describe();
- return m_cachedToString;
- }
-
- protected:
- virtual ~MatcherUntypedBase();
- virtual std::string describe() const = 0;
- mutable std::string m_cachedToString;
- private:
- MatcherUntypedBase& operator = ( MatcherUntypedBase const& );
- };
-
- template
- struct MatcherMethod {
- virtual bool match( ObjectT const& arg ) const = 0;
- };
- template
- struct MatcherMethod {
- virtual bool match( PtrT* arg ) const = 0;
- };
-
- template
- struct MatcherBase : MatcherUntypedBase, MatcherMethod {
-
- MatchAllOf operator && ( MatcherBase const& other ) const;
- MatchAnyOf operator || ( MatcherBase const& other ) const;
- MatchNotOf operator ! () const;
- };
-
- template
- struct MatchAllOf : MatcherBase {
- virtual bool match( ArgT const& arg ) const CATCH_OVERRIDE {
- for( std::size_t i = 0; i < m_matchers.size(); ++i ) {
- if (!m_matchers[i]->match(arg))
- return false;
- }
- return true;
- }
- virtual std::string describe() const CATCH_OVERRIDE {
- std::string description;
- description.reserve( 4 + m_matchers.size()*32 );
- description += "( ";
- for( std::size_t i = 0; i < m_matchers.size(); ++i ) {
- if( i != 0 )
- description += " and ";
- description += m_matchers[i]->toString();
- }
- description += " )";
- return description;
- }
-
- MatchAllOf& operator && ( MatcherBase const& other ) {
- m_matchers.push_back( &other );
- return *this;
- }
-
- std::vector const*> m_matchers;
- };
- template
- struct MatchAnyOf : MatcherBase {
-
- virtual bool match( ArgT const& arg ) const CATCH_OVERRIDE {
- for( std::size_t i = 0; i < m_matchers.size(); ++i ) {
- if (m_matchers[i]->match(arg))
- return true;
- }
- return false;
- }
- virtual std::string describe() const CATCH_OVERRIDE {
- std::string description;
- description.reserve( 4 + m_matchers.size()*32 );
- description += "( ";
- for( std::size_t i = 0; i < m_matchers.size(); ++i ) {
- if( i != 0 )
- description += " or ";
- description += m_matchers[i]->toString();
- }
- description += " )";
- return description;
- }
-
- MatchAnyOf& operator || ( MatcherBase const& other ) {
- m_matchers.push_back( &other );
- return *this;
- }
-
- std::vector const*> m_matchers;
- };
-
- template
- struct MatchNotOf : MatcherBase {
-
- MatchNotOf( MatcherBase const& underlyingMatcher ) : m_underlyingMatcher( underlyingMatcher ) {}
-
- virtual bool match( ArgT const& arg ) const CATCH_OVERRIDE {
- return !m_underlyingMatcher.match( arg );
- }
-
- virtual std::string describe() const CATCH_OVERRIDE {
- return "not " + m_underlyingMatcher.toString();
- }
- MatcherBase const& m_underlyingMatcher;
- };
-
- template
- MatchAllOf MatcherBase::operator && ( MatcherBase const& other ) const {
- return MatchAllOf() && *this && other;
- }
- template
- MatchAnyOf MatcherBase::operator || ( MatcherBase const& other ) const {
- return MatchAnyOf() || *this || other;
- }
- template
- MatchNotOf MatcherBase::operator ! () const {
- return MatchNotOf( *this );
- }
-
- } // namespace Impl
-
- // The following functions create the actual matcher objects.
- // This allows the types to be inferred
- // - deprecated: prefer ||, && and !
- template
- inline Impl::MatchNotOf Not( Impl::MatcherBase const& underlyingMatcher ) {
- return Impl::MatchNotOf( underlyingMatcher );
- }
- template
- inline Impl::MatchAllOf AllOf( Impl::MatcherBase const& m1, Impl::MatcherBase const& m2 ) {
- return Impl::MatchAllOf() && m1 && m2;
- }
- template
- inline Impl::MatchAllOf AllOf( Impl::MatcherBase const& m1, Impl::MatcherBase const& m2, Impl::MatcherBase const& m3 ) {
- return Impl::MatchAllOf() && m1 && m2 && m3;
- }
- template
- inline Impl::MatchAnyOf AnyOf( Impl::MatcherBase const& m1, Impl::MatcherBase const& m2 ) {
- return Impl::MatchAnyOf() || m1 || m2;
- }
- template
- inline Impl::MatchAnyOf AnyOf( Impl::MatcherBase const& m1, Impl::MatcherBase const& m2, Impl::MatcherBase const& m3 ) {
- return Impl::MatchAnyOf() || m1 || m2 || m3;
- }
-
-} // namespace Matchers
-
-using namespace Matchers;
-using Matchers::Impl::MatcherBase;
-
-} // namespace Catch
-
-namespace Catch {
-
- struct TestFailureException{};
-
- template class ExpressionLhs;
-
- struct CopyableStream {
- CopyableStream() {}
- CopyableStream( CopyableStream const& other ) {
- oss << other.oss.str();
- }
- CopyableStream& operator=( CopyableStream const& other ) {
- oss.str(std::string());
- oss << other.oss.str();
- return *this;
- }
- std::ostringstream oss;
- };
-
- class ResultBuilder : public DecomposedExpression {
- public:
- ResultBuilder( char const* macroName,
- SourceLineInfo const& lineInfo,
- char const* capturedExpression,
- ResultDisposition::Flags resultDisposition,
- char const* secondArg = "" );
- ~ResultBuilder();
-
- template
- ExpressionLhs operator <= ( T const& operand );
- ExpressionLhs operator <= ( bool value );
-
- template
- ResultBuilder& operator << ( T const& value ) {
- m_stream().oss << value;
- return *this;
- }
-
- ResultBuilder& setResultType( ResultWas::OfType result );
- ResultBuilder& setResultType( bool result );
-
- void endExpression( DecomposedExpression const& expr );
-
- virtual void reconstructExpression( std::string& dest ) const CATCH_OVERRIDE;
-
- AssertionResult build() const;
- AssertionResult build( DecomposedExpression const& expr ) const;
-
- void useActiveException( ResultDisposition::Flags resultDisposition = ResultDisposition::Normal );
- void captureResult( ResultWas::OfType resultType );
- void captureExpression();
- void captureExpectedException( std::string const& expectedMessage );
- void captureExpectedException( Matchers::Impl::MatcherBase const& matcher );
- void handleResult( AssertionResult const& result );
- void react();
- bool shouldDebugBreak() const;
- bool allowThrows() const;
-
- template
- void captureMatch( ArgT const& arg, MatcherT const& matcher, char const* matcherString );
-
- void setExceptionGuard();
- void unsetExceptionGuard();
-
- private:
- AssertionInfo m_assertionInfo;
- AssertionResultData m_data;
-
- static CopyableStream &m_stream()
- {
- static CopyableStream s;
- return s;
- }
-
- bool m_shouldDebugBreak;
- bool m_shouldThrow;
- bool m_guardException;
- };
-
-} // namespace Catch
-
-// Include after due to circular dependency:
-// #included from: catch_expression_lhs.hpp
-#define TWOBLUECUBES_CATCH_EXPRESSION_LHS_HPP_INCLUDED
-
-// #included from: catch_evaluate.hpp
-#define TWOBLUECUBES_CATCH_EVALUATE_HPP_INCLUDED
-
-#ifdef _MSC_VER
-#pragma warning(push)
-#pragma warning(disable:4389) // '==' : signed/unsigned mismatch
-#pragma warning(disable:4312) // Converting int to T* using reinterpret_cast (issue on x64 platform)
-#endif
-
-#include
-
-namespace Catch {
-namespace Internal {
-
- enum Operator {
- IsEqualTo,
- IsNotEqualTo,
- IsLessThan,
- IsGreaterThan,
- IsLessThanOrEqualTo,
- IsGreaterThanOrEqualTo
- };
-
- template struct OperatorTraits { static const char* getName(){ return "*error*"; } };
- template<> struct OperatorTraits { static const char* getName(){ return "=="; } };
- template<> struct OperatorTraits { static const char* getName(){ return "!="; } };
- template<> struct OperatorTraits { static const char* getName(){ return "<"; } };
- template<> struct OperatorTraits { static const char* getName(){ return ">"; } };
- template<> struct OperatorTraits { static const char* getName(){ return "<="; } };
- template<> struct OperatorTraits{ static const char* getName(){ return ">="; } };
-
- template
- inline T& opCast(T const& t) { return const_cast(t); }
-
-// nullptr_t support based on pull request #154 from Konstantin Baumann
-#ifdef CATCH_CONFIG_CPP11_NULLPTR
- inline std::nullptr_t opCast(std::nullptr_t) { return nullptr; }
-#endif // CATCH_CONFIG_CPP11_NULLPTR
-
- // So the compare overloads can be operator agnostic we convey the operator as a template
- // enum, which is used to specialise an Evaluator for doing the comparison.
- template
- class Evaluator{};
-
- template
- struct Evaluator {
- static bool evaluate( T1 const& lhs, T2 const& rhs) {
- return bool( opCast( lhs ) == opCast( rhs ) );
- }
- };
- template
- struct Evaluator {
- static bool evaluate( T1 const& lhs, T2 const& rhs ) {
- return bool( opCast( lhs ) != opCast( rhs ) );
- }
- };
- template
- struct Evaluator {
- static bool evaluate( T1 const& lhs, T2 const& rhs ) {
- return bool( opCast( lhs ) < opCast( rhs ) );
- }
- };
- template
- struct Evaluator {
- static bool evaluate( T1 const& lhs, T2 const& rhs ) {
- return bool( opCast( lhs ) > opCast( rhs ) );
- }
- };
- template
- struct Evaluator {
- static bool evaluate( T1 const& lhs, T2 const& rhs ) {
- return bool( opCast( lhs ) >= opCast( rhs ) );
- }
- };
- template
- struct Evaluator {
- static bool evaluate( T1 const& lhs, T2 const& rhs ) {
- return bool( opCast( lhs ) <= opCast( rhs ) );
- }
- };
-
- template
- bool applyEvaluator( T1 const& lhs, T2 const& rhs ) {
- return Evaluator::evaluate( lhs, rhs );
- }
-
- // This level of indirection allows us to specialise for integer types
- // to avoid signed/ unsigned warnings
-
- // "base" overload
- template
- bool compare( T1 const& lhs, T2 const& rhs ) {
- return Evaluator::evaluate( lhs, rhs );
- }
-
- // unsigned X to int
- template bool compare( unsigned int lhs, int rhs ) {
- return applyEvaluator( lhs, static_cast( rhs ) );
- }
- template bool compare( unsigned long lhs, int rhs ) {
- return applyEvaluator( lhs, static_cast( rhs ) );
- }
- template bool compare( unsigned char lhs, int rhs ) {
- return applyEvaluator( lhs, static_cast( rhs ) );
- }
-
- // unsigned X to long
- template bool compare( unsigned int lhs, long rhs ) {
- return applyEvaluator( lhs, static_cast( rhs ) );
- }
- template bool compare( unsigned long lhs, long rhs ) {
- return applyEvaluator( lhs, static_cast( rhs ) );
- }
- template bool compare( unsigned char lhs, long rhs ) {
- return applyEvaluator( lhs, static_cast( rhs ) );
- }
-
- // int to unsigned X
- template bool compare( int lhs, unsigned int rhs ) {
- return applyEvaluator( static_cast( lhs ), rhs );
- }
- template bool compare( int lhs, unsigned long rhs ) {
- return applyEvaluator( static_cast( lhs ), rhs );
- }
- template bool compare( int lhs, unsigned char rhs ) {
- return applyEvaluator( static_cast( lhs ), rhs );
- }
-
- // long to unsigned X
- template bool compare( long lhs, unsigned int rhs ) {
- return applyEvaluator( static_cast( lhs ), rhs );
- }
- template bool compare( long lhs, unsigned long rhs ) {
- return applyEvaluator( static_cast( lhs ), rhs );
- }
- template bool compare( long lhs, unsigned char rhs ) {
- return applyEvaluator( static_cast( lhs ), rhs );
- }
-
- // pointer to long (when comparing against NULL)
- template bool compare( long lhs, T* rhs ) {
- return Evaluator::evaluate( reinterpret_cast( lhs ), rhs );
- }
- template bool compare( T* lhs, long rhs ) {
- return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) );
- }
-
- // pointer to int (when comparing against NULL)
- template bool compare( int lhs, T* rhs ) {
- return Evaluator::evaluate( reinterpret_cast( lhs ), rhs );
- }
- template bool compare( T* lhs, int rhs ) {
- return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) );
- }
-
-#ifdef CATCH_CONFIG_CPP11_LONG_LONG
- // long long to unsigned X
- template bool compare( long long lhs, unsigned int rhs ) {
- return applyEvaluator( static_cast( lhs ), rhs );
- }
- template bool compare( long long lhs, unsigned long rhs ) {
- return applyEvaluator( static_cast( lhs ), rhs );
- }
- template bool compare( long long lhs, unsigned long long rhs ) {
- return applyEvaluator( static_cast( lhs ), rhs );
- }
- template bool compare( long long lhs, unsigned char rhs ) {
- return applyEvaluator( static_cast( lhs ), rhs );
- }
-
- // unsigned long long to X
- template bool compare( unsigned long long lhs, int rhs ) {
- return applyEvaluator( static_cast( lhs ), rhs );
- }
- template bool compare( unsigned long long lhs, long rhs ) {
- return applyEvaluator( static_cast( lhs ), rhs );
- }
- template bool compare( unsigned long long lhs, long long rhs ) {
- return applyEvaluator( static_cast( lhs ), rhs );
- }
- template bool compare( unsigned long long lhs, char rhs ) {
- return applyEvaluator( static_cast( lhs ), rhs );
- }
-
- // pointer to long long (when comparing against NULL)
- template bool compare( long long lhs, T* rhs ) {
- return Evaluator::evaluate( reinterpret_cast( lhs ), rhs );
- }
- template bool compare( T* lhs, long long rhs ) {
- return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) );
- }
-#endif // CATCH_CONFIG_CPP11_LONG_LONG
-
-#ifdef CATCH_CONFIG_CPP11_NULLPTR
- // pointer to nullptr_t (when comparing against nullptr)
- template bool compare( std::nullptr_t, T* rhs ) {
- return Evaluator::evaluate( nullptr, rhs );
- }
- template bool compare( T* lhs, std::nullptr_t ) {
- return Evaluator::evaluate( lhs, nullptr );
- }
-#endif // CATCH_CONFIG_CPP11_NULLPTR
-
-} // end of namespace Internal
-} // end of namespace Catch
-
-#ifdef _MSC_VER
-#pragma warning(pop)
-#endif
-
-// #included from: catch_tostring.h
-#define TWOBLUECUBES_CATCH_TOSTRING_H_INCLUDED
-
-#include
-#include
-#include
-#include
-#include
-
-#ifdef __OBJC__
-// #included from: catch_objc_arc.hpp
-#define TWOBLUECUBES_CATCH_OBJC_ARC_HPP_INCLUDED
-
-#import
-
-#ifdef __has_feature
-#define CATCH_ARC_ENABLED __has_feature(objc_arc)
-#else
-#define CATCH_ARC_ENABLED 0
-#endif
-
-void arcSafeRelease( NSObject* obj );
-id performOptionalSelector( id obj, SEL sel );
-
-#if !CATCH_ARC_ENABLED
-inline void arcSafeRelease( NSObject* obj ) {
- [obj release];
-}
-inline id performOptionalSelector( id obj, SEL sel ) {
- if( [obj respondsToSelector: sel] )
- return [obj performSelector: sel];
- return nil;
-}
-#define CATCH_UNSAFE_UNRETAINED
-#define CATCH_ARC_STRONG
-#else
-inline void arcSafeRelease( NSObject* ){}
-inline id performOptionalSelector( id obj, SEL sel ) {
-#ifdef __clang__
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
-#endif
- if( [obj respondsToSelector: sel] )
- return [obj performSelector: sel];
-#ifdef __clang__
-#pragma clang diagnostic pop
-#endif
- return nil;
-}
-#define CATCH_UNSAFE_UNRETAINED __unsafe_unretained
-#define CATCH_ARC_STRONG __strong
-#endif
-
-#endif
-
-#ifdef CATCH_CONFIG_CPP11_TUPLE
-#include
-#endif
-
-#ifdef CATCH_CONFIG_CPP11_IS_ENUM
-#include
-#endif
-
-namespace Catch {
-
-// Why we're here.
-template
-std::string toString( T const& value );
-
-// Built in overloads
-
-std::string toString( std::string const& value );
-std::string toString( std::wstring const& value );
-std::string toString( const char* const value );
-std::string toString( char* const value );
-std::string toString( const wchar_t* const value );
-std::string toString( wchar_t* const value );
-std::string toString( int value );
-std::string toString( unsigned long value );
-std::string toString( unsigned int value );
-std::string toString( const double value );
-std::string toString( const float value );
-std::string toString( bool value );
-std::string toString( char value );
-std::string toString( signed char value );
-std::string toString( unsigned char value );
-
-#ifdef CATCH_CONFIG_CPP11_LONG_LONG
-std::string toString( long long value );
-std::string toString( unsigned long long value );
-#endif
-
-#ifdef CATCH_CONFIG_CPP11_NULLPTR
-std::string toString( std::nullptr_t );
-#endif
-
-#ifdef __OBJC__
- std::string toString( NSString const * const& nsstring );
- std::string toString( NSString * CATCH_ARC_STRONG & nsstring );
- std::string toString( NSObject* const& nsObject );
-#endif
-
-namespace Detail {
-
- extern const std::string unprintableString;
-
- #if !defined(CATCH_CONFIG_CPP11_STREAM_INSERTABLE_CHECK)
- struct BorgType {
- template BorgType( T const& );
- };
-
- struct TrueType { char sizer[1]; };
- struct FalseType { char sizer[2]; };
-
- TrueType& testStreamable( std::ostream& );
- FalseType testStreamable( FalseType );
-
- FalseType operator<<( std::ostream const&, BorgType const& );
-
- template
- struct IsStreamInsertable {
- static std::ostream &s;
- static T const&t;
- enum { value = sizeof( testStreamable(s << t) ) == sizeof( TrueType ) };
- };
-#else
- template
- class IsStreamInsertable {
- template
- static auto test(int)
- -> decltype( std::declval() << std::declval(), std::true_type() );
-
- template
- static auto test(...) -> std::false_type;
-
- public:
- static const bool value = decltype(test(0))::value;
- };
-#endif
-
-#if defined(CATCH_CONFIG_CPP11_IS_ENUM)
- template::value
- >
- struct EnumStringMaker
- {
- static std::string convert( T const& ) { return unprintableString; }
- };
-
- template
- struct EnumStringMaker
- {
- static std::string convert( T const& v )
- {
- return ::Catch::toString(
- static_cast::type>(v)
- );
- }
- };
-#endif
- template
- struct StringMakerBase {
-#if defined(CATCH_CONFIG_CPP11_IS_ENUM)
- template
- static std::string convert( T const& v )
- {
- return EnumStringMaker::convert( v );
- }
-#else
- template
- static std::string convert( T const& ) { return unprintableString; }
-#endif
- };
-
- template<>
- struct StringMakerBase {
- template
- static std::string convert( T const& _value ) {
- std::ostringstream oss;
- oss << _value;
- return oss.str();
- }
- };
-
- std::string rawMemoryToString( const void *object, std::size_t size );
-
- template
- inline std::string rawMemoryToString( const T& object ) {
- return rawMemoryToString( &object, sizeof(object) );
- }
-
-} // end namespace Detail
-
-template
-struct StringMaker :
- Detail::StringMakerBase::value> {};
-
-template
-struct StringMaker {
- template
- static std::string convert( U* p ) {
- if( !p )
- return "NULL";
- else
- return Detail::rawMemoryToString( p );
- }
-};
-
-template
-struct StringMaker