[
  {
    "path": ".gitignore",
    "content": "CMakeCache.txt\nCMakeFiles\nMakefile\ncmake_install.cmake\ninstall_manifest.txt\n\n#\n# Sublime Test\n#\n# cache files for sublime text\n*.tmlanguage.cache\n*.tmPreferences.cache\n*.stTheme.cache\n\n# workspace files are user-specific\n*.sublime-workspace\n\n# project files should be checked into the repository, unless a significant\n# proportion of contributors will probably not be using SublimeText\n# *.sublime-project\n\n#\n# C / C++\n#\n\n# Compiled Object files\n*.slo\n*.lo\n*.o\n*.obj\n*.ko\n*.elf\n\n# Precompiled Headers\n*.gch\n*.pch\n\n# Compiled Dynamic libraries\n*.so\n*.dylib\n*.dll\n*.so.*\n*.dylib\n\n# Fortran module files\n*.mod\n\n# Compiled Static libraries\n*.lai\n*.la\n*.a\n*.lib\n*.lo\n\n# Executables\n*.exe\n*.out\n*.app\n\n/**/build\n/**/build.*\n\n.tags\n.vscode\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: cpp\nservices:\n  - docker\nsudo: required\ncompiler:\n- gcc\nbefore_install:\n- docker pull matrim/cmake-examples:3.5.1\n- docker pull matrim/cmake-examples:3.10.3\nscript:\n- docker run --rm -v $PWD:/data/code -e DEV_UID=`id -u` -e DEV_GID=`id -g` -it matrim/cmake-examples:3.5.1 /data/code/test.sh\n- docker run --rm -v $PWD:/data/code -e DEV_UID=`id -u` -e DEV_GID=`id -g` -it matrim/cmake-examples:3.10.3 /data/code/test.sh\nbranches:\n  except:\n  - gh-pages\nnotifications:\n  email: true\nos:\n- linux\n"
  },
  {
    "path": "01-basic/A-hello-cmake/CMakeLists.txt",
    "content": "# Set the minimum version of CMake that can be used\n# To find the cmake version run\n# $ cmake --version\ncmake_minimum_required(VERSION 3.5)\n\n# Set the project name\nproject (hello_cmake)\n\n# Add an executable\nadd_executable(hello_cmake main.cpp)\n"
  },
  {
    "path": "01-basic/A-hello-cmake/README.adoc",
    "content": "= Hello CMake\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nShows a very basic hello world example.\n\nThe files in this tutorial are below:\n\n```\nA-hello-cmake$ tree\n.\n├── CMakeLists.txt\n├── main.cpp\n```\n\n  * link:CMakeLists.txt[CMakeLists.txt] - Contains the CMake commands you wish to run\n  * link:main.cpp[main.cpp] - A simple \"Hello World\" cpp file.\n\n# Concepts\n\n### CMakeLists.txt\n\nCMakeLists.txt is the file which should store all your CMake commands. When\ncmake is run in a folder it will look for this file and if it does not exist cmake\nwill exit with an error.\n\n### Minimum CMake version\n\nWhen creating a project using CMake, you can specify the minimum version\nof CMake that is supported.\n\n[source,cmake]\n----\ncmake_minimum_required(VERSION 3.5)\n----\n\n\n### Projects\n\nA CMake build can include a project name to make referencing certain\nvariables easier when using multiple projects.\n\n[source,cmake]\n----\nproject (hello_cmake)\n----\n\n\n### Creating an Executable\n\nThe +add_executable()+ command specifies that an executable should be\nbuild from the specified source files, in this example main.cpp. The\nfirst argument to the +add_executable()+ function is the name of the\nexecutable to be built, and the second argument is the list of source files to compile.\n\n[source,cmake]\n----\nadd_executable(hello_cmake main.cpp)\n----\n\n\n[NOTE]\n====\nA shorthand that some people use is to have the project name and\nexecutable name the same. This allows you to specify the CMakeLists.txt\nas follows,\n\n[source,cmake]\n----\ncmake_minimum_required(VERSION 2.6)\nproject (hello_cmake)\nadd_executable(${PROJECT_NAME} main.cpp)\n----\n\nIn this example, the +project()+ function, will create a variable\n+${PROJECT_NAME}+ with the value hello_cmake. This can then be passed to\nthe +add_executable()+ function to output a 'hello_cmake' executable.\n====\n\n\n### Binary Directory\n\nThe root or top level folder that you run the cmake command from is known as your\nCMAKE_BINARY_DIR and is the root folder for all your binary files.\nCMake supports building and generating your binary files both in-place and also\nout-of-source.\n\n\n#### In-Place Build\n\nIn-place builds generate all temporary build files in the same directory structure\nas the source code. This means that all Makefiles and object files are interspersed\nwith your normal code. To create an in-place build target run the cmake command\nin your root directory. For example:\n\n[source,bash]\n----\nA-hello-cmake$ cmake .\n-- The C compiler identification is GNU 4.8.4\n-- The CXX compiler identification is GNU 4.8.4\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/A-hello-cmake\n\nA-hello-cmake$ tree\n.\n├── CMakeCache.txt\n├── CMakeFiles\n│   ├── 2.8.12.2\n│   │   ├── CMakeCCompiler.cmake\n│   │   ├── CMakeCXXCompiler.cmake\n│   │   ├── CMakeDetermineCompilerABI_C.bin\n│   │   ├── CMakeDetermineCompilerABI_CXX.bin\n│   │   ├── CMakeSystem.cmake\n│   │   ├── CompilerIdC\n│   │   │   ├── a.out\n│   │   │   └── CMakeCCompilerId.c\n│   │   └── CompilerIdCXX\n│   │       ├── a.out\n│   │       └── CMakeCXXCompilerId.cpp\n│   ├── cmake.check_cache\n│   ├── CMakeDirectoryInformation.cmake\n│   ├── CMakeOutput.log\n│   ├── CMakeTmp\n│   ├── hello_cmake.dir\n│   │   ├── build.make\n│   │   ├── cmake_clean.cmake\n│   │   ├── DependInfo.cmake\n│   │   ├── depend.make\n│   │   ├── flags.make\n│   │   ├── link.txt\n│   │   └── progress.make\n│   ├── Makefile2\n│   ├── Makefile.cmake\n│   ├── progress.marks\n│   └── TargetDirectories.txt\n├── cmake_install.cmake\n├── CMakeLists.txt\n├── main.cpp\n├── Makefile\n----\n\n\n#### Out-of-Source Build\n\nOut-of-source builds allow you to create a single build folder that can be anywhere on\nyour file system. All temporary build and object files are located in this directory keeping\nyour source tree clean. To create an out-of-source build run the cmake command in\nthe build folder and point it to the directory with your root CMakeLists.txt file.\nUsing out-of-source builds if you want to recreate your cmake environment\nfrom scratch, you only need to delete your build directory and then rerun cmake.\n\nFor example:\n\n[source,bash]\n----\nA-hello-cmake$ mkdir build\n\nA-hello-cmake$ cd build/\n\nmatrim@freyr:~/workspace/cmake-examples/01-basic/A-hello-cmake/build$ cmake ..\n-- The C compiler identification is GNU 4.8.4\n-- The CXX compiler identification is GNU 4.8.4\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/A-hello-cmake/build\n\nA-hello-cmake/build$ cd ..\n\nA-hello-cmake$ tree\n.\n├── build\n│   ├── CMakeCache.txt\n│   ├── CMakeFiles\n│   │   ├── 2.8.12.2\n│   │   │   ├── CMakeCCompiler.cmake\n│   │   │   ├── CMakeCXXCompiler.cmake\n│   │   │   ├── CMakeDetermineCompilerABI_C.bin\n│   │   │   ├── CMakeDetermineCompilerABI_CXX.bin\n│   │   │   ├── CMakeSystem.cmake\n│   │   │   ├── CompilerIdC\n│   │   │   │   ├── a.out\n│   │   │   │   └── CMakeCCompilerId.c\n│   │   │   └── CompilerIdCXX\n│   │   │       ├── a.out\n│   │   │       └── CMakeCXXCompilerId.cpp\n│   │   ├── cmake.check_cache\n│   │   ├── CMakeDirectoryInformation.cmake\n│   │   ├── CMakeOutput.log\n│   │   ├── CMakeTmp\n│   │   ├── hello_cmake.dir\n│   │   │   ├── build.make\n│   │   │   ├── cmake_clean.cmake\n│   │   │   ├── DependInfo.cmake\n│   │   │   ├── depend.make\n│   │   │   ├── flags.make\n│   │   │   ├── link.txt\n│   │   │   └── progress.make\n│   │   ├── Makefile2\n│   │   ├── Makefile.cmake\n│   │   ├── progress.marks\n│   │   └── TargetDirectories.txt\n│   ├── cmake_install.cmake\n│   └── Makefile\n├── CMakeLists.txt\n├── main.cpp\n----\n\nAll examples in this tutorial will use out-of-source builds.\n\n\n# Building the Examples\n\nBelow is sample output from building this example.\n\n[source,bash]\n----\n$ mkdir build\n\n$ cd build\n\n$ cmake ..\n-- The C compiler identification is GNU 4.8.4\n-- The CXX compiler identification is GNU 4.8.4\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /workspace/cmake-examples/01-basic/hello_cmake/build\n\n$ make\nScanning dependencies of target hello_cmake\n[100%] Building CXX object CMakeFiles/hello_cmake.dir/hello_cmake.cpp.o\nLinking CXX executable hello_cmake\n[100%] Built target hello_cmake\n\n$ ./hello_cmake\nHello CMake!\n----\n"
  },
  {
    "path": "01-basic/A-hello-cmake/main.cpp",
    "content": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n   std::cout << \"Hello CMake!\" << std::endl;\n   return 0;\n}"
  },
  {
    "path": "01-basic/B-hello-headers/CMakeLists.txt",
    "content": "# Set the minimum version of CMake that can be used\n# To find the cmake version run\n# $ cmake --version\ncmake_minimum_required(VERSION 3.5)\n\n# Set the project name\nproject (hello_headers)\n\n# Create a sources variable with a link to all cpp files to compile\nset(SOURCES\n    src/Hello.cpp\n    src/main.cpp\n)\n\n# Add an executable with the above sources\nadd_executable(hello_headers ${SOURCES})\n\n# Set the directories that should be included in the build command for this target\n# when running g++ these will be included as -I/directory/path/\ntarget_include_directories(hello_headers\n    PRIVATE \n        ${PROJECT_SOURCE_DIR}/include\n)\n"
  },
  {
    "path": "01-basic/B-hello-headers/README.adoc",
    "content": "= Hello Headers\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n\n# Introduction\n\nShows a hello world example which uses a different folder for source and include\nfiles.\n\nThe files in this tutorial include:\n\n```\nB-hello-headers$ tree\n.\n├── CMakeLists.txt\n├── include\n│   └── Hello.h\n└── src\n    ├── Hello.cpp\n    └── main.cpp\n```\n\n  * link:CMakeLists.txt[CMakeLists.txt] - Contains the CMake commands you wish to run.\n  * link:include/Hello.h[include/Hello.h] - The header file to include.\n  * link:src/Hello.cpp[src/Hello.cpp] - A source file to compile.\n  * link:src/main.cpp[src/main.cpp] - The source file with main.\n\n\n# Concepts\n\n## Directory Paths\n\nCMake syntax specifies a number of https://gitlab.kitware.com/cmake/community/-/wikis/doc/cmake/Useful-Variables[variables]\nwhich can be used to help find useful directories in your project or source tree.\nSome of these include:\n\n[cols=\",\",options=\"header\",]\n|=======================================================================\n|Variable |Info\n|CMAKE_SOURCE_DIR |The root source directory\n\n|CMAKE_CURRENT_SOURCE_DIR |The current source directory if using\nsub-projects and directories.\n\n|PROJECT_SOURCE_DIR |The source directory of the current cmake project.\n\n|CMAKE_BINARY_DIR |The root binary / build directory. This is the\ndirectory where you ran the cmake command.\n\n|CMAKE_CURRENT_BINARY_DIR |The build directory you are currently in.\n\n|PROJECT_BINARY_DIR |The build directory for the current project.\n|=======================================================================\n\n## Source Files Variable\n\nCreating a variable which includes the source files allows you to be\nclearer about these files and easily add them to multiple commands, for example,\nthe +add_executable()+ function.\n\n[source,cmake]\n----\n# Create a sources variable with a link to all cpp files to compile\nset(SOURCES\n    src/Hello.cpp\n    src/main.cpp\n)\n\nadd_executable(${PROJECT_NAME} ${SOURCES})\n----\n\n[NOTE]\n====\nAn alternative to setting specific file names in the +SOURCES+ variable is\nto use a GLOB command to find files using wildcard pattern matching.\n\n[source,cmake]\n----\nfile(GLOB SOURCES \"src/*.cpp\")\n----\n====\n\n\n[TIP]\n====\nFor modern CMake it is NOT recommended to use a variable for sources. Instead it is \ntypical to directly declare the sources in the add_xxx function.\n\nThis is particularly important for glob commands which may not always show you the\ncorrect results if you add a new source file.\n====\n\n## Including Directories\n\nWhen you have different include folders, you can make your compiler aware of them using the\n+target_include_directories()+ link:https://cmake.org/cmake/help/v3.0/command/target_include_directories.html[function]. When compiling this target this will add these directories to the compiler with the -I flag e.g. `-I/directory/path`\n\n[source,cmake]\n----\ntarget_include_directories(target\n    PRIVATE \n        ${PROJECT_SOURCE_DIR}/include\n)\n----\n\nThe +PRIVATE+ identifier specifies the scope of the include. This is important for libraries and is explained in the next example. More details on the function is available link:https://cmake.org/cmake/help/v3.0/command/target_include_directories.html[here]\n\n# Building the Example\n\n## Standard Output\n\nThe standard output from building this example is presented below.\n\n[source,bash]\n----\n$ mkdir build\n\n$ cd build\n\n$ cmake ..\n-- The C compiler identification is GNU 4.8.4\n-- The CXX compiler identification is GNU 4.8.4\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/hello_headers/build\n\n$ make\nScanning dependencies of target hello_headers\n[ 50%] Building CXX object CMakeFiles/hello_headers.dir/src/Hello.cpp.o\n[100%] Building CXX object CMakeFiles/hello_headers.dir/src/main.cpp.o\nLinking CXX executable hello_headers\n[100%] Built target hello_headers\n\n$ ./hello_headers\nHello Headers!\n----\n\n\n## Verbose Output\n\nIn the previous examples, when running the make command the output only\nshows the status of the build. To see the full output for debugging\npurposes you can add +VERBOSE=1+ flag when running make.\n\nThe VERBOSE output is show below, and a examination of the output shows\nthe include directories being added to the c++ compiler command.\n\n[source,bash]\n----\n$ make clean\n\n$ make VERBOSE=1\n/usr/bin/cmake -H/home/matrim/workspace/cmake-examples/01-basic/hello_headers -B/home/matrim/workspace/cmake-examples/01-basic/hello_headers/build --check-build-system CMakeFiles/Makefile.cmake 0\n/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/01-basic/hello_headers/build/CMakeFiles /home/matrim/workspace/cmake-examples/01-basic/hello_headers/build/CMakeFiles/progress.marks\nmake -f CMakeFiles/Makefile2 all\nmake[1]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/hello_headers/build'\nmake -f CMakeFiles/hello_headers.dir/build.make CMakeFiles/hello_headers.dir/depend\nmake[2]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/hello_headers/build'\ncd /home/matrim/workspace/cmake-examples/01-basic/hello_headers/build && /usr/bin/cmake -E cmake_depends \"Unix Makefiles\" /home/matrim/workspace/cmake-examples/01-basic/hello_headers /home/matrim/workspace/cmake-examples/01-basic/hello_headers /home/matrim/workspace/cmake-examples/01-basic/hello_headers/build /home/matrim/workspace/cmake-examples/01-basic/hello_headers/build /home/matrim/workspace/cmake-examples/01-basic/hello_headers/build/CMakeFiles/hello_headers.dir/DependInfo.cmake --color=\nmake[2]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/hello_headers/build'\nmake -f CMakeFiles/hello_headers.dir/build.make CMakeFiles/hello_headers.dir/build\nmake[2]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/hello_headers/build'\n/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/01-basic/hello_headers/build/CMakeFiles 1\n[ 50%] Building CXX object CMakeFiles/hello_headers.dir/src/Hello.cpp.o\n/usr/bin/c++    -I/home/matrim/workspace/cmake-examples/01-basic/hello_headers/include    -o CMakeFiles/hello_headers.dir/src/Hello.cpp.o -c /home/matrim/workspace/cmake-examples/01-basic/hello_headers/src/Hello.cpp\n/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/01-basic/hello_headers/build/CMakeFiles 2\n[100%] Building CXX object CMakeFiles/hello_headers.dir/src/main.cpp.o\n/usr/bin/c++    -I/home/matrim/workspace/cmake-examples/01-basic/hello_headers/include    -o CMakeFiles/hello_headers.dir/src/main.cpp.o -c /home/matrim/workspace/cmake-examples/01-basic/hello_headers/src/main.cpp\nLinking CXX executable hello_headers\n/usr/bin/cmake -E cmake_link_script CMakeFiles/hello_headers.dir/link.txt --verbose=1\n/usr/bin/c++       CMakeFiles/hello_headers.dir/src/Hello.cpp.o CMakeFiles/hello_headers.dir/src/main.cpp.o  -o hello_headers -rdynamic\nmake[2]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/hello_headers/build'\n/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/01-basic/hello_headers/build/CMakeFiles  1 2\n[100%] Built target hello_headers\nmake[1]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/hello_headers/build'\n/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/01-basic/hello_headers/build/CMakeFiles 0\n----\n"
  },
  {
    "path": "01-basic/B-hello-headers/include/Hello.h",
    "content": "#ifndef __HELLO_H__\n#define __HELLO_H__\n\nclass Hello\n{\npublic:\n    void print();\n};\n\n#endif\n"
  },
  {
    "path": "01-basic/B-hello-headers/src/Hello.cpp",
    "content": "#include <iostream>\n\n#include \"Hello.h\"\n\nvoid Hello::print()\n{\n    std::cout << \"Hello Headers!\" << std::endl;\n}\n"
  },
  {
    "path": "01-basic/B-hello-headers/src/main.cpp",
    "content": "#include \"Hello.h\"\n\nint main(int argc, char *argv[])\n{\n    Hello hi;\n    hi.print();\n    return 0;\n}"
  },
  {
    "path": "01-basic/C-static-library/CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 3.5)\n\nproject(hello_library)\n\n############################################################\n# Create a library\n############################################################\n\n#Generate the static library from the library sources\nadd_library(hello_library STATIC \n    src/Hello.cpp\n)\n\ntarget_include_directories(hello_library\n    PUBLIC \n        ${PROJECT_SOURCE_DIR}/include\n)\n\n\n############################################################\n# Create an executable\n############################################################\n\n# Add an executable with the above sources\nadd_executable(hello_binary \n    src/main.cpp\n)\n\n# link the new hello_library target with the hello_binary target\ntarget_link_libraries( hello_binary\n    PRIVATE \n        hello_library\n)\n"
  },
  {
    "path": "01-basic/C-static-library/README.adoc",
    "content": "= Static Library\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nShows a hello world example which first creates and links a static library. This is a \nsimplified example showing the library and binary in the same folder. Typically\nthese would be in sub-projects as described in section link:../../02-sub-projects[02-sub-projects]\n\nThe files in this tutorial are below:\n\n```\n$ tree\n.\n├── CMakeLists.txt\n├── include\n│   └── static\n│       └── Hello.h\n└── src\n    ├── Hello.cpp\n    └── main.cpp\n```\n\n  * link:CMakeLists.txt[] - Contains the CMake commands you wish to run\n  * link:include/static/Hello.h[] - The header file to include\n  * link:src/Hello.cpp[] - A source file to compile\n  * link:src/main.cpp[] - The source file with main\n\n\n# Concepts\n\n## Adding a Static Library\n\nThe +add_library()+ function is used to create a library from some source files.\nThis is called as follows:\n\n[source,cmake]\n----\nadd_library(hello_library STATIC \n    src/Hello.cpp\n)\n----\n\nThis will be used to create a static library with the name libhello_library.a with\nthe sources in the +add_library+ call.\n\n[NOTE]\n====\nAs mentioned in the previous example, we pass the source files directly to the\n+add_library+ call, as recommended for modern CMake.\n====\n\n## Populating Including Directories\n\nIn this example, we include directories in the library using the +target_include_directories()+ function with the scope set to +PUBLIC+.\n\n[source,cmake]\n----\ntarget_include_directories(hello_library\n    PUBLIC \n        ${PROJECT_SOURCE_DIR}/include\n)\n----\n\nThis will cause the included directory used in the following places:\n\n* When compiling the library\n* When compiling any additional target that links the library.\n\nThe meaning of scopes are:\n\n* +PRIVATE+ - the directory is added to this target's include directories\n* +INTERFACE+ - the directory is added to the include directories for any targets that link this library.\n* +PUBLIC+ - As above, it is included in this library and also any targets that link this library.\n\n\n[TIP]\n====\nFor public headers it is often a good idea to have your include folder be \"namespaced\"\nwith sub-directories. \n\nThe directory passed to +target_include_directories+ will be the root of your \ninclude directory tree and your C++ files should include the path from there to your header.\n\nFor this example you can see that we do it as follows:\n[source,cpp]\n----\n#include \"static/Hello.h\"\n----\n\nUsing this method means that there is less chance of header filename clashes when\nyou use multiple libraries in your project. \n====\n\n## Linking a Library\n\nWhen creating an executable that will use your library you must tell the compiler\nabout the library. This can be done using the +target_link_libraries()+ function.\n\n[source,cmake]\n----\nadd_executable(hello_binary \n    src/main.cpp\n)\n\ntarget_link_libraries( hello_binary\n    PRIVATE  \n        hello_library\n)\n----\n\nThis tells CMake to link the hello_library against the hello_binary executable\nduring link time. It will also propagate any include directories with +PUBLIC+ or +INTERFACE+ scope\n from the linked library target.\n\nAn example of this being called by the compiler is\n\n```\n/usr/bin/c++ CMakeFiles/hello_binary.dir/src/main.cpp.o -o hello_binary -rdynamic libhello_library.a\n```\n\n\n# Building the Example\n\n[source,bash]\n----\n$ mkdir build\n\n$ cd build\n\n$ cmake ..\n-- The C compiler identification is GNU 4.8.4\n-- The CXX compiler identification is GNU 4.8.4\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/C-static-library/build\n\n$ make\nScanning dependencies of target hello_library\n[ 50%] Building CXX object CMakeFiles/hello_library.dir/src/Hello.cpp.o\nLinking CXX static library libhello_library.a\n[ 50%] Built target hello_library\nScanning dependencies of target hello_binary\n[100%] Building CXX object CMakeFiles/hello_binary.dir/src/main.cpp.o\nLinking CXX executable hello_binary\n[100%] Built target hello_binary\n\n$ ls\nCMakeCache.txt  CMakeFiles  cmake_install.cmake  hello_binary  libhello_library.a  Makefile\n\n$ ./hello_binary\nHello Static Library!\n----\n"
  },
  {
    "path": "01-basic/C-static-library/include/static/Hello.h",
    "content": "#ifndef __HELLO_H__\n#define __HELLO_H__\n\nclass Hello\n{\npublic:\n    void print();\n};\n\n#endif\n"
  },
  {
    "path": "01-basic/C-static-library/src/Hello.cpp",
    "content": "#include <iostream>\n\n#include \"static/Hello.h\"\n\nvoid Hello::print()\n{\n    std::cout << \"Hello Static Library!\" << std::endl;\n}\n"
  },
  {
    "path": "01-basic/C-static-library/src/main.cpp",
    "content": "#include \"static/Hello.h\"\n\nint main(int argc, char *argv[])\n{\n    Hello hi;\n    hi.print();\n    return 0;\n}\n"
  },
  {
    "path": "01-basic/D-shared-library/CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 3.5)\n\nproject(hello_library)\n\n############################################################\n# Create a library\n############################################################\n\n#Generate the shared library from the library sources\nadd_library(hello_library SHARED \n    src/Hello.cpp\n)\nadd_library(hello::library ALIAS hello_library)\n\ntarget_include_directories(hello_library\n    PUBLIC \n        ${PROJECT_SOURCE_DIR}/include\n)\n\n############################################################\n# Create an executable\n############################################################\n\n# Add an executable with the above sources\nadd_executable(hello_binary\n    src/main.cpp\n)\n\n# link the new hello_library target with the hello_binary target\ntarget_link_libraries( hello_binary\n    PRIVATE \n        hello::library\n)\n"
  },
  {
    "path": "01-basic/D-shared-library/README.adoc",
    "content": "= Shared Library\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nShows a hello world example which first creates and links a shared library.\n\nThis also shows how to create an link:https://cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html#alias-targets[alias target]\n\nThe files in this tutorial are below:\n\n```\n$ tree\n.\n├── CMakeLists.txt\n├── include\n│   └── shared\n│       └── Hello.h\n└── src\n    ├── Hello.cpp\n    └── main.cpp\n```\n\n  * link:CMakeLists.txt[] - Contains the CMake commands you wish to run\n  * link:include/shared/Hello.h[] - The header file to include\n  * link:src/Hello.cpp[] - A source file to compile\n  * link:src/main.cpp[] - The source file with main\n\n\n# Concepts\n\n## Adding a Shared Library\n\nAs with the previous example on static libraries, the +add_library()+ function\nis also used to create a shared library from some source files.\nThis is called as follows:\n\n[source,cmake]\n----\nadd_library(hello_library SHARED\n    src/Hello.cpp\n)\n----\n\nThis will be used to create a shared library with the name libhello_library.so with\nthe sources passed to the +add_library()+ function.\n\n## Alias Target\n\nAs the name suggests an link:https://cmake.org/cmake/help/v3.0/manual/cmake-buildsystem.7.html#alias-targets[alias target] is an alternative name for a target that can be used instead of the real target name in read-only contexts.\n\n[source,cmake]\n----\nadd_library(hello::library ALIAS hello_library)\n----\n\nAs shown below, this allows you to reference the target using the alias name when linking it against other targets.\n\n## Linking a Shared Library\n\nLinking a shared library is the same as linking a static library. When creating your\nexecutable use the the +target_link_library()+ function to point to your library\n\n[source,cmake]\n----\nadd_executable(hello_binary\n    src/main.cpp\n)\n\ntarget_link_libraries(hello_binary\n    PRIVATE\n        hello::library\n)\n----\n\nThis tells CMake to link the hello_library against the hello_binary executable using the alias target name.\n\nAn example of this being called by the linker is\n\n```\n/usr/bin/c++ CMakeFiles/hello_binary.dir/src/main.cpp.o -o hello_binary -rdynamic libhello_library.so -Wl,-rpath,/home/matrim/workspace/cmake-examples/01-basic/D-shared-library/build\n```\n\n# Building the Example\n\n[source,bash]\n----\n$ mkdir build\n\n$ cd build\n\n$ cmake ..\n-- The C compiler identification is GNU 4.8.4\n-- The CXX compiler identification is GNU 4.8.4\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/D-shared-library/build\n\n$ make\nScanning dependencies of target hello_library\n[ 50%] Building CXX object CMakeFiles/hello_library.dir/src/Hello.cpp.o\nLinking CXX shared library libhello_library.so\n[ 50%] Built target hello_library\nScanning dependencies of target hello_binary\n[100%] Building CXX object CMakeFiles/hello_binary.dir/src/main.cpp.o\nLinking CXX executable hello_binary\n[100%] Built target hello_binary\n\n$ ls\nCMakeCache.txt  CMakeFiles  cmake_install.cmake  hello_binary  libhello_library.so  Makefile\n\n$ ./hello_binary\nHello Shared Library!\n----\n"
  },
  {
    "path": "01-basic/D-shared-library/include/shared/Hello.h",
    "content": "#ifndef __HELLO_H__\n#define __HELLO_H__\n\nclass Hello\n{\npublic:\n    void print();\n};\n\n#endif\n"
  },
  {
    "path": "01-basic/D-shared-library/src/Hello.cpp",
    "content": "#include <iostream>\n\n#include \"shared/Hello.h\"\n\nvoid Hello::print()\n{\n    std::cout << \"Hello Shared Library!\" << std::endl;\n}\n"
  },
  {
    "path": "01-basic/D-shared-library/src/main.cpp",
    "content": "#include \"shared/Hello.h\"\n\nint main(int argc, char *argv[])\n{\n    Hello hi;\n    hi.print();\n    return 0;\n}\n"
  },
  {
    "path": "01-basic/E-installing/CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 3.5)\n\nproject(cmake_examples_install)\n\n############################################################\n# Create a library\n############################################################\n\n#Generate the shared library from the library sources\nadd_library(cmake_examples_inst SHARED\n    src/Hello.cpp\n)\n\ntarget_include_directories(cmake_examples_inst\n    PUBLIC \n        ${PROJECT_SOURCE_DIR}/include\n)\n\n############################################################\n# Create an executable\n############################################################\n\n# Add an executable with the above sources\nadd_executable(cmake_examples_inst_bin\n    src/main.cpp\n)\n\n# link the new hello_library target with the hello_binary target\ntarget_link_libraries( cmake_examples_inst_bin\n    PRIVATE \n        cmake_examples_inst\n)\n\n############################################################\n# Install\n############################################################\n\n# Binaries\ninstall (TARGETS cmake_examples_inst_bin\n    DESTINATION bin)\n\n# Library\n# Note: may not work on windows\ninstall (TARGETS cmake_examples_inst\n    LIBRARY DESTINATION lib)\n\n# Header files\ninstall(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ \n    DESTINATION include)\n\n# Config\ninstall (FILES cmake-examples.conf\n    DESTINATION etc)\n"
  },
  {
    "path": "01-basic/E-installing/README.adoc",
    "content": "= Installing\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nThis example shows how to generate a `make install` target to install files and\nbinaries on your system. This is based on the previous shared library example.\n\nThe files in this tutorial are below:\n\n```\n$ tree\n.\n├── cmake-examples.conf\n├── CMakeLists.txt\n├── include\n│   └── installing\n│       └── Hello.h\n├── README.adoc\n└── src\n    ├── Hello.cpp\n    └── main.cpp\n```\n\n  * link:CMakeLists.txt[] - Contains the CMake commands you wish to run\n  * link:cmake-examples.conf[] - An example configuration file\n  * link:include/installing/Hello.h[] - The header file to include\n  * link:src/Hello.cpp[] - A source file to compile\n  * link:src/main.cpp[] - The source file with main\n\n# Concepts\n\n## Installing\n\nCMake offers the ability to add a `make install` target to allow a user to\ninstall binaries, libraries and other files. The base install location is controlled\nby the variable +CMAKE_INSTALL_PREFIX+ which can be set using ccmake or by calling\ncmake with `cmake .. -DCMAKE_INSTALL_PREFIX=/install/location`\n\nThe files that are installed are controlled by the https://cmake.org/cmake/help/v3.0/command/install.html[+install()+] function.\n\n[source,cmake]\n----\ninstall (TARGETS cmake_examples_inst_bin\n    DESTINATION bin)\n----\n\nInstall the binary generated from the target cmake_examples_inst_bin target to\nthe destination +${CMAKE_INSTALL_PREFIX}/bin+\n\n[source,cmake]\n----\ninstall (TARGETS cmake_examples_inst\n    LIBRARY DESTINATION lib)\n----\n\nInstall the shared library generated from the target cmake_examples_inst target to\nthe destination +${CMAKE_INSTALL_PREFIX}/lib+\n\n[NOTE]\n====\nThis may not work on windows. On platforms that have DLL targets you\nmay need to add the following\n\n[source,cmake]\n----\ninstall (TARGETS cmake_examples_inst\n    LIBRARY DESTINATION lib\n    RUNTIME DESTINATION bin)\n----\n====\n\n\n[source,cmake]\n----\ninstall(DIRECTORY ${PROJECT_SOURCE_DIR}/include/ \n    DESTINATION include)\n----\n\nInstall the header files for developing against the +cmake_examples_inst+ library\ninto the +${CMAKE_INSTALL_PREFIX}/include+ directory.\n\n[source,cmake]\n----\ninstall (FILES cmake-examples.conf\n    DESTINATION etc)\n----\n\nInstall a configuration file to the destination +${CMAKE_INSTALL_PREFIX}/etc+\n\nAfter `make install` has been run, CMake generates an install_manifest.txt file\nwhich includes details on all installed files.\n\n[NOTE]\n====\nIf you run the `make install` command as root, the install_manifest.txt file will\nbe owned by root.\n====\n\n# Building the Example\n\n[source,bash]\n----\n$ mkdir build\n\n$ cd build/\n\n$ cmake ..\n-- The C compiler identification is GNU 4.8.4\n-- The CXX compiler identification is GNU 4.8.4\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/E-installing/build\n\n$ make\nScanning dependencies of target cmake_examples_inst\n[ 50%] Building CXX object CMakeFiles/cmake_examples_inst.dir/src/Hello.cpp.o\nLinking CXX shared library libcmake_examples_inst.so\n[ 50%] Built target cmake_examples_inst\nScanning dependencies of target cmake_examples_inst_bin\n[100%] Building CXX object CMakeFiles/cmake_examples_inst_bin.dir/src/main.cpp.o\nLinking CXX executable cmake_examples_inst_bin\n[100%] Built target cmake_examples_inst_bin\n\n$ sudo make install\n[sudo] password for matrim:\n[ 50%] Built target cmake_examples_inst\n[100%] Built target cmake_examples_inst_bin\nInstall the project...\n-- Install configuration: \"\"\n-- Installing: /usr/local/bin/cmake_examples_inst_bin\n-- Removed runtime path from \"/usr/local/bin/cmake_examples_inst_bin\"\n-- Installing: /usr/local/lib/libcmake_examples_inst.so\n-- Installing: /usr/local/etc/cmake-examples.conf\n\n$ cat install_manifest.txt\n/usr/local/bin/cmake_examples_inst_bin\n/usr/local/lib/libcmake_examples_inst.so\n/usr/local/etc/cmake-examples.conf\n\n$ ls /usr/local/bin/\ncmake_examples_inst_bin\n\n$ ls /usr/local/lib\nlibcmake_examples_inst.so\n\n$ ls /usr/local/etc/\ncmake-examples.conf\n\n$ LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib cmake_examples_inst_bin\nHello Install!\n----\n\n[NOTE]\n====\nIf `/usr/local/lib` is not in your library path you may need to add it to the\npath before running the binary.\n====\n\n[[extra-notes]]\nExtra Notes\n~~~~~~~~~~~\n\n[[default-location]]\nOverriding the default install location\n^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n\nAs mentioned the default install location is set from the +CMAKE_INSTALL_PREFIX+,\nwhich defaults to `/usr/local/`\n\nIf you want to change this default location for all users you can add the\nfollowing code to your top level CMakeLists.txt before adding any binaries or\nlibraries.\n\n[source,cmake]\n----\nif( CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT )\n  message(STATUS \"Setting default CMAKE_INSTALL_PREFIX path to ${CMAKE_BINARY_DIR}/install\")\n  set(CMAKE_INSTALL_PREFIX \"${CMAKE_BINARY_DIR}/install\" CACHE STRING \"The path to use for make install\" FORCE)\nendif()\n----\n\nThis example sets the default install location to under your build directory.\n\n[[destdir]]\nDESTDIR\n^^^^^^^\n\nIf you wish to stage your install to confirm that all files are included the\n`make install` target supports the DESTDIR argument.\n\n```\nmake install DESTDIR=/tmp/stage\n```\n\nThis will create the install path `${DESTDIR}/${CMAKE_INSTALL_PREFIX}` for all\nyour installation files. In this example, it would install all files under the\npath `/tmp/stage/usr/local`\n\n```\n$ tree /tmp/stage\n/tmp/stage\n└── usr\n    └── local\n        ├── bin\n        │   └── cmake_examples_inst_bin\n        ├── etc\n        │   └── cmake-examples.conf\n        └── lib\n            └── libcmake_examples_inst.so\n```\n\n[[uninstall]]\nUninstall\n^^^^^^^^^\n\nBy default CMake does not add a `make uninstall` target. For details on how to generate\nan uninstall target see this https://cmake.org/Wiki/CMake_FAQ#Can_I_do_.22make_uninstall.22_with_CMake.3F[FAQ]\n\nFor an easy way to remove the files from this example, you can use:\n\n```\nsudo xargs rm < install_manifest.txt\n```\n"
  },
  {
    "path": "01-basic/E-installing/cmake-examples.conf",
    "content": "# Sample configuration file that could be installed\n"
  },
  {
    "path": "01-basic/E-installing/include/installing/Hello.h",
    "content": "#ifndef __HELLO_H__\n#define __HELLO_H__\n\nclass Hello\n{\npublic:\n    void print();\n};\n\n#endif\n"
  },
  {
    "path": "01-basic/E-installing/src/Hello.cpp",
    "content": "#include <iostream>\n\n#include \"installing/Hello.h\"\n\nvoid Hello::print()\n{\n    std::cout << \"Hello Install!\" << std::endl;\n}\n"
  },
  {
    "path": "01-basic/E-installing/src/main.cpp",
    "content": "#include \"installing/Hello.h\"\n\nint main(int argc, char *argv[])\n{\n    Hello hi;\n    hi.print();\n    return 0;\n}\n"
  },
  {
    "path": "01-basic/F-build-type/CMakeLists.txt",
    "content": "# Set the minimum version of CMake that can be used\n# To find the cmake version run\n# $ cmake --version\ncmake_minimum_required(VERSION 3.5)\n\n# Set a default build type if none was specified\nif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)\n  message(\"Setting build type to 'RelWithDebInfo' as none was specified.\")\n  set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING \"Choose the type of build.\" FORCE)\n  # Set the possible values of build type for cmake-gui\n  set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS \"Debug\" \"Release\"\n    \"MinSizeRel\" \"RelWithDebInfo\")\nendif()\n\n# Set the project name\nproject (build_type)\n\n# Add an executable\nadd_executable(cmake_examples_build_type main.cpp)\n"
  },
  {
    "path": "01-basic/F-build-type/README.adoc",
    "content": "= Build Type\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nCMake has a number of built in build configurations which can be used to compile\nyour project. These specify the optimization levels and if debug information is\nto be included in the binary.\n\nThe levels provided are:\n\n  * Release - Adds the `-O3 -DNDEBUG` flags to the compiler\n  * Debug - Adds the `-g` flag\n  * MinSizeRel - Adds `-Os -DNDEBUG`\n  * RelWithDebInfo - Adds `-O2 -g -DNDEBUG` flags\n\nThe files in this tutorial are below:\n\n```\n$ tree\n.\n├── CMakeLists.txt\n├── main.cpp\n```\n\n  * link:CMakeLists.txt[] - Contains the CMake commands you wish to run\n  * link:main.cpp[] - The source file with main\n\n# Concepts\n\n## Set Build Type\n\nThe build type can be set using the following methods.\n\n  - Using a gui tool such as ccmake / cmake-gui\n\nimage::cmake-gui-build-type.png[cmake-gui build type]\n\n  - Passing into cmake\n\n[source,cmake]\n----\ncmake .. -DCMAKE_BUILD_TYPE=Release\n----\n\n## Set Default Build Type\n\nThe default build type provided by CMake is to include no compiler flags for\noptimization. For some projects you may want to\nset a default build type so that you do not have to remember to set it.\n\nTo do this you can add the following to your top level CMakeLists.txt\n\n[source,cmake]\n----\nif(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)\n  message(\"Setting build type to 'RelWithDebInfo' as none was specified.\")\n  set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING \"Choose the type of build.\" FORCE)\n  # Set the possible values of build type for cmake-gui\n  set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS \"Debug\" \"Release\"\n    \"MinSizeRel\" \"RelWithDebInfo\")\nendif()\n----\n\n# Building the Example\n\n[source,bash]\n----\n$ mkdir build\n\n$ cd build/\n\n$ cmake ..\nSetting build type to 'RelWithDebInfo' as none was specified.\n-- The C compiler identification is GNU 4.8.4\n-- The CXX compiler identification is GNU 4.8.4\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build\n\n$ make VERBOSE=1\n/usr/bin/cmake -H/home/matrim/workspace/cmake-examples/01-basic/F-build-type -B/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build --check-build-system CMakeFiles/Makefile.cmake 0\n/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles/progress.marks\nmake -f CMakeFiles/Makefile2 all\nmake[1]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build'\nmake -f CMakeFiles/cmake_examples_build_type.dir/build.make CMakeFiles/cmake_examples_build_type.dir/depend\nmake[2]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build'\ncd /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build && /usr/bin/cmake -E cmake_depends \"Unix Makefiles\" /home/matrim/workspace/cmake-examples/01-basic/F-build-type /home/matrim/workspace/cmake-examples/01-basic/F-build-type /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles/cmake_examples_build_type.dir/DependInfo.cmake --color=\nDependee \"/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles/cmake_examples_build_type.dir/DependInfo.cmake\" is newer than depender \"/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles/cmake_examples_build_type.dir/depend.internal\".\nDependee \"/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles/CMakeDirectoryInformation.cmake\" is newer than depender \"/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles/cmake_examples_build_type.dir/depend.internal\".\nScanning dependencies of target cmake_examples_build_type\nmake[2]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build'\nmake -f CMakeFiles/cmake_examples_build_type.dir/build.make CMakeFiles/cmake_examples_build_type.dir/build\nmake[2]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build'\n/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles 1\n[100%] Building CXX object CMakeFiles/cmake_examples_build_type.dir/main.cpp.o\n/usr/bin/c++    -O2 -g -DNDEBUG   -o CMakeFiles/cmake_examples_build_type.dir/main.cpp.o -c /home/matrim/workspace/cmake-examples/01-basic/F-build-type/main.cpp\nLinking CXX executable cmake_examples_build_type\n/usr/bin/cmake -E cmake_link_script CMakeFiles/cmake_examples_build_type.dir/link.txt --verbose=1\n/usr/bin/c++   -O2 -g -DNDEBUG    CMakeFiles/cmake_examples_build_type.dir/main.cpp.o  -o cmake_examples_build_type -rdynamic\nmake[2]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build'\n/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles  1\n[100%] Built target cmake_examples_build_type\nmake[1]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build'\n/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles 0$ mkdir build\n$ cd build/\n/build$ cmake ..\nSetting build type to 'RelWithDebInfo' as none was specified.\n-- The C compiler identification is GNU 4.8.4\n-- The CXX compiler identification is GNU 4.8.4\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build\n/build$ make VERBOSE=1\n/usr/bin/cmake -H/home/matrim/workspace/cmake-examples/01-basic/F-build-type -B/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build --check-build-system CMakeFiles/Makefile.cmake 0\n/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles/progress.marks\nmake -f CMakeFiles/Makefile2 all\nmake[1]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build'\nmake -f CMakeFiles/cmake_examples_build_type.dir/build.make CMakeFiles/cmake_examples_build_type.dir/depend\nmake[2]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build'\ncd /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build && /usr/bin/cmake -E cmake_depends \"Unix Makefiles\" /home/matrim/workspace/cmake-examples/01-basic/F-build-type /home/matrim/workspace/cmake-examples/01-basic/F-build-type /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles/cmake_examples_build_type.dir/DependInfo.cmake --color=\nDependee \"/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles/cmake_examples_build_type.dir/DependInfo.cmake\" is newer than depender \"/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles/cmake_examples_build_type.dir/depend.internal\".\nDependee \"/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles/CMakeDirectoryInformation.cmake\" is newer than depender \"/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles/cmake_examples_build_type.dir/depend.internal\".\nScanning dependencies of target cmake_examples_build_type\nmake[2]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build'\nmake -f CMakeFiles/cmake_examples_build_type.dir/build.make CMakeFiles/cmake_examples_build_type.dir/build\nmake[2]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build'\n/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles 1\n[100%] Building CXX object CMakeFiles/cmake_examples_build_type.dir/main.cpp.o\n/usr/bin/c++    -O2 -g -DNDEBUG   -o CMakeFiles/cmake_examples_build_type.dir/main.cpp.o -c /home/matrim/workspace/cmake-examples/01-basic/F-build-type/main.cpp\nLinking CXX executable cmake_examples_build_type\n/usr/bin/cmake -E cmake_link_script CMakeFiles/cmake_examples_build_type.dir/link.txt --verbose=1\n/usr/bin/c++   -O2 -g -DNDEBUG    CMakeFiles/cmake_examples_build_type.dir/main.cpp.o  -o cmake_examples_build_type -rdynamic\nmake[2]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build'\n/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles  1\n[100%] Built target cmake_examples_build_type\nmake[1]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/F-build-type/build'\n/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/01-basic/F-build-type/build/CMakeFiles 0\n----\n"
  },
  {
    "path": "01-basic/F-build-type/main.cpp",
    "content": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n   std::cout << \"Hello Build Type!\" << std::endl;\n   return 0;\n}\n"
  },
  {
    "path": "01-basic/G-compile-flags/CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 3.5)\n\n# Set a default C++ compile flag\nset (CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -DEX2\" CACHE STRING \"Set C++ Compiler Flags\" FORCE)\n\n# Set the project name\nproject (compile_flags)\n\n# Add an executable\nadd_executable(cmake_examples_compile_flags main.cpp)\n\ntarget_compile_definitions(cmake_examples_compile_flags \n    PRIVATE EX3\n)\n"
  },
  {
    "path": "01-basic/G-compile-flags/README.adoc",
    "content": "= Compile Flags\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nCMake supports setting compile flags in a number of different ways:\n\n  * using +target_compile_definitions()+ function\n  * using the +CMAKE_C_FLAGS+ and +CMAKE_CXX_FLAGS+ variables.\n\nThe files in this tutorial are below:\n\n```\n$ tree\n.\n├── CMakeLists.txt\n├── main.cpp\n```\n\n  * link:CMakeLists.txt[] - Contains the CMake commands you wish to run\n  * link:main.cpp[] - The source file with main\n\n# Concepts\n\n# Set Per-Target C++ Flags\n\nThe recommended way to set C++ flags in modern CMake is to use per-target flags which can be populated to other targets\nthrough the +target_compile_definitions()+ link:https://cmake.org/cmake/help/v3.0/command/target_compile_definitions.html?highlight=target_compile_definitions[function]. This will populate the link:https://cmake.org/cmake/help/v3.0/prop_tgt/INTERFACE_COMPILE_DEFINITIONS.html#prop_tgt:INTERFACE_COMPILE_DEFINITIONS[INTERFACE_COMPILE_DEFINITIONS] for the library and push the definition to the linked target depending on the scope.\n\n[source,cmake]\n----\ntarget_compile_definitions(cmake_examples_compile_flags\n    PRIVATE EX3\n)\n----\n\nThis will cause the compiler to add the definition +-DEX3+ when compiling the target.\n\nIf the target was a library and the scope +PUBLIC+ or +INTERFACE+ has been chosen the definition would also be included in any executables that link this target.\n\nFor compiler options you can also use the +target_compile_options()+ link:https://cmake.org/cmake/help/v3.0/command/target_compile_options.html[function].\n\n## Set Default C++ Flags\n\nThe default `CMAKE_CXX_FLAGS` is either empty or contains the appropriate flags\nfor the build type.\n\nTo set additional default compile flags you can add the following to your\ntop level CMakeLists.txt\n\n[source,cmake]\n----\nset (CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -DEX2\" CACHE STRING \"Set C++ Compiler Flags\" FORCE)\n----\n\nSimilarly to +CMAKE_CXX_FLAGS+ other options include:\n\n  * Setting C compiler flags using +CMAKE_C_FLAGS+\n  * Setting linker flags using +CMAKE_LINKER_FLAGS+.\n\n[NOTE]\n====\nThe values `CACHE STRING \"Set C++ Compiler Flags\" FORCE` from the above command\nare used to force this variable to be set in the CMakeCache.txt file.\n\nFor more details, see https://cmake.org/cmake/help/v3.0/command/set.html[here]\n====\n\n\nOnce set the +CMAKE_C_FLAGS+ and +CMAKE_CXX_FLAGS+ will set a compiler flag / definition globally for all targets in this directory or any included sub-directories. This method is not recommended for general usage now and the +target_compile_definitions+ function is preferred.\n\n### Set CMake Flags\n\nSimilar to the build type a global C++ compiler flag can be set using the following methods.\n\n  - Using a gui tool such as ccmake / cmake-gui\n\nimage::cmake-gui-set-cxx-flag.png[cmake-gui set cxx flag]\n\n  - Passing into cmake\n\n[source,cmake]\n----\ncmake .. -DCMAKE_CXX_FLAGS=\"-DEX3\"\n----\n\n# Building the Example\n\n[source,bash]\n----\n$ mkdir build\n\n$ cd build/\n\n$ cmake ..\n-- The C compiler identification is GNU 4.8.4\n-- The CXX compiler identification is GNU 4.8.4\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build\n\n$ make VERBOSE=1\n/usr/bin/cmake -H/home/matrim/workspace/cmake-examples/01-basic/G-compile-flags -B/home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build --check-build-system CMakeFiles/Makefile.cmake 0\n/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build/CMakeFiles /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build/CMakeFiles/progress.marks\nmake -f CMakeFiles/Makefile2 all\nmake[1]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build'\nmake -f CMakeFiles/cmake_examples_compile_flags.dir/build.make CMakeFiles/cmake_examples_compile_flags.dir/depend\nmake[2]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build'\ncd /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build && /usr/bin/cmake -E cmake_depends \"Unix Makefiles\" /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build/CMakeFiles/cmake_examples_compile_flags.dir/DependInfo.cmake --color=\nDependee \"/home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build/CMakeFiles/cmake_examples_compile_flags.dir/DependInfo.cmake\" is newer than depender \"/home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build/CMakeFiles/cmake_examples_compile_flags.dir/depend.internal\".\nDependee \"/home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build/CMakeFiles/CMakeDirectoryInformation.cmake\" is newer than depender \"/home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build/CMakeFiles/cmake_examples_compile_flags.dir/depend.internal\".\nScanning dependencies of target cmake_examples_compile_flags\nmake[2]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build'\nmake -f CMakeFiles/cmake_examples_compile_flags.dir/build.make CMakeFiles/cmake_examples_compile_flags.dir/build\nmake[2]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build'\n/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build/CMakeFiles 1\n[100%] Building CXX object CMakeFiles/cmake_examples_compile_flags.dir/main.cpp.o\n/usr/bin/c++    -DEX2   -o CMakeFiles/cmake_examples_compile_flags.dir/main.cpp.o -c /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/main.cpp\nLinking CXX executable cmake_examples_compile_flags\n/usr/bin/cmake -E cmake_link_script CMakeFiles/cmake_examples_compile_flags.dir/link.txt --verbose=1\n/usr/bin/c++    -DEX2    CMakeFiles/cmake_examples_compile_flags.dir/main.cpp.o  -o cmake_examples_compile_flags -rdynamic\nmake[2]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build'\n/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build/CMakeFiles  1\n[100%] Built target cmake_examples_compile_flags\nmake[1]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build'\n/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/01-basic/G-compile-flags/build/CMakeFiles 0\n----\n"
  },
  {
    "path": "01-basic/G-compile-flags/main.cpp",
    "content": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n   std::cout << \"Hello Compile Flags!\" << std::endl;\n\n   // only print if compile flag set\n#ifdef EX2\n  std::cout << \"Hello Compile Flag EX2!\" << std::endl;\n#endif\n\n#ifdef EX3\n  std::cout << \"Hello Compile Flag EX3!\" << std::endl;\n#endif\n\n   return 0;\n}\n"
  },
  {
    "path": "01-basic/H-third-party-library/CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 3.5)\n\n# Set the project name\nproject (third_party_include)\n\n\n# find a boost install with the libraries filesystem and system\nfind_package(Boost 1.46.1 REQUIRED COMPONENTS filesystem system)\n\n# check if boost was found\nif(Boost_FOUND)\n    message (\"boost found\")\nelse()\n    message (FATAL_ERROR \"Cannot find Boost\")\nendif()\n\n# Add an executable\nadd_executable(third_party_include main.cpp)\n\n# link against the boost libraries\ntarget_link_libraries( third_party_include\n    PRIVATE\n        Boost::filesystem\n)\n"
  },
  {
    "path": "01-basic/H-third-party-library/README.adoc",
    "content": "= Including Third Party Library\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nNearly all non-trivial projects will have a requirement for including third party\nlibraries, headers, or programs. CMake has support for finding the path to these tools using\nthe `find_package()` function. This will search for CMake modules in the format\n\"FindXXX.cmake\" from the list of folders in `CMAKE_MODULE_PATH`. On linux the\ndefault search path will include `/usr/share/cmake/Modules`. On my system this\nincludes support for approximately 142 common third party libraries.\n\n\nThe files in this tutorial are below:\n\n```\n$ tree\n.\n├── CMakeLists.txt\n├── main.cpp\n```\n\n  * link:CMakeLists.txt[] - Contains the CMake commands you wish to run\n  * link:main.cpp[] - The source file with main\n\n# Requirements\n\nThis example requires the boost libraries to be installed in a default system\nlocation.\n\n# Concepts\n\n## Finding a Package\n\nAs mentioned above the `find_package()` function will search for CMake modules in the formant\n\"FindXXX.cmake\" from the list of folders in `CMAKE_MODULE_PATH`. The exact\nformat of the arguments to `find_package` will depend on the module you are looking\nfor. This is typically documented at the top of the `FindXXX.cmake` file.\n\nA basic example of finding boost is below:\n\n[source,cmake]\n----\nfind_package(Boost 1.46.1 REQUIRED COMPONENTS filesystem system)\n----\n\nThe arguments are:\n\n  * Boost - Name of the library. This is part of used to find the module file FindBoost.cmake\n  * 1.46.1 - The minimum version of boost to find\n  * REQUIRED - Tells the module that this is required and to fail if it cannot be found\n  * COMPONENTS - The list of components to find in the library.\n\nBoost includes can take more arguments and also make use of other variables.\nMore complex setups are provided in later examples.\n\n\n## Checking if the package is found\n\nMost included packages will set a variable `XXX_FOUND`, which can be used to check\nif the package is available on the system.\n\nIn this example the variable is `Boost_FOUND`:\n\n[source,cmake]\n----\nif(Boost_FOUND)\n    message (\"boost found\")\n    include_directories(${Boost_INCLUDE_DIRS})\nelse()\n    message (FATAL_ERROR \"Cannot find Boost\")\nendif()\n----\n\n## Exported Variables\n\nAfter a package is found it will often export variables which can inform the user\nwhere to find the library, header, or executable files. Similar to the `XXX_FOUND`\nvariable, these are package specific and are typically documented at the top of the\n`FindXXX.cmake` file.\n\nThe variables exported in this example include:\n\n  * `Boost_INCLUDE_DIRS` - The path to the boost header files.\n\nIn some cases you can also check these variables by examining the cache using\nccmake or cmake-gui.\n\n## Alias / Imported targets\n\nMost modern CMake libraries link:https://cmake.org/cmake/help/v3.6/prop_tgt/IMPORTED.html#prop_tgt:IMPORTED[export] +ALIAS+ targets in their module files. \nThe benefit of imported targets are that they can also populate include directories and linked libraries.\n\nFor example, starting from v3.5+ of CMake, the\nBoost module supports this. Similar to using your own ALIAS target for libraires, an +ALIAS+ in a module can make referencing found targets easier.\n\nIn the case of Boost, all targets are exported using the `Boost::` identifier and then the name \nof the subsystem. For example you can use:\n\n  * `Boost::boost` for header only libraries\n  * `Boost::system` for the boost system library.\n  * `Boost::filesystem` for filesystem library.\n\nAs with your own targets, these targets include their dependencies, so linking against\n`Boost::filesystem` will automatically add `Boost::boost` and `Boost::system` dependencies.\n\nTo link against an imported target you can use the following:\n\n[source,cmake]\n----\n  target_link_libraries( third_party_include\n      PRIVATE\n          Boost::filesystem\n  )\n----\n\n## Non-alias targets\n\nWhile most modern libraries use imported targets, not all modules have been updated. In the\ncase where a library hasn't been updated you will often find the following variables available:\n\n  * xxx_INCLUDE_DIRS - A variable pointing to the include directory for the library.\n  * xxx_LIBRARY - A variable pointing to the library path.\n\nThese can then be added to your +target_include_directories+ and +target_link_libraries+ as:\n\n[source,cmake]\n----\n# Include the boost headers\ntarget_include_directories( third_party_include\n    PRIVATE ${Boost_INCLUDE_DIRS}\n)\n\n# link against the boost libraries\ntarget_link_libraries( third_party_include\n    PRIVATE\n    ${Boost_SYSTEM_LIBRARY}\n    ${Boost_FILESYSTEM_LIBRARY}\n)\n----\n\n# Building the Example\n\n[source,bash]\n----\n$ mkdir build\n\n$ cd build/\n\n$ cmake ..\n-- The C compiler identification is GNU 4.8.4\n-- The CXX compiler identification is GNU 4.8.4\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Boost version: 1.54.0\n-- Found the following Boost libraries:\n--   filesystem\n--   system\nboost found\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/H-third-party-library/build\n\n$ make\nScanning dependencies of target third_party_include\n[100%] Building CXX object CMakeFiles/third_party_include.dir/main.cpp.o\nLinking CXX executable third_party_include\n[100%] Built target third_party_include\nmatrim@freyr:~/workspace/cmake-examples/01-basic/H-third-party-library/build$ ./\nCMakeFiles/          third_party_include\nmatrim@freyr:~/workspace/cmake-examples/01-basic/H-third-party-library/build$ ./third_party_include\nHello Third Party Include!\nPath is not relative\n$ cmake ..\n-- The C compiler identification is GNU 4.8.4\n-- The CXX compiler identification is GNU 4.8.4\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Boost version: 1.54.0\n-- Found the following Boost libraries:\n--   filesystem\n--   system\nboost found\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/H-third-party-library/build\n\n$ make\nScanning dependencies of target third_party_include\n[100%] Building CXX object CMakeFiles/third_party_include.dir/main.cpp.o\nLinking CXX executable third_party_include\n[100%] Built target third_party_include\n\n$ ./third_party_include\nHello Third Party Include!\nPath is not relative\n\n----\n"
  },
  {
    "path": "01-basic/H-third-party-library/main.cpp",
    "content": "#include <iostream>\n#include <boost/shared_ptr.hpp>\n#include <boost/filesystem.hpp>\n\nint main(int argc, char *argv[])\n{\n    std::cout << \"Hello Third Party Include!\" << std::endl;\n\n    // use a shared ptr\n    boost::shared_ptr<int> isp(new int(4));\n\n    // trivial use of boost filesystem\n    boost::filesystem::path path = \"/usr/share/cmake/modules\";\n    if(path.is_relative())\n    {\n        std::cout << \"Path is relative\" << std::endl;\n    }\n    else\n    {\n        std::cout << \"Path is not relative\" << std::endl;\n    }\n\n   return 0;\n}\n"
  },
  {
    "path": "01-basic/I-compiling-with-clang/CMakeLists.txt",
    "content": "# Set the minimum version of CMake that can be used\n# To find the cmake version run\n# $ cmake --version\ncmake_minimum_required(VERSION 3.5)\n\n# Set the project name\nproject (hello_cmake)\n\n# Add an executable\nadd_executable(hello_cmake main.cpp)\n"
  },
  {
    "path": "01-basic/I-compiling-with-clang/README.adoc",
    "content": "= Compiling with clang\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nWhen building with CMake it is possible to set the C and C++ compiler. This example\nis the same as the link:../A-hello-cmake[hello-cmake] example except that it shows the most basic\nmethod of changing the compiler from the default gcc to http://clang.llvm.org/[clang].\n\nThe files in this tutorial are below:\n\n```\n$ tree\n.\n├── CMakeLists.txt\n├── main.cpp\n```\n\n  * link:CMakeLists.txt[] - Contains the CMake commands you wish to run\n  * link:main.cpp[] - A simple \"Hello World\" cpp file.\n\n# Concepts\n\n### Compiler Option\n\nCMake exposes options to control the programs used to compile and link your code. These\nprograms include:\n\n  * CMAKE_C_COMPILER - The program used to compile c code.\n  * CMAKE_CXX_COMPILER - The program used to compile c++ code.\n  * CMAKE_LINKER - The program used to link your binary.\n\n[NOTE]\n====\nIn this example clang-3.6 is installed via the command `sudo apt-get install clang-3.6`\n====\n\n[NOTE]\n====\nThis is the most basic and easiest way to invoke clang. Future examples will show better\nways to invoke the compiler.\n====\n\n\n### Setting Flags\n\nAs described in the link:../F-build-type[Build Type] example, you can set CMake options\nusing either a cmake gui or by passing from the command line.\n\nBelow is an example of passing the compiler via the command line.\n\n[source,cmake]\n----\ncmake .. -DCMAKE_C_COMPILER=clang-3.6 -DCMAKE_CXX_COMPILER=clang++-3.6\n----\n\nAfter setting these options, when your run `make` clang will be used to compile your binary. This\ncan be seen from the following lines in the make output.\n\n[source,bash]\n----\n/usr/bin/clang++-3.6     -o CMakeFiles/hello_cmake.dir/main.cpp.o -c /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/main.cpp\nLinking CXX executable hello_cmake\n/usr/bin/cmake -E cmake_link_script CMakeFiles/hello_cmake.dir/link.txt --verbose=1\n/usr/bin/clang++-3.6       CMakeFiles/hello_cmake.dir/main.cpp.o  -o hello_cmake -rdynamic\n----\n\n\n\n# Building the Examples\n\nBelow is sample output from building this example.\n\n[source,bash]\n----\n$ mkdir build.clang\n\n$ cd build.clang/\n\n$ cmake .. -DCMAKE_C_COMPILER=clang-3.6 -DCMAKE_CXX_COMPILER=clang++-3.6\n-- The C compiler identification is Clang 3.6.0\n-- The CXX compiler identification is Clang 3.6.0\n-- Check for working C compiler: /usr/bin/clang-3.6\n-- Check for working C compiler: /usr/bin/clang-3.6 -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Check for working CXX compiler: /usr/bin/clang++-3.6\n-- Check for working CXX compiler: /usr/bin/clang++-3.6 -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang\n\n$ make VERBOSE=1\n/usr/bin/cmake -H/home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang -B/home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang --check-build-system CMakeFiles/Makefile.cmake 0\n/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang/CMakeFiles /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang/CMakeFiles/progress.marks\nmake -f CMakeFiles/Makefile2 all\nmake[1]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang'\nmake -f CMakeFiles/hello_cmake.dir/build.make CMakeFiles/hello_cmake.dir/depend\nmake[2]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang'\ncd /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang && /usr/bin/cmake -E cmake_depends \"Unix Makefiles\" /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang/CMakeFiles/hello_cmake.dir/DependInfo.cmake --color=\nDependee \"/home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang/CMakeFiles/hello_cmake.dir/DependInfo.cmake\" is newer than depender \"/home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang/CMakeFiles/hello_cmake.dir/depend.internal\".\nDependee \"/home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang/CMakeFiles/CMakeDirectoryInformation.cmake\" is newer than depender \"/home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang/CMakeFiles/hello_cmake.dir/depend.internal\".\nScanning dependencies of target hello_cmake\nmake[2]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang'\nmake -f CMakeFiles/hello_cmake.dir/build.make CMakeFiles/hello_cmake.dir/build\nmake[2]: Entering directory `/home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang'\n/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang/CMakeFiles 1\n[100%] Building CXX object CMakeFiles/hello_cmake.dir/main.cpp.o\n/usr/bin/clang++-3.6     -o CMakeFiles/hello_cmake.dir/main.cpp.o -c /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/main.cpp\nLinking CXX executable hello_cmake\n/usr/bin/cmake -E cmake_link_script CMakeFiles/hello_cmake.dir/link.txt --verbose=1\n/usr/bin/clang++-3.6       CMakeFiles/hello_cmake.dir/main.cpp.o  -o hello_cmake -rdynamic\nmake[2]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang'\n/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang/CMakeFiles  1\n[100%] Built target hello_cmake\nmake[1]: Leaving directory `/home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang'\n/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/01-basic/I-compiling-with-clang/build.clang/CMakeFiles 0\n\n$ ./hello_cmake\nHello CMake!\n----\n"
  },
  {
    "path": "01-basic/I-compiling-with-clang/main.cpp",
    "content": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n   std::cout << \"Hello CMake!\" << std::endl;\n   return 0;\n}"
  },
  {
    "path": "01-basic/I-compiling-with-clang/pre_test.sh",
    "content": "#!/bin/bash\n\nROOT_DIR=`pwd`\ndir=\"01-basic/I-compiling-with-clang\"\n\nif [ -d \"$ROOT_DIR/$dir/build.clang\" ]; then\n    echo \"deleting $dir/build.clang\"\n    rm -r $dir/build.clang\nfi\n"
  },
  {
    "path": "01-basic/I-compiling-with-clang/run_test.sh",
    "content": "#!/bin/bash\n# Ubuntu supports multiple versions of clang to be installed at the same time.\n# The tests need to determine the clang binary before calling cmake\nclang_bin=`which clang`\nclang_xx_bin=`which clang++`\n\nif [ -z $clang_bin ]; then\n    clang_ver=`dpkg --get-selections | grep clang | grep -v -m1 libclang | cut -f1 | cut -d '-' -f2`\n    clang_bin=\"clang-$clang_ver\"\n    clang_xx_bin=\"clang++-$clang_ver\"\nfi\n\necho \"Will use clang [$clang_bin] and clang++ [$clang_xx_bin]\"\n\n\nmkdir -p build.clang && cd build.clang && \\\n    cmake .. -DCMAKE_C_COMPILER=$clang_bin -DCMAKE_CXX_COMPILER=$clang_xx_bin && make\n"
  },
  {
    "path": "01-basic/J-building-with-ninja/CMakeLists.txt",
    "content": "# Set the minimum version of CMake that can be used\n# To find the cmake version run\n# $ cmake --version\ncmake_minimum_required(VERSION 3.5)\n\n# Set the project name\nproject (hello_cmake)\n\n# Add an executable\nadd_executable(hello_cmake main.cpp)\n"
  },
  {
    "path": "01-basic/J-building-with-ninja/README.adoc",
    "content": "= Building with ninja\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nAs mentioned, CMake is a meta-build system that can be used to\n create the build files for many other build tools. This example shows how\n to have CMake use the https://ninja-build.org/[ninja build] tool.\n\nThe files in this tutorial are below:\n\n```\n$ tree\n.\n├── CMakeLists.txt\n├── main.cpp\n```\n\n  * link:CMakeLists.txt[] - Contains the CMake commands you wish to run\n  * link:main.cpp[] - A simple \"Hello World\" cpp file.\n\n# Concepts\n\n### Generators\n\nCMake https://cmake.org/cmake/help/v3.0/manual/cmake-generators.7.html[generators] are\nresponsible for writing the input files (e.g. Makefiles) for the underlying build system. Running `cmake --help`\nwill show the generators available. For cmake v2.8.12.2 the generators supported\non my system include:\n\n[source,bash]\n----\nGenerators\n\nThe following generators are available on this platform:\n  Unix Makefiles              = Generates standard UNIX makefiles.\n  Ninja                       = Generates build.ninja files (experimental).\n  CodeBlocks - Ninja          = Generates CodeBlocks project files.\n  CodeBlocks - Unix Makefiles = Generates CodeBlocks project files.\n  Eclipse CDT4 - Ninja        = Generates Eclipse CDT 4.0 project files.\n  Eclipse CDT4 - Unix Makefiles\n                              = Generates Eclipse CDT 4.0 project files.\n  KDevelop3                   = Generates KDevelop 3 project files.\n  KDevelop3 - Unix Makefiles  = Generates KDevelop 3 project files.\n  Sublime Text 2 - Ninja      = Generates Sublime Text 2 project files.\n  Sublime Text 2 - Unix Makefiles\n                              = Generates Sublime Text 2 project files.Generators\n----\n\nAs specified in this https://stackoverflow.com/questions/25941536/what-is-a-cmake-generator[post],\nCMake includes different types of generators such as Command-Line, IDE, and Extra generators.\n\n#### Command-Line Build Tool Generators\n\nThese generators are for command-line build tools, like Make and Ninja. The chosen tool chain must be configured prior to generating the build system with CMake.\n\nThe supported generators include:\n\n  * Borland Makefiles\n  * MSYS Makefiles\n  * MinGW Makefiles\n  * NMake Makefiles\n  * NMake Makefiles JOM\n  * Ninja\n  * Unix Makefiles\n  * Watcom WMake\n\n#### IDE Build Tool Generators\n\nThese generators are for Integrated Development Environments that include their own compiler. Examples are Visual Studio and Xcode which include a compiler natively.\n\nThe supported generators include:\n\n  * Visual Studio 6\n  * Visual Studio 7\n  * Visual Studio 7 .NET 2003\n  * Visual Studio 8 2005\n  * Visual Studio 9 2008\n  * Visual Studio 10 2010\n  * Visual Studio 11 2012\n  * Visual Studio 12 2013\n  * Xcode\n\n#### Extra Generators\n\nThese are generators create a configuration to work with an alternative IDE tool and must be included with either an IDE or Command-Line generator.\n\nThe supported generators include:\n\n * CodeBlocks\n * CodeLite\n * Eclipse CDT4\n * KDevelop3\n * Kate\n * Sublime Text 2\n\n\n[NOTE]\n====\nIn this example ninja is installed via the command `sudo apt-get install ninja-build`\n====\n\n### Calling a Generator\n\nTo call a CMake generator you can use the `-G` command line switch, for example:\n\n[source,cmake]\n----\ncmake .. -G Ninja\n----\n\nAfter doing the above CMake will generate the required Ninja build files, which can be run\nfrom using the `ninja` command.\n\n[source,bash]\n----\n$ cmake .. -G Ninja\n\n$ ls\nbuild.ninja  CMakeCache.txt  CMakeFiles  cmake_install.cmake  rules.ninja\n----\n\n# Building the Examples\n\nBelow is sample output from building this example.\n\n[source,bash]\n----\n$ mkdir build.ninja\n\n$ cd build.ninja/\n\n$ cmake .. -G Ninja\n-- The C compiler identification is GNU 4.8.4\n-- The CXX compiler identification is GNU 4.8.4\n-- Check for working C compiler using: Ninja\n-- Check for working C compiler using: Ninja -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Check for working CXX compiler using: Ninja\n-- Check for working CXX compiler using: Ninja -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /home/matrim/workspace/cmake-examples/01-basic/J-building-with-ninja/build.ninja\n\n$ ninja -v\n[1/2] /usr/bin/c++     -MMD -MT CMakeFiles/hello_cmake.dir/main.cpp.o -MF \"CMakeFiles/hello_cmake.dir/main.cpp.o.d\" -o CMakeFiles/hello_cmake.dir/main.cpp.o -c ../main.cpp\n[2/2] : && /usr/bin/c++      CMakeFiles/hello_cmake.dir/main.cpp.o  -o hello_cmake  -rdynamic && :\n\n$ ls\nbuild.ninja  CMakeCache.txt  CMakeFiles  cmake_install.cmake  hello_cmake  rules.ninja\n\n$ ./hello_cmake\nHello CMake!\n----\n"
  },
  {
    "path": "01-basic/J-building-with-ninja/main.cpp",
    "content": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n   std::cout << \"Hello CMake!\" << std::endl;\n   return 0;\n}"
  },
  {
    "path": "01-basic/J-building-with-ninja/pre_test.sh",
    "content": "#!/bin/bash\n\nROOT_DIR=`pwd`\ndir=\"01-basic/J-building-with-ninja\"\n\nif [ -d \"$ROOT_DIR/$dir/build.ninja\" ]; then\n    echo \"deleting $dir/build.ninja\"\n    rm -r $dir/build.ninja\nfi\n"
  },
  {
    "path": "01-basic/J-building-with-ninja/run_test.sh",
    "content": "#!/bin/bash\n# Travis-ci cmake version doesn't support ninja, so first check if it's supported\nninja_supported=`cmake --help | grep Ninja`\n\nif [ -z $ninja_supported ]; then\n    echo \"Ninja not supported\"\n    exit\nfi\n\nmkdir -p build.ninja && cd build.ninja && \\\n    cmake .. -G Ninja && ninja\n"
  },
  {
    "path": "01-basic/K-imported-targets/CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 3.5)\n\n# Set the project name\nproject (imported_targets)\n\n\n# find a boost install with the libraries filesystem and system\nfind_package(Boost 1.46.1 REQUIRED COMPONENTS filesystem system)\n\n# check if boost was found\nif(Boost_FOUND)\n    message (\"boost found\")\nelse()\n    message (FATAL_ERROR \"Cannot find Boost\")\nendif()\n\n# Add an executable\nadd_executable(imported_targets main.cpp)\n\n# link against the boost libraries\ntarget_link_libraries( imported_targets\n    PRIVATE\n        Boost::filesystem\n)\n"
  },
  {
    "path": "01-basic/K-imported-targets/README.adoc",
    "content": "= Imported Targets\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nAs previously mentioned in the link:../H-third-party-library[third party library], newer\nversions of CMake allow you to link third party libraries using link:https://cmake.org/cmake/help/v3.6/prop_tgt/IMPORTED.html#prop_tgt:IMPORTED[imported] +ALIAS+ targets.\n\nThe files in this tutorial are below:\n\n```\n$ tree\n.\n├── CMakeLists.txt\n├── main.cpp\n```\n\n  * link:CMakeLists.txt[] - Contains the CMake commands you wish to run\n  * link:main.cpp[] - The source file with main\n\n# Requirements\n\nThis example requires the following:\n\n  * CMake v3.5+\n  * The boost libraries to be installed in a default system location. \n\n# Concepts\n\n## Imported Target\n\nImported targets are read-only targets that are exported by FindXXX modules. \n\nTo include boost filesystem you can do the following:\n\n[source,cmake]\n----\n  target_link_libraries( imported_targets\n      PRIVATE\n          Boost::filesystem\n  )\n----\n\nThis will automtaically link the Boost::filesystem and Boost::system libraries while also including the\nBoost include directories.\n\n# Building the Example\n\n[source,bash]\n----\n$ mkdir build\n\n$ cd build/\n\n$ cmake ..\n-- The C compiler identification is GNU 5.4.0\n-- The CXX compiler identification is GNU 5.4.0\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Detecting C compile features\n-- Detecting C compile features - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Detecting CXX compile features\n-- Detecting CXX compile features - done\n-- Boost version: 1.58.0\n-- Found the following Boost libraries:\n--   filesystem\n--   system\nboost found\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /data/code/01-basic/K-imported-targets/build\n\n$ make\nScanning dependencies of target imported_targets\n[ 50%] Building CXX object CMakeFiles/imported_targets.dir/main.cpp.o\n[100%] Linking CXX executable imported_targets\n[100%] Built target imported_targets\n\n\n$ ./imported_targets\nHello Third Party Include!\nPath is not relative\n\n\n----\n"
  },
  {
    "path": "01-basic/K-imported-targets/main.cpp",
    "content": "#include <iostream>\n#include <boost/shared_ptr.hpp>\n#include <boost/filesystem.hpp>\n\nint main(int argc, char *argv[])\n{\n    std::cout << \"Hello Third Party Include!\" << std::endl;\n\n    // use a shared ptr\n    boost::shared_ptr<int> isp(new int(4));\n\n    // trivial use of boost filesystem\n    boost::filesystem::path path = \"/usr/share/cmake/modules\";\n    if(path.is_relative())\n    {\n        std::cout << \"Path is relative\" << std::endl;\n    }\n    else\n    {\n        std::cout << \"Path is not relative\" << std::endl;\n    }\n\n   return 0;\n}\n"
  },
  {
    "path": "01-basic/K-imported-targets/run_test.sh",
    "content": "#!/bin/bash\n# Make sure we have the minimum cmake version\ncmake_version=`cmake --version | grep version | cut -d\" \" -f3`\n\n[[ \"$cmake_version\"  =~ ([3-9][.][5-9.][.][0-9]) ]] || exit 0\n\necho \"correct version of cmake\"\nmkdir -p build && cd build && cmake .. && make\nif [ $? -ne 0 ]; then\n    echo \"Error running example\"\n    exit 1\nfi\n"
  },
  {
    "path": "01-basic/L-cpp-standard/README.adoc",
    "content": "= C++ Standard\n\nSince the release of C+\\+11 and C++14 a common use case is to invoke the compiler to use these standards. As CMake has evolved, it has added features to make this easier and new versions of CMake have changed how this is achieved.\n\nThe following examples show different methods of setting the C++ standard and what versions of CMake they are available from.\n\nThe examples include:\n\n  - link:i-common-method[common-method]. A simple version that should work with most versions of CMake.\n  - link:ii-cxx-standard[cxx-standard]. Using the `CMAKE_CXX_STANDARD` variable introduced in CMake v3.1.\n  - link:iii-compile-features[compile-features]. Using the `target_compile_features` function introduced in CMake v3.1.\n"
  },
  {
    "path": "01-basic/L-cpp-standard/i-common-method/CMakeLists.txt",
    "content": "# Set the minimum version of CMake that can be used\n# To find the cmake version run\n# $ cmake --version\ncmake_minimum_required(VERSION 2.8)\n\n# Set the project name\nproject (hello_cpp11)\n\n# try conditional compilation\ninclude(CheckCXXCompilerFlag)\nCHECK_CXX_COMPILER_FLAG(\"-std=c++11\" COMPILER_SUPPORTS_CXX11)\nCHECK_CXX_COMPILER_FLAG(\"-std=c++0x\" COMPILER_SUPPORTS_CXX0X)\n\n# check results and add flag\nif(COMPILER_SUPPORTS_CXX11)#\n    set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -std=c++11\")\nelseif(COMPILER_SUPPORTS_CXX0X)#\n    set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -std=c++0x\")\nelse()\n    message(STATUS \"The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.\")\nendif()\n\n# Add an executable\nadd_executable(hello_cpp11 main.cpp)\n"
  },
  {
    "path": "01-basic/L-cpp-standard/i-common-method/README.adoc",
    "content": "= C++ Standard Common Method\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nThis example shows a common method to set the C++ Standard. This can be used with most versions of CMake. However, if you are targeting a recent version of CMake there are more convenient methods available.\n\nThe files in this tutorial are below:\n\n```\nA-hello-cmake$ tree\n.\n├── CMakeLists.txt\n├── main.cpp\n```\n\n  * link:CMakeLists.txt[CMakeLists.txt] - Contains the CMake commands you wish to run\n  * link:main.cpp[main.cpp] - A simple \"Hello World\" cpp file targeting C++11.\n\n# Concepts\n\n## Checking Compile flags\n\nCMake has support for attempting to compile a program with any flags you pass into the function `CMAKE_CXX_COMPILER_FLAG`. The result is then stored in a variable that you pass in.\n\nFor example:\n\n[source,cmake]\n----\ninclude(CheckCXXCompilerFlag)\nCHECK_CXX_COMPILER_FLAG(\"-std=c++11\" COMPILER_SUPPORTS_CXX11)\n----\n\nThis example will attempt to compile a program with the flag `-std=c++11` and store the result in the variable `COMPILER_SUPPORTS_CXX11`.\n\nThe line `include(CheckCXXCompilerFlag)` tells CMake to include this function to make it available for use.\n\n## Adding the flag\n\nOnce you have determined if the compile supports a flag, you can then use the link:../../G-compile-flags/[standard cmake methods] to add this flag to a target. In this example we use the `CMAKE_CXX_FLAGS` to propegate the flag to all targets .\n\n[source,cmake]\n----\nif(COMPILER_SUPPORTS_CXX11)#\n    set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -std=c++11\")\nelseif(COMPILER_SUPPORTS_CXX0X)#\n    set(CMAKE_CXX_FLAGS \"${CMAKE_CXX_FLAGS} -std=c++0x\")\nelse()\n    message(STATUS \"The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.\")\nendif()\n----\n\nThe above example only checks for the gcc version of the compile flags and supports fallback from C+\\+11 to the pre-standardisation C+\\+0x flag. In real usage you may want to check for C++14, or add support for different methods of setting the compile, e.g. `-std=gnu++11`\n\n# Building the Examples\n\nBelow is sample output from building this example.\n\n[source,bash]\n----\n$ mkdir build\n$ cd build\n\n$ cmake ..\n-- The C compiler identification is GNU 4.8.4\n-- The CXX compiler identification is GNU 4.8.4\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Performing Test COMPILER_SUPPORTS_CXX11\n-- Performing Test COMPILER_SUPPORTS_CXX11 - Success\n-- Performing Test COMPILER_SUPPORTS_CXX0X\n-- Performing Test COMPILER_SUPPORTS_CXX0X - Success\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /data/code/01-basic/L-cpp-standard/i-common-method/build\n\n$ make VERBOSE=1\n/usr/bin/cmake -H/data/code/01-basic/L-cpp-standard/i-common-method -B/data/code/01-basic/L-cpp-standard/i-common-method/build --check-build-system CMakeFiles/Makefile.cmake 0\n/usr/bin/cmake -E cmake_progress_start /data/code/01-basic/L-cpp-standard/i-common-method/build/CMakeFiles /data/code/01-basic/L-cpp-standard/i-common-method/build/CMakeFiles/progress.marks\nmake -f CMakeFiles/Makefile2 all\nmake[1]: Entering directory `/data/code/01-basic/L-cpp-standard/i-common-method/build'\nmake -f CMakeFiles/hello_cpp11.dir/build.make CMakeFiles/hello_cpp11.dir/depend\nmake[2]: Entering directory `/data/code/01-basic/L-cpp-standard/i-common-method/build'\ncd /data/code/01-basic/L-cpp-standard/i-common-method/build && /usr/bin/cmake -E cmake_depends \"Unix Makefiles\" /data/code/01-basic/L-cpp-standard/i-common-method /data/code/01-basic/L-cpp-standard/i-common-method /data/code/01-basic/L-cpp-standard/i-common-method/build /data/code/01-basic/L-cpp-standard/i-common-method/build /data/code/01-basic/L-cpp-standard/i-common-method/build/CMakeFiles/hello_cpp11.dir/DependInfo.cmake --color=\nDependee \"/data/code/01-basic/L-cpp-standard/i-common-method/build/CMakeFiles/hello_cpp11.dir/DependInfo.cmake\" is newer than depender \"/data/code/01-basic/L-cpp-standard/i-common-method/build/CMakeFiles/hello_cpp11.dir/depend.internal\".\nDependee \"/data/code/01-basic/L-cpp-standard/i-common-method/build/CMakeFiles/CMakeDirectoryInformation.cmake\" is newer than depender \"/data/code/01-basic/L-cpp-standard/i-common-method/build/CMakeFiles/hello_cpp11.dir/depend.internal\".\nScanning dependencies of target hello_cpp11\nmake[2]: Leaving directory `/data/code/01-basic/L-cpp-standard/i-common-method/build'\nmake -f CMakeFiles/hello_cpp11.dir/build.make CMakeFiles/hello_cpp11.dir/build\nmake[2]: Entering directory `/data/code/01-basic/L-cpp-standard/i-common-method/build'\n/usr/bin/cmake -E cmake_progress_report /data/code/01-basic/L-cpp-standard/i-common-method/build/CMakeFiles 1\n[100%] Building CXX object CMakeFiles/hello_cpp11.dir/main.cpp.o\n/usr/bin/c++    -std=c++11   -o CMakeFiles/hello_cpp11.dir/main.cpp.o -c /data/code/01-basic/L-cpp-standard/i-common-method/main.cpp\nLinking CXX executable hello_cpp11\n/usr/bin/cmake -E cmake_link_script CMakeFiles/hello_cpp11.dir/link.txt --verbose=1\n/usr/bin/c++    -std=c++11    CMakeFiles/hello_cpp11.dir/main.cpp.o  -o hello_cpp11 -rdynamic\nmake[2]: Leaving directory `/data/code/01-basic/L-cpp-standard/i-common-method/build'\n/usr/bin/cmake -E cmake_progress_report /data/code/01-basic/L-cpp-standard/i-common-method/build/CMakeFiles  1\n[100%] Built target hello_cpp11\nmake[1]: Leaving directory `/data/code/01-basic/L-cpp-standard/i-common-method/build'\n/usr/bin/cmake -E cmake_progress_start /data/code/01-basic/L-cpp-standard/i-common-method/build/CMakeFiles 0\n----\n"
  },
  {
    "path": "01-basic/L-cpp-standard/i-common-method/main.cpp",
    "content": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n    auto message = \"Hello C++11\";\n    std::cout << message << std::endl;\n    return 0;\n}\n"
  },
  {
    "path": "01-basic/L-cpp-standard/ii-cxx-standard/CMakeLists.txt",
    "content": "# Set the minimum version of CMake that can be used\n# To find the cmake version run\n# $ cmake --version\ncmake_minimum_required(VERSION 3.1)\n\n# Set the project name\nproject (hello_cpp11)\n\n# set the C++ standard to C++ 11\nset(CMAKE_CXX_STANDARD 11)\n\n# Add an executable\nadd_executable(hello_cpp11 main.cpp)\n"
  },
  {
    "path": "01-basic/L-cpp-standard/ii-cxx-standard/README.adoc",
    "content": "= Set C++ Standard\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nThis example shows how to set the C++ standard using the `CMAKE_CXX_STANDARD` variable. This is available since CMake v3.1\n\nThe files in this tutorial are below:\n\n```\nA-hello-cmake$ tree\n.\n├── CMakeLists.txt\n├── main.cpp\n```\n\n  * link:CMakeLists.txt[CMakeLists.txt] - Contains the CMake commands you wish to run\n  * link:main.cpp[main.cpp] - A simple \"Hello World\" cpp file targeting C++11.\n\n# Concepts\n\n## Using CXX_STANDARD property\n\nSetting the link:https://cmake.org/cmake/help/v3.1/variable/CMAKE_CXX_STANDARD.html[CMAKE_CXX_STANDARD] variable causes the `CXX_STANDARD` property on all targets. This causes CMake to set the appropriate flag at compille time.\n\n\n[NOTE]\n====\nThe `CMAKE_CXX_STANDARD` variable falls back to the closest appropriate standard without a failure. For example, if you request `-std=gnu++11` you may end up with `-std=gnu++0x`.\n\nThis can result in an unexpected failure at compile time.\n====\n\n# Building the Examples\n\nBelow is sample output from building this example.\n\n[source,bash]\n----\n$ mkdir build\n$ cd build\n\n\n$ cmake ..\n-- The C compiler identification is GNU 5.4.0\n-- The CXX compiler identification is GNU 5.4.0\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Detecting C compile features\n-- Detecting C compile features - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Detecting CXX compile features\n-- Detecting CXX compile features - done\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /data/code/01-basic/L-cpp-standard/ii-cxx-standard/build\n\n$ make VERBOSE=1\n/usr/bin/cmake -H/data/code/01-basic/L-cpp-standard/ii-cxx-standard -B/data/code/01-basic/L-cpp-standard/ii-cxx-standard/build --check-build-system CMakeFiles/Makefile.cmake 0\n/usr/bin/cmake -E cmake_progress_start /data/code/01-basic/L-cpp-standard/ii-cxx-standard/build/CMakeFiles /data/code/01-basic/L-cpp-standard/ii-cxx-standard/build/CMakeFiles/progress.marks\nmake -f CMakeFiles/Makefile2 all\nmake[1]: Entering directory '/data/code/01-basic/L-cpp-standard/ii-cxx-standard/build'\nmake -f CMakeFiles/hello_cpp11.dir/build.make CMakeFiles/hello_cpp11.dir/depend\nmake[2]: Entering directory '/data/code/01-basic/L-cpp-standard/ii-cxx-standard/build'\ncd /data/code/01-basic/L-cpp-standard/ii-cxx-standard/build && /usr/bin/cmake -E cmake_depends \"Unix Makefiles\" /data/code/01-basic/L-cpp-standard/ii-cxx-standard /data/code/01-basic/L-cpp-standard/ii-cxx-standard /data/code/01-basic/L-cpp-standard/ii-cxx-standard/build /data/code/01-basic/L-cpp-standard/ii-cxx-standard/build /data/code/01-basic/L-cpp-standard/ii-cxx-standard/build/CMakeFiles/hello_cpp11.dir/DependInfo.cmake --color=\nDependee \"/data/code/01-basic/L-cpp-standard/ii-cxx-standard/build/CMakeFiles/hello_cpp11.dir/DependInfo.cmake\" is newer than depender \"/data/code/01-basic/L-cpp-standard/ii-cxx-standard/build/CMakeFiles/hello_cpp11.dir/depend.internal\".\nDependee \"/data/code/01-basic/L-cpp-standard/ii-cxx-standard/build/CMakeFiles/CMakeDirectoryInformation.cmake\" is newer than depender \"/data/code/01-basic/L-cpp-standard/ii-cxx-standard/build/CMakeFiles/hello_cpp11.dir/depend.internal\".\nScanning dependencies of target hello_cpp11\nmake[2]: Leaving directory '/data/code/01-basic/L-cpp-standard/ii-cxx-standard/build'\nmake -f CMakeFiles/hello_cpp11.dir/build.make CMakeFiles/hello_cpp11.dir/build\nmake[2]: Entering directory '/data/code/01-basic/L-cpp-standard/ii-cxx-standard/build'\n[ 50%] Building CXX object CMakeFiles/hello_cpp11.dir/main.cpp.o\n/usr/bin/c++     -std=gnu++11 -o CMakeFiles/hello_cpp11.dir/main.cpp.o -c /data/code/01-basic/L-cpp-standard/ii-cxx-standard/main.cpp\n[100%] Linking CXX executable hello_cpp11\n/usr/bin/cmake -E cmake_link_script CMakeFiles/hello_cpp11.dir/link.txt --verbose=1\n/usr/bin/c++      CMakeFiles/hello_cpp11.dir/main.cpp.o  -o hello_cpp11 -rdynamic\nmake[2]: Leaving directory '/data/code/01-basic/L-cpp-standard/ii-cxx-standard/build'\n[100%] Built target hello_cpp11\nmake[1]: Leaving directory '/data/code/01-basic/L-cpp-standard/ii-cxx-standard/build'\n----\n"
  },
  {
    "path": "01-basic/L-cpp-standard/ii-cxx-standard/main.cpp",
    "content": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n    auto message = \"Hello C++11\";\n    std::cout << message << std::endl;\n    return 0;\n}\n"
  },
  {
    "path": "01-basic/L-cpp-standard/iii-compile-features/CMakeLists.txt",
    "content": "# Set the minimum version of CMake that can be used\n# To find the cmake version run\n# $ cmake --version\ncmake_minimum_required(VERSION 3.1)\n\n# Set the project name\nproject (hello_cpp11)\n\n# Add an executable\nadd_executable(hello_cpp11 main.cpp)\n\n# set the C++ standard to the appropriate standard for using auto\ntarget_compile_features(hello_cpp11 PUBLIC cxx_auto_type)\n\n# Print the list of known compile features for this version of CMake\nmessage(\"List of compile features: ${CMAKE_CXX_COMPILE_FEATURES}\")\n"
  },
  {
    "path": "01-basic/L-cpp-standard/iii-compile-features/README.adoc",
    "content": "= Set C++ Standard\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nThis example shows how to set the C++ standard using the `target_compile_features` function. This is available since CMake v3.1\n\nThe files in this tutorial are below:\n\n```\nA-hello-cmake$ tree\n.\n├── CMakeLists.txt\n├── main.cpp\n```\n\n  * link:CMakeLists.txt[CMakeLists.txt] - Contains the CMake commands you wish to run\n  * link:main.cpp[main.cpp] - A simple \"Hello World\" cpp file targeting C++11.\n\n# Concepts\n\n## Using target_compile_features\n\nCalling the link:https://cmake.org/cmake/help/v3.1/command/target_compile_features.html[target_compile_features] function on a target will look at the passed in feature and determine the correct compiler flag to use for your target.\n\n[source,cmake]\n----\ntarget_compile_features(hello_cpp11 PUBLIC cxx_auto_type)\n----\n\nAs with other `target_*` functions, you can specify the scope of the feature for the selected target. This populates the link:https://cmake.org/cmake/help/v3.1/prop_tgt/INTERFACE_COMPILE_FEATURES.html#prop_tgt:INTERFACE_COMPILE_FEATURES[INTERFACE_COMPILE_FEATURES] property for the target.\n\nThe list of available features can be found from the link:https://cmake.org/cmake/help/v3.1/variable/CMAKE_CXX_COMPILE_FEATURES.html#variable:CMAKE_CXX_COMPILE_FEATURES[CMAKE_CXX_COMPILE_FEATURES] variable. You can obtain a list of the available features using the following code:\n\n[source,cmake]\n----\nmessage(\"List of compile features: ${CMAKE_CXX_COMPILE_FEATURES}\")\n----\n\n# Building the Examples\n\nBelow is sample output from building this example.\n\n[source,bash]\n----\n$ mkdir build\n$ cd build\n\n$ cmake ..\n-- The C compiler identification is GNU 5.4.0\n-- The CXX compiler identification is GNU 5.4.0\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Detecting C compile features\n-- Detecting C compile features - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Detecting CXX compile features\n-- Detecting CXX compile features - done\nList of compile features: cxx_template_template_parameters;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates;cxx_aggregate_default_initializers;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_relaxed_constexpr;cxx_return_type_deduction;cxx_variable_templates\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /data/code/01-basic/L-cpp-standard/iii-compile-features/build\n\n\n$ make VERBOSE=1\n/usr/bin/cmake -H/data/code/01-basic/L-cpp-standard/iii-compile-features -B/data/code/01-basic/L-cpp-standard/iii-compile-features/build --check-build-system CMakeFiles/Makefile.cmake 0\n/usr/bin/cmake -E cmake_progress_start /data/code/01-basic/L-cpp-standard/iii-compile-features/build/CMakeFiles /data/code/01-basic/L-cpp-standard/iii-compile-features/build/CMakeFiles/progress.marks\nmake -f CMakeFiles/Makefile2 all\nmake[1]: Entering directory '/data/code/01-basic/L-cpp-standard/iii-compile-features/build'\nmake -f CMakeFiles/hello_cpp11.dir/build.make CMakeFiles/hello_cpp11.dir/depend\nmake[2]: Entering directory '/data/code/01-basic/L-cpp-standard/iii-compile-features/build'\ncd /data/code/01-basic/L-cpp-standard/iii-compile-features/build && /usr/bin/cmake -E cmake_depends \"Unix Makefiles\" /data/code/01-basic/L-cpp-standard/iii-compile-features /data/code/01-basic/L-cpp-standard/iii-compile-features /data/code/01-basic/L-cpp-standard/iii-compile-features/build /data/code/01-basic/L-cpp-standard/iii-compile-features/build /data/code/01-basic/L-cpp-standard/iii-compile-features/build/CMakeFiles/hello_cpp11.dir/DependInfo.cmake --color=\nDependee \"/data/code/01-basic/L-cpp-standard/iii-compile-features/build/CMakeFiles/hello_cpp11.dir/DependInfo.cmake\" is newer than depender \"/data/code/01-basic/L-cpp-standard/iii-compile-features/build/CMakeFiles/hello_cpp11.dir/depend.internal\".\nDependee \"/data/code/01-basic/L-cpp-standard/iii-compile-features/build/CMakeFiles/CMakeDirectoryInformation.cmake\" is newer than depender \"/data/code/01-basic/L-cpp-standard/iii-compile-features/build/CMakeFiles/hello_cpp11.dir/depend.internal\".\nScanning dependencies of target hello_cpp11\nmake[2]: Leaving directory '/data/code/01-basic/L-cpp-standard/iii-compile-features/build'\nmake -f CMakeFiles/hello_cpp11.dir/build.make CMakeFiles/hello_cpp11.dir/build\nmake[2]: Entering directory '/data/code/01-basic/L-cpp-standard/iii-compile-features/build'\n[ 50%] Building CXX object CMakeFiles/hello_cpp11.dir/main.cpp.o\n/usr/bin/c++     -std=gnu++11 -o CMakeFiles/hello_cpp11.dir/main.cpp.o -c /data/code/01-basic/L-cpp-standard/iii-compile-features/main.cpp\n[100%] Linking CXX executable hello_cpp11\n/usr/bin/cmake -E cmake_link_script CMakeFiles/hello_cpp11.dir/link.txt --verbose=1\n/usr/bin/c++      CMakeFiles/hello_cpp11.dir/main.cpp.o  -o hello_cpp11 -rdynamic\nmake[2]: Leaving directory '/data/code/01-basic/L-cpp-standard/iii-compile-features/build'\n[100%] Built target hello_cpp11\nmake[1]: Leaving directory '/data/code/01-basic/L-cpp-standard/iii-compile-features/build'\n/usr/bin/cmake -E cmake_progress_start /data/code/01-basic/L-cpp-standard/iii-compile-features/build/CMakeFiles 0\n\n----\n"
  },
  {
    "path": "01-basic/L-cpp-standard/iii-compile-features/main.cpp",
    "content": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n    auto message = \"Hello C++11\";\n    std::cout << message << std::endl;\n    return 0;\n}\n"
  },
  {
    "path": "01-basic/README.adoc",
    "content": "= Basic Examples\n\nThe basic examples in this directory show how the setup a CMake project,\nset compile flags, create and link executables and libraries, and install them.\n\nThe examples included are\n\n  - link:A-hello-cmake[hello-cmake]. A hello world example.\n  - link:B-hello-headers[hello-headers]. A slightly more complicated hello world example, using separate source and include folders.\n  - link:C-static-library[static-library]. An example using a static library.\n  - link:D-shared-library[shared-library]. An example using a shared library.\n  - link:E-installing[installing]. Shows how to create a 'make install' target that will install binaries and libraries.\n  - link:F-build-type[build-type]. An example showing how to set a default build and optimization flags for your project.\n  - link:G-compile-flags[compile-flags]. Shows how to set additional compile flags.\n  - link:H-third-party-library[third-party-library]. Shows an example of how to link third party libraries.\n  - link:I-compiling-with-clang[compiling-with-clang]. An example of invoking the clang compiler.\n  - link:J-building-with-ninja[building-with-ninja] - Shows how to generate ninja build files\n  - link:K-imported-targets[imported-targets] - Shows how to link boost using the new imported targets\n  - link:L-cpp-standard[cpp-standard] - Shows various methods to set the C++ standard\n"
  },
  {
    "path": "02-sub-projects/A-basic/CMakeLists.txt",
    "content": "cmake_minimum_required (VERSION 3.5)\n\nproject(subprojects)\n\n# Add sub directories\nadd_subdirectory(sublibrary1)\nadd_subdirectory(sublibrary2)\nadd_subdirectory(subbinary)\n"
  },
  {
    "path": "02-sub-projects/A-basic/README.adoc",
    "content": "= Basic Sub-Project\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nThis example shows how to setup a CMake project that includes sub-projects. The\ntop level CMakeLists.txt calls the CMakeLists.txt in the sub directories to\ncreate the following:\n\n  * sublibrary1 - A static library\n  * sublibrary2 - A header only library\n  * subbinary - An executable\n\nThe files included in this example are:\n\n```\n$ tree\n.\n├── CMakeLists.txt\n├── subbinary\n│   ├── CMakeLists.txt\n│   └── main.cpp\n├── sublibrary1\n│   ├── CMakeLists.txt\n│   ├── include\n│   │   └── sublib1\n│   │       └── sublib1.h\n│   └── src\n│       └── sublib1.cpp\n└── sublibrary2\n    ├── CMakeLists.txt\n    └── include\n        └── sublib2\n            └── sublib2.h\n```\n\n  * link:CMakeLists.txt[] - Top level CMakeLists.txt\n  * link:subbinary/CMakeLists.txt[] - to make the executable\n  * link:subbinary/main.cpp[] - source for the executable\n  * link:sublibrary1/CMakeLists.txt[] - to make a static library\n  * link:sublibrary1/include/sublib1/sublib1.h[]\n  * link:sublibrary1/src/sublib1.cpp[]\n  * link:sublibrary2/CMakeLists.txt[] - to setup header only library\n  * link:sublibrary2/include/sublib2/sublib2.h[]\n\n[TIP]\n====\nIn this example I have moved the header files to a subfolder under each projects +include+\ndirectory, while leaving the target include as the root +include+ folder. This is a good idea to prevent \nfilename clashes because you have to include a file like below:\n[source,cpp]\n----\n#include \"sublib1/sublib1.h\"\n----\n\nThis also means that if you install your library for other users the default install location would be\n+/usr/local/include/sublib1/sublib1.h+.\n====\n\n# Concepts\n\n## Adding a Sub-Directory\n\nA CMakeLists.txt file can include and call sub-directories which include a CMakeLists.txt\nfiles.\n\n[source,cmake]\n----\nadd_subdirectory(sublibrary1)\nadd_subdirectory(sublibrary2)\nadd_subdirectory(subbinary)\n----\n\n## Referencing Sub-Project Directories\n\nWhen a project is created using the `project()` command, CMake will automatically\ncreate a number of variables which can be used to reference details about the project.\nThese variables can then be used by other sub-projects or the main project. For example,\nto reference the source directory for a different project you can use.\n\n[source,cmake]\n----\n    ${sublibrary1_SOURCE_DIR}\n    ${sublibrary2_SOURCE_DIR}\n----\n\nThe variables created by CMake include:\n\n[cols=\",\",options=\"header\",]\n|=======================================================================\n|Variable |Info\n|PROJECT_NAME | The name of the project set by the current `project()`.\n\n|CMAKE_PROJECT_NAME |the name of the first project set by the `project()`\ncommand, i.e. the top level project.\n\n|PROJECT_SOURCE_DIR |The source director of the current project.\n\n|PROJECT_BINARY_DIR |The build directory for the current project.\n\n|name_SOURCE_DIR | The source directory of the project called \"name\".\nIn this example the source directories created would be `sublibrary1_SOURCE_DIR`,\n`sublibrary2_SOURCE_DIR`, and `subbinary_SOURCE_DIR`\n\n|name_BINARY_DIR | The binary directory of the project called \"name\".\nIn this example the binary directories created would be `sublibrary1_BINARY_DIR`,\n`sublibrary2_BINARY_DIR`, and `subbinary_BINARY_DIR`\n\n|=======================================================================\n\n## Header only Libraries\n\nIf you have a library that is created as a header only library, cmake supports the +INTERFACE+\ntarget to allow creating a target without any build output. More details can be found from\nlink:https://cmake.org/cmake/help/v3.4/command/add_library.html#interface-libraries[here]\n\n[source,cmake]\n----\nadd_library(${PROJECT_NAME} INTERFACE)\n----\n\nWhen creating the target you can also include directories for that target using\nthe +INTERFACE+ scope. The +INTERFACE+ scope is use to make target requirements that are used in any Libraries\nthat link this target but not in the compilation of the target itself.\n\n[source,cmake]\n----\ntarget_include_directories(${PROJECT_NAME}\n    INTERFACE\n        ${PROJECT_SOURCE_DIR}/include\n)\n----\n\n## Referencing Libraries from Sub-Projects\n\nIf a sub-project creates a library, it can be referenced by other projects by\ncalling the name of the target in the `target_link_libraries()` command. This\nmeans that you don't have to reference the full path of the new library and it\nis added as a dependency.\n\n[source,cmake]\n----\ntarget_link_libraries(subbinary\n    PUBLIC\n        sublibrary1\n)\n----\n\nAlternatively, you can create an alias target which allows you to reference the\ntarget in read only contexts.\n\nTo create an alias target run:\n\n[source,cmake]\n----\nadd_library(sublibrary2)\nadd_library(sub::lib2 ALIAS sublibrary2)\n----\n\nTo reference the alias, just it as follows:\n[source,cmake]\n----\ntarget_link_libraries(subbinary\n    sub::lib2\n)\n----\n\n## Include directories from sub-projects\n\nWhen adding the libraries from the sub-projects, starting from cmake v3, there is\nno need to add the projects include directories in the include directories of the\nbinary using them.\n\nThis is controlled by the scope in the `target_include_directories()` command when creating\nthe libraries. In this example because the subbinary executable links the sublibrary1\nand sublibrary2 libraries it will automatically include the `${sublibrary1_SOURCE_DIR}/include`\nand `${sublibrary2_SOURCE_DIR}/include` folders as they are exported with the\n +PUBLIC+ and +INTERFACE+ scopes of the libraries.\n\n# Building the example\n\n[source,bash]\n----\n$ mkdir build\n\n$ cd build/\n\n$ cmake ..\n-- The C compiler identification is GNU 4.8.4\n-- The CXX compiler identification is GNU 4.8.4\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /home/matrim/workspace/cmake-examples/02-sub-projects/A-basic/build\n\n$ make\nScanning dependencies of target sublibrary1\n[ 50%] Building CXX object sublibrary1/CMakeFiles/sublibrary1.dir/src/sublib1.cpp.o\nLinking CXX static library libsublibrary1.a\n[ 50%] Built target sublibrary1\nScanning dependencies of target subbinary\n[100%] Building CXX object subbinary/CMakeFiles/subbinary.dir/main.cpp.o\nLinking CXX executable subbinary\n[100%] Built target subbinary\n\n----\n"
  },
  {
    "path": "02-sub-projects/A-basic/subbinary/CMakeLists.txt",
    "content": "project(subbinary)\n\n# Create the executable\nadd_executable(${PROJECT_NAME} main.cpp)\n\n# Link the static library from subproject1 using its alias sub::lib1\n# Link the header only library from subproject2 using its alias sub::lib2\n# This will cause the include directories for that target to be added to this project\ntarget_link_libraries(${PROJECT_NAME}\n    sub::lib1\n    sub::lib2\n)\n"
  },
  {
    "path": "02-sub-projects/A-basic/subbinary/main.cpp",
    "content": "#include \"sublib1/sublib1.h\"\n#include \"sublib2/sublib2.h\"\n\nint main(int argc, char *argv[])\n{\n    sublib1 hi;\n    hi.print();\n\n    sublib2 howdy;\n    howdy.print();\n    \n    return 0;\n}\n"
  },
  {
    "path": "02-sub-projects/A-basic/sublibrary1/CMakeLists.txt",
    "content": "# Set the project name\nproject (sublibrary1)\n\n# Add a library with the above sources\nadd_library(${PROJECT_NAME} src/sublib1.cpp)\nadd_library(sub::lib1 ALIAS ${PROJECT_NAME})\n\ntarget_include_directories( ${PROJECT_NAME}\n    PUBLIC ${PROJECT_SOURCE_DIR}/include\n)\n"
  },
  {
    "path": "02-sub-projects/A-basic/sublibrary1/include/sublib1/sublib1.h",
    "content": "#ifndef __SUBLIB_1_H__\n#define __SUBLIB_1_H__\n\nclass sublib1\n{\npublic:\n    void print();\n};\n\n#endif\n"
  },
  {
    "path": "02-sub-projects/A-basic/sublibrary1/src/sublib1.cpp",
    "content": "#include <iostream>\n\n#include \"sublib1/sublib1.h\"\n\nvoid sublib1::print()\n{\n    std::cout << \"Hello sub-library 1!\" << std::endl;\n}\n"
  },
  {
    "path": "02-sub-projects/A-basic/sublibrary2/CMakeLists.txt",
    "content": "# Set the project name\nproject (sublibrary2)\n\nadd_library(${PROJECT_NAME} INTERFACE)\nadd_library(sub::lib2 ALIAS ${PROJECT_NAME})\n\ntarget_include_directories(${PROJECT_NAME}\n    INTERFACE\n        ${PROJECT_SOURCE_DIR}/include\n)\n"
  },
  {
    "path": "02-sub-projects/A-basic/sublibrary2/include/sublib2/sublib2.h",
    "content": "#ifndef __SUBLIB_2_H__\n#define __SUBLIB_2_H__\n\n#include <iostream>\n\nclass sublib2\n{\npublic:\n    void print()\n    {\n        std::cout << \"Hello header only sub-library 2!\" << std::endl;\n    }\n};\n\n#endif\n"
  },
  {
    "path": "02-sub-projects/README.adoc",
    "content": "= Sub-Project Examples\n\nMany large projects are made up of different libraries and binaries. These\ncan be organised into multiple folders and sub-projects to ease development.\n\nThe examples included are\n\n  - link:A-basic[basic] - This basic example includes a static library, a header only library\n  and an executable\n"
  },
  {
    "path": "03-code-generation/README.adoc",
    "content": "= Code Generation\n\nCode generation can be useful to create source code in different languages from a common description file. This can reduce the amount of manual code to write and increase interoperability.\n\nExamples showing code generation using variables from CMake and also using some common tools.\n\n  * link:configure-files[configure-file] - Using the CMake configure_file function to inject CMake variables.\n  * link:protobuf[Protocol Buffers] - Using Google Protocol Buffers to generate C++ source.\n"
  },
  {
    "path": "03-code-generation/configure-files/CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 3.5)\n\n# Set the project name\nproject (cf_example)\n\n# set a project version\nset (cf_example_VERSION_MAJOR 0)\nset (cf_example_VERSION_MINOR 2)\nset (cf_example_VERSION_PATCH 1)\nset (cf_example_VERSION \"${cf_example_VERSION_MAJOR}.${cf_example_VERSION_MINOR}.${cf_example_VERSION_PATCH}\")\n\n# Call configure files on ver.h.in to set the version.\n# Uses the standard ${VARIABLE} syntax in the file\nconfigure_file(ver.h.in ${PROJECT_BINARY_DIR}/ver.h)\n\n# configure the path.h.in file.\n# This file can only use the @VARIABLE@ syntax in the file\nconfigure_file(path.h.in ${PROJECT_BINARY_DIR}/path.h @ONLY)\n\n# Add an executable\nadd_executable(cf_example\n    main.cpp\n)\n\n# include the directory with the new files\ntarget_include_directories( cf_example\n    PUBLIC\n        ${CMAKE_BINARY_DIR}\n)\n"
  },
  {
    "path": "03-code-generation/configure-files/README.adoc",
    "content": "= Configure Files Generation\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nDuring the call to cmake it is possible to create files that use variables from\nthe CMakeLists.txt and cmake cache. During CMake generation the file is copied to a\nnew location and any cmake variables are replaced.\n\nThe files in this tutorial are below:\n\n```\n$ tree\n.\n├── CMakeLists.txt\n├── main.cpp\n├── path.h.in\n├── ver.h.in\n```\n\n  * link:CMakeLists.txt[] - Contains the CMake commands you wish to run\n  * link:main.cpp[] - The source file with main\n  * link:path.h.in[] - File to contain a path to the build directory\n  * link:ver.h.in[] - File to contain the version of the project\n\n# Concepts\n\n## Configure Files\n\nTo do variable substitution in a file you can use the `configure_file()` function\nin CMake. This core arguments for this function are source file and destination file.\n\n[source,cmake]\n----\nconfigure_file(ver.h.in ${PROJECT_BINARY_DIR}/ver.h)\n\nconfigure_file(path.h.in ${PROJECT_BINARY_DIR}/path.h @ONLY)\n----\n\nThe first example above, allows the variable to be defined like a CMake variables using\nthe `${}` syntax or an `@@` in the ver.h.in file. After generation a new file ver.h will be available\nin the `PROJECT_BINARY_DIR`.\n\n```\nconst char* ver = \"${cf_example_VERSION}\";\n```\n\nThe second example, only allows variables to be defined using the `@@` syntax in the path.h.in file.\nAfter generation a new file path.h will be available in the `PROJECT_BINARY_DIR`.\n\n```\nconst char* path = \"@CMAKE_SOURCE_DIR@\";\n```\n\n# Building the Example\n\n[source,bash]\n----\n$ mkdir build\n\n$ cd build/\n\n$ cmake ..\n-- The C compiler identification is GNU 4.8.4\n-- The CXX compiler identification is GNU 4.8.4\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /home/matrim/workspace/cmake-examples/03-code-generation/configure-files/build\n\n$ ls\nCMakeCache.txt  CMakeFiles  cmake_install.cmake  Makefile  path.h  ver.h\n\n$ cat path.h\n#ifndef __PATH_H__\n#define __PATH_H__\n\n// version variable that will be substituted by cmake\n// This shows an example using the @ variable type\nconst char* path = \"/home/matrim/workspace/cmake-examples/03-code-generation/configure-files\";\n\n#endif\n\n$ cat ver.h\n#ifndef __VER_H__\n#define __VER_H__\n\n// version variable that will be substituted by cmake\n// This shows an example using the $ variable type\nconst char* ver = \"0.2.1\";\n\n#endif\n\n$ make\nScanning dependencies of target cf_example\n[100%] Building CXX object CMakeFiles/cf_example.dir/main.cpp.o\nLinking CXX executable cf_example\n[100%] Built target cf_example\n\n$ ./cf_example\nHello Version 0.2.1!\nPath is /home/matrim/workspace/cmake-examples/03-code-generation/configure-files\n----\n"
  },
  {
    "path": "03-code-generation/configure-files/main.cpp",
    "content": "#include <iostream>\n#include \"ver.h\"\n#include \"path.h\"\n\nint main(int argc, char *argv[])\n{\n    std::cout << \"Hello Version \" << ver << \"!\" << std::endl;\n    std::cout << \"Path is \" << path << std::endl;\n   return 0;\n}\n"
  },
  {
    "path": "03-code-generation/configure-files/path.h.in",
    "content": "#ifndef __PATH_H__\n#define __PATH_H__\n\n// version variable that will be substituted by cmake\n// This shows an example using the @ variable type\nconst char* path = \"@CMAKE_SOURCE_DIR@\";\n\n#endif\n"
  },
  {
    "path": "03-code-generation/configure-files/ver.h.in",
    "content": "#ifndef __VER_H__\n#define __VER_H__\n\n// version variable that will be substituted by cmake\n// This shows an example using the $ variable type\nconst char* ver = \"${cf_example_VERSION}\";\n\n#endif\n"
  },
  {
    "path": "03-code-generation/protobuf/AddressBook.proto",
    "content": "package tutorial;\n\nmessage Person {\n  required string name = 1;\n  required int32 id = 2;\n  optional string email = 3;\n\n  enum PhoneType {\n    MOBILE = 0;\n    HOME = 1;\n    WORK = 2;\n  }\n\n  message PhoneNumber {\n    required string number = 1;\n    optional PhoneType type = 2 [default = HOME];\n  }\n\n  repeated PhoneNumber phone = 4;\n}\n\nmessage AddressBook {\n  repeated Person person = 1;\n}\n"
  },
  {
    "path": "03-code-generation/protobuf/CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 3.5)\n\n# Set the project name\nproject (protobuf_example)\n\n# find the protobuf compiler and libraries\nfind_package(Protobuf REQUIRED)\n\n# check if protobuf was found\nif(PROTOBUF_FOUND)\n    message (\"protobuf found\")\nelse()\n    message (FATAL_ERROR \"Cannot find Protobuf\")\nendif()\n\n# Generate the .h and .cxx files\nPROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS AddressBook.proto)\n\n# Print path to generated files\nmessage (\"PROTO_SRCS = ${PROTO_SRCS}\")\nmessage (\"PROTO_HDRS = ${PROTO_HDRS}\")\n\n# Add an executable\nadd_executable(protobuf_example\n    main.cpp\n    ${PROTO_SRCS}\n    ${PROTO_HDRS})\n\ntarget_include_directories(protobuf_example\n    PUBLIC\n    ${PROTOBUF_INCLUDE_DIRS}\n    ${CMAKE_CURRENT_BINARY_DIR}\n)\n\n# link the exe against the libraries\ntarget_link_libraries(protobuf_example\n    PUBLIC\n    ${PROTOBUF_LIBRARIES}\n)\n"
  },
  {
    "path": "03-code-generation/protobuf/README.adoc",
    "content": "= Protobuf Code Generation\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nThis example shows how to generate source files using https://github.com/google/protobuf[protobuf].\nProtocol Buffers is a data serialization format from Google. A user provides a\n`.proto` file with a description of the data. Then using the protobuf compiler, the proto file\ncan be translated into source code in a number of languages including C++.\n\nThe files in this tutorial are below:\n\n```\n$ tree\n.\n├── AddressBook.proto\n├── CMakeLists.txt\n├── main.cpp\n```\n\n  * link:AddressBook.proto[] - proto file from main protocol buffer https://developers.google.com/protocol-buffers/docs/cpptutorial[example]\n  * link:CMakeLists.txt[] - Contains the CMake commands you wish to run\n  * link:main.cpp[] - The source file from the protobuf example.\n\n# Requirements\n\nThis example requires the protocol buffers binary and libraries to be installed.\n\nThis can be installed on Ubuntu using\n\n[source,bash]\n----\nsudo apt-get install protobuf-compiler libprotobuf-dev\n----\n\n# Concepts\n\n## Exported Variables\n\nThe variables exported by the CMake protobuf package and used in this example include:\n\n  * `PROTOBUF_FOUND` - If Protocol Buffers is installed\n  * `PROTOBUF_INCLUDE_DIRS` - The protobuf header files\n  * `PROTOBUF_LIBRARIES` - The protobuf library\n\nMore variables are defined and can be found by examining the documentation at the\ntop of your `FindProtobuf.cmake` file.\n\n## Generating Source\n\nThe protobuf CMake package includes a number of helper functions to make the\ncode generation easier. In this example we are generating C++ source and use\nthe following code:\n\n[source,cmake]\n----\nPROTOBUF_GENERATE_CPP(PROTO_SRCS PROTO_HDRS AddressBook.proto)\n----\n\nThe arguments are:\n\n  * PROTO_SRCS - Name of the variable that will store the .pb.cc files.\n  * PROTO_HDRS- Name of the variable that will store the .pb.h files.\n  * AddressBook.proto - The .proto file to generate code from.\n\n## Generated Files\n\nAfter the `PROTOBUF_GENERATE_CPP` function is called, you will have the above\nmentioned variables available. These will be marked as the output to a custom command\nwhich calls the protobuf compiler binary to generate them.\n\nTo then have the files generated you should add them to a library or executable.\nFor example:\n\n[source,cmake]\n----\nadd_executable(protobuf_example\n    main.cpp\n    ${PROTO_SRCS}\n    ${PROTO_HDRS})\n----\n\nThis will cause the protobuf compiler to be called when you call `make` on that\nexecutables target.\n\nWhen changes are made to the .proto file, the associated source files will be\nautogenerated again. However, if no changes are made to the .proto file and you re-run\nmake, then nothing will be done.\n\n# Building the Example\n\n[source,bash]\n----\n$ mkdir build\n\n$ cd build/\n\n$ cmake ..\n-- The C compiler identification is GNU 4.8.4\n-- The CXX compiler identification is GNU 4.8.4\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Looking for include file pthread.h\n-- Looking for include file pthread.h - found\n-- Looking for pthread_create\n-- Looking for pthread_create - not found\n-- Looking for pthread_create in pthreads\n-- Looking for pthread_create in pthreads - not found\n-- Looking for pthread_create in pthread\n-- Looking for pthread_create in pthread - found\n-- Found Threads: TRUE\n-- Found PROTOBUF: /usr/lib/x86_64-linux-gnu/libprotobuf.so\nprotobuf found\nPROTO_SRCS = /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/AddressBook.pb.cc\nPROTO_HDRS = /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/AddressBook.pb.h\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build\n\n$ ls\nCMakeCache.txt  CMakeFiles  cmake_install.cmake  Makefile\n\n$ make VERBOSE=1\n/usr/bin/cmake -H/home/matrim/workspace/cmake-examples/03-code-generation/protobuf -B/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build --check-build-system CMakeFiles/Makefile.cmake 0\n/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles/progress.marks\nmake -f CMakeFiles/Makefile2 all\nmake[1]: Entering directory `/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build'\nmake -f CMakeFiles/protobuf_example.dir/build.make CMakeFiles/protobuf_example.dir/depend\nmake[2]: Entering directory `/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build'\n/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles 1\n[ 33%] Running C++ protocol buffer compiler on AddressBook.proto\n/usr/bin/protoc --cpp_out /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build -I /home/matrim/workspace/cmake-examples/03-code-generation/protobuf /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/AddressBook.proto\ncd /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build && /usr/bin/cmake -E cmake_depends \"Unix Makefiles\" /home/matrim/workspace/cmake-examples/03-code-generation/protobuf /home/matrim/workspace/cmake-examples/03-code-generation/protobuf /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles/protobuf_example.dir/DependInfo.cmake --color=\nDependee \"/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles/protobuf_example.dir/DependInfo.cmake\" is newer than depender \"/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles/protobuf_example.dir/depend.internal\".\nDependee \"/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles/CMakeDirectoryInformation.cmake\" is newer than depender \"/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles/protobuf_example.dir/depend.internal\".\nScanning dependencies of target protobuf_example\nmake[2]: Leaving directory `/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build'\nmake -f CMakeFiles/protobuf_example.dir/build.make CMakeFiles/protobuf_example.dir/build\nmake[2]: Entering directory `/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build'\n/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles 2\n[ 66%] Building CXX object CMakeFiles/protobuf_example.dir/main.cpp.o\n/usr/bin/c++    -I/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build    -o CMakeFiles/protobuf_example.dir/main.cpp.o -c /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/main.cpp\n/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles 3\n[100%] Building CXX object CMakeFiles/protobuf_example.dir/AddressBook.pb.cc.o\n/usr/bin/c++    -I/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build    -o CMakeFiles/protobuf_example.dir/AddressBook.pb.cc.o -c /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/AddressBook.pb.cc\nLinking CXX executable protobuf_example\n/usr/bin/cmake -E cmake_link_script CMakeFiles/protobuf_example.dir/link.txt --verbose=1\n/usr/bin/c++       CMakeFiles/protobuf_example.dir/main.cpp.o CMakeFiles/protobuf_example.dir/AddressBook.pb.cc.o  -o protobuf_example -rdynamic -lprotobuf -lpthread\nmake[2]: Leaving directory `/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build'\n/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles  1 2 3\n[100%] Built target protobuf_example\nmake[1]: Leaving directory `/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build'\n/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles 0\n$ make VERBOSE=1\n/usr/bin/cmake -H/home/matrim/workspace/cmake-examples/03-code-generation/protobuf -B/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build --check-build-system CMakeFiles/Makefile.cmake 0\n/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles/progress.marks\nmake -f CMakeFiles/Makefile2 all\nmake[1]: Entering directory `/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build'\nmake -f CMakeFiles/protobuf_example.dir/build.make CMakeFiles/protobuf_example.dir/depend\nmake[2]: Entering directory `/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build'\n/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles 1\n[ 33%] Running C++ protocol buffer compiler on AddressBook.proto\n/usr/bin/protoc --cpp_out /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build -I /home/matrim/workspace/cmake-examples/03-code-generation/protobuf /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/AddressBook.proto\ncd /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build && /usr/bin/cmake -E cmake_depends \"Unix Makefiles\" /home/matrim/workspace/cmake-examples/03-code-generation/protobuf /home/matrim/workspace/cmake-examples/03-code-generation/protobuf /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles/protobuf_example.dir/DependInfo.cmake --color=\nDependee \"/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles/protobuf_example.dir/DependInfo.cmake\" is newer than depender \"/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles/protobuf_example.dir/depend.internal\".\nDependee \"/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles/CMakeDirectoryInformation.cmake\" is newer than depender \"/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles/protobuf_example.dir/depend.internal\".\nScanning dependencies of target protobuf_example\nmake[2]: Leaving directory `/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build'\nmake -f CMakeFiles/protobuf_example.dir/build.make CMakeFiles/protobuf_example.dir/build\nmake[2]: Entering directory `/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build'\n/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles 2\n[ 66%] Building CXX object CMakeFiles/protobuf_example.dir/main.cpp.o\n/usr/bin/c++    -I/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build    -o CMakeFiles/protobuf_example.dir/main.cpp.o -c /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/main.cpp\n/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles 3\n[100%] Building CXX object CMakeFiles/protobuf_example.dir/AddressBook.pb.cc.o\n/usr/bin/c++    -I/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build    -o CMakeFiles/protobuf_example.dir/AddressBook.pb.cc.o -c /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/AddressBook.pb.cc\nLinking CXX executable protobuf_example\n/usr/bin/cmake -E cmake_link_script CMakeFiles/protobuf_example.dir/link.txt --verbose=1\n/usr/bin/c++       CMakeFiles/protobuf_example.dir/main.cpp.o CMakeFiles/protobuf_example.dir/AddressBook.pb.cc.o  -o protobuf_example -rdynamic -lprotobuf -lpthread\nmake[2]: Leaving directory `/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build'\n/usr/bin/cmake -E cmake_progress_report /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles  1 2 3\n[100%] Built target protobuf_example\nmake[1]: Leaving directory `/home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build'\n/usr/bin/cmake -E cmake_progress_start /home/matrim/workspace/cmake-examples/03-code-generation/protobuf/build/CMakeFiles 0\n\n$ ls\nAddressBook.pb.cc  CMakeCache.txt  cmake_install.cmake  protobuf_example\nAddressBook.pb.h   CMakeFiles      Makefile\n\n$ ./protobuf_example test.db\ntest.db: File not found.  Creating a new file.\nEnter person ID number: 11\nEnter name: John Doe\nEnter email address (blank for none): wolly@sheep.ie\nEnter a phone number (or leave blank to finish):\n\n$ ls\nAddressBook.pb.cc  CMakeCache.txt  cmake_install.cmake  protobuf_example\nAddressBook.pb.h   CMakeFiles      Makefile             test.db\n----\n"
  },
  {
    "path": "03-code-generation/protobuf/main.cpp",
    "content": "#include <iostream>\n#include <fstream>\n#include <string>\n#include \"AddressBook.pb.h\"\nusing namespace std;\n\n// This function fills in a Person message based on user input.\nvoid PromptForAddress(tutorial::Person* person) {\n  cout << \"Enter person ID number: \";\n  int id;\n  cin >> id;\n  person->set_id(id);\n  cin.ignore(256, '\\n');\n\n  cout << \"Enter name: \";\n  getline(cin, *person->mutable_name());\n\n  cout << \"Enter email address (blank for none): \";\n  string email;\n  getline(cin, email);\n  if (!email.empty()) {\n    person->set_email(email);\n  }\n\n  while (true) {\n    cout << \"Enter a phone number (or leave blank to finish): \";\n    string number;\n    getline(cin, number);\n    if (number.empty()) {\n      break;\n    }\n\n    tutorial::Person::PhoneNumber* phone_number = person->add_phone();\n    phone_number->set_number(number);\n\n    cout << \"Is this a mobile, home, or work phone? \";\n    string type;\n    getline(cin, type);\n    if (type == \"mobile\") {\n      phone_number->set_type(tutorial::Person::MOBILE);\n    } else if (type == \"home\") {\n      phone_number->set_type(tutorial::Person::HOME);\n    } else if (type == \"work\") {\n      phone_number->set_type(tutorial::Person::WORK);\n    } else {\n      cout << \"Unknown phone type.  Using default.\" << endl;\n    }\n  }\n}\n\n// Main function:  Reads the entire address book from a file,\n//   adds one person based on user input, then writes it back out to the same\n//   file.\nint main(int argc, char* argv[]) {\n  // Verify that the version of the library that we linked against is\n  // compatible with the version of the headers we compiled against.\n  GOOGLE_PROTOBUF_VERIFY_VERSION;\n\n  if (argc != 2) {\n    cerr << \"Usage:  \" << argv[0] << \" ADDRESS_BOOK_FILE\" << endl;\n    return -1;\n  }\n\n  tutorial::AddressBook address_book;\n\n  {\n    // Read the existing address book.\n    fstream input(argv[1], ios::in | ios::binary);\n    if (!input) {\n      cout << argv[1] << \": File not found.  Creating a new file.\" << endl;\n    } else if (!address_book.ParseFromIstream(&input)) {\n      cerr << \"Failed to parse address book.\" << endl;\n      return -1;\n    }\n  }\n\n  // Add an address.\n  PromptForAddress(address_book.add_person());\n\n  {\n    // Write the new address book back to disk.\n    fstream output(argv[1], ios::out | ios::trunc | ios::binary);\n    if (!address_book.SerializeToOstream(&output)) {\n      cerr << \"Failed to write address book.\" << endl;\n      return -1;\n    }\n  }\n\n  // Optional:  Delete all global objects allocated by libprotobuf.\n  google::protobuf::ShutdownProtobufLibrary();\n\n  return 0;\n}\n"
  },
  {
    "path": "04-static-analysis/README.adoc",
    "content": "= Static Analysis\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nStatic analysis is the analysis of code without executing it. It can be\nused to find common programming errors and enforce coding guidelines.\nExamples of errors that can be found using static analysis tools\ninclude:\n\n* Out of bounds errors\n* Memory leaks\n* Usage of uninitialized variables\n* Use of unsafe functions\n\nAnalysis tools can detect errors early and are becoming a standard tool\nin most build chains. Some build tools such as\nhttp://clang-analyzer.llvm.org/[Clang] include a build in static\nanalysis tool. However standalone tools also exist.\n\nThe examples here include using the following tools:\n\n* http://cppcheck.sourceforge.net/[CppCheck]\n* https://clang-analyzer.llvm.org/[Clang Static Analyzer]\n* https://clang.llvm.org/docs/ClangFormat.html[Clang Format]\n"
  },
  {
    "path": "04-static-analysis/clang-analyzer/CMakeLists.txt",
    "content": "cmake_minimum_required (VERSION 3.5)\n\nproject(cppcheck_analysis)\n\n# Use debug build as recommended\nset(CMAKE_BUILD_TYPE Debug)\n\n# Have cmake create a compile database\nset(CMAKE_EXPORT_COMPILE_COMMANDS ON)\n\n# Add sub directories\nadd_subdirectory(subproject1)\nadd_subdirectory(subproject2)\n"
  },
  {
    "path": "04-static-analysis/clang-analyzer/README.adoc",
    "content": "= clang-analyzer\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nThis example shows how to call the\nhttps://clang-analyzer.llvm.org/[Clang Static Analyzer] to do static analysis using the\nscan-build tool.\n\nThe files included in this example are:\n\n```\n$ tree\n.\n├── CMakeLists.txt\n├── subproject1\n│   ├── CMakeLists.txt\n│   └── main1.cpp\n└── subproject2\n    ├── CMakeLists.txt\n    └── main2.cpp\n```\n\n  * link:CMakeLists.txt[] - Top level CMakeLists.txt\n  * link:subproject1/CMakeLists.txt[] - CMake commands for subproject 1\n  * link:subproject1/main.cpp[] - source for a subproject with no errors\n  * link:subproject2/CMakeLists.txt[] - CMake commands for subproject 2\n  * link:subproject2/main2.cpp[] - source for a subproject that includes errors\n\n# Requirements\n\nTo run this example you must have clang analyzer and the scan-build tool installed. This can be installed on Ubuntu using the following command.\n\n[source,bash]\n----\n$ sudo apt-get install clang\n----\n\nIt will result in the tool being available as:\n\n[source,bash]\n----\n$ scan-build-3.6\n----\n\n# Concepts\n\n## scan-build\n\nTo run clang static analyzer you can use the tool `scan-build` to run the analyzer when you\nalso run the compiler. This overrides the CC and CXX environment variables and replaces them with it's own tools. To run it you can do\n\n[source,bash]\n----\n$ scan-build-3.6 cmake ..\n$ scan-build-3.6 make\n----\n\nBy default this will run the standard compiler for your platform, i.e. `gcc` on linux. However, if you want to override this you can change the command to:\n\n[source,bash]\n----\n$ scan-build-3.6 --use-cc=clang-3.6 --use-c++=clang++-3.6 -o ./scanbuildout/ make\n----\n\n## scan-build output\n\nscan-build will only output warnings during compile time and will also generate a list of HTML files which contain detailed analysis of the error.\n\n[source,bash]\n----\n$ cd scanbuildout/\n$ tree\n.\n└── 2017-07-03-213514-3653-1\n    ├── index.html\n    ├── report-42eba1.html\n    ├── scanview.css\n    └── sorttable.js\n\n1 directory, 4 files\n----\n\nBy default these are output to +/tmp/scanbuildout/{run folder}+. You can change this using `scan-build -o /output/folder`.\n\n# Building the example\n\n[source,bash]\n----\n$ mkdir build\n\n$ cd build/\n\n$ scan-build-3.6 -o ./scanbuildout make\nscan-build: Using '/usr/lib/llvm-3.6/bin/clang' for static analysis\nmake: *** No targets specified and no makefile found.  Stop.\nscan-build: Removing directory '/data/code/clang-analyzer/build/scanbuildout/2017-07-03-211632-937-1' because it contains no reports.\nscan-build: No bugs found.\ndevuser@91457fbfa423:/data/code/clang-analyzer/build$ scan-build-3.6 -o ./scanbuildout cmake ..\nscan-build: Using '/usr/lib/llvm-3.6/bin/clang' for static analysis\n-- The C compiler identification is GNU 5.4.0\n-- The CXX compiler identification is GNU 5.4.0\n-- Check for working C compiler: /usr/share/clang/scan-build-3.6/ccc-analyzer\n-- Check for working C compiler: /usr/share/clang/scan-build-3.6/ccc-analyzer -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Detecting C compile features\n-- Detecting C compile features - done\n-- Check for working CXX compiler: /usr/share/clang/scan-build-3.6/c++-analyzer\n-- Check for working CXX compiler: /usr/share/clang/scan-build-3.6/c++-analyzer -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Detecting CXX compile features\n-- Detecting CXX compile features - done\n-- Found CPPCHECK: /usr/local/bin/cppcheck  \ncppcheck found. Use cppccheck-analysis targets to run it\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /data/code/clang-analyzer/build\nscan-build: Removing directory '/data/code/clang-analyzer/build/scanbuildout/2017-07-03-211641-941-1' because it contains no reports.\nscan-build: No bugs found.\n\n$ $ scan-build-3.6 -o ./scanbuildout make    \nscan-build: Using '/usr/lib/llvm-3.6/bin/clang' for static analysis\nScanning dependencies of target subproject1\n[ 25%] Building CXX object subproject1/CMakeFiles/subproject1.dir/main1.cpp.o\n[ 50%] Linking CXX executable subproject1\n[ 50%] Built target subproject1\nScanning dependencies of target subproject2\n[ 75%] Building CXX object subproject2/CMakeFiles/subproject2.dir/main2.cpp.o\n/data/code/clang-analyzer/subproject2/main2.cpp:7:17: warning: Dereference of null pointer (loaded from variable 'x')\n   std::cout << *x << std::endl;\n                ^~\n1 warning generated.\n[100%] Linking CXX executable subproject2\n[100%] Built target subproject2\nscan-build: 1 bug found.\nscan-build: Run 'scan-view /data/code/clang-analyzer/build/scanbuildout/2017-07-03-211647-1172-1' to examine bug reports.\n\n$ cd scanbuildout/\n$ tree\n.\n└── 2017-07-03-213514-3653-1\n    ├── index.html\n    ├── report-42eba1.html\n    ├── scanview.css\n    └── sorttable.js\n\n1 directory, 4 files\n----\n\n"
  },
  {
    "path": "04-static-analysis/clang-analyzer/run_test.sh",
    "content": "#!/bin/bash\nmkdir -p build \\\n\t&& cd build \\\n\t&& scan-build-3.6 -o scanbuildout cmake .. \\\n\t&& scan-build-3.6 -o scanbuildout make\n"
  },
  {
    "path": "04-static-analysis/clang-analyzer/subproject1/CMakeLists.txt",
    "content": "# Set the project name\nproject (subproject1)\n\n# Add an executable with the above sources\nadd_executable(${PROJECT_NAME} main1.cpp)\n"
  },
  {
    "path": "04-static-analysis/clang-analyzer/subproject1/main1.cpp",
    "content": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n   std::cout << \"Hello Main1!\" << std::endl;\n   return 0;\n}"
  },
  {
    "path": "04-static-analysis/clang-analyzer/subproject2/CMakeLists.txt",
    "content": "# Set the project name\nproject (subproject2)\n\n# Add an executable with the above sources\nadd_executable(${PROJECT_NAME} main2.cpp)\n"
  },
  {
    "path": "04-static-analysis/clang-analyzer/subproject2/main2.cpp",
    "content": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n   std::cout << \"Hello Main2!\" << std::endl;\n   int* x = NULL;\n   std::cout << *x << std::endl;\n   return 0;\n}\n"
  },
  {
    "path": "04-static-analysis/clang-format/.clang-format",
    "content": "---\nLanguage:        Cpp\n# BasedOnStyle:  LLVM\nAccessModifierOffset: -4\nAlignEscapedNewlinesLeft: false\nAlignOperands:   true\nAlignTrailingComments: true\nAllowAllParametersOfDeclarationOnNextLine: true\nAllowShortBlocksOnASingleLine: false\nAllowShortCaseLabelsOnASingleLine: false\nAllowShortFunctionsOnASingleLine: All\nAllowShortIfStatementsOnASingleLine: false\nAllowShortLoopsOnASingleLine: false\nAlwaysBreakBeforeMultilineStrings: false\nAlwaysBreakTemplateDeclarations: false\nBinPackArguments: true\nBinPackParameters: true\nBreakBeforeBinaryOperators: None\nBreakBeforeBraces: Allman\nBreakBeforeTernaryOperators: true\nBreakConstructorInitializersBeforeComma: false\nColumnLimit:     120\nCommentPragmas:  ''\nConstructorInitializerAllOnOneLineOrOnePerLine: false\nConstructorInitializerIndentWidth: 8\nContinuationIndentWidth: 4\nCpp11BracedListStyle: true\nDerivePointerAlignment: false\nDisableFormat:   false\nExperimentalAutoDetectBinPacking: false\nForEachMacros:   [ foreach, Q_FOREACH, BOOST_FOREACH ]\nIndentCaseLabels: false\nIndentWidth:     4\nIndentWrappedFunctionNames: false\nKeepEmptyLinesAtTheStartOfBlocks: true\nMaxEmptyLinesToKeep: 3\nNamespaceIndentation: All\nObjCBlockIndentWidth: 2\nObjCSpaceAfterProperty: false\nObjCSpaceBeforeProtocolList: true\nPenaltyBreakBeforeFirstCallParameter: 19\nPenaltyBreakComment: 300\nPenaltyBreakFirstLessLess: 120\nPenaltyBreakString: 1000\nPenaltyExcessCharacter: 1000000\nPenaltyReturnTypeOnItsOwnLine: 60\nPointerAlignment: Left\nSpaceAfterCStyleCast: false\nSpaceBeforeAssignmentOperators: true\nSpaceBeforeParens: ControlStatements\nSpaceInEmptyParentheses: false\nSpacesBeforeTrailingComments: 1\nSpacesInAngles:  false\nSpacesInContainerLiterals: true\nSpacesInCStyleCastParentheses: false\nSpacesInParentheses: false\nSpacesInSquareBrackets: false\nStandard:        Cpp11\nTabWidth:        4\nUseTab:          Never\n...\n"
  },
  {
    "path": "04-static-analysis/clang-format/CMakeLists.txt",
    "content": "cmake_minimum_required (VERSION 3.5)\n\nproject(cppcheck_analysis)\n\n# Add a custom CMake Modules directory\nset(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules\n                      ${CMAKE_MODULE_PATH})\n\n# Add sub directories\nadd_subdirectory(subproject1)\nadd_subdirectory(subproject2)\n\nset(CLANG_FORMAT_BIN_NAME clang-format-3.6)\nset(CLANG_FORMAT_EXCLUDE_PATTERNS  \"build/\" ${CMAKE_BINARY_DIR})\nfind_package(ClangFormat)\n"
  },
  {
    "path": "04-static-analysis/clang-format/README.adoc",
    "content": "= clang-format\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nThis example shows how to call the\nhttps://clang.llvm.org/docs/ClangFormat.html[Clang Format] to check if your source code\nmatches against your code style guidelines.\n\nThe files included in this example are:\n\n```\n$ tree\n.\n├── .clang-format\n├── CMakeLists.txt\n├── cmake\n│   ├── modules\n│   │   ├── clang-format.cmake\n│   │   └── FindClangFormat.cmake\n│   └── scripts\n│       └── clang-format-check-changed\n├── subproject1\n│   ├── CMakeLists.txt\n│   └── main1.cpp\n└── subproject2\n    ├── CMakeLists.txt\n    └── main2.cpp\n```\n\n  * link:CMakeLists.txt[] - Top level CMakeLists.txt\n  * link:.clang-format[] - The file describing the style guide\n  * link:cmake/modules/FindClangFormat.cmake[] - Script to find the clang-format binary\n  * link:cmake/modules/clang-format.cmake[] - Script to setup the format targets\n  * link:cmake/scripts/clang-format-check-changed.py[] - A helper script to check against changed files in git\n  * link:cmake/scripts/clang-format-check-changed.py[] - An old simplified version of the above helper script\n  * link:subproject1/CMakeLists.txt[] - CMake commands for subproject 1\n  * link:subproject1/main1.cpp[] - source for a subproject with no style errors\n  * link:subproject2/CMakeLists.txt[] - CMake commands for subproject 2\n  * link:subproject2/main2.cpp[] - source for a subproject that includes style errors\n\n# Requirements\n\nTo run this example you must have clang format tool installed. This can be installed on Ubuntu using the following command.\n\n[source,bash]\n----\n$ sudo apt-get install clang-format-3.6\n----\n\nIt will result in the tool being available as:\n\n[source,bash]\n----\n$ clang-format-3.6\n----\n\nIf you install a different version, you can edit the `CLANG_FORMAT_BIN_NAME` variable in the root CMakeLists.txt\n\n# Concepts\n\n## clang-format\n\n+clang-format+ can scan a source file then find and optionally format it to match your \ncompanys style guidelines. There are default styles build in but you can also setup a style guide using a custom file called +.clang-format+, for example a snipped from this\nrepositories +.clang-format+ is below:\n\n[source]\n----\nLanguage:        Cpp\n# BasedOnStyle:  LLVM\nAccessModifierOffset: -4\nAlignAfterOpenBracket: Align\nAlignConsecutiveAssignments: false\nAlignConsecutiveDeclarations: false\n----\n\n## format style\n\nAs mentioned, the style in this example is based on the +.clang-format+ file. This can be changed by editing link:cmake/modules/clang-format.cmake[clang-format.cmake] and changing\nthe `-style=file` to the required style; \n\n# Targets\n\nThis example will setup 3 targets:\n\n * format\n * format-check\n * format-check-changed\n\n## format\n\nThe format target will find any C++ source files and in place modify them to match the \n+.clang-format+ style. The source files are found using the following cmake code\n\n[source,cmake]\n----\nfile(GLOB_RECURSE ALL_SOURCE_FILES *.cpp *.h *.cxx *.hxx *.hpp *.cc *.ipp)\n\n# Don't include some common build folders\nset(CLANG_FORMAT_EXCLUDE_PATTERNS ${CLANG_FORMAT_EXCLUDE_PATTERNS} \"/CMakeFiles/\" \"cmake\")\n\n# get all project files file\nforeach (SOURCE_FILE ${ALL_SOURCE_FILES}) \n    foreach (EXCLUDE_PATTERN ${CLANG_FORMAT_EXCLUDE_PATTERNS})\n        string(FIND ${SOURCE_FILE} ${EXCLUDE_PATTERN} EXCLUDE_FOUND) \n        if (NOT ${EXCLUDE_FOUND} EQUAL -1) \n            list(REMOVE_ITEM ALL_SOURCE_FILES ${SOURCE_FILE})\n        endif () \n    endforeach ()\nendforeach ()\n----\n\nThis will find files matching the common C++ suffixes and then remove any that match some\ncommon CMake directories.\n\nIn the root `CMakeList.txt` we also exclude the build directory by adding the line \n\n[source,cmake]\n----\nset(CLANG_FORMAT_EXCLUDE_PATTERNS  \"build/\")\n----\n\n## format-check \n\nThis target will work as above but instead of formatting the files it will cause a failure\nif any files don't match the clang-format style\n\n## format-check-changed\n\nThis target will check the output of `git status` and scan the files to check if they match the style. This can be used by developers to make sure their changed files match the correct style.\n\nIn this example the actual check is done with a helper script +clang-format-check-changed.py+. This script will run `git status --porcelain --ignore-submodules`\nto get a list of changed files, match them against the allowed extensions from the above list, and finally remove any\nthat match the exclude pattern from +CLANG_FORMAT_EXCLUDE_PATTERNS+. It will then run these files through clang-format and \nexit with an error if the files do not match the style.\n\nAn example call to the +clang-format-check-changed.py+ script is:\n\n[source,bash]\n----\ncmake/scripts/clang-format-check-changed.py --file-extensions \".cpp,*.cpp,*.h,*.cxx,*.hxx,*.hpp,*.cc,*.ipp\" --exclude=build/ --exclude=/CMakeFiles/ --exclude=cmake --clang-format-bin /usr/bin/clang-format-3.6\n----\n\n[NOTE]\n====\nThis will include all changed files in your git repository that match the patterns. In this example repository this can include files that \nare part of different examples.\n====\n"
  },
  {
    "path": "04-static-analysis/clang-format/cmake/modules/FindClangFormat.cmake",
    "content": "# Find Clang format\n# \n# \nif(NOT CLANG_FORMAT_BIN_NAME)\n\tset(CLANG_FORMAT_BIN_NAME clang-format)\nendif()\n\n# if custom path check there first\nif(CLANG_FORMAT_ROOT_DIR)\n    find_program(CLANG_FORMAT_BIN \n        NAMES\n        ${CLANG_FORMAT_BIN_NAME}\n        PATHS\n        \"${CLANG_FORMAT_ROOT_DIR}\"\n        NO_DEFAULT_PATH)\nendif()\n\nfind_program(CLANG_FORMAT_BIN NAMES ${CLANG_FORMAT_BIN_NAME})\n\ninclude(FindPackageHandleStandardArgs)\nFIND_PACKAGE_HANDLE_STANDARD_ARGS(\n    CLANG_FORMAT\n    DEFAULT_MSG \n    CLANG_FORMAT_BIN)\n\nmark_as_advanced(\n    CLANG_FORMAT_BIN)\n\nif(CLANG_FORMAT_FOUND)\n\t# A CMake script to find all source files and setup clang-format targets for them\n\tinclude(clang-format)\nelse()\n    message(\"clang-format not found. Not setting up format targets\")\nendif()\n"
  },
  {
    "path": "04-static-analysis/clang-format/cmake/modules/clang-format.cmake",
    "content": "# A CMake script to find all source files and setup clang-format targets for them\n\n# Find all source files\nset(CLANG_FORMAT_CXX_FILE_EXTENSIONS ${CLANG_FORMAT_CXX_FILE_EXTENSIONS} *.cpp *.h *.cxx *.hxx *.hpp *.cc *.ipp)\nfile(GLOB_RECURSE ALL_SOURCE_FILES ${CLANG_FORMAT_CXX_FILE_EXTENSIONS})\n\n# Don't include some common build folders\nset(CLANG_FORMAT_EXCLUDE_PATTERNS ${CLANG_FORMAT_EXCLUDE_PATTERNS} \"/CMakeFiles/\" \"cmake\")\n\n# get all project files file\nforeach (SOURCE_FILE ${ALL_SOURCE_FILES}) \n    foreach (EXCLUDE_PATTERN ${CLANG_FORMAT_EXCLUDE_PATTERNS})\n        string(FIND ${SOURCE_FILE} ${EXCLUDE_PATTERN} EXCLUDE_FOUND) \n        if (NOT ${EXCLUDE_FOUND} EQUAL -1) \n            list(REMOVE_ITEM ALL_SOURCE_FILES ${SOURCE_FILE})\n        endif () \n    endforeach ()\nendforeach ()\n\nadd_custom_target(format\n    COMMENT \"Running clang-format to change files\"\n    COMMAND ${CLANG_FORMAT_BIN}\n    -style=file\n    -i\n    ${ALL_SOURCE_FILES}\n)\n\n\nadd_custom_target(format-check\n    COMMENT \"Checking clang-format changes\"\n    # Use ! to negate the result for correct output\n    COMMAND !\n    ${CLANG_FORMAT_BIN}\n    -style=file\n    -output-replacements-xml\n    ${ALL_SOURCE_FILES}\n    | grep -q \"replacement offset\" \n)\n\n# Get the path to this file\nget_filename_component(_clangcheckpath ${CMAKE_CURRENT_LIST_FILE} PATH)\n# have at least one here by default\nset(CHANGED_FILE_EXTENSIONS \".cpp\")\nforeach(EXTENSION ${CLANG_FORMAT_CXX_FILE_EXTENSIONS})\n    set(CHANGED_FILE_EXTENSIONS \"${CHANGED_FILE_EXTENSIONS},${EXTENSION}\" )\nendforeach()\n\nset(EXCLUDE_PATTERN_ARGS)\nforeach(EXCLUDE_PATTERN ${CLANG_FORMAT_EXCLUDE_PATTERNS})\n    list(APPEND EXCLUDE_PATTERN_ARGS \"--exclude=${EXCLUDE_PATTERN}\")\nendforeach()\n\n# call the script to check changed files in git\nadd_custom_target(format-check-changed\n    COMMENT \"Checking changed files in git\"\n    WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}\n    COMMAND ${_clangcheckpath}/../scripts/clang-format-check-changed.py \n    --file-extensions \\\"${CHANGED_FILE_EXTENSIONS}\\\"\n    ${EXCLUDE_PATTERN_ARGS}\n    --clang-format-bin ${CLANG_FORMAT_BIN}\n)\n\n"
  },
  {
    "path": "04-static-analysis/clang-format/cmake/scripts/clang-format-check-changed",
    "content": "#!/bin/bash\n\n# Required because cmake root isn't git root in this example\nCLANG_FORMAT_BIN=$1\nGIT_ROOT=`git rev-parse --show-toplevel`\n\npushd ${GIT_ROOT} > /dev/null\n\ngit status --porcelain \\\n\t| egrep '*\\.cpp|*\\.h|*\\.cxx|*\\.hxx|*\\.hpp|*\\.cc' \\\n\t| awk -F \" \" '{print $NF}' \\\n\t| xargs -r ${CLANG_FORMAT_BIN} -style=file -output-replacements-xml \\\n\t| grep \"replacement offset\" 2>&1 > /dev/null\n\nRET=$?\npopd > /dev/null\n\nexit ${RET}\n"
  },
  {
    "path": "04-static-analysis/clang-format/cmake/scripts/clang-format-check-changed.py",
    "content": "#!/usr/bin/env python\n\nimport argparse\nimport os\nimport sys\nimport subprocess\n\n\ndef check_file(filename, excludes, extensions):\n    \"\"\"\n    Check if a file should be included in our check\n    \"\"\"\n    name, ext = os.path.splitext(filename)\n\n    if len(ext) > 0 and ext in extensions:\n        if len(excludes) == 0:\n            return True\n\n        for exclude in excludes:\n            if exclude in filename:\n                return False\n\n        return True\n\n    return False\n\n\ndef check_directory(directory, excludes, extensions):\n    output = []\n\n    if len(excludes) > 0:\n        for exclude in excludes:\n            if exclude in directory:\n                directory_excluded = False\n                return output\n\n    for root, _, files in os.walk(directory):\n        for file in files:\n            filename = os.path.join(root, file)\n            if check_file(filename, excludes, extensions):\n                print(\"Will check file [{}]\".format(filename))\n                output.append(filename)\n    return output\n\ndef get_git_root(git_bin):\n    cmd = [git_bin, \"rev-parse\", \"--show-toplevel\"]\n    try:\n        return subprocess.check_output(cmd).strip()\n    except subprocess.CalledProcessError, e:\n        print(\"Error calling git [{}]\".format(e))\n        raise\n\ndef clean_git_filename(line):\n    \"\"\"\n    Takes a line from git status --porcelain and returns the filename\n    \"\"\"\n    file = None\n    git_status = line[:2]\n    # Not an exhaustive list of git status output but should\n    # be enough for this case\n    # check if this is a delete\n    if 'D' in git_status:\n        return None\n    # ignored file\n    if '!' in git_status:\n        return None\n    # Covers renamed files\n    if '->' in line:\n        file = line[3:].split('->')[-1].strip()\n    else:\n        file = line[3:].strip()\n\n    return file\n\n\ndef get_changed_files(git_bin, excludes, file_extensions):\n    \"\"\"\n    Run git status and return the list of changed files\n    \"\"\"\n    extensions = file_extensions.split(\",\")\n    # arguments coming from cmake will be *.xx. We want to remove the *\n    for i, extension in enumerate(extensions):\n        if extension[0] == '*':\n            extensions[i] = extension[1:]\n\n    git_root = get_git_root(git_bin)\n\n    cmd = [git_bin, \"status\", \"--porcelain\", \"--ignore-submodules\"]\n    print(\"git cmd = {}\".format(cmd))\n    output = []\n    returncode = 0\n    try:\n        cmd_output = subprocess.check_output(cmd)\n        for line in cmd_output.split('\\n'):\n            if len(line) > 0:\n                file = clean_git_filename(line)\n                if not file:\n                    continue\n                file = os.path.join(git_root, file)\n\n                if file[-1] == \"/\":\n                    directory_files = check_directory(\n                        file, excludes, file_extensions)\n                    output = output + directory_files\n                else:\n                    if check_file(file, excludes, file_extensions):\n                        print(\"Will check file [{}]\".format(file))\n                        output.append(file)\n\n    except subprocess.CalledProcessError, e:\n        print(\"Error calling git [{}]\".format(e))\n        returncode = e.returncode\n\n    return output, returncode\n\n\ndef run_clang_format(clang_format_bin, changed_files):\n    \"\"\"\n    Run clang format on a list of files \n    @return 0 if formatted correctly.\n    \"\"\"\n    if len(changed_files) == 0:\n        return 0\n    cmd = [clang_format_bin, \"-style=file\",\n           \"-output-replacements-xml\"] + changed_files\n    print(\"clang-format cmd = {}\".format(cmd))\n    try:\n        cmd_output = subprocess.check_output(cmd)\n        if \"replacement offset\" in cmd_output:\n            print(\"ERROR: Changed files don't match format\")\n            return 1\n    except subprocess.CalledProcessError, e:\n        print(\"Error calling clang-format [{}]\".format(e))\n        return e.returncode\n\n    return 0\n\n\ndef cli():\n    # global params\n    parser = argparse.ArgumentParser(prog='clang-format-check-changed',\n                                     description='Checks if files chagned in git match the .clang-format specification')\n    parser.add_argument(\"--file-extensions\", type=str,\n                        default=\".cpp,.h,.cxx,.hxx,.hpp,.cc,.ipp\",\n                        help=\"Comma separated list of file extensions to check\")\n    parser.add_argument('--exclude', action='append', default=[],\n                        help='Will not match the files / directories with these in the name')\n    parser.add_argument('--clang-format-bin', type=str, default=\"clang-format\",\n                        help=\"The clang format binary\")\n    parser.add_argument('--git-bin', type=str, default=\"git\",\n                        help=\"The git binary\")\n    args = parser.parse_args()\n\n    # Run gcovr to get the .gcda files form .gcno\n    changed_files, returncode = get_changed_files(\n        args.git_bin, args.exclude, args.file_extensions)\n    if returncode != 0:\n        return returncode\n\n    return run_clang_format(args.clang_format_bin, changed_files)\n\nif __name__ == '__main__':\n    sys.exit(cli())\n"
  },
  {
    "path": "04-static-analysis/clang-format/run_test.sh",
    "content": "#!/bin/bash\nmkdir -p build && cd build && cmake .. && make format-check\nRET=$?\necho \"return code was ${RET}\"\nif [ ${RET} == \"0\" ]; then\n\techo \"test failed. Expected format-check to fail\"\n\texit 1\nelse\n\techo \"test success\"\n\texit 0\nfi\n"
  },
  {
    "path": "04-static-analysis/clang-format/subproject1/CMakeLists.txt",
    "content": "# Set the project name\nproject (subproject1)\n\n# Add an executable with the above sources\nadd_executable(${PROJECT_NAME} main1.cpp)\n"
  },
  {
    "path": "04-static-analysis/clang-format/subproject1/main1.cpp",
    "content": "#include <iostream>\n\nint main(int argc, char* argv[])\n{\n    std::cout << \"Hello Main1!\" << std::endl;\n    return 0;\n}"
  },
  {
    "path": "04-static-analysis/clang-format/subproject2/CMakeLists.txt",
    "content": "# Set the project name\nproject (subproject2)\n\n# Add an executable with the above sources\nadd_executable(${PROJECT_NAME} main2.cpp)\n"
  },
  {
    "path": "04-static-analysis/clang-format/subproject2/main2.cpp",
    "content": "#include <iostream>\n\nclass TestClass {\npublic:\n    TestClass();\n};\n\nTestClass::TestClass() {\n\n}\n\nint main(int argc, char* argv[])\n{\n    std::cout << \"Hello Main2!\" << std::endl;\n    int* x = NULL;\n    std::cout << *x << std::endl;\n    return 0;\n}\n"
  },
  {
    "path": "04-static-analysis/cppcheck/CMakeLists.txt",
    "content": "cmake_minimum_required (VERSION 3.5)\n\nproject(cppcheck_analysis)\n\n# Add a custom CMake Modules directory\nset(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules\n                      ${CMAKE_MODULE_PATH})\n\n# find the cppcheck binary\nfind_package(CppCheck)\n\n# static analysis. Should be before adding subprojects\nset (ALL_ANALYSIS_TARGETS)\n\n# Add sub directories\nadd_subdirectory(subproject1)\nadd_subdirectory(subproject2)\n\n\n# Add the \"make analysis\" target\nif( CPPCHECK_FOUND )\n    add_custom_target(analysis)\n    ADD_DEPENDENCIES(analysis ${ALL_ANALYSIS_TARGETS})\n    set_target_properties(analysis PROPERTIES EXCLUDE_FROM_ALL TRUE)\n    message(\"analysis analysis targets are ${ALL_ANALYSIS_TARGETS}\")\nendif()\n"
  },
  {
    "path": "04-static-analysis/cppcheck/README.adoc",
    "content": "= CppCheck Static Analysis\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nThis example shows how to call the\nhttp://cppcheck.sourceforge.net/[CppCheck] tool to do static analysis.\nThis shows how to make an analysis target for each project in your repository.\n\nIt includes code to\n\n  * Find the cppcheck binary\n  * Add cppcheck with a target for each sub-projects\n  * Generate an overall `make analysis` target to do static\nanalysis on all sub-projects.\n\nThe files included in this example are:\n\n```\n$ tree\n.\n├── cmake\n│   ├── analysis.cmake\n│   └── modules\n│       └── FindCppCheck.cmake\n├── CMakeLists.txt\n├── subproject1\n│   ├── CMakeLists.txt\n│   └── main1.cpp\n└── subproject2\n    ├── CMakeLists.txt\n    └── main2.cpp\n```\n\n  * link:CMakeLists.txt[] - Top level CMakeLists.txt\n  * link:cmake/analysis.cmake[] - Includes functions to add analysis targets\n  * link:cmake/modules/FindCppCheck.cmake[] - A custom package module to find CppCheck\n  * link:subproject1/CMakeLists.txt[] - CMake commands for subproject 1\n  * link:subproject1/main.cpp[] - source for a subproject with no errors\n  * link:subproject2/CMakeLists.txt[] - CMake commands for subproject 2\n  * link:subproject2/main2.cpp[] - source for a subproject that includes errors\n\n# Requirements\n\nTo run this example you must have the CppCheck utility installed. On\nUbuntu you can install it as\n\n[source,bash]\n----\n$ sudo apt-get install cppcheck\n----\n\n# Concepts\n\n## Adding Custom Package Modules\n\nCustom modules can be used to find programs, libraries and header files\nto include in your program.\n\n### Adding a custom module\n\nThe `cmake/modules/FindCppCheck.cmake` file contains the code to initialise a\ncustom package module.\n\nThe following is a breakdown of the file:\n\n[source,cmake,numbered]\n----\nfind_program(CPPCHECK_BIN NAMES cppcheck)\n----\n\nSearch the path for the cppcheck binary. Once found store the result in the\n+CPPCHECK_BIN+ variable\n\n[source,cmake,numbered]\n----\nset (CPPCHECK_THREADS \"-j 4\" CACHE STRING \"The -j argument to have cppcheck use multiple threads / cores\")\n\nset (CPPCHECK_ARG \"${CPPCHECK_THREADS}\" CACHE STRING \"The arguments to pass to cppcheck. If set will overwrite CPPCHECK_THREADS\")\n----\n\nSet some custom arguments that can be later passed to cppcheck.\n\n[source,cmake]\n----\ninclude(FindPackageHandleStandardArgs)\nFIND_PACKAGE_HANDLE_STANDARD_ARGS(\n    CPPCHECK\n    DEFAULT_MSG\n    CPPCHECK_BIN\n    CPPCHECK_THREADS\n    CPPCHECK_ARG)\n\nmark_as_advanced(\n    CPPCHECK_BIN\n    CPPCHECK_THREADS\n    CPPCHECK_ARG)\n----\n\nExport the variables so that they can be seen from ccmake / cmake-gui\nand set in the cache. By default these will not be visible unless the\nview advanced flag is set.\n\n### Setting path to custom modules\n\nThe default path that CMake will search for modules is `/usr/share/cmake/Modules`.\nTo include custom modules you must tell CMake where to search for them.\nThis can be done using the variable +${CMAKE_MODULE_PATH}+ which\ncontains the paths that CMake will search for modules.\n\n[source,cmake]\n----\nset(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules\n                      ${CMAKE_MODULE_PATH})\n----\n\n\nTo then add the package module to your CMakeLists.txt you can call\n\n[source,cmake]\n----\nfind_package(CppCheck)\n----\n\n## Parent Scope Variables\n\nThe scope of variables when they are declared / changed is typically in\nthe function of file the are called. To make a change to a variable\nwhich is the caller of your scope, you should call it as follows:\n\n[source,cmake]\n----\nset(ALL_ANALYSIS_TARGETS \"${ALL_ANALYSIS_TARGETS}\" PARENT_SCOPE)\n----\n\n## add_analysis macro\n\nThe +add_analysis()+ macro in `cmake/analysis.cmake` is the core idea for this\nexample. If cppcheck is available then a list of arguments are compiled\nand added to a custom command that calls cppcheck on the sources. These\nare then added to a custom target.\n\nA breakdown of this macro is below:\n\n[source,cmake]\n----\nget_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)\nforeach(dir ${dirs})\n    LIST(APPEND cppcheck_includes \"-I${dir}\")\nendforeach()\n----\n\nFind the include files from and calls to +include_directories()+ in the\nsame project.\n\n[source,cmake]\n----\nLIST(APPEND ALL_ANALYSIS_TARGETS \"${_target}_analysis\")\nset(ALL_ANALYSIS_TARGETS \"${ALL_ANALYSIS_TARGETS}\" PARENT_SCOPE)\n----\n\nExport the target name into a variable that can later be used to add a\nglobal `make analysis` target.\n\n[source,cmake]\n----\nif (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VESION} GREATER 2.7)\n    separate_arguments(tmp_args UNIX_COMMAND ${CPPCHECK_ARG})\nelse ()\n    # cmake 2.6 has different arguments\n    string(REPLACE \" \" \";\" tmp_args ${CPPCHECK_ARG})\nendif ()\n----\n\nChange the +CPPCHECK_ARG+ so that the can be added to command correctly in\nthe custom command.\n\n[source,cmake]\n----\nadd_custom_target(${_target}_analysis)\nset_target_properties(${_target}_analysis PROPERTIES EXCLUDE_FROM_ALL TRUE)\n----\n\nAdd a custom target with a name you have passed in followed by\n_analysis. Do not include this in the all target.\n\n[source,cmake]\n----\nadd_custom_command(TARGET ${_target}_analysis PRE_BUILD\n            WORKING_DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}\"\n            COMMAND ${CPPCHECK_BIN} ${tmp_args} ${cppcheck_includes} ${${_sources}}\n            DEPENDS ${${_sources}}\n            COMMENT \"Running cppcheck: ${_target}\"\n            VERBATIM)\n----\n\nAdd a custom command which is called from the custom target added above.\nThis will call cppcheck with any includes, arguments and sources that\nyou have provided. The sources that are analysed come from a _sources\nvariable. This should be the name of the variable which holds your list\nof source files.\n\nTo call the +add_analysis()+ marco add the following to your projects\nCMakeLists.txt file:\n\n[source,cmake]\n----\ninclude(${CMAKE_SOURCE_DIR}/cmake/analysis.cmake)\nadd_analysis(${PROJECT_NAME} SOURCES)\n----\n\n## Creating a target to call other targets\n\nIn the top level CMakeLists.txt a custom target is created, which will call\nall other analysis targets. This allows you to call `make analysis` and\nscan all sub projects.\n\nTo achieve this 2 things should be added to the top level CMakeLists.txt\n\nFirst add an empty variable +ALL_ANALYSIS_TARGETS+ before calling your\n+add_subdirectories()+ function.\n\n[source,cmake]\n----\nset (ALL_ANALYSIS_TARGETS)\n----\n\nSecond add the following after your +add_subdirectories()+ call.\n\n[source,cmake]\n----\nif( CPPCHECK_FOUND )\n    add_custom_target(analysis)\n    ADD_DEPENDENCIES(analysis ${ALL_ANALYSIS_TARGETS})\n    set_target_properties(analysis PROPERTIES EXCLUDE_FROM_ALL TRUE)\n    message(\"analysis analysis targets are ${ALL_ANALYSIS_TARGETS}\")\nendif()\n----\n\nThis adds the \"make analysis\" target which calls all the sub-targets.\n\n# Building the example\n\n[source,bash]\n----\n$ mkdir build\n\n$ cd build/\n\n$ cmake ..\n-- The C compiler identification is GNU 4.8.4\n-- The CXX compiler identification is GNU 4.8.4\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Found CPPCHECK: /usr/bin/cppcheck\nadding cppcheck analysys target for subproject1\nadding cppcheck analysys target for subproject2\nanalysis analysis targets are subproject1_analysis;subproject2_analysis\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /home/matrim/workspace/cmake-examples/04-static-analysis/cppcheck/build\n\n$ make analysis\nScanning dependencies of target subproject1_analysis\nRunning cppcheck: subproject1\nChecking main1.cpp...\nBuilt target subproject1_analysis\nScanning dependencies of target subproject2_analysis\nRunning cppcheck: subproject2\nChecking main2.cpp...\n[main2.cpp:7]: (error) Array 'tmp[10]' accessed at index 11, which is out of bounds.\nBuilt target subproject2_analysis\nScanning dependencies of target analysis\nBuilt target analysis\n----\n\nThe above calls cppcheck in both subproject folders as\n\n[source,bash]\n----\n...\ncd /path/to/subproject1 && /usr/bin/cppcheck -j 4 main1.cpp\n...\ncd /path/to/subproject2 && /usr/bin/cppcheck -j 4 main2.cpp\n...\n----\n\nThe main1.cpp has no errors so will complete correctly, however the\nmain2.cpp includes an out-of-bounds error. This is show with a warning as\n\n------------------------------------------------------------------------------------\n[main2.cpp:7]: (error) Array 'tmp[10]' accessed at index 11, which is out of bounds.\n------------------------------------------------------------------------------------\n\nBy default cppcheck only prints warnings and exits with a successful\nexit code. If the +${CPPCHECK_ARG}+ variable is set with\n`--error-exitcode=1`, the make analysis will finish early as follows.\n\n[source,bash]\n----\n$ make analysis\nRunning cppcheck: subproject2\nChecking main2.cpp...\n[main2.cpp:7]: (error) Array 'tmp[10]' accessed at index 11, which is out of bounds.\nmake[3]: *** [subproject2_analysis] Error 1\nmake[2]: *** [subproject2/CMakeFiles/subproject2_analysis.dir/all] Error 2\nmake[1]: *** [CMakeFiles/analysis.dir/rule] Error 2\nmake: *** [analysis] Error 2\n----\n\n# Extra Notes\n\n## Multiple Folders\n\nIf you have a multiple folders levels, where one folder just points to\nsub folders, such as below:\n\n------------------------------\n├── root\n│   ├── CMakeLists.txt\n│   ├── src\n│   │   ├── CMakeLists.txt\n│   │   ├── project1\n│   │   │   ├── CMakeLists.txt\n│   │   │   ├── main.cpp\n│   │   ├── project2\n│   │   │   ├── CMakeLists.txt\n│   │   │   ├── main.cpp\n------------------------------\n\nTo correctly generate the root `make analysis` target you must export the +ALL_ANALYSIS_TARGET+\nvariable to the parent scope in `src/CMakeLists.txt`.\n\n[source,cmake]\n----\nadd_subdirectory(project1)\nadd_subdirectory(project2)\nset(ALL_ANALYSIS_TARGETS \"${ALL_ANALYSIS_TARGETS}\" PARENT_SCOPE)\n----\n\n## Include Directories\n\nIn the +add_analysis+ macro in `analysis.cmake` we extract the +INCLUDE_DIRECTORIES+ from the \ntarget and add them to the call to cppcheck.\n\n[source,cmake]\n----\n    get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)\n        foreach(dir ${dirs})\n            LIST(APPEND cppcheck_includes \"-I${dir}\")\n        endforeach()\n----\n\nThis works for basic examples but if you use some CMake features such as \ngenerator expressions this will not add the include directory.\n\n"
  },
  {
    "path": "04-static-analysis/cppcheck/cmake/analysis.cmake",
    "content": "# Make sure cppcheck binary is available\nif( NOT CPPCHECK_FOUND )\n    find_package(CppCheck)\nendif()\n\n# add a target for CppCheck\n# _target - The name of the project that this is for. Will generate ${_target}_analysis \n# _sources - The name of the variable holding the sources list. \n#            This is the name of the variable not the actual list\n#\n# Macro instead of function to make the PARENT_SCOPE stuff easier\nmacro(add_analysis _target _sources)\n    if( CPPCHECK_FOUND )\n\n        # Get the include files to also feed to cppcheck\n        get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)\n        foreach(dir ${dirs})\n            LIST(APPEND cppcheck_includes \"-I${dir}\")\n        endforeach()\n\n        # Add to the all target to have a high level \"make analysis\"\n        LIST(APPEND ALL_ANALYSIS_TARGETS \"${_target}_analysis\")\n        set(ALL_ANALYSIS_TARGETS \"${ALL_ANALYSIS_TARGETS}\" PARENT_SCOPE)\n\n        # This is used to make the command run correctly on the command line.\n        # The COMMAND argument expects a list and this does the change\n        # I need to check which version works with 2.7\n        if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VESION} GREATER 2.7)\n            separate_arguments(tmp_args UNIX_COMMAND ${CPPCHECK_ARG})\n        else ()\n            # cmake 2.6 has different arguments \n            string(REPLACE \" \" \";\" tmp_args ${CPPCHECK_ARG})         \n        endif ()\n\n        # add a custom _target_analysis target\n        add_custom_target(${_target}_analysis)\n        set_target_properties(${_target}_analysis PROPERTIES EXCLUDE_FROM_ALL TRUE)\n        \n        # add the cppcheck command to the target\n        add_custom_command(TARGET ${_target}_analysis PRE_BUILD\n            WORKING_DIRECTORY \"${CMAKE_CURRENT_SOURCE_DIR}\"\n            COMMAND ${CPPCHECK_BIN} ${tmp_args} ${cppcheck_includes} ${${_sources}}\n            DEPENDS ${${_sources}}\n            COMMENT \"Running cppcheck: ${_target}\"\n            VERBATIM)\n        message(\"adding cppcheck analysys target for ${_target}\")\n    endif()\n\nendmacro()\n\n"
  },
  {
    "path": "04-static-analysis/cppcheck/cmake/modules/FindCppCheck.cmake",
    "content": "# Locate cppcheck\n#\n# This module defines\n#  CPPCHECK_FOUND, if false, do not try to link to cppcheck --- if (CPPCHECK_FOUND)\n#  CPPCHECK_BIN, where to find cppcheck\n#\n# Exported argumets include\n#   CPPCHECK_THREADS\n#   CPPCHECK_ARG\n#\n# find the cppcheck binary\nfind_program(CPPCHECK_BIN NAMES cppcheck)\n\n#\n# Arguments are \n# -j use multiple threads (and thread count)\n# --quite only show errors / warnings etc\n# --error-exitcode The code to exit with if an error shows up\n# --enabled  Comma separated list of the check types. Can include warning,performance,style\n# Note nightly build on earth changes error-exitcode to 0\nset (CPPCHECK_THREADS \"-j 4\" CACHE STRING \"The -j argument to have cppcheck use multiple threads / cores\")\n\nset (CPPCHECK_ARG \"${CPPCHECK_THREADS}\" CACHE STRING \"The arguments to pass to cppcheck. If set will overwrite CPPCHECK_THREADS\")\n\n# handle the QUIETLY and REQUIRED arguments and set YAMLCPP_FOUND to TRUE if all listed variables are TRUE\ninclude(FindPackageHandleStandardArgs)\nFIND_PACKAGE_HANDLE_STANDARD_ARGS(\n    CPPCHECK \n    DEFAULT_MSG \n    CPPCHECK_BIN\n    CPPCHECK_THREADS\n    CPPCHECK_ARG)\n\nmark_as_advanced(\n    CPPCHECK_BIN  \n    CPPCHECK_THREADS\n    CPPCHECK_ARG)\n"
  },
  {
    "path": "04-static-analysis/cppcheck/run_test.sh",
    "content": "#!/bin/bash\nmkdir -p build && cd build && cmake .. && make analysis\n"
  },
  {
    "path": "04-static-analysis/cppcheck/subproject1/CMakeLists.txt",
    "content": "# Set the project name\nproject (subproject1)\n\n# Create a sources variable with a link to all cpp files to compile\nset(SOURCES\n    main1.cpp\n)\n\n# include the file with the function then call the macro\ninclude(${CMAKE_SOURCE_DIR}/cmake/analysis.cmake)\nadd_analysis(${PROJECT_NAME} SOURCES)\n\n# Add an executable with the above sources\nadd_executable(${PROJECT_NAME} ${SOURCES})"
  },
  {
    "path": "04-static-analysis/cppcheck/subproject1/main1.cpp",
    "content": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n   std::cout << \"Hello Main1!\" << std::endl;\n   return 0;\n}"
  },
  {
    "path": "04-static-analysis/cppcheck/subproject2/CMakeLists.txt",
    "content": "# Set the project name\nproject (subproject2)\n\n# Create a sources variable with a link to all cpp files to compile\nset(SOURCES\n    main2.cpp\n)\n\n# include the file with the function then call the macro\ninclude(${CMAKE_SOURCE_DIR}/cmake/analysis.cmake)\nadd_analysis(${PROJECT_NAME} SOURCES)\n\n# Add an executable with the above sources\nadd_executable(${PROJECT_NAME} ${SOURCES})"
  },
  {
    "path": "04-static-analysis/cppcheck/subproject2/main2.cpp",
    "content": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n   std::cout << \"Hello Main2!\" << std::endl;\n   char tmp[10];\n   tmp[11] = 's';\n   return 0;\n}"
  },
  {
    "path": "04-static-analysis/cppcheck-compile-commands/.cppcheck_suppressions",
    "content": ""
  },
  {
    "path": "04-static-analysis/cppcheck-compile-commands/CMakeLists.txt",
    "content": "cmake_minimum_required (VERSION 3.5)\n\nproject(cppcheck_analysis)\n\n# Have cmake create a compile database\nset(CMAKE_EXPORT_COMPILE_COMMANDS ON)\n\n# Add a custom CMake Modules directory\nset(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules\n                      ${CMAKE_MODULE_PATH})\n\n# find the cppcheck binary\nfind_package(CppCheck)\n\n# Add sub directories\nadd_subdirectory(subproject1)\nadd_subdirectory(subproject2)\n"
  },
  {
    "path": "04-static-analysis/cppcheck-compile-commands/README.adoc",
    "content": "= CppCheck Static Analysis using Compile Commands\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nThis example shows how to call the\nhttp://cppcheck.sourceforge.net/[CppCheck] tool to do static analysis.\nThis shows how to use projects and a compile database.\nProjects are available from cppcheck v1.77\n\nIt includes code to\n\n  * Find the cppcheck binary\n  * Generate an overall `make cppcheck-analysis` target to do static\nanalysis on all sub-projects.\n\nThe files included in this example are:\n\n```\n$ tree\n.\n├── cmake\n│   └── modules\n│       └── FindCppCheck.cmake\n├── CMakeLists.txt\n├── subproject1\n│   ├── CMakeLists.txt\n│   └── main1.cpp\n└── subproject2\n    ├── CMakeLists.txt\n    └── main2.cpp\n```\n\n  * link:CMakeLists.txt[] - Top level CMakeLists.txt\n  * link:cmake/modules/FindCppCheck.cmake[] - A custom package module to find CppCheck\n  * link:subproject1/CMakeLists.txt[] - CMake commands for subproject 1\n  * link:subproject1/main1.cpp[] - source for a subproject with no errors\n  * link:subproject2/CMakeLists.txt[] - CMake commands for subproject 2\n  * link:subproject2/main2.cpp[] - source for a subproject that includes errors\n\n# Requirements\n\nTo run this example you must have CppCheck of at least v1.77 installed. This is not\navailable by default on Ubuntu but can be compiled using the following command.\n\n[source,bash]\n----\n$ wget https://github.com/danmar/cppcheck/archive/1.79.tar.gz \\\n    && tar xvf 1.79.tar.gz \\\n    && cd cppcheck-1.79 \\\n    && mkdir build \\\n    && cd build \\\n    && cmake .. \\\n    && sudo make install\n----\n\n# Concepts\n\n## Adding Custom Package Modules\n\nAs with the previous example I use a custom module to find CppCheck. This version is slightly different to the previous one and \nwill automatically add a `make cppcheck-analysis` target.\n\n[source,cmake]\n----\nif(CPPCHECK_FOUND)\n    file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/analysis/cppcheck)\n    add_custom_target(cppcheck-analysis \n        COMMAND ${CPPCHECK_COMMAND})\n    message(\"cppcheck found. Use cppccheck-analysis targets to run it\")\nelse()\n    message(\"cppcheck not found. No cppccheck-analysis targets\")\nendif()\n---- \n\nThe variables available have also changed. For full details on the commands see the `FindCppCheck.cmake` module. Below are a subset of the available options:\n\n### Suppressions\n\nAdding a suppression file called `.cppcheck-suppressions` which must be in your +CMAKE_SOURCE_DIR+\n\n### Error Exitcode\n\nWhen cppcheck finds an error it can cause it to exit with a specific error. In this \nexample, by default, it will exit with `1`. To change this you can set the \n+CPPCHECK_ERROR_EXITCODE_ARG+ argument when running CMake.\n\n### Exitcode suppressions\n\nSometimes you wish to display an error in the log, but to not have that error cause a failed build. To do this you can create a file `.cppcheck_exitcode_suppressions` and add suppressions to it. This file must be in your +CMAKE_SOURCE_DIR+\n\n### CppCheck arguments\n\nThe default enabled checks are `--enabled=warning`. To change this you can override the `CPPCHECK_CHECK_ARGS` variable before calling `find(cppcheck)`.\n\n### Excluding files / folders\n\nMany projects include some vendored 3rd party code. To exclude this from you check you can create a list `CPPCHECK_EXCLUDES` before calling the find module. This will add all files and folders in the list into the list of excluded folders.\n\n### CppCheck build dir\n\nIn this example, we set +CPPCHECK_BUILD_DIR_ARG+, to `${PROJECT_BINARY_DIR}/analysis/cppcheck`. This will output details of the build to this folder and can be used to \nincrease the speed of rechecks if a file hasn't changed\n\n## Compile Database\n\nCMake allows you to export all https://cmake.org/cmake/help/v3.5/variable/CMAKE_EXPORT_COMPILE_COMMANDS.html[compile commands] \nthat are used to build the project into a file called `compile_commands.json`\n\nThis can be done by setting the +CMAKE_EXPORT_COMPILE_COMMANDS+ variable to +ON+ \nas below:\n\n[source,cmake]\n----\nset(CMAKE_EXPORT_COMPILE_COMMANDS ON)\n----\n\nThe JSON file will look like:\n\n[source,json]\n----\n[\n  {\n    \"directory\": \"/home/user/development/project\",\n    \"command\": \"/usr/bin/c++ ... -c ../foo/foo.cc\",\n    \"file\": \"../foo/foo.cc\"\n  },\n\n  ...\n\n  {\n    \"directory\": \"/home/user/development/project\",\n    \"command\": \"/usr/bin/c++ ... -c ../foo/bar.cc\",\n    \"file\": \"../foo/bar.cc\"\n  }\n]\n----\n\n[NOTE]\n====\nThis is only available for the `Makefile` and `ninja` generators.\n====\n\n## CppCheck Projects\n\nStarting with CppCheck v1.77, you can pass the `--project` flag pointing to the \ncompile database. This will cause CppCheck to run on al your cpp files using the same\ninclude directories and compiler flags as your normal build.\n\n[source,bash]\n----\ncppcheck --project=compile_comands.json\n----\n\nThis will check all files in your project and sub-projects. There will be no analysis target per sub-project as with our previous example.\n\n# Building the example\n\n[source,bash]\n----\n$ mkdir build\n\n$ cd build/\n\n$ cmake ..\n-- The C compiler identification is GNU 4.8.4\n-- The CXX compiler identification is GNU 4.8.4\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Detecting C compile features\n-- Detecting C compile features - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Detecting CXX compile features\n-- Detecting CXX compile features - done\n-- Found CPPCHECK: /usr/local/bin/cppcheck  \ncppcheck found. Use cppccheck-analysis targets to run it\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /data/code/04-static-analysis/cppcheck-compile-commands/build\n\n$ make cppcheck-analysis\nScanning dependencies of target cppcheck-analysis\n[/data/code/04-static-analysis/cppcheck-compile-commands/subproject2/main2.cpp:7]: (error) Array 'tmp[10]' accessed at index 11, which is out of bounds.\nmake[3]: *** [CMakeFiles/cppcheck-analysis] Error 1\nmake[2]: *** [CMakeFiles/cppcheck-analysis.dir/all] Error 2\nmake[1]: *** [CMakeFiles/cppcheck-analysis.dir/rule] Error 2\nmake: *** [cppcheck-analysis] Error 2\n"
  },
  {
    "path": "04-static-analysis/cppcheck-compile-commands/cmake/modules/FindCppCheck.cmake",
    "content": "# Locate cppcheck\n#\n# This module defines\n#  CPPCHECK_BIN, where to find cppcheck\n#\n# To help find the binary you can set CPPCHECK_ROOT_DIR to search a custom path\n# Exported argumets include\n#   CPPCHECK_FOUND, if false, do not try to link to cppcheck --- if (CPPCHECK_FOUND)\n#   \n#   CPPCHECK_THREADS_ARG - Number of threads to use (e.g. -j 3)\n#   CPPCHECK_PROJECT_ARG - The project to use (compile_comands.json)\n#   CPPCHECK_BUILD_DIR_ARG - The build output directory\n#   CPPCHECK_ERROR_EXITCODE_ARG - The exit code if an error is found\n#   CPPCHECK_SUPPRESSIONS - A suppressiosn file to use\n#   CPPCHECK_CHECKS_ARGS - The checks to run\n#   CPPCHECK_OTHER_ARGS - Any other arguments\n#   CPPCHECK_COMMAND - The full command to run the default cppcheck configuration\n#   CPPCHECK_EXCLUDES - A list of files or folders to exclude from the scan. Must be the full path\n#   \n# if CPPCHECK_XML_OUTPUT is set before calling this. CppCheck will create an xml file with that name\n# find the cppcheck binary\n\n# if custom path check there first\nif(CPPCHECK_ROOT_DIR)\n    find_program(CPPCHECK_BIN \n        NAMES\n        cppcheck\n        PATHS\n        \"${CPPCHECK_ROOT_DIR}\"\n        NO_DEFAULT_PATH)\nendif()\n\nfind_program(CPPCHECK_BIN NAMES cppcheck)\n\nif(CPPCHECK_BIN)\n    execute_process(COMMAND ${CPPCHECK_BIN} --version\n                  OUTPUT_VARIABLE CPPCHECK_VERSION\n                  ERROR_QUIET\n                  OUTPUT_STRIP_TRAILING_WHITESPACE)\n\n    set(CPPCHECK_THREADS_ARG \"-j4\" CACHE STRING \"The number of threads to use\")\n    set(CPPCHECK_PROJECT_ARG \"--project=${PROJECT_BINARY_DIR}/compile_commands.json\")\n    set(CPPCHECK_BUILD_DIR_ARG \"--cppcheck-build-dir=${PROJECT_BINARY_DIR}/analysis/cppcheck\" CACHE STRING \"The build directory to use\")\n    # Don't show these errors\n    if(EXISTS \"${CMAKE_SOURCE_DIR}/.cppcheck_suppressions\")\n        set(CPPCHECK_SUPPRESSIONS \"--suppressions-list=${CMAKE_SOURCE_DIR}/.cppcheck_suppressions\" CACHE STRING \"The suppressions file to use\")\n    else()\n        set(CPPCHECK_SUPPRESSIONS \"\" CACHE STRING \"The suppressions file to use\")\n    endif()\n\n    # Show these errors but don't fail the build\n    # These are mainly going to be from the \"warning\" category that is enabled by default later\n    if(EXISTS \"${CMAKE_SOURCE_DIR}/.cppcheck_exitcode_suppressions\")\n        set(CPPCHECK_EXITCODE_SUPPRESSIONS \"--exitcode-suppressions=${CMAKE_SOURCE_DIR}/.cppcheck_exitcode_suppressions\" CACHE STRING \"The exitcode suppressions file to use\")\n    else()\n        set(CPPCHECK_EXITCODE_SUPPRESSIONS \"\" CACHE STRING \"The exitcode suppressions file to use\")\n    endif()\n\n    set(CPPCHECK_ERROR_EXITCODE_ARG \"--error-exitcode=1\" CACHE STRING \"The exitcode to use if an error is found\")\n    set(CPPCHECK_CHECKS_ARGS \"--enable=warning\" CACHE STRING \"Arguments for the checks to run\")\n    set(CPPCHECK_OTHER_ARGS \"\" CACHE STRING \"Other arguments\")\n    set(_CPPCHECK_EXCLUDES)\n\n    foreach(ex ${CPPCHECK_EXCLUDES})\n        list(APPEND _CPPCHECK_EXCLUDES \"-i${ex}\")\n    endforeach(ex)\n\n    set(CPPCHECK_ALL_ARGS \n        ${CPPCHECK_THREADS_ARG} \n        ${CPPCHECK_PROJECT_ARG} \n        ${CPPCHECK_BUILD_DIR_ARG} \n        ${CPPCHECK_ERROR_EXITCODE_ARG} \n        ${CPPCHECK_SUPPRESSIONS} \n        ${CPPCHECK_EXITCODE_SUPPRESSIONS}\n        ${CPPCHECK_CHECKS_ARGS} \n        ${CPPCHECK_OTHER_ARGS}\n        ${_CPPCHECK_EXCLUDES}\n    )\n\n    if(NOT CPPCHECK_XML_OUTPUT)\n        set(CPPCHECK_COMMAND \n            ${CPPCHECK_BIN}\n            ${CPPCHECK_ALL_ARGS}\n        )\n    else()\n        set(CPPCHECK_COMMAND\n            ${CPPCHECK_BIN}\n            ${CPPCHECK_ALL_ARGS}\n            --xml \n            --xml-version=2\n            2> ${CPPCHECK_XML_OUTPUT})\n    endif()\n    \nendif()\n\n\n\n# handle the QUIETLY and REQUIRED arguments and set YAMLCPP_FOUND to TRUE if all listed variables are TRUE\ninclude(FindPackageHandleStandardArgs)\nFIND_PACKAGE_HANDLE_STANDARD_ARGS(\n    CPPCHECK \n    DEFAULT_MSG \n    CPPCHECK_BIN)\n\nmark_as_advanced(\n    CPPCHECK_BIN  \n    CPPCHECK_THREADS_ARG\n    CPPCHECK_PROJECT_ARG\n    CPPCHECK_BUILD_DIR_ARG\n    CPPCHECK_ERROR_EXITCODE_ARG\n    CPPCHECK_SUPPRESSIONS\n    CPPCHECK_CHECKS_ARGS\n    CPPCHECK_OTHER_ARGS)\n\nif(CPPCHECK_FOUND)\n    file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/analysis/cppcheck)\n    add_custom_target(cppcheck-analysis \n        COMMAND ${CPPCHECK_COMMAND})\n    message(\"cppcheck found. Use cppccheck-analysis targets to run it\")\nelse()\n    message(\"cppcheck not found. No cppccheck-analysis targets\")\nendif()\n"
  },
  {
    "path": "04-static-analysis/cppcheck-compile-commands/run_test.sh",
    "content": "#!/bin/bash\nmkdir -p build && cd build && cmake -DCPPCHECK_ERROR_EXITCODE_ARG=\"\" .. && make cppcheck-analysis\n"
  },
  {
    "path": "04-static-analysis/cppcheck-compile-commands/subproject1/CMakeLists.txt",
    "content": "# Set the project name\nproject (subproject1)\n\n# Add an executable with the above sources\nadd_executable(${PROJECT_NAME} main1.cpp)\n"
  },
  {
    "path": "04-static-analysis/cppcheck-compile-commands/subproject1/main1.cpp",
    "content": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n   std::cout << \"Hello Main1!\" << std::endl;\n   return 0;\n}"
  },
  {
    "path": "04-static-analysis/cppcheck-compile-commands/subproject2/CMakeLists.txt",
    "content": "# Set the project name\nproject (subproject2)\n\n# Add an executable with the above sources\nadd_executable(${PROJECT_NAME} main2.cpp)\n"
  },
  {
    "path": "04-static-analysis/cppcheck-compile-commands/subproject2/main2.cpp",
    "content": "#include <iostream>\n\nint main(int argc, char *argv[])\n{\n   std::cout << \"Hello Main2!\" << std::endl;\n   char tmp[10];\n   tmp[11] = 's';\n   return 0;\n}"
  },
  {
    "path": "05-unit-testing/README.adoc",
    "content": "= Unit Testing\n\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n[[intro]]\nIntroduction\n------------\n\nUnit testing is a software development process in which the smallest testable parts of an\napplication, called units, are individually and independently scrutinized\nfor proper operation. This can involve taking a class, function, or algorithm\nand writing test cases that can be run to verify that the unit is working correctly.\n\nCMake includes a tool called link:https://cmake.org/Wiki/CMake/Testing_With_CTest[CTest]\nwhich allows you to enable the `make test` target to run automated tests such as unit tests.\n\nThere are many unit-testing frameworks available which can be used to help automate\nand ease the development of unit tests. In these examples I show how to use\nsome of these frameworks and call them using the CMake testing utility CTest.\n\nThe examples here include using the following frameworks:\n\n* http://www.boost.org/doc/libs/1_56_0/libs/test/doc/html/utf/user-guide.html[Boost Unit Test Framework]\n* https://github.com/google/googletest[Google Test - Download]\n* https://github.com/catchorg/Catch2[Catch2]\n"
  },
  {
    "path": "05-unit-testing/boost/CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 3.5)\n\n# Set the project name\nproject (boost_unit_test)\n\n\n# find a boost install with the libraries unit_test_framework\nfind_package(Boost 1.46.1 REQUIRED COMPONENTS unit_test_framework)\n\n# Add an library for the example classes\nadd_library(example_boost_unit_test\n    Reverse.cpp\n    Palindrome.cpp\n)\n\ntarget_include_directories(example_boost_unit_test\n    PUBLIC\n        ${CMAKE_CURRENT_SOURCE_DIR}\n)\n\ntarget_link_libraries(example_boost_unit_test\n    PUBLIC\n        Boost::boost\n)\n\n#############################################\n# Unit tests\n\n# enable CTest testing\nenable_testing()\n\n# Add a testing executable\nadd_executable(unit_tests unit_tests.cpp)\n\ntarget_link_libraries(unit_tests\n    example_boost_unit_test\n    Boost::unit_test_framework\n)\n\ntarget_compile_definitions(unit_tests\n    PRIVATE\n        BOOST_TEST_DYN_LINK\n)\n\nadd_test(test_all unit_tests)\n"
  },
  {
    "path": "05-unit-testing/boost/Palindrome.cpp",
    "content": "#include \"Palindrome.h\"\n\nbool Palindrome::isPalindrome(const std::string& toCheck)\n{\n\n    if (toCheck == std::string(toCheck.rbegin(), toCheck.rend())) {\n        return true;\n    }\n\n    return false;\n}\n"
  },
  {
    "path": "05-unit-testing/boost/Palindrome.h",
    "content": "#ifndef __PALINDROME_H__\n#define __PALINDROME_H__\n\n#include <string>\n\n/**\n * Trivial class to check if a string is a palindrome.\n */\nclass Palindrome\n{\npublic:\n    bool isPalindrome(const std::string& toCheck);\n};\n\n#endif\n"
  },
  {
    "path": "05-unit-testing/boost/README.adoc",
    "content": "= Boost Unit Testing Framework\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n\n# Introduction\n\nUsing link:https://cmake.org/Wiki/CMake/Testing_With_CTest[CTest] you can generate\na `make test` target to run automated unit-tests. This example shows how to\nfind the link:http://www.boost.org/doc/libs/1_56_0/libs/test/doc/html/utf/user-guide.html[boost unit-test-framework],\ncreate tests and run them.\n\nThe files in this tutorial are below:\n\n```\n$ tree\n.\n├── CMakeLists.txt\n├── Reverse.h\n├── Reverse.cpp\n├── Palindrome.h\n├── Palindrome.cpp\n├── unit_tests.cpp\n```\n\n  * link:CMakeLists.txt[] - Contains the CMake commands you wish to run\n  * link:Reverse.h[] / link:Reverse.cpp[.cpp] - Class to reverse a string\n  * link:Palindrome.h[] / link:Palindrome.cpp[.cpp] - Class to test if a string is a palindrome\n  * link:unit_test.cpp[] - Unit Tests using boost unit test framework\n\n# Requirements\n\nThis example requires the boost libraries to be installed in a default system\nlocation. The library in use is the boost unit-test-framework.\n\n# Concepts\n\n## Enabling testing\n\nTo enable testing you must include the following line in your top level CMakeLists.txt\n\n[source,cmake]\n----\nenable_testing()\n----\n\nThis will enable testing for the current folder and all folders below it.\n\n## Adding a testing executable\n\nThe requirement for this step will depend on your unit-test framework. In the example\nof boost, you can create binary(s) which includes all the unit tests that you want to run.\n\n[source,cmake]\n----\nadd_executable(unit_tests unit_tests.cpp)\n\ntarget_link_libraries(unit_tests\n    example_boost_unit_test\n    Boost::unit_test_framework\n)\n\ntarget_compile_definitions(unit_tests\n    PRIVATE\n        BOOST_TEST_DYN_LINK\n)\n----\n\nIn the above code, a unit test binary is added, which links against the boost unit-test-framework\nand includes a definition to tell it that we are using dynamic linking.\n\n## Add A test\n\nTo add a test you call the link:https://cmake.org/cmake/help/v3.0/command/add_test.html[`add_test()`] function.\nThis will create a named test which will run the supplied command.\n\n[source,cmake]\n----\nadd_test(test_all unit_tests)\n----\n\nIn this example, we create a test called `test_all` which will run the executable\ncreated by the `unit_tests` executable created from the call to `add_executable`\n\n# Building the Example\n\n[source,bash]\n----\n$ mkdir build\n\n$ cd build/\n\n$ cmake ..\n-- The C compiler identification is GNU 4.8.4\n-- The CXX compiler identification is GNU 4.8.4\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Boost version: 1.54.0\n-- Found the following Boost libraries:\n--   unit_test_framework\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /home/matrim/workspace/cmake-examples/05-unit-testing/boost/build\n\n$ make\nScanning dependencies of target example_boost_unit_test\n[ 33%] Building CXX object CMakeFiles/example_boost_unit_test.dir/Reverse.cpp.o\n[ 66%] Building CXX object CMakeFiles/example_boost_unit_test.dir/Palindrome.cpp.o\nLinking CXX static library libexample_boost_unit_test.a\n[ 66%] Built target example_boost_unit_test\nScanning dependencies of target unit_tests\n[100%] Building CXX object CMakeFiles/unit_tests.dir/unit_tests.cpp.o\nLinking CXX executable unit_tests\n[100%] Built target unit_tests\n\n$ make test\nRunning tests...\nTest project /home/matrim/workspace/cmake-examples/05-unit-testing/boost/build\n    Start 1: test_all\n1/1 Test #1: test_all .........................   Passed    0.00 sec\n\n100% tests passed, 0 tests failed out of 1\n\nTotal Test time (real) =   0.01 sec\n----\n\nIf the code is changed and it causes the unit tests to produce an error.\nThen when running the tests you will see the following output.\n\n[source,bash]\n----\n$ make test\nRunning tests...\nTest project /home/matrim/workspace/cmake-examples/05-unit-testing/boost/build\n    Start 1: test_all\n1/1 Test #1: test_all .........................***Failed    0.00 sec\n\n0% tests passed, 1 tests failed out of 1\n\nTotal Test time (real) =   0.00 sec\n\nThe following tests FAILED:\n          1 - test_all (Failed)\nErrors while running CTest\nmake: *** [test] Error 8\n\n----\n"
  },
  {
    "path": "05-unit-testing/boost/Reverse.cpp",
    "content": "#include \"Reverse.h\"\n\nstd::string Reverse::reverse(std::string& toReverse)\n{\n    std::string ret;\n\n    for(std::string::reverse_iterator rit=toReverse.rbegin(); rit!=toReverse.rend(); ++rit)\n    {\n        ret.insert(ret.end(), *rit);\n    }\n    return ret;\n}\n"
  },
  {
    "path": "05-unit-testing/boost/Reverse.h",
    "content": "#ifndef __REVERSE_H__\n#define __REVERSE_H__\n\n#include <string>\n\n/**\n * Trivial class whose only function is to reverse a string.\n * Should use std::reverse instead but want to have example with own class\n */\nclass Reverse\n{\npublic:\n    std::string reverse(std::string& toReverse);\n};\n#endif\n"
  },
  {
    "path": "05-unit-testing/boost/main.cpp",
    "content": "#include <iostream>\n#include <boost/shared_ptr.hpp>\n#include <boost/filesystem.hpp>\n\nint main(int argc, char *argv[])\n{\n    std::cout << \"Hello Third Party Include!\" << std::endl;\n\n    // use a shared ptr\n    boost::shared_ptr<int> isp(new int(4));\n\n    // trivial use of boost filesystem\n    boost::filesystem::path path = \"/usr/share/cmake/modules\";\n    if(path.is_relative())\n    {\n        std::cout << \"Path is relative\" << std::endl;\n    }\n    else\n    {\n        std::cout << \"Path is not relative\" << std::endl;\n    }\n\n   return 0;\n}\n"
  },
  {
    "path": "05-unit-testing/boost/post_test.sh",
    "content": "#!/bin/bash\n\nmake test\n"
  },
  {
    "path": "05-unit-testing/boost/unit_tests.cpp",
    "content": "#include <string>\n#include \"Reverse.h\"\n#include \"Palindrome.h\"\n\n#define BOOST_TEST_MODULE VsidCommonTest\n#include <boost/test/unit_test.hpp>\n\nBOOST_AUTO_TEST_SUITE( reverse_tests )\n\nBOOST_AUTO_TEST_CASE( simple )\n{\n    std::string toRev = \"Hello\";\n\n    Reverse rev;\n    std::string res = rev.reverse(toRev);\n\n    BOOST_CHECK_EQUAL( res, \"olleH\" );\n\n}\n\n\nBOOST_AUTO_TEST_CASE( empty )\n{\n    std::string toRev;\n\n    Reverse rev;\n    std::string res = rev.reverse(toRev);\n\n    BOOST_CHECK_EQUAL( res, \"\" );\n}\n\nBOOST_AUTO_TEST_SUITE_END()\n\n\nBOOST_AUTO_TEST_SUITE( palindrome_tests )\n\nBOOST_AUTO_TEST_CASE( is_palindrome )\n{\n    std::string pal = \"mom\";\n    Palindrome pally;\n\n    BOOST_CHECK_EQUAL( pally.isPalindrome(pal), true );\n\n}\n\nBOOST_AUTO_TEST_SUITE_END()\n"
  },
  {
    "path": "05-unit-testing/catch2-vendored/3rd_party/catch2/CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 3.0)\n\nproject(catch2)\n\n# Prepare \"Catch2\" library for other executables\nadd_library(Catch2 INTERFACE)\nadd_library(Catch2::Test ALIAS Catch2)\ntarget_include_directories(Catch2 INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})\n"
  },
  {
    "path": "05-unit-testing/catch2-vendored/3rd_party/catch2/catch2/catch.hpp",
    "content": "/*\n *  Catch v2.5.0\n *  Generated: 2018-11-26 20:46:12.165372\n *  ----------------------------------------------------------\n *  This file has been merged from multiple headers. Please don't edit it directly\n *  Copyright (c) 2018 Two Blue Cubes Ltd. All rights reserved.\n *\n *  Distributed under the Boost Software License, Version 1.0. (See accompanying\n *  file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n */\n#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n// start catch.hpp\n\n\n#define CATCH_VERSION_MAJOR 2\n#define CATCH_VERSION_MINOR 5\n#define CATCH_VERSION_PATCH 0\n\n#ifdef __clang__\n#    pragma clang system_header\n#elif defined __GNUC__\n#    pragma GCC system_header\n#endif\n\n// start catch_suppress_warnings.h\n\n#ifdef __clang__\n#   ifdef __ICC // icpc defines the __clang__ macro\n#       pragma warning(push)\n#       pragma warning(disable: 161 1682)\n#   else // __ICC\n#       pragma clang diagnostic push\n#       pragma clang diagnostic ignored \"-Wpadded\"\n#       pragma clang diagnostic ignored \"-Wswitch-enum\"\n#       pragma clang diagnostic ignored \"-Wcovered-switch-default\"\n#    endif\n#elif defined __GNUC__\n     // GCC likes to warn on REQUIREs, and we cannot suppress them\n     // locally because g++'s support for _Pragma is lacking in older,\n     // still supported, versions\n#    pragma GCC diagnostic ignored \"-Wparentheses\"\n#    pragma GCC diagnostic push\n#    pragma GCC diagnostic ignored \"-Wunused-variable\"\n#    pragma GCC diagnostic ignored \"-Wpadded\"\n#endif\n// end catch_suppress_warnings.h\n#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER)\n#  define CATCH_IMPL\n#  define CATCH_CONFIG_ALL_PARTS\n#endif\n\n// In the impl file, we want to have access to all parts of the headers\n// Can also be used to sanely support PCHs\n#if defined(CATCH_CONFIG_ALL_PARTS)\n#  define CATCH_CONFIG_EXTERNAL_INTERFACES\n#  if defined(CATCH_CONFIG_DISABLE_MATCHERS)\n#    undef CATCH_CONFIG_DISABLE_MATCHERS\n#  endif\n#  if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER)\n#    define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER\n#  endif\n#endif\n\n#if !defined(CATCH_CONFIG_IMPL_ONLY)\n// start catch_platform.h\n\n#ifdef __APPLE__\n# include <TargetConditionals.h>\n# if TARGET_OS_OSX == 1\n#  define CATCH_PLATFORM_MAC\n# elif TARGET_OS_IPHONE == 1\n#  define CATCH_PLATFORM_IPHONE\n# endif\n\n#elif defined(linux) || defined(__linux) || defined(__linux__)\n#  define CATCH_PLATFORM_LINUX\n\n#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) || defined(__MINGW32__)\n#  define CATCH_PLATFORM_WINDOWS\n#endif\n\n// end catch_platform.h\n\n#ifdef CATCH_IMPL\n#  ifndef CLARA_CONFIG_MAIN\n#    define CLARA_CONFIG_MAIN_NOT_DEFINED\n#    define CLARA_CONFIG_MAIN\n#  endif\n#endif\n\n// start catch_user_interfaces.h\n\nnamespace Catch {\n    unsigned int rngSeed();\n}\n\n// end catch_user_interfaces.h\n// start catch_tag_alias_autoregistrar.h\n\n// start catch_common.h\n\n// start catch_compiler_capabilities.h\n\n// Detect a number of compiler features - by compiler\n// The following features are defined:\n//\n// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported?\n// CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported?\n// CATCH_CONFIG_POSIX_SIGNALS : are POSIX signals supported?\n// CATCH_CONFIG_DISABLE_EXCEPTIONS : Are exceptions enabled?\n// ****************\n// Note to maintainers: if new toggles are added please document them\n// in configuration.md, too\n// ****************\n\n// In general each macro has a _NO_<feature name> form\n// (e.g. CATCH_CONFIG_NO_POSIX_SIGNALS) which disables the feature.\n// Many features, at point of detection, define an _INTERNAL_ macro, so they\n// can be combined, en-mass, with the _NO_ forms later.\n\n#ifdef __cplusplus\n\n#  if (__cplusplus >= 201402L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201402L)\n#    define CATCH_CPP14_OR_GREATER\n#  endif\n\n#  if (__cplusplus >= 201703L) || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)\n#    define CATCH_CPP17_OR_GREATER\n#  endif\n\n#endif\n\n#if defined(CATCH_CPP17_OR_GREATER)\n#  define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS\n#endif\n\n#ifdef __clang__\n\n#       define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \\\n            _Pragma( \"clang diagnostic push\" ) \\\n            _Pragma( \"clang diagnostic ignored \\\"-Wexit-time-destructors\\\"\" ) \\\n            _Pragma( \"clang diagnostic ignored \\\"-Wglobal-constructors\\\"\")\n#       define CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \\\n            _Pragma( \"clang diagnostic pop\" )\n\n#       define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \\\n            _Pragma( \"clang diagnostic push\" ) \\\n            _Pragma( \"clang diagnostic ignored \\\"-Wparentheses\\\"\" )\n#       define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \\\n            _Pragma( \"clang diagnostic pop\" )\n\n#       define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \\\n            _Pragma( \"clang diagnostic push\" ) \\\n            _Pragma( \"clang diagnostic ignored \\\"-Wunused-variable\\\"\" )\n#       define CATCH_INTERNAL_UNSUPPRESS_UNUSED_WARNINGS \\\n            _Pragma( \"clang diagnostic pop\" )\n\n#endif // __clang__\n\n////////////////////////////////////////////////////////////////////////////////\n// Assume that non-Windows platforms support posix signals by default\n#if !defined(CATCH_PLATFORM_WINDOWS)\n    #define CATCH_INTERNAL_CONFIG_POSIX_SIGNALS\n#endif\n\n////////////////////////////////////////////////////////////////////////////////\n// We know some environments not to support full POSIX signals\n#if defined(__CYGWIN__) || defined(__QNX__) || defined(__EMSCRIPTEN__) || defined(__DJGPP__)\n    #define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS\n#endif\n\n#ifdef __OS400__\n#       define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS\n#       define CATCH_CONFIG_COLOUR_NONE\n#endif\n\n////////////////////////////////////////////////////////////////////////////////\n// Android somehow still does not support std::to_string\n#if defined(__ANDROID__)\n#    define CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING\n#endif\n\n////////////////////////////////////////////////////////////////////////////////\n// Not all Windows environments support SEH properly\n#if defined(__MINGW32__)\n#    define CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH\n#endif\n\n////////////////////////////////////////////////////////////////////////////////\n// PS4\n#if defined(__ORBIS__)\n#    define CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE\n#endif\n\n////////////////////////////////////////////////////////////////////////////////\n// Cygwin\n#ifdef __CYGWIN__\n\n// Required for some versions of Cygwin to declare gettimeofday\n// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin\n#   define _BSD_SOURCE\n// some versions of cygwin (most) do not support std::to_string. Use the libstd check.\n// https://gcc.gnu.org/onlinedocs/gcc-4.8.2/libstdc++/api/a01053_source.html line 2812-2813\n# if !((__cplusplus >= 201103L) && defined(_GLIBCXX_USE_C99) \\\n\t       && !defined(_GLIBCXX_HAVE_BROKEN_VSWPRINTF))\n\n#\tdefine CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING\n\n# endif\n#endif // __CYGWIN__\n\n////////////////////////////////////////////////////////////////////////////////\n// Visual C++\n#ifdef _MSC_VER\n\n#  if _MSC_VER >= 1900 // Visual Studio 2015 or newer\n#    define CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS\n#  endif\n\n// Universal Windows platform does not support SEH\n// Or console colours (or console at all...)\n#  if defined(WINAPI_FAMILY) && (WINAPI_FAMILY == WINAPI_FAMILY_APP)\n#    define CATCH_CONFIG_COLOUR_NONE\n#  else\n#    define CATCH_INTERNAL_CONFIG_WINDOWS_SEH\n#  endif\n\n// MSVC traditional preprocessor needs some workaround for __VA_ARGS__\n// _MSVC_TRADITIONAL == 0 means new conformant preprocessor\n// _MSVC_TRADITIONAL == 1 means old traditional non-conformant preprocessor\n#  if !defined(_MSVC_TRADITIONAL) || (defined(_MSVC_TRADITIONAL) && _MSVC_TRADITIONAL)\n#    define CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR\n#  endif\n\n#endif // _MSC_VER\n\n////////////////////////////////////////////////////////////////////////////////\n// Check if we are compiled with -fno-exceptions or equivalent\n#if defined(__EXCEPTIONS) || defined(__cpp_exceptions) || defined(_CPPUNWIND)\n#  define CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED\n#endif\n\n////////////////////////////////////////////////////////////////////////////////\n// DJGPP\n#ifdef __DJGPP__\n#  define CATCH_INTERNAL_CONFIG_NO_WCHAR\n#endif // __DJGPP__\n\n////////////////////////////////////////////////////////////////////////////////\n// Embarcadero C++Build\n#if defined(__BORLANDC__)\n    #define CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN\n#endif\n\n////////////////////////////////////////////////////////////////////////////////\n\n// Use of __COUNTER__ is suppressed during code analysis in\n// CLion/AppCode 2017.2.x and former, because __COUNTER__ is not properly\n// handled by it.\n// Otherwise all supported compilers support COUNTER macro,\n// but user still might want to turn it off\n#if ( !defined(__JETBRAINS_IDE__) || __JETBRAINS_IDE__ >= 20170300L )\n    #define CATCH_INTERNAL_CONFIG_COUNTER\n#endif\n\n////////////////////////////////////////////////////////////////////////////////\n// Check if string_view is available and usable\n// The check is split apart to work around v140 (VS2015) preprocessor issue...\n#if defined(__has_include)\n#if __has_include(<string_view>) && defined(CATCH_CPP17_OR_GREATER)\n#    define CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW\n#endif\n#endif\n\n////////////////////////////////////////////////////////////////////////////////\n// Check if variant is available and usable\n#if defined(__has_include)\n#  if __has_include(<variant>) && defined(CATCH_CPP17_OR_GREATER)\n#    if defined(__clang__) && (__clang_major__ < 8)\n       // work around clang bug with libstdc++ https://bugs.llvm.org/show_bug.cgi?id=31852\n       // fix should be in clang 8, workaround in libstdc++ 8.2\n#      include <ciso646>\n#      if defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9)\n#        define CATCH_CONFIG_NO_CPP17_VARIANT\n#     else\n#        define CATCH_INTERNAL_CONFIG_CPP17_VARIANT\n#      endif // defined(__GLIBCXX__) && defined(_GLIBCXX_RELEASE) && (_GLIBCXX_RELEASE < 9)\n#    endif // defined(__clang__) && (__clang_major__ < 8)\n#  endif // __has_include(<variant>) && defined(CATCH_CPP17_OR_GREATER)\n#endif // __has_include\n\n#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER)\n#   define CATCH_CONFIG_COUNTER\n#endif\n#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) && !defined(CATCH_INTERNAL_CONFIG_NO_WINDOWS_SEH)\n#   define CATCH_CONFIG_WINDOWS_SEH\n#endif\n// This is set by default, because we assume that unix compilers are posix-signal-compatible by default.\n#if defined(CATCH_INTERNAL_CONFIG_POSIX_SIGNALS) && !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS)\n#   define CATCH_CONFIG_POSIX_SIGNALS\n#endif\n// This is set by default, because we assume that compilers with no wchar_t support are just rare exceptions.\n#if !defined(CATCH_INTERNAL_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_NO_WCHAR) && !defined(CATCH_CONFIG_WCHAR)\n#   define CATCH_CONFIG_WCHAR\n#endif\n\n#if !defined(CATCH_INTERNAL_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_NO_CPP11_TO_STRING) && !defined(CATCH_CONFIG_CPP11_TO_STRING)\n#    define CATCH_CONFIG_CPP11_TO_STRING\n#endif\n\n#if defined(CATCH_INTERNAL_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_NO_CPP17_UNCAUGHT_EXCEPTIONS) && !defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS)\n#  define CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS\n#endif\n\n#if defined(CATCH_INTERNAL_CONFIG_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_NO_CPP17_STRING_VIEW) && !defined(CATCH_CONFIG_CPP17_STRING_VIEW)\n#  define CATCH_CONFIG_CPP17_STRING_VIEW\n#endif\n\n#if defined(CATCH_INTERNAL_CONFIG_CPP17_VARIANT) && !defined(CATCH_CONFIG_NO_CPP17_VARIANT) && !defined(CATCH_CONFIG_CPP17_VARIANT)\n#  define CATCH_CONFIG_CPP17_VARIANT\n#endif\n\n#if defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT)\n#  define CATCH_INTERNAL_CONFIG_NEW_CAPTURE\n#endif\n\n#if defined(CATCH_INTERNAL_CONFIG_NEW_CAPTURE) && !defined(CATCH_INTERNAL_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NO_NEW_CAPTURE) && !defined(CATCH_CONFIG_NEW_CAPTURE)\n#  define CATCH_CONFIG_NEW_CAPTURE\n#endif\n\n#if !defined(CATCH_INTERNAL_CONFIG_EXCEPTIONS_ENABLED) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)\n#  define CATCH_CONFIG_DISABLE_EXCEPTIONS\n#endif\n\n#if defined(CATCH_INTERNAL_CONFIG_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_NO_POLYFILL_ISNAN) && !defined(CATCH_CONFIG_POLYFILL_ISNAN)\n#  define CATCH_CONFIG_POLYFILL_ISNAN\n#endif\n\n#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS)\n#   define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS\n#   define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS\n#endif\n#if !defined(CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS)\n#   define CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS\n#   define CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS\n#endif\n#if !defined(CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS)\n#   define CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS\n#   define CATCH_INTERNAL_UNSUPPRESS_UNUSED_WARNINGS\n#endif\n\n#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)\n#define CATCH_TRY if ((true))\n#define CATCH_CATCH_ALL if ((false))\n#define CATCH_CATCH_ANON(type) if ((false))\n#else\n#define CATCH_TRY try\n#define CATCH_CATCH_ALL catch (...)\n#define CATCH_CATCH_ANON(type) catch (type)\n#endif\n\n#if defined(CATCH_INTERNAL_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_NO_TRADITIONAL_MSVC_PREPROCESSOR) && !defined(CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR)\n#define CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR\n#endif\n\n// end catch_compiler_capabilities.h\n#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line\n#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line )\n#ifdef CATCH_CONFIG_COUNTER\n#  define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ )\n#else\n#  define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ )\n#endif\n\n#include <iosfwd>\n#include <string>\n#include <cstdint>\n\n// We need a dummy global operator<< so we can bring it into Catch namespace later\nstruct Catch_global_namespace_dummy {};\nstd::ostream& operator<<(std::ostream&, Catch_global_namespace_dummy);\n\nnamespace Catch {\n\n    struct CaseSensitive { enum Choice {\n        Yes,\n        No\n    }; };\n\n    class NonCopyable {\n        NonCopyable( NonCopyable const& )              = delete;\n        NonCopyable( NonCopyable && )                  = delete;\n        NonCopyable& operator = ( NonCopyable const& ) = delete;\n        NonCopyable& operator = ( NonCopyable && )     = delete;\n\n    protected:\n        NonCopyable();\n        virtual ~NonCopyable();\n    };\n\n    struct SourceLineInfo {\n\n        SourceLineInfo() = delete;\n        SourceLineInfo( char const* _file, std::size_t _line ) noexcept\n        :   file( _file ),\n            line( _line )\n        {}\n\n        SourceLineInfo( SourceLineInfo const& other )        = default;\n        SourceLineInfo( SourceLineInfo && )                  = default;\n        SourceLineInfo& operator = ( SourceLineInfo const& ) = default;\n        SourceLineInfo& operator = ( SourceLineInfo && )     = default;\n\n        bool empty() const noexcept;\n        bool operator == ( SourceLineInfo const& other ) const noexcept;\n        bool operator < ( SourceLineInfo const& other ) const noexcept;\n\n        char const* file;\n        std::size_t line;\n    };\n\n    std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info );\n\n    // Bring in operator<< from global namespace into Catch namespace\n    // This is necessary because the overload of operator<< above makes\n    // lookup stop at namespace Catch\n    using ::operator<<;\n\n    // Use this in variadic streaming macros to allow\n    //    >> +StreamEndStop\n    // as well as\n    //    >> stuff +StreamEndStop\n    struct StreamEndStop {\n        std::string operator+() const;\n    };\n    template<typename T>\n    T const& operator + ( T const& value, StreamEndStop ) {\n        return value;\n    }\n}\n\n#define CATCH_INTERNAL_LINEINFO \\\n    ::Catch::SourceLineInfo( __FILE__, static_cast<std::size_t>( __LINE__ ) )\n\n// end catch_common.h\nnamespace Catch {\n\n    struct RegistrarForTagAliases {\n        RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo );\n    };\n\n} // end namespace Catch\n\n#define CATCH_REGISTER_TAG_ALIAS( alias, spec ) \\\n    CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \\\n    namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } \\\n    CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS\n\n// end catch_tag_alias_autoregistrar.h\n// start catch_test_registry.h\n\n// start catch_interfaces_testcase.h\n\n#include <vector>\n#include <memory>\n\nnamespace Catch {\n\n    class TestSpec;\n\n    struct ITestInvoker {\n        virtual void invoke () const = 0;\n        virtual ~ITestInvoker();\n    };\n\n    using ITestCasePtr = std::shared_ptr<ITestInvoker>;\n\n    class TestCase;\n    struct IConfig;\n\n    struct ITestCaseRegistry {\n        virtual ~ITestCaseRegistry();\n        virtual std::vector<TestCase> const& getAllTests() const = 0;\n        virtual std::vector<TestCase> const& getAllTestsSorted( IConfig const& config ) const = 0;\n    };\n\n    bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config );\n    std::vector<TestCase> filterTests( std::vector<TestCase> const& testCases, TestSpec const& testSpec, IConfig const& config );\n    std::vector<TestCase> const& getAllTestCasesSorted( IConfig const& config );\n\n}\n\n// end catch_interfaces_testcase.h\n// start catch_stringref.h\n\n#include <cstddef>\n#include <string>\n#include <iosfwd>\n\nnamespace Catch {\n\n    class StringData;\n\n    /// A non-owning string class (similar to the forthcoming std::string_view)\n    /// Note that, because a StringRef may be a substring of another string,\n    /// it may not be null terminated. c_str() must return a null terminated\n    /// string, however, and so the StringRef will internally take ownership\n    /// (taking a copy), if necessary. In theory this ownership is not externally\n    /// visible - but it does mean (substring) StringRefs should not be shared between\n    /// threads.\n    class StringRef {\n    public:\n        using size_type = std::size_t;\n\n    private:\n        friend struct StringRefTestAccess;\n\n        char const* m_start;\n        size_type m_size;\n\n        char* m_data = nullptr;\n\n        void takeOwnership();\n\n        static constexpr char const* const s_empty = \"\";\n\n    public: // construction/ assignment\n        StringRef() noexcept\n        :   StringRef( s_empty, 0 )\n        {}\n\n        StringRef( StringRef const& other ) noexcept\n        :   m_start( other.m_start ),\n            m_size( other.m_size )\n        {}\n\n        StringRef( StringRef&& other ) noexcept\n        :   m_start( other.m_start ),\n            m_size( other.m_size ),\n            m_data( other.m_data )\n        {\n            other.m_data = nullptr;\n        }\n\n        StringRef( char const* rawChars ) noexcept;\n\n        StringRef( char const* rawChars, size_type size ) noexcept\n        :   m_start( rawChars ),\n            m_size( size )\n        {}\n\n        StringRef( std::string const& stdString ) noexcept\n        :   m_start( stdString.c_str() ),\n            m_size( stdString.size() )\n        {}\n\n        ~StringRef() noexcept {\n            delete[] m_data;\n        }\n\n        auto operator = ( StringRef const &other ) noexcept -> StringRef& {\n            delete[] m_data;\n            m_data = nullptr;\n            m_start = other.m_start;\n            m_size = other.m_size;\n            return *this;\n        }\n\n        operator std::string() const;\n\n        void swap( StringRef& other ) noexcept;\n\n    public: // operators\n        auto operator == ( StringRef const& other ) const noexcept -> bool;\n        auto operator != ( StringRef const& other ) const noexcept -> bool;\n\n        auto operator[] ( size_type index ) const noexcept -> char;\n\n    public: // named queries\n        auto empty() const noexcept -> bool {\n            return m_size == 0;\n        }\n        auto size() const noexcept -> size_type {\n            return m_size;\n        }\n\n        auto numberOfCharacters() const noexcept -> size_type;\n        auto c_str() const -> char const*;\n\n    public: // substrings and searches\n        auto substr( size_type start, size_type size ) const noexcept -> StringRef;\n\n        // Returns the current start pointer.\n        // Note that the pointer can change when if the StringRef is a substring\n        auto currentData() const noexcept -> char const*;\n\n    private: // ownership queries - may not be consistent between calls\n        auto isOwned() const noexcept -> bool;\n        auto isSubstring() const noexcept -> bool;\n    };\n\n    auto operator + ( StringRef const& lhs, StringRef const& rhs ) -> std::string;\n    auto operator + ( StringRef const& lhs, char const* rhs ) -> std::string;\n    auto operator + ( char const* lhs, StringRef const& rhs ) -> std::string;\n\n    auto operator += ( std::string& lhs, StringRef const& sr ) -> std::string&;\n    auto operator << ( std::ostream& os, StringRef const& sr ) -> std::ostream&;\n\n    inline auto operator \"\" _sr( char const* rawChars, std::size_t size ) noexcept -> StringRef {\n        return StringRef( rawChars, size );\n    }\n\n} // namespace Catch\n\ninline auto operator \"\" _catch_sr( char const* rawChars, std::size_t size ) noexcept -> Catch::StringRef {\n    return Catch::StringRef( rawChars, size );\n}\n\n// end catch_stringref.h\n// start catch_type_traits.hpp\n\n\nnamespace Catch{\n\n#ifdef CATCH_CPP17_OR_GREATER\n\ttemplate <typename...>\n\tinline constexpr auto is_unique = std::true_type{};\n\n\ttemplate <typename T, typename... Rest>\n\tinline constexpr auto is_unique<T, Rest...> = std::bool_constant<\n\t\t(!std::is_same_v<T, Rest> && ...) && is_unique<Rest...>\n\t>{};\n#else\n\ntemplate <typename...>\nstruct is_unique : std::true_type{};\n\ntemplate <typename T0, typename T1, typename... Rest>\nstruct is_unique<T0, T1, Rest...> : std::integral_constant\n<bool,\n     !std::is_same<T0, T1>::value\n     && is_unique<T0, Rest...>::value\n     && is_unique<T1, Rest...>::value\n>{};\n\n#endif\n}\n\n// end catch_type_traits.hpp\n// start catch_preprocessor.hpp\n\n\n#define CATCH_RECURSION_LEVEL0(...) __VA_ARGS__\n#define CATCH_RECURSION_LEVEL1(...) CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(CATCH_RECURSION_LEVEL0(__VA_ARGS__)))\n#define CATCH_RECURSION_LEVEL2(...) CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(CATCH_RECURSION_LEVEL1(__VA_ARGS__)))\n#define CATCH_RECURSION_LEVEL3(...) CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(CATCH_RECURSION_LEVEL2(__VA_ARGS__)))\n#define CATCH_RECURSION_LEVEL4(...) CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(CATCH_RECURSION_LEVEL3(__VA_ARGS__)))\n#define CATCH_RECURSION_LEVEL5(...) CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(CATCH_RECURSION_LEVEL4(__VA_ARGS__)))\n\n#ifdef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR\n#define INTERNAL_CATCH_EXPAND_VARGS(...) __VA_ARGS__\n// MSVC needs more evaluations\n#define CATCH_RECURSION_LEVEL6(...) CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(CATCH_RECURSION_LEVEL5(__VA_ARGS__)))\n#define CATCH_RECURSE(...)  CATCH_RECURSION_LEVEL6(CATCH_RECURSION_LEVEL6(__VA_ARGS__))\n#else\n#define CATCH_RECURSE(...)  CATCH_RECURSION_LEVEL5(__VA_ARGS__)\n#endif\n\n#define CATCH_REC_END(...)\n#define CATCH_REC_OUT\n\n#define CATCH_EMPTY()\n#define CATCH_DEFER(id) id CATCH_EMPTY()\n\n#define CATCH_REC_GET_END2() 0, CATCH_REC_END\n#define CATCH_REC_GET_END1(...) CATCH_REC_GET_END2\n#define CATCH_REC_GET_END(...) CATCH_REC_GET_END1\n#define CATCH_REC_NEXT0(test, next, ...) next CATCH_REC_OUT\n#define CATCH_REC_NEXT1(test, next) CATCH_DEFER ( CATCH_REC_NEXT0 ) ( test, next, 0)\n#define CATCH_REC_NEXT(test, next)  CATCH_REC_NEXT1(CATCH_REC_GET_END test, next)\n\n#define CATCH_REC_LIST0(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ )\n#define CATCH_REC_LIST1(f, x, peek, ...) , f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0) ) ( f, peek, __VA_ARGS__ )\n#define CATCH_REC_LIST2(f, x, peek, ...)   f(x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1) ) ( f, peek, __VA_ARGS__ )\n\n#define CATCH_REC_LIST0_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ )\n#define CATCH_REC_LIST1_UD(f, userdata, x, peek, ...) , f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST0_UD) ) ( f, userdata, peek, __VA_ARGS__ )\n#define CATCH_REC_LIST2_UD(f, userdata, x, peek, ...)   f(userdata, x) CATCH_DEFER ( CATCH_REC_NEXT(peek, CATCH_REC_LIST1_UD) ) ( f, userdata, peek, __VA_ARGS__ )\n\n// Applies the function macro `f` to each of the remaining parameters, inserts commas between the results,\n// and passes userdata as the first parameter to each invocation,\n// e.g. CATCH_REC_LIST_UD(f, x, a, b, c) evaluates to f(x, a), f(x, b), f(x, c)\n#define CATCH_REC_LIST_UD(f, userdata, ...) CATCH_RECURSE(CATCH_REC_LIST2_UD(f, userdata, __VA_ARGS__, ()()(), ()()(), ()()(), 0))\n\n#define CATCH_REC_LIST(f, ...) CATCH_RECURSE(CATCH_REC_LIST2(f, __VA_ARGS__, ()()(), ()()(), ()()(), 0))\n\n#define INTERNAL_CATCH_EXPAND1(param) INTERNAL_CATCH_EXPAND2(param)\n#define INTERNAL_CATCH_EXPAND2(...) INTERNAL_CATCH_NO## __VA_ARGS__\n#define INTERNAL_CATCH_DEF(...) INTERNAL_CATCH_DEF __VA_ARGS__\n#define INTERNAL_CATCH_NOINTERNAL_CATCH_DEF\n\n#define INTERNAL_CATCH_REMOVE_PARENS(...) INTERNAL_CATCH_EXPAND1(INTERNAL_CATCH_DEF __VA_ARGS__)\n\n#define INTERNAL_CATCH_TEMPLATE_UNIQUE_NAME2(Name, ...) INTERNAL_CATCH_TEMPLATE_UNIQUE_NAME3(Name, __VA_ARGS__)\n#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR\n#define INTERNAL_CATCH_TEMPLATE_UNIQUE_NAME3(Name,...) Name \" - \" #__VA_ARGS__\n#define INTERNAL_CATCH_TEMPLATE_UNIQUE_NAME(Name,...) INTERNAL_CATCH_TEMPLATE_UNIQUE_NAME2(Name, INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__))\n#else\n// MSVC is adding extra space and needs more calls to properly remove ()\n#define INTERNAL_CATCH_TEMPLATE_UNIQUE_NAME3(Name,...) Name \" -\" #__VA_ARGS__\n#define INTERNAL_CATCH_TEMPLATE_UNIQUE_NAME1(Name, ...) INTERNAL_CATCH_TEMPLATE_UNIQUE_NAME2(Name, __VA_ARGS__)\n#define INTERNAL_CATCH_TEMPLATE_UNIQUE_NAME(Name, ...) INTERNAL_CATCH_TEMPLATE_UNIQUE_NAME1(Name, INTERNAL_CATCH_EXPAND_VARGS(INTERNAL_CATCH_REMOVE_PARENS(__VA_ARGS__)))\n#endif\n\n// end catch_preprocessor.hpp\nnamespace Catch {\n\ntemplate<typename C>\nclass TestInvokerAsMethod : public ITestInvoker {\n    void (C::*m_testAsMethod)();\npublic:\n    TestInvokerAsMethod( void (C::*testAsMethod)() ) noexcept : m_testAsMethod( testAsMethod ) {}\n\n    void invoke() const override {\n        C obj;\n        (obj.*m_testAsMethod)();\n    }\n};\n\nauto makeTestInvoker( void(*testAsFunction)() ) noexcept -> ITestInvoker*;\n\ntemplate<typename C>\nauto makeTestInvoker( void (C::*testAsMethod)() ) noexcept -> ITestInvoker* {\n    return new(std::nothrow) TestInvokerAsMethod<C>( testAsMethod );\n}\n\nstruct NameAndTags {\n    NameAndTags( StringRef const& name_ = StringRef(), StringRef const& tags_ = StringRef() ) noexcept;\n    StringRef name;\n    StringRef tags;\n};\n\nstruct AutoReg : NonCopyable {\n    AutoReg( ITestInvoker* invoker, SourceLineInfo const& lineInfo, StringRef const& classOrMethod, NameAndTags const& nameAndTags ) noexcept;\n    ~AutoReg();\n};\n\n} // end namespace Catch\n\n#if defined(CATCH_CONFIG_DISABLE)\n    #define INTERNAL_CATCH_TESTCASE_NO_REGISTRATION( TestName, ... ) \\\n        static void TestName()\n    #define INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION( TestName, ClassName, ... ) \\\n        namespace{                        \\\n            struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \\\n                void test();              \\\n            };                            \\\n        }                                 \\\n        void TestName::test()\n    #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION( TestName, ... )  \\\n        template<typename TestType>                                             \\\n        static void TestName()\n    #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION( TestName, ClassName, ... )    \\\n        namespace{                                                                                  \\\n            template<typename TestType>                                                             \\\n            struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName <TestType>) {     \\\n                void test();                                                                        \\\n            };                                                                                      \\\n        }                                                                                           \\\n        template<typename TestType>                                                                 \\\n        void TestName::test()\n#endif\n\n    ///////////////////////////////////////////////////////////////////////////////\n    #define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \\\n        static void TestName(); \\\n        CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \\\n        namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &TestName ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \\\n        CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \\\n        static void TestName()\n    #define INTERNAL_CATCH_TESTCASE( ... ) \\\n        INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), __VA_ARGS__ )\n\n    ///////////////////////////////////////////////////////////////////////////////\n    #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \\\n        CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \\\n        namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &QualifiedMethod ), CATCH_INTERNAL_LINEINFO, \"&\" #QualifiedMethod, Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \\\n        CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS\n\n    ///////////////////////////////////////////////////////////////////////////////\n    #define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\\\n        CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \\\n        namespace{ \\\n            struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName) { \\\n                void test(); \\\n            }; \\\n            Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( Catch::makeTestInvoker( &TestName::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \\\n        } \\\n        CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \\\n        void TestName::test()\n    #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \\\n        INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, __VA_ARGS__ )\n\n    ///////////////////////////////////////////////////////////////////////////////\n    #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \\\n        CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \\\n        Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( Function ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \\\n        CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS\n\n    ///////////////////////////////////////////////////////////////////////////////\n    #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_2(TestName, TestFunc, Name, Tags, ... )\\\n        CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \\\n        template<typename TestType> \\\n        static void TestFunc();\\\n        namespace {\\\n            template<typename...Types> \\\n            struct TestName{\\\n                template<typename...Ts> \\\n                TestName(Ts...names){\\\n                    CATCH_INTERNAL_CHECK_UNIQUE_TYPES(CATCH_REC_LIST(INTERNAL_CATCH_REMOVE_PARENS, __VA_ARGS__)) \\\n                    using expander = int[];\\\n                    (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestFunc<Types> ), CATCH_INTERNAL_LINEINFO, Catch::StringRef(), Catch::NameAndTags{ names, Tags } ), 0)... };/* NOLINT */ \\\n                }\\\n            };\\\n            INTERNAL_CATCH_TEMPLATE_REGISTRY_INITIATE(TestName, Name, __VA_ARGS__) \\\n        }\\\n        CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \\\n        template<typename TestType> \\\n        static void TestFunc()\n\n#if defined(CATCH_CPP17_OR_GREATER)\n#define CATCH_INTERNAL_CHECK_UNIQUE_TYPES(...) static_assert(Catch::is_unique<__VA_ARGS__>,\"Duplicate type detected in declaration of template test case\");\n#else\n#define CATCH_INTERNAL_CHECK_UNIQUE_TYPES(...) static_assert(Catch::is_unique<__VA_ARGS__>::value,\"Duplicate type detected in declaration of template test case\");\n#endif\n\n#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR\n    #define INTERNAL_CATCH_TEMPLATE_TEST_CASE(Name, Tags, ...) \\\n        INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, __VA_ARGS__ )\n#else\n    #define INTERNAL_CATCH_TEMPLATE_TEST_CASE(Name, Tags, ...) \\\n        INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____F_U_N_C____ ), Name, Tags, __VA_ARGS__ ) )\n#endif\n\n    #define INTERNAL_CATCH_TEMPLATE_REGISTRY_INITIATE(TestName, Name, ...)\\\n        static int INTERNAL_CATCH_UNIQUE_NAME( globalRegistrar ) = [](){\\\n            TestName<CATCH_REC_LIST(INTERNAL_CATCH_REMOVE_PARENS, __VA_ARGS__)>(CATCH_REC_LIST_UD(INTERNAL_CATCH_TEMPLATE_UNIQUE_NAME,Name, __VA_ARGS__));\\\n            return 0;\\\n        }();\n\n    #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( TestNameClass, TestName, ClassName, Name, Tags, ... ) \\\n        CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \\\n        namespace{ \\\n            template<typename TestType> \\\n            struct TestName : INTERNAL_CATCH_REMOVE_PARENS(ClassName <TestType>) { \\\n                void test();\\\n            };\\\n            template<typename...Types> \\\n            struct TestNameClass{\\\n                template<typename...Ts> \\\n                TestNameClass(Ts...names){\\\n                    CATCH_INTERNAL_CHECK_UNIQUE_TYPES(CATCH_REC_LIST(INTERNAL_CATCH_REMOVE_PARENS, __VA_ARGS__)) \\\n                    using expander = int[];\\\n                    (void)expander{(Catch::AutoReg( Catch::makeTestInvoker( &TestName<Types>::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ names, Tags } ), 0)... };/* NOLINT */ \\\n                }\\\n            };\\\n            INTERNAL_CATCH_TEMPLATE_REGISTRY_INITIATE(TestNameClass, Name, __VA_ARGS__)\\\n        }\\\n        CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS\\\n        template<typename TestType> \\\n        void TestName<TestType>::test()\n\n#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR\n    #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( ClassName, Name, Tags,... ) \\\n        INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, __VA_ARGS__ )\n#else\n    #define INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( ClassName, Name, Tags,... ) \\\n        INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____C_L_A_S_S____ ), INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) , ClassName, Name, Tags, __VA_ARGS__ ) )\n#endif\n\n// end catch_test_registry.h\n// start catch_capture.hpp\n\n// start catch_assertionhandler.h\n\n// start catch_assertioninfo.h\n\n// start catch_result_type.h\n\nnamespace Catch {\n\n    // ResultWas::OfType enum\n    struct ResultWas { enum OfType {\n        Unknown = -1,\n        Ok = 0,\n        Info = 1,\n        Warning = 2,\n\n        FailureBit = 0x10,\n\n        ExpressionFailed = FailureBit | 1,\n        ExplicitFailure = FailureBit | 2,\n\n        Exception = 0x100 | FailureBit,\n\n        ThrewException = Exception | 1,\n        DidntThrowException = Exception | 2,\n\n        FatalErrorCondition = 0x200 | FailureBit\n\n    }; };\n\n    bool isOk( ResultWas::OfType resultType );\n    bool isJustInfo( int flags );\n\n    // ResultDisposition::Flags enum\n    struct ResultDisposition { enum Flags {\n        Normal = 0x01,\n\n        ContinueOnFailure = 0x02,   // Failures fail test, but execution continues\n        FalseTest = 0x04,           // Prefix expression with !\n        SuppressFail = 0x08         // Failures are reported but do not fail the test\n    }; };\n\n    ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs );\n\n    bool shouldContinueOnFailure( int flags );\n    inline bool isFalseTest( int flags ) { return ( flags & ResultDisposition::FalseTest ) != 0; }\n    bool shouldSuppressFailure( int flags );\n\n} // end namespace Catch\n\n// end catch_result_type.h\nnamespace Catch {\n\n    struct AssertionInfo\n    {\n        StringRef macroName;\n        SourceLineInfo lineInfo;\n        StringRef capturedExpression;\n        ResultDisposition::Flags resultDisposition;\n\n        // We want to delete this constructor but a compiler bug in 4.8 means\n        // the struct is then treated as non-aggregate\n        //AssertionInfo() = delete;\n    };\n\n} // end namespace Catch\n\n// end catch_assertioninfo.h\n// start catch_decomposer.h\n\n// start catch_tostring.h\n\n#include <vector>\n#include <cstddef>\n#include <type_traits>\n#include <string>\n// start catch_stream.h\n\n#include <iosfwd>\n#include <cstddef>\n#include <ostream>\n\nnamespace Catch {\n\n    std::ostream& cout();\n    std::ostream& cerr();\n    std::ostream& clog();\n\n    class StringRef;\n\n    struct IStream {\n        virtual ~IStream();\n        virtual std::ostream& stream() const = 0;\n    };\n\n    auto makeStream( StringRef const &filename ) -> IStream const*;\n\n    class ReusableStringStream {\n        std::size_t m_index;\n        std::ostream* m_oss;\n    public:\n        ReusableStringStream();\n        ~ReusableStringStream();\n\n        auto str() const -> std::string;\n\n        template<typename T>\n        auto operator << ( T const& value ) -> ReusableStringStream& {\n            *m_oss << value;\n            return *this;\n        }\n        auto get() -> std::ostream& { return *m_oss; }\n    };\n}\n\n// end catch_stream.h\n\n#ifdef CATCH_CONFIG_CPP17_STRING_VIEW\n#include <string_view>\n#endif\n\n#ifdef __OBJC__\n// start catch_objc_arc.hpp\n\n#import <Foundation/Foundation.h>\n\n#ifdef __has_feature\n#define CATCH_ARC_ENABLED __has_feature(objc_arc)\n#else\n#define CATCH_ARC_ENABLED 0\n#endif\n\nvoid arcSafeRelease( NSObject* obj );\nid performOptionalSelector( id obj, SEL sel );\n\n#if !CATCH_ARC_ENABLED\ninline void arcSafeRelease( NSObject* obj ) {\n    [obj release];\n}\ninline id performOptionalSelector( id obj, SEL sel ) {\n    if( [obj respondsToSelector: sel] )\n        return [obj performSelector: sel];\n    return nil;\n}\n#define CATCH_UNSAFE_UNRETAINED\n#define CATCH_ARC_STRONG\n#else\ninline void arcSafeRelease( NSObject* ){}\ninline id performOptionalSelector( id obj, SEL sel ) {\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Warc-performSelector-leaks\"\n#endif\n    if( [obj respondsToSelector: sel] )\n        return [obj performSelector: sel];\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n    return nil;\n}\n#define CATCH_UNSAFE_UNRETAINED __unsafe_unretained\n#define CATCH_ARC_STRONG __strong\n#endif\n\n// end catch_objc_arc.hpp\n#endif\n\n#ifdef _MSC_VER\n#pragma warning(push)\n#pragma warning(disable:4180) // We attempt to stream a function (address) by const&, which MSVC complains about but is harmless\n#endif\n\nnamespace Catch {\n    namespace Detail {\n\n        extern const std::string unprintableString;\n\n        std::string rawMemoryToString( const void *object, std::size_t size );\n\n        template<typename T>\n        std::string rawMemoryToString( const T& object ) {\n          return rawMemoryToString( &object, sizeof(object) );\n        }\n\n        template<typename T>\n        class IsStreamInsertable {\n            template<typename SS, typename TT>\n            static auto test(int)\n                -> decltype(std::declval<SS&>() << std::declval<TT>(), std::true_type());\n\n            template<typename, typename>\n            static auto test(...)->std::false_type;\n\n        public:\n            static const bool value = decltype(test<std::ostream, const T&>(0))::value;\n        };\n\n        template<typename E>\n        std::string convertUnknownEnumToString( E e );\n\n        template<typename T>\n        typename std::enable_if<\n            !std::is_enum<T>::value && !std::is_base_of<std::exception, T>::value,\n        std::string>::type convertUnstreamable( T const& ) {\n            return Detail::unprintableString;\n        }\n        template<typename T>\n        typename std::enable_if<\n            !std::is_enum<T>::value && std::is_base_of<std::exception, T>::value,\n         std::string>::type convertUnstreamable(T const& ex) {\n            return ex.what();\n        }\n\n        template<typename T>\n        typename std::enable_if<\n            std::is_enum<T>::value\n        , std::string>::type convertUnstreamable( T const& value ) {\n            return convertUnknownEnumToString( value );\n        }\n\n#if defined(_MANAGED)\n        //! Convert a CLR string to a utf8 std::string\n        template<typename T>\n        std::string clrReferenceToString( T^ ref ) {\n            if (ref == nullptr)\n                return std::string(\"null\");\n            auto bytes = System::Text::Encoding::UTF8->GetBytes(ref->ToString());\n            cli::pin_ptr<System::Byte> p = &bytes[0];\n            return std::string(reinterpret_cast<char const *>(p), bytes->Length);\n        }\n#endif\n\n    } // namespace Detail\n\n    // If we decide for C++14, change these to enable_if_ts\n    template <typename T, typename = void>\n    struct StringMaker {\n        template <typename Fake = T>\n        static\n        typename std::enable_if<::Catch::Detail::IsStreamInsertable<Fake>::value, std::string>::type\n            convert(const Fake& value) {\n                ReusableStringStream rss;\n                // NB: call using the function-like syntax to avoid ambiguity with\n                // user-defined templated operator<< under clang.\n                rss.operator<<(value);\n                return rss.str();\n        }\n\n        template <typename Fake = T>\n        static\n        typename std::enable_if<!::Catch::Detail::IsStreamInsertable<Fake>::value, std::string>::type\n            convert( const Fake& value ) {\n#if !defined(CATCH_CONFIG_FALLBACK_STRINGIFIER)\n            return Detail::convertUnstreamable(value);\n#else\n            return CATCH_CONFIG_FALLBACK_STRINGIFIER(value);\n#endif\n        }\n    };\n\n    namespace Detail {\n\n        // This function dispatches all stringification requests inside of Catch.\n        // Should be preferably called fully qualified, like ::Catch::Detail::stringify\n        template <typename T>\n        std::string stringify(const T& e) {\n            return ::Catch::StringMaker<typename std::remove_cv<typename std::remove_reference<T>::type>::type>::convert(e);\n        }\n\n        template<typename E>\n        std::string convertUnknownEnumToString( E e ) {\n            return ::Catch::Detail::stringify(static_cast<typename std::underlying_type<E>::type>(e));\n        }\n\n#if defined(_MANAGED)\n        template <typename T>\n        std::string stringify( T^ e ) {\n            return ::Catch::StringMaker<T^>::convert(e);\n        }\n#endif\n\n    } // namespace Detail\n\n    // Some predefined specializations\n\n    template<>\n    struct StringMaker<std::string> {\n        static std::string convert(const std::string& str);\n    };\n\n#ifdef CATCH_CONFIG_CPP17_STRING_VIEW\n    template<>\n    struct StringMaker<std::string_view> {\n        static std::string convert(std::string_view str);\n    };\n#endif\n\n    template<>\n    struct StringMaker<char const *> {\n        static std::string convert(char const * str);\n    };\n    template<>\n    struct StringMaker<char *> {\n        static std::string convert(char * str);\n    };\n\n#ifdef CATCH_CONFIG_WCHAR\n    template<>\n    struct StringMaker<std::wstring> {\n        static std::string convert(const std::wstring& wstr);\n    };\n\n# ifdef CATCH_CONFIG_CPP17_STRING_VIEW\n    template<>\n    struct StringMaker<std::wstring_view> {\n        static std::string convert(std::wstring_view str);\n    };\n# endif\n\n    template<>\n    struct StringMaker<wchar_t const *> {\n        static std::string convert(wchar_t const * str);\n    };\n    template<>\n    struct StringMaker<wchar_t *> {\n        static std::string convert(wchar_t * str);\n    };\n#endif\n\n    // TBD: Should we use `strnlen` to ensure that we don't go out of the buffer,\n    //      while keeping string semantics?\n    template<int SZ>\n    struct StringMaker<char[SZ]> {\n        static std::string convert(char const* str) {\n            return ::Catch::Detail::stringify(std::string{ str });\n        }\n    };\n    template<int SZ>\n    struct StringMaker<signed char[SZ]> {\n        static std::string convert(signed char const* str) {\n            return ::Catch::Detail::stringify(std::string{ reinterpret_cast<char const *>(str) });\n        }\n    };\n    template<int SZ>\n    struct StringMaker<unsigned char[SZ]> {\n        static std::string convert(unsigned char const* str) {\n            return ::Catch::Detail::stringify(std::string{ reinterpret_cast<char const *>(str) });\n        }\n    };\n\n    template<>\n    struct StringMaker<int> {\n        static std::string convert(int value);\n    };\n    template<>\n    struct StringMaker<long> {\n        static std::string convert(long value);\n    };\n    template<>\n    struct StringMaker<long long> {\n        static std::string convert(long long value);\n    };\n    template<>\n    struct StringMaker<unsigned int> {\n        static std::string convert(unsigned int value);\n    };\n    template<>\n    struct StringMaker<unsigned long> {\n        static std::string convert(unsigned long value);\n    };\n    template<>\n    struct StringMaker<unsigned long long> {\n        static std::string convert(unsigned long long value);\n    };\n\n    template<>\n    struct StringMaker<bool> {\n        static std::string convert(bool b);\n    };\n\n    template<>\n    struct StringMaker<char> {\n        static std::string convert(char c);\n    };\n    template<>\n    struct StringMaker<signed char> {\n        static std::string convert(signed char c);\n    };\n    template<>\n    struct StringMaker<unsigned char> {\n        static std::string convert(unsigned char c);\n    };\n\n    template<>\n    struct StringMaker<std::nullptr_t> {\n        static std::string convert(std::nullptr_t);\n    };\n\n    template<>\n    struct StringMaker<float> {\n        static std::string convert(float value);\n    };\n    template<>\n    struct StringMaker<double> {\n        static std::string convert(double value);\n    };\n\n    template <typename T>\n    struct StringMaker<T*> {\n        template <typename U>\n        static std::string convert(U* p) {\n            if (p) {\n                return ::Catch::Detail::rawMemoryToString(p);\n            } else {\n                return \"nullptr\";\n            }\n        }\n    };\n\n    template <typename R, typename C>\n    struct StringMaker<R C::*> {\n        static std::string convert(R C::* p) {\n            if (p) {\n                return ::Catch::Detail::rawMemoryToString(p);\n            } else {\n                return \"nullptr\";\n            }\n        }\n    };\n\n#if defined(_MANAGED)\n    template <typename T>\n    struct StringMaker<T^> {\n        static std::string convert( T^ ref ) {\n            return ::Catch::Detail::clrReferenceToString(ref);\n        }\n    };\n#endif\n\n    namespace Detail {\n        template<typename InputIterator>\n        std::string rangeToString(InputIterator first, InputIterator last) {\n            ReusableStringStream rss;\n            rss << \"{ \";\n            if (first != last) {\n                rss << ::Catch::Detail::stringify(*first);\n                for (++first; first != last; ++first)\n                    rss << \", \" << ::Catch::Detail::stringify(*first);\n            }\n            rss << \" }\";\n            return rss.str();\n        }\n    }\n\n#ifdef __OBJC__\n    template<>\n    struct StringMaker<NSString*> {\n        static std::string convert(NSString * nsstring) {\n            if (!nsstring)\n                return \"nil\";\n            return std::string(\"@\") + [nsstring UTF8String];\n        }\n    };\n    template<>\n    struct StringMaker<NSObject*> {\n        static std::string convert(NSObject* nsObject) {\n            return ::Catch::Detail::stringify([nsObject description]);\n        }\n\n    };\n    namespace Detail {\n        inline std::string stringify( NSString* nsstring ) {\n            return StringMaker<NSString*>::convert( nsstring );\n        }\n\n    } // namespace Detail\n#endif // __OBJC__\n\n} // namespace Catch\n\n//////////////////////////////////////////////////////\n// Separate std-lib types stringification, so it can be selectively enabled\n// This means that we do not bring in\n\n#if defined(CATCH_CONFIG_ENABLE_ALL_STRINGMAKERS)\n#  define CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER\n#  define CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER\n#  define CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER\n#  define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER\n#endif\n\n// Separate std::pair specialization\n#if defined(CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER)\n#include <utility>\nnamespace Catch {\n    template<typename T1, typename T2>\n    struct StringMaker<std::pair<T1, T2> > {\n        static std::string convert(const std::pair<T1, T2>& pair) {\n            ReusableStringStream rss;\n            rss << \"{ \"\n                << ::Catch::Detail::stringify(pair.first)\n                << \", \"\n                << ::Catch::Detail::stringify(pair.second)\n                << \" }\";\n            return rss.str();\n        }\n    };\n}\n#endif // CATCH_CONFIG_ENABLE_PAIR_STRINGMAKER\n\n// Separate std::tuple specialization\n#if defined(CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER)\n#include <tuple>\nnamespace Catch {\n    namespace Detail {\n        template<\n            typename Tuple,\n            std::size_t N = 0,\n            bool = (N < std::tuple_size<Tuple>::value)\n            >\n            struct TupleElementPrinter {\n            static void print(const Tuple& tuple, std::ostream& os) {\n                os << (N ? \", \" : \" \")\n                    << ::Catch::Detail::stringify(std::get<N>(tuple));\n                TupleElementPrinter<Tuple, N + 1>::print(tuple, os);\n            }\n        };\n\n        template<\n            typename Tuple,\n            std::size_t N\n        >\n            struct TupleElementPrinter<Tuple, N, false> {\n            static void print(const Tuple&, std::ostream&) {}\n        };\n\n    }\n\n    template<typename ...Types>\n    struct StringMaker<std::tuple<Types...>> {\n        static std::string convert(const std::tuple<Types...>& tuple) {\n            ReusableStringStream rss;\n            rss << '{';\n            Detail::TupleElementPrinter<std::tuple<Types...>>::print(tuple, rss.get());\n            rss << \" }\";\n            return rss.str();\n        }\n    };\n}\n#endif // CATCH_CONFIG_ENABLE_TUPLE_STRINGMAKER\n\n#if defined(CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER) && defined(CATCH_CONFIG_CPP17_VARIANT)\n#include <variant>\nnamespace Catch {\n    template<>\n    struct StringMaker<std::monostate> {\n        static std::string convert(const std::monostate&) {\n            return \"{ }\";\n        }\n    };\n\n    template<typename... Elements>\n    struct StringMaker<std::variant<Elements...>> {\n        static std::string convert(const std::variant<Elements...>& variant) {\n            if (variant.valueless_by_exception()) {\n                return \"{valueless variant}\";\n            } else {\n                return std::visit(\n                    [](const auto& value) {\n                        return ::Catch::Detail::stringify(value);\n                    },\n                    variant\n                );\n            }\n        }\n    };\n}\n#endif // CATCH_CONFIG_ENABLE_VARIANT_STRINGMAKER\n\nnamespace Catch {\n    struct not_this_one {}; // Tag type for detecting which begin/ end are being selected\n\n    // Import begin/ end from std here so they are considered alongside the fallback (...) overloads in this namespace\n    using std::begin;\n    using std::end;\n\n    not_this_one begin( ... );\n    not_this_one end( ... );\n\n    template <typename T>\n    struct is_range {\n        static const bool value =\n            !std::is_same<decltype(begin(std::declval<T>())), not_this_one>::value &&\n            !std::is_same<decltype(end(std::declval<T>())), not_this_one>::value;\n    };\n\n#if defined(_MANAGED) // Managed types are never ranges\n    template <typename T>\n    struct is_range<T^> {\n        static const bool value = false;\n    };\n#endif\n\n    template<typename Range>\n    std::string rangeToString( Range const& range ) {\n        return ::Catch::Detail::rangeToString( begin( range ), end( range ) );\n    }\n\n    // Handle vector<bool> specially\n    template<typename Allocator>\n    std::string rangeToString( std::vector<bool, Allocator> const& v ) {\n        ReusableStringStream rss;\n        rss << \"{ \";\n        bool first = true;\n        for( bool b : v ) {\n            if( first )\n                first = false;\n            else\n                rss << \", \";\n            rss << ::Catch::Detail::stringify( b );\n        }\n        rss << \" }\";\n        return rss.str();\n    }\n\n    template<typename R>\n    struct StringMaker<R, typename std::enable_if<is_range<R>::value && !::Catch::Detail::IsStreamInsertable<R>::value>::type> {\n        static std::string convert( R const& range ) {\n            return rangeToString( range );\n        }\n    };\n\n    template <typename T, int SZ>\n    struct StringMaker<T[SZ]> {\n        static std::string convert(T const(&arr)[SZ]) {\n            return rangeToString(arr);\n        }\n    };\n\n} // namespace Catch\n\n// Separate std::chrono::duration specialization\n#if defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER)\n#include <ctime>\n#include <ratio>\n#include <chrono>\n\nnamespace Catch {\n\ntemplate <class Ratio>\nstruct ratio_string {\n    static std::string symbol();\n};\n\ntemplate <class Ratio>\nstd::string ratio_string<Ratio>::symbol() {\n    Catch::ReusableStringStream rss;\n    rss << '[' << Ratio::num << '/'\n        << Ratio::den << ']';\n    return rss.str();\n}\ntemplate <>\nstruct ratio_string<std::atto> {\n    static std::string symbol();\n};\ntemplate <>\nstruct ratio_string<std::femto> {\n    static std::string symbol();\n};\ntemplate <>\nstruct ratio_string<std::pico> {\n    static std::string symbol();\n};\ntemplate <>\nstruct ratio_string<std::nano> {\n    static std::string symbol();\n};\ntemplate <>\nstruct ratio_string<std::micro> {\n    static std::string symbol();\n};\ntemplate <>\nstruct ratio_string<std::milli> {\n    static std::string symbol();\n};\n\n    ////////////\n    // std::chrono::duration specializations\n    template<typename Value, typename Ratio>\n    struct StringMaker<std::chrono::duration<Value, Ratio>> {\n        static std::string convert(std::chrono::duration<Value, Ratio> const& duration) {\n            ReusableStringStream rss;\n            rss << duration.count() << ' ' << ratio_string<Ratio>::symbol() << 's';\n            return rss.str();\n        }\n    };\n    template<typename Value>\n    struct StringMaker<std::chrono::duration<Value, std::ratio<1>>> {\n        static std::string convert(std::chrono::duration<Value, std::ratio<1>> const& duration) {\n            ReusableStringStream rss;\n            rss << duration.count() << \" s\";\n            return rss.str();\n        }\n    };\n    template<typename Value>\n    struct StringMaker<std::chrono::duration<Value, std::ratio<60>>> {\n        static std::string convert(std::chrono::duration<Value, std::ratio<60>> const& duration) {\n            ReusableStringStream rss;\n            rss << duration.count() << \" m\";\n            return rss.str();\n        }\n    };\n    template<typename Value>\n    struct StringMaker<std::chrono::duration<Value, std::ratio<3600>>> {\n        static std::string convert(std::chrono::duration<Value, std::ratio<3600>> const& duration) {\n            ReusableStringStream rss;\n            rss << duration.count() << \" h\";\n            return rss.str();\n        }\n    };\n\n    ////////////\n    // std::chrono::time_point specialization\n    // Generic time_point cannot be specialized, only std::chrono::time_point<system_clock>\n    template<typename Clock, typename Duration>\n    struct StringMaker<std::chrono::time_point<Clock, Duration>> {\n        static std::string convert(std::chrono::time_point<Clock, Duration> const& time_point) {\n            return ::Catch::Detail::stringify(time_point.time_since_epoch()) + \" since epoch\";\n        }\n    };\n    // std::chrono::time_point<system_clock> specialization\n    template<typename Duration>\n    struct StringMaker<std::chrono::time_point<std::chrono::system_clock, Duration>> {\n        static std::string convert(std::chrono::time_point<std::chrono::system_clock, Duration> const& time_point) {\n            auto converted = std::chrono::system_clock::to_time_t(time_point);\n\n#ifdef _MSC_VER\n            std::tm timeInfo = {};\n            gmtime_s(&timeInfo, &converted);\n#else\n            std::tm* timeInfo = std::gmtime(&converted);\n#endif\n\n            auto const timeStampSize = sizeof(\"2017-01-16T17:06:45Z\");\n            char timeStamp[timeStampSize];\n            const char * const fmt = \"%Y-%m-%dT%H:%M:%SZ\";\n\n#ifdef _MSC_VER\n            std::strftime(timeStamp, timeStampSize, fmt, &timeInfo);\n#else\n            std::strftime(timeStamp, timeStampSize, fmt, timeInfo);\n#endif\n            return std::string(timeStamp);\n        }\n    };\n}\n#endif // CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER\n\n#ifdef _MSC_VER\n#pragma warning(pop)\n#endif\n\n// end catch_tostring.h\n#include <iosfwd>\n\n#ifdef _MSC_VER\n#pragma warning(push)\n#pragma warning(disable:4389) // '==' : signed/unsigned mismatch\n#pragma warning(disable:4018) // more \"signed/unsigned mismatch\"\n#pragma warning(disable:4312) // Converting int to T* using reinterpret_cast (issue on x64 platform)\n#pragma warning(disable:4180) // qualifier applied to function type has no meaning\n#endif\n\nnamespace Catch {\n\n    struct ITransientExpression {\n        auto isBinaryExpression() const -> bool { return m_isBinaryExpression; }\n        auto getResult() const -> bool { return m_result; }\n        virtual void streamReconstructedExpression( std::ostream &os ) const = 0;\n\n        ITransientExpression( bool isBinaryExpression, bool result )\n        :   m_isBinaryExpression( isBinaryExpression ),\n            m_result( result )\n        {}\n\n        // We don't actually need a virtual destructor, but many static analyzers\n        // complain if it's not here :-(\n        virtual ~ITransientExpression();\n\n        bool m_isBinaryExpression;\n        bool m_result;\n\n    };\n\n    void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs );\n\n    template<typename LhsT, typename RhsT>\n    class BinaryExpr  : public ITransientExpression {\n        LhsT m_lhs;\n        StringRef m_op;\n        RhsT m_rhs;\n\n        void streamReconstructedExpression( std::ostream &os ) const override {\n            formatReconstructedExpression\n                    ( os, Catch::Detail::stringify( m_lhs ), m_op, Catch::Detail::stringify( m_rhs ) );\n        }\n\n    public:\n        BinaryExpr( bool comparisonResult, LhsT lhs, StringRef op, RhsT rhs )\n        :   ITransientExpression{ true, comparisonResult },\n            m_lhs( lhs ),\n            m_op( op ),\n            m_rhs( rhs )\n        {}\n    };\n\n    template<typename LhsT>\n    class UnaryExpr : public ITransientExpression {\n        LhsT m_lhs;\n\n        void streamReconstructedExpression( std::ostream &os ) const override {\n            os << Catch::Detail::stringify( m_lhs );\n        }\n\n    public:\n        explicit UnaryExpr( LhsT lhs )\n        :   ITransientExpression{ false, lhs ? true : false },\n            m_lhs( lhs )\n        {}\n    };\n\n    // Specialised comparison functions to handle equality comparisons between ints and pointers (NULL deduces as an int)\n    template<typename LhsT, typename RhsT>\n    auto compareEqual( LhsT const& lhs, RhsT const& rhs ) -> bool { return static_cast<bool>(lhs == rhs); }\n    template<typename T>\n    auto compareEqual( T* const& lhs, int rhs ) -> bool { return lhs == reinterpret_cast<void const*>( rhs ); }\n    template<typename T>\n    auto compareEqual( T* const& lhs, long rhs ) -> bool { return lhs == reinterpret_cast<void const*>( rhs ); }\n    template<typename T>\n    auto compareEqual( int lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) == rhs; }\n    template<typename T>\n    auto compareEqual( long lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) == rhs; }\n\n    template<typename LhsT, typename RhsT>\n    auto compareNotEqual( LhsT const& lhs, RhsT&& rhs ) -> bool { return static_cast<bool>(lhs != rhs); }\n    template<typename T>\n    auto compareNotEqual( T* const& lhs, int rhs ) -> bool { return lhs != reinterpret_cast<void const*>( rhs ); }\n    template<typename T>\n    auto compareNotEqual( T* const& lhs, long rhs ) -> bool { return lhs != reinterpret_cast<void const*>( rhs ); }\n    template<typename T>\n    auto compareNotEqual( int lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) != rhs; }\n    template<typename T>\n    auto compareNotEqual( long lhs, T* const& rhs ) -> bool { return reinterpret_cast<void const*>( lhs ) != rhs; }\n\n    template<typename LhsT>\n    class ExprLhs {\n        LhsT m_lhs;\n    public:\n        explicit ExprLhs( LhsT lhs ) : m_lhs( lhs ) {}\n\n        template<typename RhsT>\n        auto operator == ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {\n            return { compareEqual( m_lhs, rhs ), m_lhs, \"==\", rhs };\n        }\n        auto operator == ( bool rhs ) -> BinaryExpr<LhsT, bool> const {\n            return { m_lhs == rhs, m_lhs, \"==\", rhs };\n        }\n\n        template<typename RhsT>\n        auto operator != ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {\n            return { compareNotEqual( m_lhs, rhs ), m_lhs, \"!=\", rhs };\n        }\n        auto operator != ( bool rhs ) -> BinaryExpr<LhsT, bool> const {\n            return { m_lhs != rhs, m_lhs, \"!=\", rhs };\n        }\n\n        template<typename RhsT>\n        auto operator > ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {\n            return { static_cast<bool>(m_lhs > rhs), m_lhs, \">\", rhs };\n        }\n        template<typename RhsT>\n        auto operator < ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {\n            return { static_cast<bool>(m_lhs < rhs), m_lhs, \"<\", rhs };\n        }\n        template<typename RhsT>\n        auto operator >= ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {\n            return { static_cast<bool>(m_lhs >= rhs), m_lhs, \">=\", rhs };\n        }\n        template<typename RhsT>\n        auto operator <= ( RhsT const& rhs ) -> BinaryExpr<LhsT, RhsT const&> const {\n            return { static_cast<bool>(m_lhs <= rhs), m_lhs, \"<=\", rhs };\n        }\n\n        auto makeUnaryExpr() const -> UnaryExpr<LhsT> {\n            return UnaryExpr<LhsT>{ m_lhs };\n        }\n    };\n\n    void handleExpression( ITransientExpression const& expr );\n\n    template<typename T>\n    void handleExpression( ExprLhs<T> const& expr ) {\n        handleExpression( expr.makeUnaryExpr() );\n    }\n\n    struct Decomposer {\n        template<typename T>\n        auto operator <= ( T const& lhs ) -> ExprLhs<T const&> {\n            return ExprLhs<T const&>{ lhs };\n        }\n\n        auto operator <=( bool value ) -> ExprLhs<bool> {\n            return ExprLhs<bool>{ value };\n        }\n    };\n\n} // end namespace Catch\n\n#ifdef _MSC_VER\n#pragma warning(pop)\n#endif\n\n// end catch_decomposer.h\n// start catch_interfaces_capture.h\n\n#include <string>\n\nnamespace Catch {\n\n    class AssertionResult;\n    struct AssertionInfo;\n    struct SectionInfo;\n    struct SectionEndInfo;\n    struct MessageInfo;\n    struct Counts;\n    struct BenchmarkInfo;\n    struct BenchmarkStats;\n    struct AssertionReaction;\n    struct SourceLineInfo;\n\n    struct ITransientExpression;\n    struct IGeneratorTracker;\n\n    struct IResultCapture {\n\n        virtual ~IResultCapture();\n\n        virtual bool sectionStarted(    SectionInfo const& sectionInfo,\n                                        Counts& assertions ) = 0;\n        virtual void sectionEnded( SectionEndInfo const& endInfo ) = 0;\n        virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) = 0;\n\n        virtual auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker& = 0;\n\n        virtual void benchmarkStarting( BenchmarkInfo const& info ) = 0;\n        virtual void benchmarkEnded( BenchmarkStats const& stats ) = 0;\n\n        virtual void pushScopedMessage( MessageInfo const& message ) = 0;\n        virtual void popScopedMessage( MessageInfo const& message ) = 0;\n\n        virtual void handleFatalErrorCondition( StringRef message ) = 0;\n\n        virtual void handleExpr\n                (   AssertionInfo const& info,\n                    ITransientExpression const& expr,\n                    AssertionReaction& reaction ) = 0;\n        virtual void handleMessage\n                (   AssertionInfo const& info,\n                    ResultWas::OfType resultType,\n                    StringRef const& message,\n                    AssertionReaction& reaction ) = 0;\n        virtual void handleUnexpectedExceptionNotThrown\n                (   AssertionInfo const& info,\n                    AssertionReaction& reaction ) = 0;\n        virtual void handleUnexpectedInflightException\n                (   AssertionInfo const& info,\n                    std::string const& message,\n                    AssertionReaction& reaction ) = 0;\n        virtual void handleIncomplete\n                (   AssertionInfo const& info ) = 0;\n        virtual void handleNonExpr\n                (   AssertionInfo const &info,\n                    ResultWas::OfType resultType,\n                    AssertionReaction &reaction ) = 0;\n\n        virtual bool lastAssertionPassed() = 0;\n        virtual void assertionPassed() = 0;\n\n        // Deprecated, do not use:\n        virtual std::string getCurrentTestName() const = 0;\n        virtual const AssertionResult* getLastResult() const = 0;\n        virtual void exceptionEarlyReported() = 0;\n    };\n\n    IResultCapture& getResultCapture();\n}\n\n// end catch_interfaces_capture.h\nnamespace Catch {\n\n    struct TestFailureException{};\n    struct AssertionResultData;\n    struct IResultCapture;\n    class RunContext;\n\n    class LazyExpression {\n        friend class AssertionHandler;\n        friend struct AssertionStats;\n        friend class RunContext;\n\n        ITransientExpression const* m_transientExpression = nullptr;\n        bool m_isNegated;\n    public:\n        LazyExpression( bool isNegated );\n        LazyExpression( LazyExpression const& other );\n        LazyExpression& operator = ( LazyExpression const& ) = delete;\n\n        explicit operator bool() const;\n\n        friend auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream&;\n    };\n\n    struct AssertionReaction {\n        bool shouldDebugBreak = false;\n        bool shouldThrow = false;\n    };\n\n    class AssertionHandler {\n        AssertionInfo m_assertionInfo;\n        AssertionReaction m_reaction;\n        bool m_completed = false;\n        IResultCapture& m_resultCapture;\n\n    public:\n        AssertionHandler\n            (   StringRef const& macroName,\n                SourceLineInfo const& lineInfo,\n                StringRef capturedExpression,\n                ResultDisposition::Flags resultDisposition );\n        ~AssertionHandler() {\n            if ( !m_completed ) {\n                m_resultCapture.handleIncomplete( m_assertionInfo );\n            }\n        }\n\n        template<typename T>\n        void handleExpr( ExprLhs<T> const& expr ) {\n            handleExpr( expr.makeUnaryExpr() );\n        }\n        void handleExpr( ITransientExpression const& expr );\n\n        void handleMessage(ResultWas::OfType resultType, StringRef const& message);\n\n        void handleExceptionThrownAsExpected();\n        void handleUnexpectedExceptionNotThrown();\n        void handleExceptionNotThrownAsExpected();\n        void handleThrowingCallSkipped();\n        void handleUnexpectedInflightException();\n\n        void complete();\n        void setCompleted();\n\n        // query\n        auto allowThrows() const -> bool;\n    };\n\n    void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef const& matcherString );\n\n} // namespace Catch\n\n// end catch_assertionhandler.h\n// start catch_message.h\n\n#include <string>\n#include <vector>\n\nnamespace Catch {\n\n    struct MessageInfo {\n        MessageInfo(    StringRef const& _macroName,\n                        SourceLineInfo const& _lineInfo,\n                        ResultWas::OfType _type );\n\n        StringRef macroName;\n        std::string message;\n        SourceLineInfo lineInfo;\n        ResultWas::OfType type;\n        unsigned int sequence;\n\n        bool operator == ( MessageInfo const& other ) const;\n        bool operator < ( MessageInfo const& other ) const;\n    private:\n        static unsigned int globalCount;\n    };\n\n    struct MessageStream {\n\n        template<typename T>\n        MessageStream& operator << ( T const& value ) {\n            m_stream << value;\n            return *this;\n        }\n\n        ReusableStringStream m_stream;\n    };\n\n    struct MessageBuilder : MessageStream {\n        MessageBuilder( StringRef const& macroName,\n                        SourceLineInfo const& lineInfo,\n                        ResultWas::OfType type );\n\n        template<typename T>\n        MessageBuilder& operator << ( T const& value ) {\n            m_stream << value;\n            return *this;\n        }\n\n        MessageInfo m_info;\n    };\n\n    class ScopedMessage {\n    public:\n        explicit ScopedMessage( MessageBuilder const& builder );\n        ~ScopedMessage();\n\n        MessageInfo m_info;\n    };\n\n    class Capturer {\n        std::vector<MessageInfo> m_messages;\n        IResultCapture& m_resultCapture = getResultCapture();\n        size_t m_captured = 0;\n    public:\n        Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names );\n        ~Capturer();\n\n        void captureValue( size_t index, std::string const& value );\n\n        template<typename T>\n        void captureValues( size_t index, T const& value ) {\n            captureValue( index, Catch::Detail::stringify( value ) );\n        }\n\n        template<typename T, typename... Ts>\n        void captureValues( size_t index, T const& value, Ts const&... values ) {\n            captureValue( index, Catch::Detail::stringify(value) );\n            captureValues( index+1, values... );\n        }\n    };\n\n} // end namespace Catch\n\n// end catch_message.h\n#if !defined(CATCH_CONFIG_DISABLE)\n\n#if !defined(CATCH_CONFIG_DISABLE_STRINGIFICATION)\n  #define CATCH_INTERNAL_STRINGIFY(...) #__VA_ARGS__\n#else\n  #define CATCH_INTERNAL_STRINGIFY(...) \"Disabled by CATCH_CONFIG_DISABLE_STRINGIFICATION\"\n#endif\n\n#if defined(CATCH_CONFIG_FAST_COMPILE) || defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)\n\n///////////////////////////////////////////////////////////////////////////////\n// Another way to speed-up compilation is to omit local try-catch for REQUIRE*\n// macros.\n#define INTERNAL_CATCH_TRY\n#define INTERNAL_CATCH_CATCH( capturer )\n\n#else // CATCH_CONFIG_FAST_COMPILE\n\n#define INTERNAL_CATCH_TRY try\n#define INTERNAL_CATCH_CATCH( handler ) catch(...) { handler.handleUnexpectedInflightException(); }\n\n#endif\n\n#define INTERNAL_CATCH_REACT( handler ) handler.complete();\n\n///////////////////////////////////////////////////////////////////////////////\n#define INTERNAL_CATCH_TEST( macroName, resultDisposition, ... ) \\\n    do { \\\n        Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition ); \\\n        INTERNAL_CATCH_TRY { \\\n            CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \\\n            catchAssertionHandler.handleExpr( Catch::Decomposer() <= __VA_ARGS__ ); \\\n            CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \\\n        } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \\\n        INTERNAL_CATCH_REACT( catchAssertionHandler ) \\\n    } while( (void)0, false && static_cast<bool>( !!(__VA_ARGS__) ) ) // the expression here is never evaluated at runtime but it forces the compiler to give it a look\n    // The double negation silences MSVC's C4800 warning, the static_cast forces short-circuit evaluation if the type has overloaded &&.\n\n///////////////////////////////////////////////////////////////////////////////\n#define INTERNAL_CATCH_IF( macroName, resultDisposition, ... ) \\\n    INTERNAL_CATCH_TEST( macroName, resultDisposition, __VA_ARGS__ ); \\\n    if( Catch::getResultCapture().lastAssertionPassed() )\n\n///////////////////////////////////////////////////////////////////////////////\n#define INTERNAL_CATCH_ELSE( macroName, resultDisposition, ... ) \\\n    INTERNAL_CATCH_TEST( macroName, resultDisposition, __VA_ARGS__ ); \\\n    if( !Catch::getResultCapture().lastAssertionPassed() )\n\n///////////////////////////////////////////////////////////////////////////////\n#define INTERNAL_CATCH_NO_THROW( macroName, resultDisposition, ... ) \\\n    do { \\\n        Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition ); \\\n        try { \\\n            static_cast<void>(__VA_ARGS__); \\\n            catchAssertionHandler.handleExceptionNotThrownAsExpected(); \\\n        } \\\n        catch( ... ) { \\\n            catchAssertionHandler.handleUnexpectedInflightException(); \\\n        } \\\n        INTERNAL_CATCH_REACT( catchAssertionHandler ) \\\n    } while( false )\n\n///////////////////////////////////////////////////////////////////////////////\n#define INTERNAL_CATCH_THROWS( macroName, resultDisposition, ... ) \\\n    do { \\\n        Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__), resultDisposition); \\\n        if( catchAssertionHandler.allowThrows() ) \\\n            try { \\\n                static_cast<void>(__VA_ARGS__); \\\n                catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \\\n            } \\\n            catch( ... ) { \\\n                catchAssertionHandler.handleExceptionThrownAsExpected(); \\\n            } \\\n        else \\\n            catchAssertionHandler.handleThrowingCallSkipped(); \\\n        INTERNAL_CATCH_REACT( catchAssertionHandler ) \\\n    } while( false )\n\n///////////////////////////////////////////////////////////////////////////////\n#define INTERNAL_CATCH_THROWS_AS( macroName, exceptionType, resultDisposition, expr ) \\\n    do { \\\n        Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(expr) \", \" CATCH_INTERNAL_STRINGIFY(exceptionType), resultDisposition ); \\\n        if( catchAssertionHandler.allowThrows() ) \\\n            try { \\\n                static_cast<void>(expr); \\\n                catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \\\n            } \\\n            catch( exceptionType const& ) { \\\n                catchAssertionHandler.handleExceptionThrownAsExpected(); \\\n            } \\\n            catch( ... ) { \\\n                catchAssertionHandler.handleUnexpectedInflightException(); \\\n            } \\\n        else \\\n            catchAssertionHandler.handleThrowingCallSkipped(); \\\n        INTERNAL_CATCH_REACT( catchAssertionHandler ) \\\n    } while( false )\n\n///////////////////////////////////////////////////////////////////////////////\n#define INTERNAL_CATCH_MSG( macroName, messageType, resultDisposition, ... ) \\\n    do { \\\n        Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::StringRef(), resultDisposition ); \\\n        catchAssertionHandler.handleMessage( messageType, ( Catch::MessageStream() << __VA_ARGS__ + ::Catch::StreamEndStop() ).m_stream.str() ); \\\n        INTERNAL_CATCH_REACT( catchAssertionHandler ) \\\n    } while( false )\n\n///////////////////////////////////////////////////////////////////////////////\n#define INTERNAL_CATCH_CAPTURE( varName, macroName, ... ) \\\n    auto varName = Catch::Capturer( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info, #__VA_ARGS__ ); \\\n    varName.captureValues( 0, __VA_ARGS__ )\n\n///////////////////////////////////////////////////////////////////////////////\n#define INTERNAL_CATCH_INFO( macroName, log ) \\\n    Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage )( Catch::MessageBuilder( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log );\n\n///////////////////////////////////////////////////////////////////////////////\n// Although this is matcher-based, it can be used with just a string\n#define INTERNAL_CATCH_THROWS_STR_MATCHES( macroName, resultDisposition, matcher, ... ) \\\n    do { \\\n        Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__) \", \" CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \\\n        if( catchAssertionHandler.allowThrows() ) \\\n            try { \\\n                static_cast<void>(__VA_ARGS__); \\\n                catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \\\n            } \\\n            catch( ... ) { \\\n                Catch::handleExceptionMatchExpr( catchAssertionHandler, matcher, #matcher##_catch_sr ); \\\n            } \\\n        else \\\n            catchAssertionHandler.handleThrowingCallSkipped(); \\\n        INTERNAL_CATCH_REACT( catchAssertionHandler ) \\\n    } while( false )\n\n#endif // CATCH_CONFIG_DISABLE\n\n// end catch_capture.hpp\n// start catch_section.h\n\n// start catch_section_info.h\n\n// start catch_totals.h\n\n#include <cstddef>\n\nnamespace Catch {\n\n    struct Counts {\n        Counts operator - ( Counts const& other ) const;\n        Counts& operator += ( Counts const& other );\n\n        std::size_t total() const;\n        bool allPassed() const;\n        bool allOk() const;\n\n        std::size_t passed = 0;\n        std::size_t failed = 0;\n        std::size_t failedButOk = 0;\n    };\n\n    struct Totals {\n\n        Totals operator - ( Totals const& other ) const;\n        Totals& operator += ( Totals const& other );\n\n        Totals delta( Totals const& prevTotals ) const;\n\n        int error = 0;\n        Counts assertions;\n        Counts testCases;\n    };\n}\n\n// end catch_totals.h\n#include <string>\n\nnamespace Catch {\n\n    struct SectionInfo {\n        SectionInfo\n            (   SourceLineInfo const& _lineInfo,\n                std::string const& _name );\n\n        // Deprecated\n        SectionInfo\n            (   SourceLineInfo const& _lineInfo,\n                std::string const& _name,\n                std::string const& ) : SectionInfo( _lineInfo, _name ) {}\n\n        std::string name;\n        std::string description; // !Deprecated: this will always be empty\n        SourceLineInfo lineInfo;\n    };\n\n    struct SectionEndInfo {\n        SectionInfo sectionInfo;\n        Counts prevAssertions;\n        double durationInSeconds;\n    };\n\n} // end namespace Catch\n\n// end catch_section_info.h\n// start catch_timer.h\n\n#include <cstdint>\n\nnamespace Catch {\n\n    auto getCurrentNanosecondsSinceEpoch() -> uint64_t;\n    auto getEstimatedClockResolution() -> uint64_t;\n\n    class Timer {\n        uint64_t m_nanoseconds = 0;\n    public:\n        void start();\n        auto getElapsedNanoseconds() const -> uint64_t;\n        auto getElapsedMicroseconds() const -> uint64_t;\n        auto getElapsedMilliseconds() const -> unsigned int;\n        auto getElapsedSeconds() const -> double;\n    };\n\n} // namespace Catch\n\n// end catch_timer.h\n#include <string>\n\nnamespace Catch {\n\n    class Section : NonCopyable {\n    public:\n        Section( SectionInfo const& info );\n        ~Section();\n\n        // This indicates whether the section should be executed or not\n        explicit operator bool() const;\n\n    private:\n        SectionInfo m_info;\n\n        std::string m_name;\n        Counts m_assertions;\n        bool m_sectionIncluded;\n        Timer m_timer;\n    };\n\n} // end namespace Catch\n\n#define INTERNAL_CATCH_SECTION( ... ) \\\n    CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \\\n    if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) ) \\\n    CATCH_INTERNAL_UNSUPPRESS_UNUSED_WARNINGS\n\n#define INTERNAL_CATCH_DYNAMIC_SECTION( ... ) \\\n    CATCH_INTERNAL_SUPPRESS_UNUSED_WARNINGS \\\n    if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, (Catch::ReusableStringStream() << __VA_ARGS__).str() ) ) \\\n    CATCH_INTERNAL_UNSUPPRESS_UNUSED_WARNINGS\n\n// end catch_section.h\n// start catch_benchmark.h\n\n#include <cstdint>\n#include <string>\n\nnamespace Catch {\n\n    class BenchmarkLooper {\n\n        std::string m_name;\n        std::size_t m_count = 0;\n        std::size_t m_iterationsToRun = 1;\n        uint64_t m_resolution;\n        Timer m_timer;\n\n        static auto getResolution() -> uint64_t;\n    public:\n        // Keep most of this inline as it's on the code path that is being timed\n        BenchmarkLooper( StringRef name )\n        :   m_name( name ),\n            m_resolution( getResolution() )\n        {\n            reportStart();\n            m_timer.start();\n        }\n\n        explicit operator bool() {\n            if( m_count < m_iterationsToRun )\n                return true;\n            return needsMoreIterations();\n        }\n\n        void increment() {\n            ++m_count;\n        }\n\n        void reportStart();\n        auto needsMoreIterations() -> bool;\n    };\n\n} // end namespace Catch\n\n#define BENCHMARK( name ) \\\n    for( Catch::BenchmarkLooper looper( name ); looper; looper.increment() )\n\n// end catch_benchmark.h\n// start catch_interfaces_exception.h\n\n// start catch_interfaces_registry_hub.h\n\n#include <string>\n#include <memory>\n\nnamespace Catch {\n\n    class TestCase;\n    struct ITestCaseRegistry;\n    struct IExceptionTranslatorRegistry;\n    struct IExceptionTranslator;\n    struct IReporterRegistry;\n    struct IReporterFactory;\n    struct ITagAliasRegistry;\n    class StartupExceptionRegistry;\n\n    using IReporterFactoryPtr = std::shared_ptr<IReporterFactory>;\n\n    struct IRegistryHub {\n        virtual ~IRegistryHub();\n\n        virtual IReporterRegistry const& getReporterRegistry() const = 0;\n        virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0;\n        virtual ITagAliasRegistry const& getTagAliasRegistry() const = 0;\n\n        virtual IExceptionTranslatorRegistry const& getExceptionTranslatorRegistry() const = 0;\n\n        virtual StartupExceptionRegistry const& getStartupExceptionRegistry() const = 0;\n    };\n\n    struct IMutableRegistryHub {\n        virtual ~IMutableRegistryHub();\n        virtual void registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) = 0;\n        virtual void registerListener( IReporterFactoryPtr const& factory ) = 0;\n        virtual void registerTest( TestCase const& testInfo ) = 0;\n        virtual void registerTranslator( const IExceptionTranslator* translator ) = 0;\n        virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) = 0;\n        virtual void registerStartupException() noexcept = 0;\n    };\n\n    IRegistryHub const& getRegistryHub();\n    IMutableRegistryHub& getMutableRegistryHub();\n    void cleanUp();\n    std::string translateActiveException();\n\n}\n\n// end catch_interfaces_registry_hub.h\n#if defined(CATCH_CONFIG_DISABLE)\n    #define INTERNAL_CATCH_TRANSLATE_EXCEPTION_NO_REG( translatorName, signature) \\\n        static std::string translatorName( signature )\n#endif\n\n#include <exception>\n#include <string>\n#include <vector>\n\nnamespace Catch {\n    using exceptionTranslateFunction = std::string(*)();\n\n    struct IExceptionTranslator;\n    using ExceptionTranslators = std::vector<std::unique_ptr<IExceptionTranslator const>>;\n\n    struct IExceptionTranslator {\n        virtual ~IExceptionTranslator();\n        virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const = 0;\n    };\n\n    struct IExceptionTranslatorRegistry {\n        virtual ~IExceptionTranslatorRegistry();\n\n        virtual std::string translateActiveException() const = 0;\n    };\n\n    class ExceptionTranslatorRegistrar {\n        template<typename T>\n        class ExceptionTranslator : public IExceptionTranslator {\n        public:\n\n            ExceptionTranslator( std::string(*translateFunction)( T& ) )\n            : m_translateFunction( translateFunction )\n            {}\n\n            std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const override {\n                try {\n                    if( it == itEnd )\n                        std::rethrow_exception(std::current_exception());\n                    else\n                        return (*it)->translate( it+1, itEnd );\n                }\n                catch( T& ex ) {\n                    return m_translateFunction( ex );\n                }\n            }\n\n        protected:\n            std::string(*m_translateFunction)( T& );\n        };\n\n    public:\n        template<typename T>\n        ExceptionTranslatorRegistrar( std::string(*translateFunction)( T& ) ) {\n            getMutableRegistryHub().registerTranslator\n                ( new ExceptionTranslator<T>( translateFunction ) );\n        }\n    };\n}\n\n///////////////////////////////////////////////////////////////////////////////\n#define INTERNAL_CATCH_TRANSLATE_EXCEPTION2( translatorName, signature ) \\\n    static std::string translatorName( signature ); \\\n    CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS \\\n    namespace{ Catch::ExceptionTranslatorRegistrar INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionRegistrar )( &translatorName ); } \\\n    CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS \\\n    static std::string translatorName( signature )\n\n#define INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION2( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature )\n\n// end catch_interfaces_exception.h\n// start catch_approx.h\n\n#include <type_traits>\n\nnamespace Catch {\nnamespace Detail {\n\n    class Approx {\n    private:\n        bool equalityComparisonImpl(double other) const;\n        // Validates the new margin (margin >= 0)\n        // out-of-line to avoid including stdexcept in the header\n        void setMargin(double margin);\n        // Validates the new epsilon (0 < epsilon < 1)\n        // out-of-line to avoid including stdexcept in the header\n        void setEpsilon(double epsilon);\n\n    public:\n        explicit Approx ( double value );\n\n        static Approx custom();\n\n        Approx operator-() const;\n\n        template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>\n        Approx operator()( T const& value ) {\n            Approx approx( static_cast<double>(value) );\n            approx.m_epsilon = m_epsilon;\n            approx.m_margin = m_margin;\n            approx.m_scale = m_scale;\n            return approx;\n        }\n\n        template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>\n        explicit Approx( T const& value ): Approx(static_cast<double>(value))\n        {}\n\n        template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>\n        friend bool operator == ( const T& lhs, Approx const& rhs ) {\n            auto lhs_v = static_cast<double>(lhs);\n            return rhs.equalityComparisonImpl(lhs_v);\n        }\n\n        template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>\n        friend bool operator == ( Approx const& lhs, const T& rhs ) {\n            return operator==( rhs, lhs );\n        }\n\n        template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>\n        friend bool operator != ( T const& lhs, Approx const& rhs ) {\n            return !operator==( lhs, rhs );\n        }\n\n        template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>\n        friend bool operator != ( Approx const& lhs, T const& rhs ) {\n            return !operator==( rhs, lhs );\n        }\n\n        template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>\n        friend bool operator <= ( T const& lhs, Approx const& rhs ) {\n            return static_cast<double>(lhs) < rhs.m_value || lhs == rhs;\n        }\n\n        template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>\n        friend bool operator <= ( Approx const& lhs, T const& rhs ) {\n            return lhs.m_value < static_cast<double>(rhs) || lhs == rhs;\n        }\n\n        template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>\n        friend bool operator >= ( T const& lhs, Approx const& rhs ) {\n            return static_cast<double>(lhs) > rhs.m_value || lhs == rhs;\n        }\n\n        template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>\n        friend bool operator >= ( Approx const& lhs, T const& rhs ) {\n            return lhs.m_value > static_cast<double>(rhs) || lhs == rhs;\n        }\n\n        template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>\n        Approx& epsilon( T const& newEpsilon ) {\n            double epsilonAsDouble = static_cast<double>(newEpsilon);\n            setEpsilon(epsilonAsDouble);\n            return *this;\n        }\n\n        template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>\n        Approx& margin( T const& newMargin ) {\n            double marginAsDouble = static_cast<double>(newMargin);\n            setMargin(marginAsDouble);\n            return *this;\n        }\n\n        template <typename T, typename = typename std::enable_if<std::is_constructible<double, T>::value>::type>\n        Approx& scale( T const& newScale ) {\n            m_scale = static_cast<double>(newScale);\n            return *this;\n        }\n\n        std::string toString() const;\n\n    private:\n        double m_epsilon;\n        double m_margin;\n        double m_scale;\n        double m_value;\n    };\n} // end namespace Detail\n\nnamespace literals {\n    Detail::Approx operator \"\" _a(long double val);\n    Detail::Approx operator \"\" _a(unsigned long long val);\n} // end namespace literals\n\ntemplate<>\nstruct StringMaker<Catch::Detail::Approx> {\n    static std::string convert(Catch::Detail::Approx const& value);\n};\n\n} // end namespace Catch\n\n// end catch_approx.h\n// start catch_string_manip.h\n\n#include <string>\n#include <iosfwd>\n\nnamespace Catch {\n\n    bool startsWith( std::string const& s, std::string const& prefix );\n    bool startsWith( std::string const& s, char prefix );\n    bool endsWith( std::string const& s, std::string const& suffix );\n    bool endsWith( std::string const& s, char suffix );\n    bool contains( std::string const& s, std::string const& infix );\n    void toLowerInPlace( std::string& s );\n    std::string toLower( std::string const& s );\n    std::string trim( std::string const& str );\n    bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis );\n\n    struct pluralise {\n        pluralise( std::size_t count, std::string const& label );\n\n        friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser );\n\n        std::size_t m_count;\n        std::string m_label;\n    };\n}\n\n// end catch_string_manip.h\n#ifndef CATCH_CONFIG_DISABLE_MATCHERS\n// start catch_capture_matchers.h\n\n// start catch_matchers.h\n\n#include <string>\n#include <vector>\n\nnamespace Catch {\nnamespace Matchers {\n    namespace Impl {\n\n        template<typename ArgT> struct MatchAllOf;\n        template<typename ArgT> struct MatchAnyOf;\n        template<typename ArgT> struct MatchNotOf;\n\n        class MatcherUntypedBase {\n        public:\n            MatcherUntypedBase() = default;\n            MatcherUntypedBase ( MatcherUntypedBase const& ) = default;\n            MatcherUntypedBase& operator = ( MatcherUntypedBase const& ) = delete;\n            std::string toString() const;\n\n        protected:\n            virtual ~MatcherUntypedBase();\n            virtual std::string describe() const = 0;\n            mutable std::string m_cachedToString;\n        };\n\n#ifdef __clang__\n#    pragma clang diagnostic push\n#    pragma clang diagnostic ignored \"-Wnon-virtual-dtor\"\n#endif\n\n        template<typename ObjectT>\n        struct MatcherMethod {\n            virtual bool match( ObjectT const& arg ) const = 0;\n        };\n\n#ifdef __clang__\n#    pragma clang diagnostic pop\n#endif\n\n        template<typename T>\n        struct MatcherBase : MatcherUntypedBase, MatcherMethod<T> {\n\n            MatchAllOf<T> operator && ( MatcherBase const& other ) const;\n            MatchAnyOf<T> operator || ( MatcherBase const& other ) const;\n            MatchNotOf<T> operator ! () const;\n        };\n\n        template<typename ArgT>\n        struct MatchAllOf : MatcherBase<ArgT> {\n            bool match( ArgT const& arg ) const override {\n                for( auto matcher : m_matchers ) {\n                    if (!matcher->match(arg))\n                        return false;\n                }\n                return true;\n            }\n            std::string describe() const override {\n                std::string description;\n                description.reserve( 4 + m_matchers.size()*32 );\n                description += \"( \";\n                bool first = true;\n                for( auto matcher : m_matchers ) {\n                    if( first )\n                        first = false;\n                    else\n                        description += \" and \";\n                    description += matcher->toString();\n                }\n                description += \" )\";\n                return description;\n            }\n\n            MatchAllOf<ArgT>& operator && ( MatcherBase<ArgT> const& other ) {\n                m_matchers.push_back( &other );\n                return *this;\n            }\n\n            std::vector<MatcherBase<ArgT> const*> m_matchers;\n        };\n        template<typename ArgT>\n        struct MatchAnyOf : MatcherBase<ArgT> {\n\n            bool match( ArgT const& arg ) const override {\n                for( auto matcher : m_matchers ) {\n                    if (matcher->match(arg))\n                        return true;\n                }\n                return false;\n            }\n            std::string describe() const override {\n                std::string description;\n                description.reserve( 4 + m_matchers.size()*32 );\n                description += \"( \";\n                bool first = true;\n                for( auto matcher : m_matchers ) {\n                    if( first )\n                        first = false;\n                    else\n                        description += \" or \";\n                    description += matcher->toString();\n                }\n                description += \" )\";\n                return description;\n            }\n\n            MatchAnyOf<ArgT>& operator || ( MatcherBase<ArgT> const& other ) {\n                m_matchers.push_back( &other );\n                return *this;\n            }\n\n            std::vector<MatcherBase<ArgT> const*> m_matchers;\n        };\n\n        template<typename ArgT>\n        struct MatchNotOf : MatcherBase<ArgT> {\n\n            MatchNotOf( MatcherBase<ArgT> const& underlyingMatcher ) : m_underlyingMatcher( underlyingMatcher ) {}\n\n            bool match( ArgT const& arg ) const override {\n                return !m_underlyingMatcher.match( arg );\n            }\n\n            std::string describe() const override {\n                return \"not \" + m_underlyingMatcher.toString();\n            }\n            MatcherBase<ArgT> const& m_underlyingMatcher;\n        };\n\n        template<typename T>\n        MatchAllOf<T> MatcherBase<T>::operator && ( MatcherBase const& other ) const {\n            return MatchAllOf<T>() && *this && other;\n        }\n        template<typename T>\n        MatchAnyOf<T> MatcherBase<T>::operator || ( MatcherBase const& other ) const {\n            return MatchAnyOf<T>() || *this || other;\n        }\n        template<typename T>\n        MatchNotOf<T> MatcherBase<T>::operator ! () const {\n            return MatchNotOf<T>( *this );\n        }\n\n    } // namespace Impl\n\n} // namespace Matchers\n\nusing namespace Matchers;\nusing Matchers::Impl::MatcherBase;\n\n} // namespace Catch\n\n// end catch_matchers.h\n// start catch_matchers_floating.h\n\n#include <type_traits>\n#include <cmath>\n\nnamespace Catch {\nnamespace Matchers {\n\n    namespace Floating {\n\n        enum class FloatingPointKind : uint8_t;\n\n        struct WithinAbsMatcher : MatcherBase<double> {\n            WithinAbsMatcher(double target, double margin);\n            bool match(double const& matchee) const override;\n            std::string describe() const override;\n        private:\n            double m_target;\n            double m_margin;\n        };\n\n        struct WithinUlpsMatcher : MatcherBase<double> {\n            WithinUlpsMatcher(double target, int ulps, FloatingPointKind baseType);\n            bool match(double const& matchee) const override;\n            std::string describe() const override;\n        private:\n            double m_target;\n            int m_ulps;\n            FloatingPointKind m_type;\n        };\n\n    } // namespace Floating\n\n    // The following functions create the actual matcher objects.\n    // This allows the types to be inferred\n    Floating::WithinUlpsMatcher WithinULP(double target, int maxUlpDiff);\n    Floating::WithinUlpsMatcher WithinULP(float target, int maxUlpDiff);\n    Floating::WithinAbsMatcher WithinAbs(double target, double margin);\n\n} // namespace Matchers\n} // namespace Catch\n\n// end catch_matchers_floating.h\n// start catch_matchers_generic.hpp\n\n#include <functional>\n#include <string>\n\nnamespace Catch {\nnamespace Matchers {\nnamespace Generic {\n\nnamespace Detail {\n    std::string finalizeDescription(const std::string& desc);\n}\n\ntemplate <typename T>\nclass PredicateMatcher : public MatcherBase<T> {\n    std::function<bool(T const&)> m_predicate;\n    std::string m_description;\npublic:\n\n    PredicateMatcher(std::function<bool(T const&)> const& elem, std::string const& descr)\n        :m_predicate(std::move(elem)),\n        m_description(Detail::finalizeDescription(descr))\n    {}\n\n    bool match( T const& item ) const override {\n        return m_predicate(item);\n    }\n\n    std::string describe() const override {\n        return m_description;\n    }\n};\n\n} // namespace Generic\n\n    // The following functions create the actual matcher objects.\n    // The user has to explicitly specify type to the function, because\n    // inferring std::function<bool(T const&)> is hard (but possible) and\n    // requires a lot of TMP.\n    template<typename T>\n    Generic::PredicateMatcher<T> Predicate(std::function<bool(T const&)> const& predicate, std::string const& description = \"\") {\n        return Generic::PredicateMatcher<T>(predicate, description);\n    }\n\n} // namespace Matchers\n} // namespace Catch\n\n// end catch_matchers_generic.hpp\n// start catch_matchers_string.h\n\n#include <string>\n\nnamespace Catch {\nnamespace Matchers {\n\n    namespace StdString {\n\n        struct CasedString\n        {\n            CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity );\n            std::string adjustString( std::string const& str ) const;\n            std::string caseSensitivitySuffix() const;\n\n            CaseSensitive::Choice m_caseSensitivity;\n            std::string m_str;\n        };\n\n        struct StringMatcherBase : MatcherBase<std::string> {\n            StringMatcherBase( std::string const& operation, CasedString const& comparator );\n            std::string describe() const override;\n\n            CasedString m_comparator;\n            std::string m_operation;\n        };\n\n        struct EqualsMatcher : StringMatcherBase {\n            EqualsMatcher( CasedString const& comparator );\n            bool match( std::string const& source ) const override;\n        };\n        struct ContainsMatcher : StringMatcherBase {\n            ContainsMatcher( CasedString const& comparator );\n            bool match( std::string const& source ) const override;\n        };\n        struct StartsWithMatcher : StringMatcherBase {\n            StartsWithMatcher( CasedString const& comparator );\n            bool match( std::string const& source ) const override;\n        };\n        struct EndsWithMatcher : StringMatcherBase {\n            EndsWithMatcher( CasedString const& comparator );\n            bool match( std::string const& source ) const override;\n        };\n\n        struct RegexMatcher : MatcherBase<std::string> {\n            RegexMatcher( std::string regex, CaseSensitive::Choice caseSensitivity );\n            bool match( std::string const& matchee ) const override;\n            std::string describe() const override;\n\n        private:\n            std::string m_regex;\n            CaseSensitive::Choice m_caseSensitivity;\n        };\n\n    } // namespace StdString\n\n    // The following functions create the actual matcher objects.\n    // This allows the types to be inferred\n\n    StdString::EqualsMatcher Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes );\n    StdString::ContainsMatcher Contains( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes );\n    StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes );\n    StdString::StartsWithMatcher StartsWith( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes );\n    StdString::RegexMatcher Matches( std::string const& regex, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes );\n\n} // namespace Matchers\n} // namespace Catch\n\n// end catch_matchers_string.h\n// start catch_matchers_vector.h\n\n#include <algorithm>\n\nnamespace Catch {\nnamespace Matchers {\n\n    namespace Vector {\n        namespace Detail {\n            template <typename InputIterator, typename T>\n            size_t count(InputIterator first, InputIterator last, T const& item) {\n                size_t cnt = 0;\n                for (; first != last; ++first) {\n                    if (*first == item) {\n                        ++cnt;\n                    }\n                }\n                return cnt;\n            }\n            template <typename InputIterator, typename T>\n            bool contains(InputIterator first, InputIterator last, T const& item) {\n                for (; first != last; ++first) {\n                    if (*first == item) {\n                        return true;\n                    }\n                }\n                return false;\n            }\n        }\n\n        template<typename T>\n        struct ContainsElementMatcher : MatcherBase<std::vector<T>> {\n\n            ContainsElementMatcher(T const &comparator) : m_comparator( comparator) {}\n\n            bool match(std::vector<T> const &v) const override {\n                for (auto const& el : v) {\n                    if (el == m_comparator) {\n                        return true;\n                    }\n                }\n                return false;\n            }\n\n            std::string describe() const override {\n                return \"Contains: \" + ::Catch::Detail::stringify( m_comparator );\n            }\n\n            T const& m_comparator;\n        };\n\n        template<typename T>\n        struct ContainsMatcher : MatcherBase<std::vector<T>> {\n\n            ContainsMatcher(std::vector<T> const &comparator) : m_comparator( comparator ) {}\n\n            bool match(std::vector<T> const &v) const override {\n                // !TBD: see note in EqualsMatcher\n                if (m_comparator.size() > v.size())\n                    return false;\n                for (auto const& comparator : m_comparator) {\n                    auto present = false;\n                    for (const auto& el : v) {\n                        if (el == comparator) {\n                            present = true;\n                            break;\n                        }\n                    }\n                    if (!present) {\n                        return false;\n                    }\n                }\n                return true;\n            }\n            std::string describe() const override {\n                return \"Contains: \" + ::Catch::Detail::stringify( m_comparator );\n            }\n\n            std::vector<T> const& m_comparator;\n        };\n\n        template<typename T>\n        struct EqualsMatcher : MatcherBase<std::vector<T>> {\n\n            EqualsMatcher(std::vector<T> const &comparator) : m_comparator( comparator ) {}\n\n            bool match(std::vector<T> const &v) const override {\n                // !TBD: This currently works if all elements can be compared using !=\n                // - a more general approach would be via a compare template that defaults\n                // to using !=. but could be specialised for, e.g. std::vector<T> etc\n                // - then just call that directly\n                if (m_comparator.size() != v.size())\n                    return false;\n                for (std::size_t i = 0; i < v.size(); ++i)\n                    if (m_comparator[i] != v[i])\n                        return false;\n                return true;\n            }\n            std::string describe() const override {\n                return \"Equals: \" + ::Catch::Detail::stringify( m_comparator );\n            }\n            std::vector<T> const& m_comparator;\n        };\n\n        template<typename T>\n        struct UnorderedEqualsMatcher : MatcherBase<std::vector<T>> {\n            UnorderedEqualsMatcher(std::vector<T> const& target) : m_target(target) {}\n            bool match(std::vector<T> const& vec) const override {\n                // Note: This is a reimplementation of std::is_permutation,\n                //       because I don't want to include <algorithm> inside the common path\n                if (m_target.size() != vec.size()) {\n                    return false;\n                }\n                auto lfirst = m_target.begin(), llast = m_target.end();\n                auto rfirst = vec.begin(), rlast = vec.end();\n                // Cut common prefix to optimize checking of permuted parts\n                while (lfirst != llast && *lfirst == *rfirst) {\n                    ++lfirst; ++rfirst;\n                }\n                if (lfirst == llast) {\n                    return true;\n                }\n\n                for (auto mid = lfirst; mid != llast; ++mid) {\n                    // Skip already counted items\n                    if (Detail::contains(lfirst, mid, *mid)) {\n                        continue;\n                    }\n                    size_t num_vec = Detail::count(rfirst, rlast, *mid);\n                    if (num_vec == 0 || Detail::count(lfirst, llast, *mid) != num_vec) {\n                        return false;\n                    }\n                }\n\n                return true;\n            }\n\n            std::string describe() const override {\n                return \"UnorderedEquals: \" + ::Catch::Detail::stringify(m_target);\n            }\n        private:\n            std::vector<T> const& m_target;\n        };\n\n    } // namespace Vector\n\n    // The following functions create the actual matcher objects.\n    // This allows the types to be inferred\n\n    template<typename T>\n    Vector::ContainsMatcher<T> Contains( std::vector<T> const& comparator ) {\n        return Vector::ContainsMatcher<T>( comparator );\n    }\n\n    template<typename T>\n    Vector::ContainsElementMatcher<T> VectorContains( T const& comparator ) {\n        return Vector::ContainsElementMatcher<T>( comparator );\n    }\n\n    template<typename T>\n    Vector::EqualsMatcher<T> Equals( std::vector<T> const& comparator ) {\n        return Vector::EqualsMatcher<T>( comparator );\n    }\n\n    template<typename T>\n    Vector::UnorderedEqualsMatcher<T> UnorderedEquals(std::vector<T> const& target) {\n        return Vector::UnorderedEqualsMatcher<T>(target);\n    }\n\n} // namespace Matchers\n} // namespace Catch\n\n// end catch_matchers_vector.h\nnamespace Catch {\n\n    template<typename ArgT, typename MatcherT>\n    class MatchExpr : public ITransientExpression {\n        ArgT const& m_arg;\n        MatcherT m_matcher;\n        StringRef m_matcherString;\n    public:\n        MatchExpr( ArgT const& arg, MatcherT const& matcher, StringRef const& matcherString )\n        :   ITransientExpression{ true, matcher.match( arg ) },\n            m_arg( arg ),\n            m_matcher( matcher ),\n            m_matcherString( matcherString )\n        {}\n\n        void streamReconstructedExpression( std::ostream &os ) const override {\n            auto matcherAsString = m_matcher.toString();\n            os << Catch::Detail::stringify( m_arg ) << ' ';\n            if( matcherAsString == Detail::unprintableString )\n                os << m_matcherString;\n            else\n                os << matcherAsString;\n        }\n    };\n\n    using StringMatcher = Matchers::Impl::MatcherBase<std::string>;\n\n    void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef const& matcherString  );\n\n    template<typename ArgT, typename MatcherT>\n    auto makeMatchExpr( ArgT const& arg, MatcherT const& matcher, StringRef const& matcherString  ) -> MatchExpr<ArgT, MatcherT> {\n        return MatchExpr<ArgT, MatcherT>( arg, matcher, matcherString );\n    }\n\n} // namespace Catch\n\n///////////////////////////////////////////////////////////////////////////////\n#define INTERNAL_CHECK_THAT( macroName, matcher, resultDisposition, arg ) \\\n    do { \\\n        Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(arg) \", \" CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \\\n        INTERNAL_CATCH_TRY { \\\n            catchAssertionHandler.handleExpr( Catch::makeMatchExpr( arg, matcher, #matcher##_catch_sr ) ); \\\n        } INTERNAL_CATCH_CATCH( catchAssertionHandler ) \\\n        INTERNAL_CATCH_REACT( catchAssertionHandler ) \\\n    } while( false )\n\n///////////////////////////////////////////////////////////////////////////////\n#define INTERNAL_CATCH_THROWS_MATCHES( macroName, exceptionType, resultDisposition, matcher, ... ) \\\n    do { \\\n        Catch::AssertionHandler catchAssertionHandler( macroName##_catch_sr, CATCH_INTERNAL_LINEINFO, CATCH_INTERNAL_STRINGIFY(__VA_ARGS__) \", \" CATCH_INTERNAL_STRINGIFY(exceptionType) \", \" CATCH_INTERNAL_STRINGIFY(matcher), resultDisposition ); \\\n        if( catchAssertionHandler.allowThrows() ) \\\n            try { \\\n                static_cast<void>(__VA_ARGS__ ); \\\n                catchAssertionHandler.handleUnexpectedExceptionNotThrown(); \\\n            } \\\n            catch( exceptionType const& ex ) { \\\n                catchAssertionHandler.handleExpr( Catch::makeMatchExpr( ex, matcher, #matcher##_catch_sr ) ); \\\n            } \\\n            catch( ... ) { \\\n                catchAssertionHandler.handleUnexpectedInflightException(); \\\n            } \\\n        else \\\n            catchAssertionHandler.handleThrowingCallSkipped(); \\\n        INTERNAL_CATCH_REACT( catchAssertionHandler ) \\\n    } while( false )\n\n// end catch_capture_matchers.h\n#endif\n// start catch_generators.hpp\n\n// start catch_interfaces_generatortracker.h\n\n\n#include <memory>\n\nnamespace Catch {\n\n    namespace Generators {\n        class GeneratorBase {\n        protected:\n            size_t m_size = 0;\n\n        public:\n            GeneratorBase( size_t size ) : m_size( size ) {}\n            virtual ~GeneratorBase();\n            auto size() const -> size_t { return m_size; }\n        };\n        using GeneratorBasePtr = std::unique_ptr<GeneratorBase>;\n\n    } // namespace Generators\n\n    struct IGeneratorTracker {\n        virtual ~IGeneratorTracker();\n        virtual auto hasGenerator() const -> bool = 0;\n        virtual auto getGenerator() const -> Generators::GeneratorBasePtr const& = 0;\n        virtual void setGenerator( Generators::GeneratorBasePtr&& generator ) = 0;\n        virtual auto getIndex() const -> std::size_t = 0;\n    };\n\n} // namespace Catch\n\n// end catch_interfaces_generatortracker.h\n// start catch_enforce.h\n\n#include <stdexcept>\n\nnamespace Catch {\n#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)\n    template <typename Ex>\n    [[noreturn]]\n    void throw_exception(Ex const& e) {\n        throw e;\n    }\n#else // ^^ Exceptions are enabled //  Exceptions are disabled vv\n    [[noreturn]]\n    void throw_exception(std::exception const& e);\n#endif\n} // namespace Catch;\n\n#define CATCH_PREPARE_EXCEPTION( type, msg ) \\\n    type( ( Catch::ReusableStringStream() << msg ).str() )\n#define CATCH_INTERNAL_ERROR( msg ) \\\n    Catch::throw_exception(CATCH_PREPARE_EXCEPTION( std::logic_error, CATCH_INTERNAL_LINEINFO << \": Internal Catch error: \" << msg))\n#define CATCH_ERROR( msg ) \\\n    Catch::throw_exception(CATCH_PREPARE_EXCEPTION( std::domain_error, msg ))\n#define CATCH_RUNTIME_ERROR( msg ) \\\n    Catch::throw_exception(CATCH_PREPARE_EXCEPTION( std::runtime_error, msg ))\n#define CATCH_ENFORCE( condition, msg ) \\\n    do{ if( !(condition) ) CATCH_ERROR( msg ); } while(false)\n\n// end catch_enforce.h\n#include <memory>\n#include <vector>\n#include <cassert>\n\n#include <utility>\n\nnamespace Catch {\nnamespace Generators {\n\n    // !TBD move this into its own location?\n    namespace pf{\n        template<typename T, typename... Args>\n        std::unique_ptr<T> make_unique( Args&&... args ) {\n            return std::unique_ptr<T>(new T(std::forward<Args>(args)...));\n        }\n    }\n\n    template<typename T>\n    struct IGenerator {\n        virtual ~IGenerator() {}\n        virtual auto get( size_t index ) const -> T = 0;\n    };\n\n    template<typename T>\n    class SingleValueGenerator : public IGenerator<T> {\n        T m_value;\n    public:\n        SingleValueGenerator( T const& value ) : m_value( value ) {}\n\n        auto get( size_t ) const -> T override {\n            return m_value;\n        }\n    };\n\n    template<typename T>\n    class FixedValuesGenerator : public IGenerator<T> {\n        std::vector<T> m_values;\n\n    public:\n        FixedValuesGenerator( std::initializer_list<T> values ) : m_values( values ) {}\n\n        auto get( size_t index ) const -> T override {\n            return m_values[index];\n        }\n    };\n\n    template<typename T>\n    class RangeGenerator : public IGenerator<T> {\n        T const m_first;\n        T const m_last;\n\n    public:\n        RangeGenerator( T const& first, T const& last ) : m_first( first ), m_last( last ) {\n            assert( m_last > m_first );\n        }\n\n        auto get( size_t index ) const -> T override {\n            // ToDo:: introduce a safe cast to catch potential overflows\n            return static_cast<T>(m_first+index);\n        }\n    };\n\n    template<typename T>\n    struct NullGenerator : IGenerator<T> {\n        auto get( size_t ) const -> T override {\n            CATCH_INTERNAL_ERROR(\"A Null Generator is always empty\");\n        }\n    };\n\n    template<typename T>\n    class Generator {\n        std::unique_ptr<IGenerator<T>> m_generator;\n        size_t m_size;\n\n    public:\n        Generator( size_t size, std::unique_ptr<IGenerator<T>> generator )\n        :   m_generator( std::move( generator ) ),\n            m_size( size )\n        {}\n\n        auto size() const -> size_t { return m_size; }\n        auto operator[]( size_t index ) const -> T {\n            assert( index < m_size );\n            return m_generator->get( index );\n        }\n    };\n\n    std::vector<size_t> randomiseIndices( size_t selectionSize, size_t sourceSize );\n\n    template<typename T>\n    class GeneratorRandomiser : public IGenerator<T> {\n        Generator<T> m_baseGenerator;\n\n        std::vector<size_t> m_indices;\n    public:\n        GeneratorRandomiser( Generator<T>&& baseGenerator, size_t numberOfItems )\n        :   m_baseGenerator( std::move( baseGenerator ) ),\n            m_indices( randomiseIndices( numberOfItems, m_baseGenerator.size() ) )\n        {}\n\n        auto get( size_t index ) const -> T override {\n            return m_baseGenerator[m_indices[index]];\n        }\n    };\n\n    template<typename T>\n    struct RequiresASpecialisationFor;\n\n    template<typename T>\n    auto all() -> Generator<T> { return RequiresASpecialisationFor<T>(); }\n\n    template<>\n    auto all<int>() -> Generator<int>;\n\n    template<typename T>\n    auto range( T const& first, T const& last ) -> Generator<T> {\n        return Generator<T>( (last-first), pf::make_unique<RangeGenerator<T>>( first, last ) );\n    }\n\n    template<typename T>\n    auto random( T const& first, T const& last ) -> Generator<T> {\n        auto gen = range( first, last );\n        auto size = gen.size();\n\n        return Generator<T>( size, pf::make_unique<GeneratorRandomiser<T>>( std::move( gen ), size ) );\n    }\n    template<typename T>\n    auto random( size_t size ) -> Generator<T> {\n        return Generator<T>( size, pf::make_unique<GeneratorRandomiser<T>>( all<T>(), size ) );\n    }\n\n    template<typename T>\n    auto values( std::initializer_list<T> values ) -> Generator<T> {\n        return Generator<T>( values.size(), pf::make_unique<FixedValuesGenerator<T>>( values ) );\n    }\n    template<typename T>\n    auto value( T const& val ) -> Generator<T> {\n        return Generator<T>( 1, pf::make_unique<SingleValueGenerator<T>>( val ) );\n    }\n\n    template<typename T>\n    auto as() -> Generator<T> {\n        return Generator<T>( 0, pf::make_unique<NullGenerator<T>>() );\n    }\n\n    template<typename... Ts>\n    auto table( std::initializer_list<std::tuple<Ts...>>&& tuples ) -> Generator<std::tuple<Ts...>> {\n        return values<std::tuple<Ts...>>( std::forward<std::initializer_list<std::tuple<Ts...>>>( tuples ) );\n    }\n\n    template<typename T>\n    struct Generators : GeneratorBase {\n        std::vector<Generator<T>> m_generators;\n\n        using type = T;\n\n        Generators() : GeneratorBase( 0 ) {}\n\n        void populate( T&& val ) {\n            m_size += 1;\n            m_generators.emplace_back( value( std::move( val ) ) );\n        }\n        template<typename U>\n        void populate( U&& val ) {\n            populate( T( std::move( val ) ) );\n        }\n        void populate( Generator<T>&& generator ) {\n            m_size += generator.size();\n            m_generators.emplace_back( std::move( generator ) );\n        }\n\n        template<typename U, typename... Gs>\n        void populate( U&& valueOrGenerator, Gs... moreGenerators ) {\n            populate( std::forward<U>( valueOrGenerator ) );\n            populate( std::forward<Gs>( moreGenerators )... );\n        }\n\n        auto operator[]( size_t index ) const -> T {\n            size_t sizes = 0;\n            for( auto const& gen : m_generators ) {\n                auto localIndex = index-sizes;\n                sizes += gen.size();\n                if( index < sizes )\n                    return gen[localIndex];\n            }\n            CATCH_INTERNAL_ERROR(\"Index '\" << index << \"' is out of range (\" << sizes << ')');\n        }\n    };\n\n    template<typename T, typename... Gs>\n    auto makeGenerators( Generator<T>&& generator, Gs... moreGenerators ) -> Generators<T> {\n        Generators<T> generators;\n        generators.m_generators.reserve( 1+sizeof...(Gs) );\n        generators.populate( std::move( generator ), std::forward<Gs>( moreGenerators )... );\n        return generators;\n    }\n    template<typename T>\n    auto makeGenerators( Generator<T>&& generator ) -> Generators<T> {\n        Generators<T> generators;\n        generators.populate( std::move( generator ) );\n        return generators;\n    }\n    template<typename T, typename... Gs>\n    auto makeGenerators( T&& val, Gs... moreGenerators ) -> Generators<T> {\n        return makeGenerators( value( std::forward<T>( val ) ), std::forward<Gs>( moreGenerators )... );\n    }\n    template<typename T, typename U, typename... Gs>\n    auto makeGenerators( U&& val, Gs... moreGenerators ) -> Generators<T> {\n        return makeGenerators( value( T( std::forward<U>( val ) ) ), std::forward<Gs>( moreGenerators )... );\n    }\n\n    auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker&;\n\n    template<typename L>\n    // Note: The type after -> is weird, because VS2015 cannot parse\n    //       the expression used in the typedef inside, when it is in\n    //       return type. Yeah, ¯\\_(ツ)_/¯\n    auto generate( SourceLineInfo const& lineInfo, L const& generatorExpression ) -> decltype(std::declval<decltype(generatorExpression())>()[0]) {\n        using UnderlyingType = typename decltype(generatorExpression())::type;\n\n        IGeneratorTracker& tracker = acquireGeneratorTracker( lineInfo );\n        if( !tracker.hasGenerator() )\n            tracker.setGenerator( pf::make_unique<Generators<UnderlyingType>>( generatorExpression() ) );\n\n        auto const& generator = static_cast<Generators<UnderlyingType> const&>( *tracker.getGenerator() );\n        return generator[tracker.getIndex()];\n    }\n\n} // namespace Generators\n} // namespace Catch\n\n#define GENERATE( ... ) \\\n    Catch::Generators::generate( CATCH_INTERNAL_LINEINFO, []{ using namespace Catch::Generators; return makeGenerators( __VA_ARGS__ ); } )\n\n// end catch_generators.hpp\n\n// These files are included here so the single_include script doesn't put them\n// in the conditionally compiled sections\n// start catch_test_case_info.h\n\n#include <string>\n#include <vector>\n#include <memory>\n\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wpadded\"\n#endif\n\nnamespace Catch {\n\n    struct ITestInvoker;\n\n    struct TestCaseInfo {\n        enum SpecialProperties{\n            None = 0,\n            IsHidden = 1 << 1,\n            ShouldFail = 1 << 2,\n            MayFail = 1 << 3,\n            Throws = 1 << 4,\n            NonPortable = 1 << 5,\n            Benchmark = 1 << 6\n        };\n\n        TestCaseInfo(   std::string const& _name,\n                        std::string const& _className,\n                        std::string const& _description,\n                        std::vector<std::string> const& _tags,\n                        SourceLineInfo const& _lineInfo );\n\n        friend void setTags( TestCaseInfo& testCaseInfo, std::vector<std::string> tags );\n\n        bool isHidden() const;\n        bool throws() const;\n        bool okToFail() const;\n        bool expectedToFail() const;\n\n        std::string tagsAsString() const;\n\n        std::string name;\n        std::string className;\n        std::string description;\n        std::vector<std::string> tags;\n        std::vector<std::string> lcaseTags;\n        SourceLineInfo lineInfo;\n        SpecialProperties properties;\n    };\n\n    class TestCase : public TestCaseInfo {\n    public:\n\n        TestCase( ITestInvoker* testCase, TestCaseInfo&& info );\n\n        TestCase withName( std::string const& _newName ) const;\n\n        void invoke() const;\n\n        TestCaseInfo const& getTestCaseInfo() const;\n\n        bool operator == ( TestCase const& other ) const;\n        bool operator < ( TestCase const& other ) const;\n\n    private:\n        std::shared_ptr<ITestInvoker> test;\n    };\n\n    TestCase makeTestCase(  ITestInvoker* testCase,\n                            std::string const& className,\n                            NameAndTags const& nameAndTags,\n                            SourceLineInfo const& lineInfo );\n}\n\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n\n// end catch_test_case_info.h\n// start catch_interfaces_runner.h\n\nnamespace Catch {\n\n    struct IRunner {\n        virtual ~IRunner();\n        virtual bool aborting() const = 0;\n    };\n}\n\n// end catch_interfaces_runner.h\n\n#ifdef __OBJC__\n// start catch_objc.hpp\n\n#import <objc/runtime.h>\n\n#include <string>\n\n// NB. Any general catch headers included here must be included\n// in catch.hpp first to make sure they are included by the single\n// header for non obj-usage\n\n///////////////////////////////////////////////////////////////////////////////\n// This protocol is really only here for (self) documenting purposes, since\n// all its methods are optional.\n@protocol OcFixture\n\n@optional\n\n-(void) setUp;\n-(void) tearDown;\n\n@end\n\nnamespace Catch {\n\n    class OcMethod : public ITestInvoker {\n\n    public:\n        OcMethod( Class cls, SEL sel ) : m_cls( cls ), m_sel( sel ) {}\n\n        virtual void invoke() const {\n            id obj = [[m_cls alloc] init];\n\n            performOptionalSelector( obj, @selector(setUp)  );\n            performOptionalSelector( obj, m_sel );\n            performOptionalSelector( obj, @selector(tearDown)  );\n\n            arcSafeRelease( obj );\n        }\n    private:\n        virtual ~OcMethod() {}\n\n        Class m_cls;\n        SEL m_sel;\n    };\n\n    namespace Detail{\n\n        inline std::string getAnnotation(   Class cls,\n                                            std::string const& annotationName,\n                                            std::string const& testCaseName ) {\n            NSString* selStr = [[NSString alloc] initWithFormat:@\"Catch_%s_%s\", annotationName.c_str(), testCaseName.c_str()];\n            SEL sel = NSSelectorFromString( selStr );\n            arcSafeRelease( selStr );\n            id value = performOptionalSelector( cls, sel );\n            if( value )\n                return [(NSString*)value UTF8String];\n            return \"\";\n        }\n    }\n\n    inline std::size_t registerTestMethods() {\n        std::size_t noTestMethods = 0;\n        int noClasses = objc_getClassList( nullptr, 0 );\n\n        Class* classes = (CATCH_UNSAFE_UNRETAINED Class *)malloc( sizeof(Class) * noClasses);\n        objc_getClassList( classes, noClasses );\n\n        for( int c = 0; c < noClasses; c++ ) {\n            Class cls = classes[c];\n            {\n                u_int count;\n                Method* methods = class_copyMethodList( cls, &count );\n                for( u_int m = 0; m < count ; m++ ) {\n                    SEL selector = method_getName(methods[m]);\n                    std::string methodName = sel_getName(selector);\n                    if( startsWith( methodName, \"Catch_TestCase_\" ) ) {\n                        std::string testCaseName = methodName.substr( 15 );\n                        std::string name = Detail::getAnnotation( cls, \"Name\", testCaseName );\n                        std::string desc = Detail::getAnnotation( cls, \"Description\", testCaseName );\n                        const char* className = class_getName( cls );\n\n                        getMutableRegistryHub().registerTest( makeTestCase( new OcMethod( cls, selector ), className, NameAndTags( name.c_str(), desc.c_str() ), SourceLineInfo(\"\",0) ) );\n                        noTestMethods++;\n                    }\n                }\n                free(methods);\n            }\n        }\n        return noTestMethods;\n    }\n\n#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)\n\n    namespace Matchers {\n        namespace Impl {\n        namespace NSStringMatchers {\n\n            struct StringHolder : MatcherBase<NSString*>{\n                StringHolder( NSString* substr ) : m_substr( [substr copy] ){}\n                StringHolder( StringHolder const& other ) : m_substr( [other.m_substr copy] ){}\n                StringHolder() {\n                    arcSafeRelease( m_substr );\n                }\n\n                bool match( NSString* arg ) const override {\n                    return false;\n                }\n\n                NSString* CATCH_ARC_STRONG m_substr;\n            };\n\n            struct Equals : StringHolder {\n                Equals( NSString* substr ) : StringHolder( substr ){}\n\n                bool match( NSString* str ) const override {\n                    return  (str != nil || m_substr == nil ) &&\n                            [str isEqualToString:m_substr];\n                }\n\n                std::string describe() const override {\n                    return \"equals string: \" + Catch::Detail::stringify( m_substr );\n                }\n            };\n\n            struct Contains : StringHolder {\n                Contains( NSString* substr ) : StringHolder( substr ){}\n\n                bool match( NSString* str ) const {\n                    return  (str != nil || m_substr == nil ) &&\n                            [str rangeOfString:m_substr].location != NSNotFound;\n                }\n\n                std::string describe() const override {\n                    return \"contains string: \" + Catch::Detail::stringify( m_substr );\n                }\n            };\n\n            struct StartsWith : StringHolder {\n                StartsWith( NSString* substr ) : StringHolder( substr ){}\n\n                bool match( NSString* str ) const override {\n                    return  (str != nil || m_substr == nil ) &&\n                            [str rangeOfString:m_substr].location == 0;\n                }\n\n                std::string describe() const override {\n                    return \"starts with: \" + Catch::Detail::stringify( m_substr );\n                }\n            };\n            struct EndsWith : StringHolder {\n                EndsWith( NSString* substr ) : StringHolder( substr ){}\n\n                bool match( NSString* str ) const override {\n                    return  (str != nil || m_substr == nil ) &&\n                            [str rangeOfString:m_substr].location == [str length] - [m_substr length];\n                }\n\n                std::string describe() const override {\n                    return \"ends with: \" + Catch::Detail::stringify( m_substr );\n                }\n            };\n\n        } // namespace NSStringMatchers\n        } // namespace Impl\n\n        inline Impl::NSStringMatchers::Equals\n            Equals( NSString* substr ){ return Impl::NSStringMatchers::Equals( substr ); }\n\n        inline Impl::NSStringMatchers::Contains\n            Contains( NSString* substr ){ return Impl::NSStringMatchers::Contains( substr ); }\n\n        inline Impl::NSStringMatchers::StartsWith\n            StartsWith( NSString* substr ){ return Impl::NSStringMatchers::StartsWith( substr ); }\n\n        inline Impl::NSStringMatchers::EndsWith\n            EndsWith( NSString* substr ){ return Impl::NSStringMatchers::EndsWith( substr ); }\n\n    } // namespace Matchers\n\n    using namespace Matchers;\n\n#endif // CATCH_CONFIG_DISABLE_MATCHERS\n\n} // namespace Catch\n\n///////////////////////////////////////////////////////////////////////////////\n#define OC_MAKE_UNIQUE_NAME( root, uniqueSuffix ) root##uniqueSuffix\n#define OC_TEST_CASE2( name, desc, uniqueSuffix ) \\\n+(NSString*) OC_MAKE_UNIQUE_NAME( Catch_Name_test_, uniqueSuffix ) \\\n{ \\\nreturn @ name; \\\n} \\\n+(NSString*) OC_MAKE_UNIQUE_NAME( Catch_Description_test_, uniqueSuffix ) \\\n{ \\\nreturn @ desc; \\\n} \\\n-(void) OC_MAKE_UNIQUE_NAME( Catch_TestCase_test_, uniqueSuffix )\n\n#define OC_TEST_CASE( name, desc ) OC_TEST_CASE2( name, desc, __LINE__ )\n\n// end catch_objc.hpp\n#endif\n\n#ifdef CATCH_CONFIG_EXTERNAL_INTERFACES\n// start catch_external_interfaces.h\n\n// start catch_reporter_bases.hpp\n\n// start catch_interfaces_reporter.h\n\n// start catch_config.hpp\n\n// start catch_test_spec_parser.h\n\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wpadded\"\n#endif\n\n// start catch_test_spec.h\n\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wpadded\"\n#endif\n\n// start catch_wildcard_pattern.h\n\nnamespace Catch\n{\n    class WildcardPattern {\n        enum WildcardPosition {\n            NoWildcard = 0,\n            WildcardAtStart = 1,\n            WildcardAtEnd = 2,\n            WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd\n        };\n\n    public:\n\n        WildcardPattern( std::string const& pattern, CaseSensitive::Choice caseSensitivity );\n        virtual ~WildcardPattern() = default;\n        virtual bool matches( std::string const& str ) const;\n\n    private:\n        std::string adjustCase( std::string const& str ) const;\n        CaseSensitive::Choice m_caseSensitivity;\n        WildcardPosition m_wildcard = NoWildcard;\n        std::string m_pattern;\n    };\n}\n\n// end catch_wildcard_pattern.h\n#include <string>\n#include <vector>\n#include <memory>\n\nnamespace Catch {\n\n    class TestSpec {\n        struct Pattern {\n            virtual ~Pattern();\n            virtual bool matches( TestCaseInfo const& testCase ) const = 0;\n        };\n        using PatternPtr = std::shared_ptr<Pattern>;\n\n        class NamePattern : public Pattern {\n        public:\n            NamePattern( std::string const& name );\n            virtual ~NamePattern();\n            virtual bool matches( TestCaseInfo const& testCase ) const override;\n        private:\n            WildcardPattern m_wildcardPattern;\n        };\n\n        class TagPattern : public Pattern {\n        public:\n            TagPattern( std::string const& tag );\n            virtual ~TagPattern();\n            virtual bool matches( TestCaseInfo const& testCase ) const override;\n        private:\n            std::string m_tag;\n        };\n\n        class ExcludedPattern : public Pattern {\n        public:\n            ExcludedPattern( PatternPtr const& underlyingPattern );\n            virtual ~ExcludedPattern();\n            virtual bool matches( TestCaseInfo const& testCase ) const override;\n        private:\n            PatternPtr m_underlyingPattern;\n        };\n\n        struct Filter {\n            std::vector<PatternPtr> m_patterns;\n\n            bool matches( TestCaseInfo const& testCase ) const;\n        };\n\n    public:\n        bool hasFilters() const;\n        bool matches( TestCaseInfo const& testCase ) const;\n\n    private:\n        std::vector<Filter> m_filters;\n\n        friend class TestSpecParser;\n    };\n}\n\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n\n// end catch_test_spec.h\n// start catch_interfaces_tag_alias_registry.h\n\n#include <string>\n\nnamespace Catch {\n\n    struct TagAlias;\n\n    struct ITagAliasRegistry {\n        virtual ~ITagAliasRegistry();\n        // Nullptr if not present\n        virtual TagAlias const* find( std::string const& alias ) const = 0;\n        virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const = 0;\n\n        static ITagAliasRegistry const& get();\n    };\n\n} // end namespace Catch\n\n// end catch_interfaces_tag_alias_registry.h\nnamespace Catch {\n\n    class TestSpecParser {\n        enum Mode{ None, Name, QuotedName, Tag, EscapedName };\n        Mode m_mode = None;\n        bool m_exclusion = false;\n        std::size_t m_start = std::string::npos, m_pos = 0;\n        std::string m_arg;\n        std::vector<std::size_t> m_escapeChars;\n        TestSpec::Filter m_currentFilter;\n        TestSpec m_testSpec;\n        ITagAliasRegistry const* m_tagAliases = nullptr;\n\n    public:\n        TestSpecParser( ITagAliasRegistry const& tagAliases );\n\n        TestSpecParser& parse( std::string const& arg );\n        TestSpec testSpec();\n\n    private:\n        void visitChar( char c );\n        void startNewMode( Mode mode, std::size_t start );\n        void escape();\n        std::string subString() const;\n\n        template<typename T>\n        void addPattern() {\n            std::string token = subString();\n            for( std::size_t i = 0; i < m_escapeChars.size(); ++i )\n                token = token.substr( 0, m_escapeChars[i]-m_start-i ) + token.substr( m_escapeChars[i]-m_start-i+1 );\n            m_escapeChars.clear();\n            if( startsWith( token, \"exclude:\" ) ) {\n                m_exclusion = true;\n                token = token.substr( 8 );\n            }\n            if( !token.empty() ) {\n                TestSpec::PatternPtr pattern = std::make_shared<T>( token );\n                if( m_exclusion )\n                    pattern = std::make_shared<TestSpec::ExcludedPattern>( pattern );\n                m_currentFilter.m_patterns.push_back( pattern );\n            }\n            m_exclusion = false;\n            m_mode = None;\n        }\n\n        void addFilter();\n    };\n    TestSpec parseTestSpec( std::string const& arg );\n\n} // namespace Catch\n\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n\n// end catch_test_spec_parser.h\n// start catch_interfaces_config.h\n\n#include <iosfwd>\n#include <string>\n#include <vector>\n#include <memory>\n\nnamespace Catch {\n\n    enum class Verbosity {\n        Quiet = 0,\n        Normal,\n        High\n    };\n\n    struct WarnAbout { enum What {\n        Nothing = 0x00,\n        NoAssertions = 0x01,\n        NoTests = 0x02\n    }; };\n\n    struct ShowDurations { enum OrNot {\n        DefaultForReporter,\n        Always,\n        Never\n    }; };\n    struct RunTests { enum InWhatOrder {\n        InDeclarationOrder,\n        InLexicographicalOrder,\n        InRandomOrder\n    }; };\n    struct UseColour { enum YesOrNo {\n        Auto,\n        Yes,\n        No\n    }; };\n    struct WaitForKeypress { enum When {\n        Never,\n        BeforeStart = 1,\n        BeforeExit = 2,\n        BeforeStartAndExit = BeforeStart | BeforeExit\n    }; };\n\n    class TestSpec;\n\n    struct IConfig : NonCopyable {\n\n        virtual ~IConfig();\n\n        virtual bool allowThrows() const = 0;\n        virtual std::ostream& stream() const = 0;\n        virtual std::string name() const = 0;\n        virtual bool includeSuccessfulResults() const = 0;\n        virtual bool shouldDebugBreak() const = 0;\n        virtual bool warnAboutMissingAssertions() const = 0;\n        virtual bool warnAboutNoTests() const = 0;\n        virtual int abortAfter() const = 0;\n        virtual bool showInvisibles() const = 0;\n        virtual ShowDurations::OrNot showDurations() const = 0;\n        virtual TestSpec const& testSpec() const = 0;\n        virtual bool hasTestFilters() const = 0;\n        virtual RunTests::InWhatOrder runOrder() const = 0;\n        virtual unsigned int rngSeed() const = 0;\n        virtual int benchmarkResolutionMultiple() const = 0;\n        virtual UseColour::YesOrNo useColour() const = 0;\n        virtual std::vector<std::string> const& getSectionsToRun() const = 0;\n        virtual Verbosity verbosity() const = 0;\n    };\n\n    using IConfigPtr = std::shared_ptr<IConfig const>;\n}\n\n// end catch_interfaces_config.h\n// Libstdc++ doesn't like incomplete classes for unique_ptr\n\n#include <memory>\n#include <vector>\n#include <string>\n\n#ifndef CATCH_CONFIG_CONSOLE_WIDTH\n#define CATCH_CONFIG_CONSOLE_WIDTH 80\n#endif\n\nnamespace Catch {\n\n    struct IStream;\n\n    struct ConfigData {\n        bool listTests = false;\n        bool listTags = false;\n        bool listReporters = false;\n        bool listTestNamesOnly = false;\n\n        bool showSuccessfulTests = false;\n        bool shouldDebugBreak = false;\n        bool noThrow = false;\n        bool showHelp = false;\n        bool showInvisibles = false;\n        bool filenamesAsTags = false;\n        bool libIdentify = false;\n\n        int abortAfter = -1;\n        unsigned int rngSeed = 0;\n        int benchmarkResolutionMultiple = 100;\n\n        Verbosity verbosity = Verbosity::Normal;\n        WarnAbout::What warnings = WarnAbout::Nothing;\n        ShowDurations::OrNot showDurations = ShowDurations::DefaultForReporter;\n        RunTests::InWhatOrder runOrder = RunTests::InDeclarationOrder;\n        UseColour::YesOrNo useColour = UseColour::Auto;\n        WaitForKeypress::When waitForKeypress = WaitForKeypress::Never;\n\n        std::string outputFilename;\n        std::string name;\n        std::string processName;\n#ifndef CATCH_CONFIG_DEFAULT_REPORTER\n#define CATCH_CONFIG_DEFAULT_REPORTER \"console\"\n#endif\n        std::string reporterName = CATCH_CONFIG_DEFAULT_REPORTER;\n#undef CATCH_CONFIG_DEFAULT_REPORTER\n\n        std::vector<std::string> testsOrTags;\n        std::vector<std::string> sectionsToRun;\n    };\n\n    class Config : public IConfig {\n    public:\n\n        Config() = default;\n        Config( ConfigData const& data );\n        virtual ~Config() = default;\n\n        std::string const& getFilename() const;\n\n        bool listTests() const;\n        bool listTestNamesOnly() const;\n        bool listTags() const;\n        bool listReporters() const;\n\n        std::string getProcessName() const;\n        std::string const& getReporterName() const;\n\n        std::vector<std::string> const& getTestsOrTags() const;\n        std::vector<std::string> const& getSectionsToRun() const override;\n\n        virtual TestSpec const& testSpec() const override;\n        bool hasTestFilters() const override;\n\n        bool showHelp() const;\n\n        // IConfig interface\n        bool allowThrows() const override;\n        std::ostream& stream() const override;\n        std::string name() const override;\n        bool includeSuccessfulResults() const override;\n        bool warnAboutMissingAssertions() const override;\n        bool warnAboutNoTests() const override;\n        ShowDurations::OrNot showDurations() const override;\n        RunTests::InWhatOrder runOrder() const override;\n        unsigned int rngSeed() const override;\n        int benchmarkResolutionMultiple() const override;\n        UseColour::YesOrNo useColour() const override;\n        bool shouldDebugBreak() const override;\n        int abortAfter() const override;\n        bool showInvisibles() const override;\n        Verbosity verbosity() const override;\n\n    private:\n\n        IStream const* openStream();\n        ConfigData m_data;\n\n        std::unique_ptr<IStream const> m_stream;\n        TestSpec m_testSpec;\n        bool m_hasTestFilters = false;\n    };\n\n} // end namespace Catch\n\n// end catch_config.hpp\n// start catch_assertionresult.h\n\n#include <string>\n\nnamespace Catch {\n\n    struct AssertionResultData\n    {\n        AssertionResultData() = delete;\n\n        AssertionResultData( ResultWas::OfType _resultType, LazyExpression const& _lazyExpression );\n\n        std::string message;\n        mutable std::string reconstructedExpression;\n        LazyExpression lazyExpression;\n        ResultWas::OfType resultType;\n\n        std::string reconstructExpression() const;\n    };\n\n    class AssertionResult {\n    public:\n        AssertionResult() = delete;\n        AssertionResult( AssertionInfo const& info, AssertionResultData const& data );\n\n        bool isOk() const;\n        bool succeeded() const;\n        ResultWas::OfType getResultType() const;\n        bool hasExpression() const;\n        bool hasMessage() const;\n        std::string getExpression() const;\n        std::string getExpressionInMacro() const;\n        bool hasExpandedExpression() const;\n        std::string getExpandedExpression() const;\n        std::string getMessage() const;\n        SourceLineInfo getSourceInfo() const;\n        StringRef getTestMacroName() const;\n\n    //protected:\n        AssertionInfo m_info;\n        AssertionResultData m_resultData;\n    };\n\n} // end namespace Catch\n\n// end catch_assertionresult.h\n// start catch_option.hpp\n\nnamespace Catch {\n\n    // An optional type\n    template<typename T>\n    class Option {\n    public:\n        Option() : nullableValue( nullptr ) {}\n        Option( T const& _value )\n        : nullableValue( new( storage ) T( _value ) )\n        {}\n        Option( Option const& _other )\n        : nullableValue( _other ? new( storage ) T( *_other ) : nullptr )\n        {}\n\n        ~Option() {\n            reset();\n        }\n\n        Option& operator= ( Option const& _other ) {\n            if( &_other != this ) {\n                reset();\n                if( _other )\n                    nullableValue = new( storage ) T( *_other );\n            }\n            return *this;\n        }\n        Option& operator = ( T const& _value ) {\n            reset();\n            nullableValue = new( storage ) T( _value );\n            return *this;\n        }\n\n        void reset() {\n            if( nullableValue )\n                nullableValue->~T();\n            nullableValue = nullptr;\n        }\n\n        T& operator*() { return *nullableValue; }\n        T const& operator*() const { return *nullableValue; }\n        T* operator->() { return nullableValue; }\n        const T* operator->() const { return nullableValue; }\n\n        T valueOr( T const& defaultValue ) const {\n            return nullableValue ? *nullableValue : defaultValue;\n        }\n\n        bool some() const { return nullableValue != nullptr; }\n        bool none() const { return nullableValue == nullptr; }\n\n        bool operator !() const { return nullableValue == nullptr; }\n        explicit operator bool() const {\n            return some();\n        }\n\n    private:\n        T *nullableValue;\n        alignas(alignof(T)) char storage[sizeof(T)];\n    };\n\n} // end namespace Catch\n\n// end catch_option.hpp\n#include <string>\n#include <iosfwd>\n#include <map>\n#include <set>\n#include <memory>\n\nnamespace Catch {\n\n    struct ReporterConfig {\n        explicit ReporterConfig( IConfigPtr const& _fullConfig );\n\n        ReporterConfig( IConfigPtr const& _fullConfig, std::ostream& _stream );\n\n        std::ostream& stream() const;\n        IConfigPtr fullConfig() const;\n\n    private:\n        std::ostream* m_stream;\n        IConfigPtr m_fullConfig;\n    };\n\n    struct ReporterPreferences {\n        bool shouldRedirectStdOut = false;\n        bool shouldReportAllAssertions = false;\n    };\n\n    template<typename T>\n    struct LazyStat : Option<T> {\n        LazyStat& operator=( T const& _value ) {\n            Option<T>::operator=( _value );\n            used = false;\n            return *this;\n        }\n        void reset() {\n            Option<T>::reset();\n            used = false;\n        }\n        bool used = false;\n    };\n\n    struct TestRunInfo {\n        TestRunInfo( std::string const& _name );\n        std::string name;\n    };\n    struct GroupInfo {\n        GroupInfo(  std::string const& _name,\n                    std::size_t _groupIndex,\n                    std::size_t _groupsCount );\n\n        std::string name;\n        std::size_t groupIndex;\n        std::size_t groupsCounts;\n    };\n\n    struct AssertionStats {\n        AssertionStats( AssertionResult const& _assertionResult,\n                        std::vector<MessageInfo> const& _infoMessages,\n                        Totals const& _totals );\n\n        AssertionStats( AssertionStats const& )              = default;\n        AssertionStats( AssertionStats && )                  = default;\n        AssertionStats& operator = ( AssertionStats const& ) = default;\n        AssertionStats& operator = ( AssertionStats && )     = default;\n        virtual ~AssertionStats();\n\n        AssertionResult assertionResult;\n        std::vector<MessageInfo> infoMessages;\n        Totals totals;\n    };\n\n    struct SectionStats {\n        SectionStats(   SectionInfo const& _sectionInfo,\n                        Counts const& _assertions,\n                        double _durationInSeconds,\n                        bool _missingAssertions );\n        SectionStats( SectionStats const& )              = default;\n        SectionStats( SectionStats && )                  = default;\n        SectionStats& operator = ( SectionStats const& ) = default;\n        SectionStats& operator = ( SectionStats && )     = default;\n        virtual ~SectionStats();\n\n        SectionInfo sectionInfo;\n        Counts assertions;\n        double durationInSeconds;\n        bool missingAssertions;\n    };\n\n    struct TestCaseStats {\n        TestCaseStats(  TestCaseInfo const& _testInfo,\n                        Totals const& _totals,\n                        std::string const& _stdOut,\n                        std::string const& _stdErr,\n                        bool _aborting );\n\n        TestCaseStats( TestCaseStats const& )              = default;\n        TestCaseStats( TestCaseStats && )                  = default;\n        TestCaseStats& operator = ( TestCaseStats const& ) = default;\n        TestCaseStats& operator = ( TestCaseStats && )     = default;\n        virtual ~TestCaseStats();\n\n        TestCaseInfo testInfo;\n        Totals totals;\n        std::string stdOut;\n        std::string stdErr;\n        bool aborting;\n    };\n\n    struct TestGroupStats {\n        TestGroupStats( GroupInfo const& _groupInfo,\n                        Totals const& _totals,\n                        bool _aborting );\n        TestGroupStats( GroupInfo const& _groupInfo );\n\n        TestGroupStats( TestGroupStats const& )              = default;\n        TestGroupStats( TestGroupStats && )                  = default;\n        TestGroupStats& operator = ( TestGroupStats const& ) = default;\n        TestGroupStats& operator = ( TestGroupStats && )     = default;\n        virtual ~TestGroupStats();\n\n        GroupInfo groupInfo;\n        Totals totals;\n        bool aborting;\n    };\n\n    struct TestRunStats {\n        TestRunStats(   TestRunInfo const& _runInfo,\n                        Totals const& _totals,\n                        bool _aborting );\n\n        TestRunStats( TestRunStats const& )              = default;\n        TestRunStats( TestRunStats && )                  = default;\n        TestRunStats& operator = ( TestRunStats const& ) = default;\n        TestRunStats& operator = ( TestRunStats && )     = default;\n        virtual ~TestRunStats();\n\n        TestRunInfo runInfo;\n        Totals totals;\n        bool aborting;\n    };\n\n    struct BenchmarkInfo {\n        std::string name;\n    };\n    struct BenchmarkStats {\n        BenchmarkInfo info;\n        std::size_t iterations;\n        uint64_t elapsedTimeInNanoseconds;\n    };\n\n    struct IStreamingReporter {\n        virtual ~IStreamingReporter() = default;\n\n        // Implementing class must also provide the following static methods:\n        // static std::string getDescription();\n        // static std::set<Verbosity> getSupportedVerbosities()\n\n        virtual ReporterPreferences getPreferences() const = 0;\n\n        virtual void noMatchingTestCases( std::string const& spec ) = 0;\n\n        virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0;\n        virtual void testGroupStarting( GroupInfo const& groupInfo ) = 0;\n\n        virtual void testCaseStarting( TestCaseInfo const& testInfo ) = 0;\n        virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0;\n\n        // *** experimental ***\n        virtual void benchmarkStarting( BenchmarkInfo const& ) {}\n\n        virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0;\n\n        // The return value indicates if the messages buffer should be cleared:\n        virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0;\n\n        // *** experimental ***\n        virtual void benchmarkEnded( BenchmarkStats const& ) {}\n\n        virtual void sectionEnded( SectionStats const& sectionStats ) = 0;\n        virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0;\n        virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0;\n        virtual void testRunEnded( TestRunStats const& testRunStats ) = 0;\n\n        virtual void skipTest( TestCaseInfo const& testInfo ) = 0;\n\n        // Default empty implementation provided\n        virtual void fatalErrorEncountered( StringRef name );\n\n        virtual bool isMulti() const;\n    };\n    using IStreamingReporterPtr = std::unique_ptr<IStreamingReporter>;\n\n    struct IReporterFactory {\n        virtual ~IReporterFactory();\n        virtual IStreamingReporterPtr create( ReporterConfig const& config ) const = 0;\n        virtual std::string getDescription() const = 0;\n    };\n    using IReporterFactoryPtr = std::shared_ptr<IReporterFactory>;\n\n    struct IReporterRegistry {\n        using FactoryMap = std::map<std::string, IReporterFactoryPtr>;\n        using Listeners = std::vector<IReporterFactoryPtr>;\n\n        virtual ~IReporterRegistry();\n        virtual IStreamingReporterPtr create( std::string const& name, IConfigPtr const& config ) const = 0;\n        virtual FactoryMap const& getFactories() const = 0;\n        virtual Listeners const& getListeners() const = 0;\n    };\n\n} // end namespace Catch\n\n// end catch_interfaces_reporter.h\n#include <algorithm>\n#include <cstring>\n#include <cfloat>\n#include <cstdio>\n#include <cassert>\n#include <memory>\n#include <ostream>\n\nnamespace Catch {\n    void prepareExpandedExpression(AssertionResult& result);\n\n    // Returns double formatted as %.3f (format expected on output)\n    std::string getFormattedDuration( double duration );\n\n    template<typename DerivedT>\n    struct StreamingReporterBase : IStreamingReporter {\n\n        StreamingReporterBase( ReporterConfig const& _config )\n        :   m_config( _config.fullConfig() ),\n            stream( _config.stream() )\n        {\n            m_reporterPrefs.shouldRedirectStdOut = false;\n            if( !DerivedT::getSupportedVerbosities().count( m_config->verbosity() ) )\n                CATCH_ERROR( \"Verbosity level not supported by this reporter\" );\n        }\n\n        ReporterPreferences getPreferences() const override {\n            return m_reporterPrefs;\n        }\n\n        static std::set<Verbosity> getSupportedVerbosities() {\n            return { Verbosity::Normal };\n        }\n\n        ~StreamingReporterBase() override = default;\n\n        void noMatchingTestCases(std::string const&) override {}\n\n        void testRunStarting(TestRunInfo const& _testRunInfo) override {\n            currentTestRunInfo = _testRunInfo;\n        }\n        void testGroupStarting(GroupInfo const& _groupInfo) override {\n            currentGroupInfo = _groupInfo;\n        }\n\n        void testCaseStarting(TestCaseInfo const& _testInfo) override  {\n            currentTestCaseInfo = _testInfo;\n        }\n        void sectionStarting(SectionInfo const& _sectionInfo) override {\n            m_sectionStack.push_back(_sectionInfo);\n        }\n\n        void sectionEnded(SectionStats const& /* _sectionStats */) override {\n            m_sectionStack.pop_back();\n        }\n        void testCaseEnded(TestCaseStats const& /* _testCaseStats */) override {\n            currentTestCaseInfo.reset();\n        }\n        void testGroupEnded(TestGroupStats const& /* _testGroupStats */) override {\n            currentGroupInfo.reset();\n        }\n        void testRunEnded(TestRunStats const& /* _testRunStats */) override {\n            currentTestCaseInfo.reset();\n            currentGroupInfo.reset();\n            currentTestRunInfo.reset();\n        }\n\n        void skipTest(TestCaseInfo const&) override {\n            // Don't do anything with this by default.\n            // It can optionally be overridden in the derived class.\n        }\n\n        IConfigPtr m_config;\n        std::ostream& stream;\n\n        LazyStat<TestRunInfo> currentTestRunInfo;\n        LazyStat<GroupInfo> currentGroupInfo;\n        LazyStat<TestCaseInfo> currentTestCaseInfo;\n\n        std::vector<SectionInfo> m_sectionStack;\n        ReporterPreferences m_reporterPrefs;\n    };\n\n    template<typename DerivedT>\n    struct CumulativeReporterBase : IStreamingReporter {\n        template<typename T, typename ChildNodeT>\n        struct Node {\n            explicit Node( T const& _value ) : value( _value ) {}\n            virtual ~Node() {}\n\n            using ChildNodes = std::vector<std::shared_ptr<ChildNodeT>>;\n            T value;\n            ChildNodes children;\n        };\n        struct SectionNode {\n            explicit SectionNode(SectionStats const& _stats) : stats(_stats) {}\n            virtual ~SectionNode() = default;\n\n            bool operator == (SectionNode const& other) const {\n                return stats.sectionInfo.lineInfo == other.stats.sectionInfo.lineInfo;\n            }\n            bool operator == (std::shared_ptr<SectionNode> const& other) const {\n                return operator==(*other);\n            }\n\n            SectionStats stats;\n            using ChildSections = std::vector<std::shared_ptr<SectionNode>>;\n            using Assertions = std::vector<AssertionStats>;\n            ChildSections childSections;\n            Assertions assertions;\n            std::string stdOut;\n            std::string stdErr;\n        };\n\n        struct BySectionInfo {\n            BySectionInfo( SectionInfo const& other ) : m_other( other ) {}\n            BySectionInfo( BySectionInfo const& other ) : m_other( other.m_other ) {}\n            bool operator() (std::shared_ptr<SectionNode> const& node) const {\n                return ((node->stats.sectionInfo.name == m_other.name) &&\n                        (node->stats.sectionInfo.lineInfo == m_other.lineInfo));\n            }\n            void operator=(BySectionInfo const&) = delete;\n\n        private:\n            SectionInfo const& m_other;\n        };\n\n        using TestCaseNode = Node<TestCaseStats, SectionNode>;\n        using TestGroupNode = Node<TestGroupStats, TestCaseNode>;\n        using TestRunNode = Node<TestRunStats, TestGroupNode>;\n\n        CumulativeReporterBase( ReporterConfig const& _config )\n        :   m_config( _config.fullConfig() ),\n            stream( _config.stream() )\n        {\n            m_reporterPrefs.shouldRedirectStdOut = false;\n            if( !DerivedT::getSupportedVerbosities().count( m_config->verbosity() ) )\n                CATCH_ERROR( \"Verbosity level not supported by this reporter\" );\n        }\n        ~CumulativeReporterBase() override = default;\n\n        ReporterPreferences getPreferences() const override {\n            return m_reporterPrefs;\n        }\n\n        static std::set<Verbosity> getSupportedVerbosities() {\n            return { Verbosity::Normal };\n        }\n\n        void testRunStarting( TestRunInfo const& ) override {}\n        void testGroupStarting( GroupInfo const& ) override {}\n\n        void testCaseStarting( TestCaseInfo const& ) override {}\n\n        void sectionStarting( SectionInfo const& sectionInfo ) override {\n            SectionStats incompleteStats( sectionInfo, Counts(), 0, false );\n            std::shared_ptr<SectionNode> node;\n            if( m_sectionStack.empty() ) {\n                if( !m_rootSection )\n                    m_rootSection = std::make_shared<SectionNode>( incompleteStats );\n                node = m_rootSection;\n            }\n            else {\n                SectionNode& parentNode = *m_sectionStack.back();\n                auto it =\n                    std::find_if(   parentNode.childSections.begin(),\n                                    parentNode.childSections.end(),\n                                    BySectionInfo( sectionInfo ) );\n                if( it == parentNode.childSections.end() ) {\n                    node = std::make_shared<SectionNode>( incompleteStats );\n                    parentNode.childSections.push_back( node );\n                }\n                else\n                    node = *it;\n            }\n            m_sectionStack.push_back( node );\n            m_deepestSection = std::move(node);\n        }\n\n        void assertionStarting(AssertionInfo const&) override {}\n\n        bool assertionEnded(AssertionStats const& assertionStats) override {\n            assert(!m_sectionStack.empty());\n            // AssertionResult holds a pointer to a temporary DecomposedExpression,\n            // which getExpandedExpression() calls to build the expression string.\n            // Our section stack copy of the assertionResult will likely outlive the\n            // temporary, so it must be expanded or discarded now to avoid calling\n            // a destroyed object later.\n            prepareExpandedExpression(const_cast<AssertionResult&>( assertionStats.assertionResult ) );\n            SectionNode& sectionNode = *m_sectionStack.back();\n            sectionNode.assertions.push_back(assertionStats);\n            return true;\n        }\n        void sectionEnded(SectionStats const& sectionStats) override {\n            assert(!m_sectionStack.empty());\n            SectionNode& node = *m_sectionStack.back();\n            node.stats = sectionStats;\n            m_sectionStack.pop_back();\n        }\n        void testCaseEnded(TestCaseStats const& testCaseStats) override {\n            auto node = std::make_shared<TestCaseNode>(testCaseStats);\n            assert(m_sectionStack.size() == 0);\n            node->children.push_back(m_rootSection);\n            m_testCases.push_back(node);\n            m_rootSection.reset();\n\n            assert(m_deepestSection);\n            m_deepestSection->stdOut = testCaseStats.stdOut;\n            m_deepestSection->stdErr = testCaseStats.stdErr;\n        }\n        void testGroupEnded(TestGroupStats const& testGroupStats) override {\n            auto node = std::make_shared<TestGroupNode>(testGroupStats);\n            node->children.swap(m_testCases);\n            m_testGroups.push_back(node);\n        }\n        void testRunEnded(TestRunStats const& testRunStats) override {\n            auto node = std::make_shared<TestRunNode>(testRunStats);\n            node->children.swap(m_testGroups);\n            m_testRuns.push_back(node);\n            testRunEndedCumulative();\n        }\n        virtual void testRunEndedCumulative() = 0;\n\n        void skipTest(TestCaseInfo const&) override {}\n\n        IConfigPtr m_config;\n        std::ostream& stream;\n        std::vector<AssertionStats> m_assertions;\n        std::vector<std::vector<std::shared_ptr<SectionNode>>> m_sections;\n        std::vector<std::shared_ptr<TestCaseNode>> m_testCases;\n        std::vector<std::shared_ptr<TestGroupNode>> m_testGroups;\n\n        std::vector<std::shared_ptr<TestRunNode>> m_testRuns;\n\n        std::shared_ptr<SectionNode> m_rootSection;\n        std::shared_ptr<SectionNode> m_deepestSection;\n        std::vector<std::shared_ptr<SectionNode>> m_sectionStack;\n        ReporterPreferences m_reporterPrefs;\n    };\n\n    template<char C>\n    char const* getLineOfChars() {\n        static char line[CATCH_CONFIG_CONSOLE_WIDTH] = {0};\n        if( !*line ) {\n            std::memset( line, C, CATCH_CONFIG_CONSOLE_WIDTH-1 );\n            line[CATCH_CONFIG_CONSOLE_WIDTH-1] = 0;\n        }\n        return line;\n    }\n\n    struct TestEventListenerBase : StreamingReporterBase<TestEventListenerBase> {\n        TestEventListenerBase( ReporterConfig const& _config );\n\n        static std::set<Verbosity> getSupportedVerbosities();\n\n        void assertionStarting(AssertionInfo const&) override;\n        bool assertionEnded(AssertionStats const&) override;\n    };\n\n} // end namespace Catch\n\n// end catch_reporter_bases.hpp\n// start catch_console_colour.h\n\nnamespace Catch {\n\n    struct Colour {\n        enum Code {\n            None = 0,\n\n            White,\n            Red,\n            Green,\n            Blue,\n            Cyan,\n            Yellow,\n            Grey,\n\n            Bright = 0x10,\n\n            BrightRed = Bright | Red,\n            BrightGreen = Bright | Green,\n            LightGrey = Bright | Grey,\n            BrightWhite = Bright | White,\n            BrightYellow = Bright | Yellow,\n\n            // By intention\n            FileName = LightGrey,\n            Warning = BrightYellow,\n            ResultError = BrightRed,\n            ResultSuccess = BrightGreen,\n            ResultExpectedFailure = Warning,\n\n            Error = BrightRed,\n            Success = Green,\n\n            OriginalExpression = Cyan,\n            ReconstructedExpression = BrightYellow,\n\n            SecondaryText = LightGrey,\n            Headers = White\n        };\n\n        // Use constructed object for RAII guard\n        Colour( Code _colourCode );\n        Colour( Colour&& other ) noexcept;\n        Colour& operator=( Colour&& other ) noexcept;\n        ~Colour();\n\n        // Use static method for one-shot changes\n        static void use( Code _colourCode );\n\n    private:\n        bool m_moved = false;\n    };\n\n    std::ostream& operator << ( std::ostream& os, Colour const& );\n\n} // end namespace Catch\n\n// end catch_console_colour.h\n// start catch_reporter_registrars.hpp\n\n\nnamespace Catch {\n\n    template<typename T>\n    class ReporterRegistrar {\n\n        class ReporterFactory : public IReporterFactory {\n\n            virtual IStreamingReporterPtr create( ReporterConfig const& config ) const override {\n                return std::unique_ptr<T>( new T( config ) );\n            }\n\n            virtual std::string getDescription() const override {\n                return T::getDescription();\n            }\n        };\n\n    public:\n\n        explicit ReporterRegistrar( std::string const& name ) {\n            getMutableRegistryHub().registerReporter( name, std::make_shared<ReporterFactory>() );\n        }\n    };\n\n    template<typename T>\n    class ListenerRegistrar {\n\n        class ListenerFactory : public IReporterFactory {\n\n            virtual IStreamingReporterPtr create( ReporterConfig const& config ) const override {\n                return std::unique_ptr<T>( new T( config ) );\n            }\n            virtual std::string getDescription() const override {\n                return std::string();\n            }\n        };\n\n    public:\n\n        ListenerRegistrar() {\n            getMutableRegistryHub().registerListener( std::make_shared<ListenerFactory>() );\n        }\n    };\n}\n\n#if !defined(CATCH_CONFIG_DISABLE)\n\n#define CATCH_REGISTER_REPORTER( name, reporterType ) \\\n    CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS          \\\n    namespace{ Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name ); } \\\n    CATCH_INTERNAL_UNSUPPRESS_GLOBALS_WARNINGS\n\n#define CATCH_REGISTER_LISTENER( listenerType ) \\\n     CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS   \\\n     namespace{ Catch::ListenerRegistrar<listenerType> catch_internal_RegistrarFor##listenerType; } \\\n     CATCH_INTERNAL_SUPPRESS_GLOBALS_WARNINGS\n#else // CATCH_CONFIG_DISABLE\n\n#define CATCH_REGISTER_REPORTER(name, reporterType)\n#define CATCH_REGISTER_LISTENER(listenerType)\n\n#endif // CATCH_CONFIG_DISABLE\n\n// end catch_reporter_registrars.hpp\n// Allow users to base their work off existing reporters\n// start catch_reporter_compact.h\n\nnamespace Catch {\n\n    struct CompactReporter : StreamingReporterBase<CompactReporter> {\n\n        using StreamingReporterBase::StreamingReporterBase;\n\n        ~CompactReporter() override;\n\n        static std::string getDescription();\n\n        ReporterPreferences getPreferences() const override;\n\n        void noMatchingTestCases(std::string const& spec) override;\n\n        void assertionStarting(AssertionInfo const&) override;\n\n        bool assertionEnded(AssertionStats const& _assertionStats) override;\n\n        void sectionEnded(SectionStats const& _sectionStats) override;\n\n        void testRunEnded(TestRunStats const& _testRunStats) override;\n\n    };\n\n} // end namespace Catch\n\n// end catch_reporter_compact.h\n// start catch_reporter_console.h\n\n#if defined(_MSC_VER)\n#pragma warning(push)\n#pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch\n                              // Note that 4062 (not all labels are handled\n                              // and default is missing) is enabled\n#endif\n\nnamespace Catch {\n    // Fwd decls\n    struct SummaryColumn;\n    class TablePrinter;\n\n    struct ConsoleReporter : StreamingReporterBase<ConsoleReporter> {\n        std::unique_ptr<TablePrinter> m_tablePrinter;\n\n        ConsoleReporter(ReporterConfig const& config);\n        ~ConsoleReporter() override;\n        static std::string getDescription();\n\n        void noMatchingTestCases(std::string const& spec) override;\n\n        void assertionStarting(AssertionInfo const&) override;\n\n        bool assertionEnded(AssertionStats const& _assertionStats) override;\n\n        void sectionStarting(SectionInfo const& _sectionInfo) override;\n        void sectionEnded(SectionStats const& _sectionStats) override;\n\n        void benchmarkStarting(BenchmarkInfo const& info) override;\n        void benchmarkEnded(BenchmarkStats const& stats) override;\n\n        void testCaseEnded(TestCaseStats const& _testCaseStats) override;\n        void testGroupEnded(TestGroupStats const& _testGroupStats) override;\n        void testRunEnded(TestRunStats const& _testRunStats) override;\n\n    private:\n\n        void lazyPrint();\n\n        void lazyPrintWithoutClosingBenchmarkTable();\n        void lazyPrintRunInfo();\n        void lazyPrintGroupInfo();\n        void printTestCaseAndSectionHeader();\n\n        void printClosedHeader(std::string const& _name);\n        void printOpenHeader(std::string const& _name);\n\n        // if string has a : in first line will set indent to follow it on\n        // subsequent lines\n        void printHeaderString(std::string const& _string, std::size_t indent = 0);\n\n        void printTotals(Totals const& totals);\n        void printSummaryRow(std::string const& label, std::vector<SummaryColumn> const& cols, std::size_t row);\n\n        void printTotalsDivider(Totals const& totals);\n        void printSummaryDivider();\n\n    private:\n        bool m_headerPrinted = false;\n    };\n\n} // end namespace Catch\n\n#if defined(_MSC_VER)\n#pragma warning(pop)\n#endif\n\n// end catch_reporter_console.h\n// start catch_reporter_junit.h\n\n// start catch_xmlwriter.h\n\n#include <vector>\n\nnamespace Catch {\n\n    class XmlEncode {\n    public:\n        enum ForWhat { ForTextNodes, ForAttributes };\n\n        XmlEncode( std::string const& str, ForWhat forWhat = ForTextNodes );\n\n        void encodeTo( std::ostream& os ) const;\n\n        friend std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode );\n\n    private:\n        std::string m_str;\n        ForWhat m_forWhat;\n    };\n\n    class XmlWriter {\n    public:\n\n        class ScopedElement {\n        public:\n            ScopedElement( XmlWriter* writer );\n\n            ScopedElement( ScopedElement&& other ) noexcept;\n            ScopedElement& operator=( ScopedElement&& other ) noexcept;\n\n            ~ScopedElement();\n\n            ScopedElement& writeText( std::string const& text, bool indent = true );\n\n            template<typename T>\n            ScopedElement& writeAttribute( std::string const& name, T const& attribute ) {\n                m_writer->writeAttribute( name, attribute );\n                return *this;\n            }\n\n        private:\n            mutable XmlWriter* m_writer = nullptr;\n        };\n\n        XmlWriter( std::ostream& os = Catch::cout() );\n        ~XmlWriter();\n\n        XmlWriter( XmlWriter const& ) = delete;\n        XmlWriter& operator=( XmlWriter const& ) = delete;\n\n        XmlWriter& startElement( std::string const& name );\n\n        ScopedElement scopedElement( std::string const& name );\n\n        XmlWriter& endElement();\n\n        XmlWriter& writeAttribute( std::string const& name, std::string const& attribute );\n\n        XmlWriter& writeAttribute( std::string const& name, bool attribute );\n\n        template<typename T>\n        XmlWriter& writeAttribute( std::string const& name, T const& attribute ) {\n            ReusableStringStream rss;\n            rss << attribute;\n            return writeAttribute( name, rss.str() );\n        }\n\n        XmlWriter& writeText( std::string const& text, bool indent = true );\n\n        XmlWriter& writeComment( std::string const& text );\n\n        void writeStylesheetRef( std::string const& url );\n\n        XmlWriter& writeBlankLine();\n\n        void ensureTagClosed();\n\n    private:\n\n        void writeDeclaration();\n\n        void newlineIfNecessary();\n\n        bool m_tagIsOpen = false;\n        bool m_needsNewline = false;\n        std::vector<std::string> m_tags;\n        std::string m_indent;\n        std::ostream& m_os;\n    };\n\n}\n\n// end catch_xmlwriter.h\nnamespace Catch {\n\n    class JunitReporter : public CumulativeReporterBase<JunitReporter> {\n    public:\n        JunitReporter(ReporterConfig const& _config);\n\n        ~JunitReporter() override;\n\n        static std::string getDescription();\n\n        void noMatchingTestCases(std::string const& /*spec*/) override;\n\n        void testRunStarting(TestRunInfo const& runInfo) override;\n\n        void testGroupStarting(GroupInfo const& groupInfo) override;\n\n        void testCaseStarting(TestCaseInfo const& testCaseInfo) override;\n        bool assertionEnded(AssertionStats const& assertionStats) override;\n\n        void testCaseEnded(TestCaseStats const& testCaseStats) override;\n\n        void testGroupEnded(TestGroupStats const& testGroupStats) override;\n\n        void testRunEndedCumulative() override;\n\n        void writeGroup(TestGroupNode const& groupNode, double suiteTime);\n\n        void writeTestCase(TestCaseNode const& testCaseNode);\n\n        void writeSection(std::string const& className,\n                          std::string const& rootName,\n                          SectionNode const& sectionNode);\n\n        void writeAssertions(SectionNode const& sectionNode);\n        void writeAssertion(AssertionStats const& stats);\n\n        XmlWriter xml;\n        Timer suiteTimer;\n        std::string stdOutForSuite;\n        std::string stdErrForSuite;\n        unsigned int unexpectedExceptions = 0;\n        bool m_okToFail = false;\n    };\n\n} // end namespace Catch\n\n// end catch_reporter_junit.h\n// start catch_reporter_xml.h\n\nnamespace Catch {\n    class XmlReporter : public StreamingReporterBase<XmlReporter> {\n    public:\n        XmlReporter(ReporterConfig const& _config);\n\n        ~XmlReporter() override;\n\n        static std::string getDescription();\n\n        virtual std::string getStylesheetRef() const;\n\n        void writeSourceInfo(SourceLineInfo const& sourceInfo);\n\n    public: // StreamingReporterBase\n\n        void noMatchingTestCases(std::string const& s) override;\n\n        void testRunStarting(TestRunInfo const& testInfo) override;\n\n        void testGroupStarting(GroupInfo const& groupInfo) override;\n\n        void testCaseStarting(TestCaseInfo const& testInfo) override;\n\n        void sectionStarting(SectionInfo const& sectionInfo) override;\n\n        void assertionStarting(AssertionInfo const&) override;\n\n        bool assertionEnded(AssertionStats const& assertionStats) override;\n\n        void sectionEnded(SectionStats const& sectionStats) override;\n\n        void testCaseEnded(TestCaseStats const& testCaseStats) override;\n\n        void testGroupEnded(TestGroupStats const& testGroupStats) override;\n\n        void testRunEnded(TestRunStats const& testRunStats) override;\n\n    private:\n        Timer m_testCaseTimer;\n        XmlWriter m_xml;\n        int m_sectionDepth = 0;\n    };\n\n} // end namespace Catch\n\n// end catch_reporter_xml.h\n\n// end catch_external_interfaces.h\n#endif\n\n#endif // ! CATCH_CONFIG_IMPL_ONLY\n\n#ifdef CATCH_IMPL\n// start catch_impl.hpp\n\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wweak-vtables\"\n#endif\n\n// Keep these here for external reporters\n// start catch_test_case_tracker.h\n\n#include <string>\n#include <vector>\n#include <memory>\n\nnamespace Catch {\nnamespace TestCaseTracking {\n\n    struct NameAndLocation {\n        std::string name;\n        SourceLineInfo location;\n\n        NameAndLocation( std::string const& _name, SourceLineInfo const& _location );\n    };\n\n    struct ITracker;\n\n    using ITrackerPtr = std::shared_ptr<ITracker>;\n\n    struct ITracker {\n        virtual ~ITracker();\n\n        // static queries\n        virtual NameAndLocation const& nameAndLocation() const = 0;\n\n        // dynamic queries\n        virtual bool isComplete() const = 0; // Successfully completed or failed\n        virtual bool isSuccessfullyCompleted() const = 0;\n        virtual bool isOpen() const = 0; // Started but not complete\n        virtual bool hasChildren() const = 0;\n\n        virtual ITracker& parent() = 0;\n\n        // actions\n        virtual void close() = 0; // Successfully complete\n        virtual void fail() = 0;\n        virtual void markAsNeedingAnotherRun() = 0;\n\n        virtual void addChild( ITrackerPtr const& child ) = 0;\n        virtual ITrackerPtr findChild( NameAndLocation const& nameAndLocation ) = 0;\n        virtual void openChild() = 0;\n\n        // Debug/ checking\n        virtual bool isSectionTracker() const = 0;\n        virtual bool isIndexTracker() const = 0;\n    };\n\n    class TrackerContext {\n\n        enum RunState {\n            NotStarted,\n            Executing,\n            CompletedCycle\n        };\n\n        ITrackerPtr m_rootTracker;\n        ITracker* m_currentTracker = nullptr;\n        RunState m_runState = NotStarted;\n\n    public:\n\n        static TrackerContext& instance();\n\n        ITracker& startRun();\n        void endRun();\n\n        void startCycle();\n        void completeCycle();\n\n        bool completedCycle() const;\n        ITracker& currentTracker();\n        void setCurrentTracker( ITracker* tracker );\n    };\n\n    class TrackerBase : public ITracker {\n    protected:\n        enum CycleState {\n            NotStarted,\n            Executing,\n            ExecutingChildren,\n            NeedsAnotherRun,\n            CompletedSuccessfully,\n            Failed\n        };\n\n        using Children = std::vector<ITrackerPtr>;\n        NameAndLocation m_nameAndLocation;\n        TrackerContext& m_ctx;\n        ITracker* m_parent;\n        Children m_children;\n        CycleState m_runState = NotStarted;\n\n    public:\n        TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent );\n\n        NameAndLocation const& nameAndLocation() const override;\n        bool isComplete() const override;\n        bool isSuccessfullyCompleted() const override;\n        bool isOpen() const override;\n        bool hasChildren() const override;\n\n        void addChild( ITrackerPtr const& child ) override;\n\n        ITrackerPtr findChild( NameAndLocation const& nameAndLocation ) override;\n        ITracker& parent() override;\n\n        void openChild() override;\n\n        bool isSectionTracker() const override;\n        bool isIndexTracker() const override;\n\n        void open();\n\n        void close() override;\n        void fail() override;\n        void markAsNeedingAnotherRun() override;\n\n    private:\n        void moveToParent();\n        void moveToThis();\n    };\n\n    class SectionTracker : public TrackerBase {\n        std::vector<std::string> m_filters;\n    public:\n        SectionTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent );\n\n        bool isSectionTracker() const override;\n\n        static SectionTracker& acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation );\n\n        void tryOpen();\n\n        void addInitialFilters( std::vector<std::string> const& filters );\n        void addNextFilters( std::vector<std::string> const& filters );\n    };\n\n    class IndexTracker : public TrackerBase {\n        int m_size;\n        int m_index = -1;\n    public:\n        IndexTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent, int size );\n\n        bool isIndexTracker() const override;\n        void close() override;\n\n        static IndexTracker& acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation, int size );\n\n        int index() const;\n\n        void moveNext();\n    };\n\n} // namespace TestCaseTracking\n\nusing TestCaseTracking::ITracker;\nusing TestCaseTracking::TrackerContext;\nusing TestCaseTracking::SectionTracker;\nusing TestCaseTracking::IndexTracker;\n\n} // namespace Catch\n\n// end catch_test_case_tracker.h\n\n// start catch_leak_detector.h\n\nnamespace Catch {\n\n    struct LeakDetector {\n        LeakDetector();\n        ~LeakDetector();\n    };\n\n}\n// end catch_leak_detector.h\n// Cpp files will be included in the single-header file here\n// start catch_approx.cpp\n\n#include <cmath>\n#include <limits>\n\nnamespace {\n\n// Performs equivalent check of std::fabs(lhs - rhs) <= margin\n// But without the subtraction to allow for INFINITY in comparison\nbool marginComparison(double lhs, double rhs, double margin) {\n    return (lhs + margin >= rhs) && (rhs + margin >= lhs);\n}\n\n}\n\nnamespace Catch {\nnamespace Detail {\n\n    Approx::Approx ( double value )\n    :   m_epsilon( std::numeric_limits<float>::epsilon()*100 ),\n        m_margin( 0.0 ),\n        m_scale( 0.0 ),\n        m_value( value )\n    {}\n\n    Approx Approx::custom() {\n        return Approx( 0 );\n    }\n\n    Approx Approx::operator-() const {\n        auto temp(*this);\n        temp.m_value = -temp.m_value;\n        return temp;\n    }\n\n    std::string Approx::toString() const {\n        ReusableStringStream rss;\n        rss << \"Approx( \" << ::Catch::Detail::stringify( m_value ) << \" )\";\n        return rss.str();\n    }\n\n    bool Approx::equalityComparisonImpl(const double other) const {\n        // First try with fixed margin, then compute margin based on epsilon, scale and Approx's value\n        // Thanks to Richard Harris for his help refining the scaled margin value\n        return marginComparison(m_value, other, m_margin) || marginComparison(m_value, other, m_epsilon * (m_scale + std::fabs(m_value)));\n    }\n\n    void Approx::setMargin(double margin) {\n        CATCH_ENFORCE(margin >= 0,\n            \"Invalid Approx::margin: \" << margin << '.'\n            << \" Approx::Margin has to be non-negative.\");\n        m_margin = margin;\n    }\n\n    void Approx::setEpsilon(double epsilon) {\n        CATCH_ENFORCE(epsilon >= 0 && epsilon <= 1.0,\n            \"Invalid Approx::epsilon: \" << epsilon << '.'\n            << \" Approx::epsilon has to be in [0, 1]\");\n        m_epsilon = epsilon;\n    }\n\n} // end namespace Detail\n\nnamespace literals {\n    Detail::Approx operator \"\" _a(long double val) {\n        return Detail::Approx(val);\n    }\n    Detail::Approx operator \"\" _a(unsigned long long val) {\n        return Detail::Approx(val);\n    }\n} // end namespace literals\n\nstd::string StringMaker<Catch::Detail::Approx>::convert(Catch::Detail::Approx const& value) {\n    return value.toString();\n}\n\n} // end namespace Catch\n// end catch_approx.cpp\n// start catch_assertionhandler.cpp\n\n// start catch_context.h\n\n#include <memory>\n\nnamespace Catch {\n\n    struct IResultCapture;\n    struct IRunner;\n    struct IConfig;\n    struct IMutableContext;\n\n    using IConfigPtr = std::shared_ptr<IConfig const>;\n\n    struct IContext\n    {\n        virtual ~IContext();\n\n        virtual IResultCapture* getResultCapture() = 0;\n        virtual IRunner* getRunner() = 0;\n        virtual IConfigPtr const& getConfig() const = 0;\n    };\n\n    struct IMutableContext : IContext\n    {\n        virtual ~IMutableContext();\n        virtual void setResultCapture( IResultCapture* resultCapture ) = 0;\n        virtual void setRunner( IRunner* runner ) = 0;\n        virtual void setConfig( IConfigPtr const& config ) = 0;\n\n    private:\n        static IMutableContext *currentContext;\n        friend IMutableContext& getCurrentMutableContext();\n        friend void cleanUpContext();\n        static void createContext();\n    };\n\n    inline IMutableContext& getCurrentMutableContext()\n    {\n        if( !IMutableContext::currentContext )\n            IMutableContext::createContext();\n        return *IMutableContext::currentContext;\n    }\n\n    inline IContext& getCurrentContext()\n    {\n        return getCurrentMutableContext();\n    }\n\n    void cleanUpContext();\n}\n\n// end catch_context.h\n// start catch_debugger.h\n\nnamespace Catch {\n    bool isDebuggerActive();\n}\n\n#ifdef CATCH_PLATFORM_MAC\n\n    #define CATCH_TRAP() __asm__(\"int $3\\n\" : : ) /* NOLINT */\n\n#elif defined(CATCH_PLATFORM_LINUX)\n    // If we can use inline assembler, do it because this allows us to break\n    // directly at the location of the failing check instead of breaking inside\n    // raise() called from it, i.e. one stack frame below.\n    #if defined(__GNUC__) && (defined(__i386) || defined(__x86_64))\n        #define CATCH_TRAP() asm volatile (\"int $3\") /* NOLINT */\n    #else // Fall back to the generic way.\n        #include <signal.h>\n\n        #define CATCH_TRAP() raise(SIGTRAP)\n    #endif\n#elif defined(_MSC_VER)\n    #define CATCH_TRAP() __debugbreak()\n#elif defined(__MINGW32__)\n    extern \"C\" __declspec(dllimport) void __stdcall DebugBreak();\n    #define CATCH_TRAP() DebugBreak()\n#endif\n\n#ifdef CATCH_TRAP\n    #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { CATCH_TRAP(); }\n#else\n    namespace Catch {\n        inline void doNothing() {}\n    }\n    #define CATCH_BREAK_INTO_DEBUGGER() Catch::doNothing()\n#endif\n\n// end catch_debugger.h\n// start catch_run_context.h\n\n// start catch_fatal_condition.h\n\n// start catch_windows_h_proxy.h\n\n\n#if defined(CATCH_PLATFORM_WINDOWS)\n\n#if !defined(NOMINMAX) && !defined(CATCH_CONFIG_NO_NOMINMAX)\n#  define CATCH_DEFINED_NOMINMAX\n#  define NOMINMAX\n#endif\n#if !defined(WIN32_LEAN_AND_MEAN) && !defined(CATCH_CONFIG_NO_WIN32_LEAN_AND_MEAN)\n#  define CATCH_DEFINED_WIN32_LEAN_AND_MEAN\n#  define WIN32_LEAN_AND_MEAN\n#endif\n\n#ifdef __AFXDLL\n#include <AfxWin.h>\n#else\n#include <windows.h>\n#endif\n\n#ifdef CATCH_DEFINED_NOMINMAX\n#  undef NOMINMAX\n#endif\n#ifdef CATCH_DEFINED_WIN32_LEAN_AND_MEAN\n#  undef WIN32_LEAN_AND_MEAN\n#endif\n\n#endif // defined(CATCH_PLATFORM_WINDOWS)\n\n// end catch_windows_h_proxy.h\n#if defined( CATCH_CONFIG_WINDOWS_SEH )\n\nnamespace Catch {\n\n    struct FatalConditionHandler {\n\n        static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo);\n        FatalConditionHandler();\n        static void reset();\n        ~FatalConditionHandler();\n\n    private:\n        static bool isSet;\n        static ULONG guaranteeSize;\n        static PVOID exceptionHandlerHandle;\n    };\n\n} // namespace Catch\n\n#elif defined ( CATCH_CONFIG_POSIX_SIGNALS )\n\n#include <signal.h>\n\nnamespace Catch {\n\n    struct FatalConditionHandler {\n\n        static bool isSet;\n        static struct sigaction oldSigActions[];\n        static stack_t oldSigStack;\n        static char altStackMem[];\n\n        static void handleSignal( int sig );\n\n        FatalConditionHandler();\n        ~FatalConditionHandler();\n        static void reset();\n    };\n\n} // namespace Catch\n\n#else\n\nnamespace Catch {\n    struct FatalConditionHandler {\n        void reset();\n    };\n}\n\n#endif\n\n// end catch_fatal_condition.h\n#include <string>\n\nnamespace Catch {\n\n    struct IMutableContext;\n\n    ///////////////////////////////////////////////////////////////////////////\n\n    class RunContext : public IResultCapture, public IRunner {\n\n    public:\n        RunContext( RunContext const& ) = delete;\n        RunContext& operator =( RunContext const& ) = delete;\n\n        explicit RunContext( IConfigPtr const& _config, IStreamingReporterPtr&& reporter );\n\n        ~RunContext() override;\n\n        void testGroupStarting( std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount );\n        void testGroupEnded( std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount );\n\n        Totals runTest(TestCase const& testCase);\n\n        IConfigPtr config() const;\n        IStreamingReporter& reporter() const;\n\n    public: // IResultCapture\n\n        // Assertion handlers\n        void handleExpr\n                (   AssertionInfo const& info,\n                    ITransientExpression const& expr,\n                    AssertionReaction& reaction ) override;\n        void handleMessage\n                (   AssertionInfo const& info,\n                    ResultWas::OfType resultType,\n                    StringRef const& message,\n                    AssertionReaction& reaction ) override;\n        void handleUnexpectedExceptionNotThrown\n                (   AssertionInfo const& info,\n                    AssertionReaction& reaction ) override;\n        void handleUnexpectedInflightException\n                (   AssertionInfo const& info,\n                    std::string const& message,\n                    AssertionReaction& reaction ) override;\n        void handleIncomplete\n                (   AssertionInfo const& info ) override;\n        void handleNonExpr\n                (   AssertionInfo const &info,\n                    ResultWas::OfType resultType,\n                    AssertionReaction &reaction ) override;\n\n        bool sectionStarted( SectionInfo const& sectionInfo, Counts& assertions ) override;\n\n        void sectionEnded( SectionEndInfo const& endInfo ) override;\n        void sectionEndedEarly( SectionEndInfo const& endInfo ) override;\n\n        auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker& override;\n\n        void benchmarkStarting( BenchmarkInfo const& info ) override;\n        void benchmarkEnded( BenchmarkStats const& stats ) override;\n\n        void pushScopedMessage( MessageInfo const& message ) override;\n        void popScopedMessage( MessageInfo const& message ) override;\n\n        std::string getCurrentTestName() const override;\n\n        const AssertionResult* getLastResult() const override;\n\n        void exceptionEarlyReported() override;\n\n        void handleFatalErrorCondition( StringRef message ) override;\n\n        bool lastAssertionPassed() override;\n\n        void assertionPassed() override;\n\n    public:\n        // !TBD We need to do this another way!\n        bool aborting() const final;\n\n    private:\n\n        void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr );\n        void invokeActiveTestCase();\n\n        void resetAssertionInfo();\n        bool testForMissingAssertions( Counts& assertions );\n\n        void assertionEnded( AssertionResult const& result );\n        void reportExpr\n                (   AssertionInfo const &info,\n                    ResultWas::OfType resultType,\n                    ITransientExpression const *expr,\n                    bool negated );\n\n        void populateReaction( AssertionReaction& reaction );\n\n    private:\n\n        void handleUnfinishedSections();\n\n        TestRunInfo m_runInfo;\n        IMutableContext& m_context;\n        TestCase const* m_activeTestCase = nullptr;\n        ITracker* m_testCaseTracker;\n        Option<AssertionResult> m_lastResult;\n\n        IConfigPtr m_config;\n        Totals m_totals;\n        IStreamingReporterPtr m_reporter;\n        std::vector<MessageInfo> m_messages;\n        AssertionInfo m_lastAssertionInfo;\n        std::vector<SectionEndInfo> m_unfinishedSections;\n        std::vector<ITracker*> m_activeSections;\n        TrackerContext m_trackerContext;\n        bool m_lastAssertionPassed = false;\n        bool m_shouldReportUnexpected = true;\n        bool m_includeSuccessfulResults;\n    };\n\n} // end namespace Catch\n\n// end catch_run_context.h\nnamespace Catch {\n\n    namespace {\n        auto operator <<( std::ostream& os, ITransientExpression const& expr ) -> std::ostream& {\n            expr.streamReconstructedExpression( os );\n            return os;\n        }\n    }\n\n    LazyExpression::LazyExpression( bool isNegated )\n    :   m_isNegated( isNegated )\n    {}\n\n    LazyExpression::LazyExpression( LazyExpression const& other ) : m_isNegated( other.m_isNegated ) {}\n\n    LazyExpression::operator bool() const {\n        return m_transientExpression != nullptr;\n    }\n\n    auto operator << ( std::ostream& os, LazyExpression const& lazyExpr ) -> std::ostream& {\n        if( lazyExpr.m_isNegated )\n            os << \"!\";\n\n        if( lazyExpr ) {\n            if( lazyExpr.m_isNegated && lazyExpr.m_transientExpression->isBinaryExpression() )\n                os << \"(\" << *lazyExpr.m_transientExpression << \")\";\n            else\n                os << *lazyExpr.m_transientExpression;\n        }\n        else {\n            os << \"{** error - unchecked empty expression requested **}\";\n        }\n        return os;\n    }\n\n    AssertionHandler::AssertionHandler\n        (   StringRef const& macroName,\n            SourceLineInfo const& lineInfo,\n            StringRef capturedExpression,\n            ResultDisposition::Flags resultDisposition )\n    :   m_assertionInfo{ macroName, lineInfo, capturedExpression, resultDisposition },\n        m_resultCapture( getResultCapture() )\n    {}\n\n    void AssertionHandler::handleExpr( ITransientExpression const& expr ) {\n        m_resultCapture.handleExpr( m_assertionInfo, expr, m_reaction );\n    }\n    void AssertionHandler::handleMessage(ResultWas::OfType resultType, StringRef const& message) {\n        m_resultCapture.handleMessage( m_assertionInfo, resultType, message, m_reaction );\n    }\n\n    auto AssertionHandler::allowThrows() const -> bool {\n        return getCurrentContext().getConfig()->allowThrows();\n    }\n\n    void AssertionHandler::complete() {\n        setCompleted();\n        if( m_reaction.shouldDebugBreak ) {\n\n            // If you find your debugger stopping you here then go one level up on the\n            // call-stack for the code that caused it (typically a failed assertion)\n\n            // (To go back to the test and change execution, jump over the throw, next)\n            CATCH_BREAK_INTO_DEBUGGER();\n        }\n        if (m_reaction.shouldThrow) {\n#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)\n            throw Catch::TestFailureException();\n#else\n            CATCH_ERROR( \"Test failure requires aborting test!\" );\n#endif\n        }\n    }\n    void AssertionHandler::setCompleted() {\n        m_completed = true;\n    }\n\n    void AssertionHandler::handleUnexpectedInflightException() {\n        m_resultCapture.handleUnexpectedInflightException( m_assertionInfo, Catch::translateActiveException(), m_reaction );\n    }\n\n    void AssertionHandler::handleExceptionThrownAsExpected() {\n        m_resultCapture.handleNonExpr(m_assertionInfo, ResultWas::Ok, m_reaction);\n    }\n    void AssertionHandler::handleExceptionNotThrownAsExpected() {\n        m_resultCapture.handleNonExpr(m_assertionInfo, ResultWas::Ok, m_reaction);\n    }\n\n    void AssertionHandler::handleUnexpectedExceptionNotThrown() {\n        m_resultCapture.handleUnexpectedExceptionNotThrown( m_assertionInfo, m_reaction );\n    }\n\n    void AssertionHandler::handleThrowingCallSkipped() {\n        m_resultCapture.handleNonExpr(m_assertionInfo, ResultWas::Ok, m_reaction);\n    }\n\n    // This is the overload that takes a string and infers the Equals matcher from it\n    // The more general overload, that takes any string matcher, is in catch_capture_matchers.cpp\n    void handleExceptionMatchExpr( AssertionHandler& handler, std::string const& str, StringRef const& matcherString  ) {\n        handleExceptionMatchExpr( handler, Matchers::Equals( str ), matcherString );\n    }\n\n} // namespace Catch\n// end catch_assertionhandler.cpp\n// start catch_assertionresult.cpp\n\nnamespace Catch {\n    AssertionResultData::AssertionResultData(ResultWas::OfType _resultType, LazyExpression const & _lazyExpression):\n        lazyExpression(_lazyExpression),\n        resultType(_resultType) {}\n\n    std::string AssertionResultData::reconstructExpression() const {\n\n        if( reconstructedExpression.empty() ) {\n            if( lazyExpression ) {\n                ReusableStringStream rss;\n                rss << lazyExpression;\n                reconstructedExpression = rss.str();\n            }\n        }\n        return reconstructedExpression;\n    }\n\n    AssertionResult::AssertionResult( AssertionInfo const& info, AssertionResultData const& data )\n    :   m_info( info ),\n        m_resultData( data )\n    {}\n\n    // Result was a success\n    bool AssertionResult::succeeded() const {\n        return Catch::isOk( m_resultData.resultType );\n    }\n\n    // Result was a success, or failure is suppressed\n    bool AssertionResult::isOk() const {\n        return Catch::isOk( m_resultData.resultType ) || shouldSuppressFailure( m_info.resultDisposition );\n    }\n\n    ResultWas::OfType AssertionResult::getResultType() const {\n        return m_resultData.resultType;\n    }\n\n    bool AssertionResult::hasExpression() const {\n        return m_info.capturedExpression[0] != 0;\n    }\n\n    bool AssertionResult::hasMessage() const {\n        return !m_resultData.message.empty();\n    }\n\n    std::string AssertionResult::getExpression() const {\n        if( isFalseTest( m_info.resultDisposition ) )\n            return \"!(\" + m_info.capturedExpression + \")\";\n        else\n            return m_info.capturedExpression;\n    }\n\n    std::string AssertionResult::getExpressionInMacro() const {\n        std::string expr;\n        if( m_info.macroName[0] == 0 )\n            expr = m_info.capturedExpression;\n        else {\n            expr.reserve( m_info.macroName.size() + m_info.capturedExpression.size() + 4 );\n            expr += m_info.macroName;\n            expr += \"( \";\n            expr += m_info.capturedExpression;\n            expr += \" )\";\n        }\n        return expr;\n    }\n\n    bool AssertionResult::hasExpandedExpression() const {\n        return hasExpression() && getExpandedExpression() != getExpression();\n    }\n\n    std::string AssertionResult::getExpandedExpression() const {\n        std::string expr = m_resultData.reconstructExpression();\n        return expr.empty()\n                ? getExpression()\n                : expr;\n    }\n\n    std::string AssertionResult::getMessage() const {\n        return m_resultData.message;\n    }\n    SourceLineInfo AssertionResult::getSourceInfo() const {\n        return m_info.lineInfo;\n    }\n\n    StringRef AssertionResult::getTestMacroName() const {\n        return m_info.macroName;\n    }\n\n} // end namespace Catch\n// end catch_assertionresult.cpp\n// start catch_benchmark.cpp\n\nnamespace Catch {\n\n    auto BenchmarkLooper::getResolution() -> uint64_t {\n        return getEstimatedClockResolution() * getCurrentContext().getConfig()->benchmarkResolutionMultiple();\n    }\n\n    void BenchmarkLooper::reportStart() {\n        getResultCapture().benchmarkStarting( { m_name } );\n    }\n    auto BenchmarkLooper::needsMoreIterations() -> bool {\n        auto elapsed = m_timer.getElapsedNanoseconds();\n\n        // Exponentially increasing iterations until we're confident in our timer resolution\n        if( elapsed < m_resolution ) {\n            m_iterationsToRun *= 10;\n            return true;\n        }\n\n        getResultCapture().benchmarkEnded( { { m_name }, m_count, elapsed } );\n        return false;\n    }\n\n} // end namespace Catch\n// end catch_benchmark.cpp\n// start catch_capture_matchers.cpp\n\nnamespace Catch {\n\n    using StringMatcher = Matchers::Impl::MatcherBase<std::string>;\n\n    // This is the general overload that takes a any string matcher\n    // There is another overload, in catch_assertionhandler.h/.cpp, that only takes a string and infers\n    // the Equals matcher (so the header does not mention matchers)\n    void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef const& matcherString  ) {\n        std::string exceptionMessage = Catch::translateActiveException();\n        MatchExpr<std::string, StringMatcher const&> expr( exceptionMessage, matcher, matcherString );\n        handler.handleExpr( expr );\n    }\n\n} // namespace Catch\n// end catch_capture_matchers.cpp\n// start catch_commandline.cpp\n\n// start catch_commandline.h\n\n// start catch_clara.h\n\n// Use Catch's value for console width (store Clara's off to the side, if present)\n#ifdef CLARA_CONFIG_CONSOLE_WIDTH\n#define CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH\n#undef CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH\n#endif\n#define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH CATCH_CONFIG_CONSOLE_WIDTH-1\n\n#ifdef __clang__\n#pragma clang diagnostic push\n#pragma clang diagnostic ignored \"-Wweak-vtables\"\n#pragma clang diagnostic ignored \"-Wexit-time-destructors\"\n#pragma clang diagnostic ignored \"-Wshadow\"\n#endif\n\n// start clara.hpp\n// Copyright 2017 Two Blue Cubes Ltd. All rights reserved.\n//\n// Distributed under the Boost Software License, Version 1.0. (See accompanying\n// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n//\n// See https://github.com/philsquared/Clara for more details\n\n// Clara v1.1.5\n\n\n#ifndef CATCH_CLARA_CONFIG_CONSOLE_WIDTH\n#define CATCH_CLARA_CONFIG_CONSOLE_WIDTH 80\n#endif\n\n#ifndef CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH\n#define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH CATCH_CLARA_CONFIG_CONSOLE_WIDTH\n#endif\n\n#ifndef CLARA_CONFIG_OPTIONAL_TYPE\n#ifdef __has_include\n#if __has_include(<optional>) && __cplusplus >= 201703L\n#include <optional>\n#define CLARA_CONFIG_OPTIONAL_TYPE std::optional\n#endif\n#endif\n#endif\n\n// ----------- #included from clara_textflow.hpp -----------\n\n// TextFlowCpp\n//\n// A single-header library for wrapping and laying out basic text, by Phil Nash\n//\n// Distributed under the Boost Software License, Version 1.0. (See accompanying\n// file LICENSE.txt or copy at http://www.boost.org/LICENSE_1_0.txt)\n//\n// This project is hosted at https://github.com/philsquared/textflowcpp\n\n\n#include <cassert>\n#include <ostream>\n#include <sstream>\n#include <vector>\n\n#ifndef CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH\n#define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH 80\n#endif\n\nnamespace Catch {\nnamespace clara {\nnamespace TextFlow {\n\ninline auto isWhitespace(char c) -> bool {\n\tstatic std::string chars = \" \\t\\n\\r\";\n\treturn chars.find(c) != std::string::npos;\n}\ninline auto isBreakableBefore(char c) -> bool {\n\tstatic std::string chars = \"[({<|\";\n\treturn chars.find(c) != std::string::npos;\n}\ninline auto isBreakableAfter(char c) -> bool {\n\tstatic std::string chars = \"])}>.,:;*+-=&/\\\\\";\n\treturn chars.find(c) != std::string::npos;\n}\n\nclass Columns;\n\nclass Column {\n\tstd::vector<std::string> m_strings;\n\tsize_t m_width = CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH;\n\tsize_t m_indent = 0;\n\tsize_t m_initialIndent = std::string::npos;\n\npublic:\n\tclass iterator {\n\t\tfriend Column;\n\n\t\tColumn const& m_column;\n\t\tsize_t m_stringIndex = 0;\n\t\tsize_t m_pos = 0;\n\n\t\tsize_t m_len = 0;\n\t\tsize_t m_end = 0;\n\t\tbool m_suffix = false;\n\n\t\titerator(Column const& column, size_t stringIndex)\n\t\t\t: m_column(column),\n\t\t\tm_stringIndex(stringIndex) {}\n\n\t\tauto line() const -> std::string const& { return m_column.m_strings[m_stringIndex]; }\n\n\t\tauto isBoundary(size_t at) const -> bool {\n\t\t\tassert(at > 0);\n\t\t\tassert(at <= line().size());\n\n\t\t\treturn at == line().size() ||\n\t\t\t\t(isWhitespace(line()[at]) && !isWhitespace(line()[at - 1])) ||\n\t\t\t\tisBreakableBefore(line()[at]) ||\n\t\t\t\tisBreakableAfter(line()[at - 1]);\n\t\t}\n\n\t\tvoid calcLength() {\n\t\t\tassert(m_stringIndex < m_column.m_strings.size());\n\n\t\t\tm_suffix = false;\n\t\t\tauto width = m_column.m_width - indent();\n\t\t\tm_end = m_pos;\n\t\t\twhile (m_end < line().size() && line()[m_end] != '\\n')\n\t\t\t\t++m_end;\n\n\t\t\tif (m_end < m_pos + width) {\n\t\t\t\tm_len = m_end - m_pos;\n\t\t\t} else {\n\t\t\t\tsize_t len = width;\n\t\t\t\twhile (len > 0 && !isBoundary(m_pos + len))\n\t\t\t\t\t--len;\n\t\t\t\twhile (len > 0 && isWhitespace(line()[m_pos + len - 1]))\n\t\t\t\t\t--len;\n\n\t\t\t\tif (len > 0) {\n\t\t\t\t\tm_len = len;\n\t\t\t\t} else {\n\t\t\t\t\tm_suffix = true;\n\t\t\t\t\tm_len = width - 1;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tauto indent() const -> size_t {\n\t\t\tauto initial = m_pos == 0 && m_stringIndex == 0 ? m_column.m_initialIndent : std::string::npos;\n\t\t\treturn initial == std::string::npos ? m_column.m_indent : initial;\n\t\t}\n\n\t\tauto addIndentAndSuffix(std::string const &plain) const -> std::string {\n\t\t\treturn std::string(indent(), ' ') + (m_suffix ? plain + \"-\" : plain);\n\t\t}\n\n\tpublic:\n\t\tusing difference_type = std::ptrdiff_t;\n\t\tusing value_type = std::string;\n\t\tusing pointer = value_type * ;\n\t\tusing reference = value_type & ;\n\t\tusing iterator_category = std::forward_iterator_tag;\n\n\t\texplicit iterator(Column const& column) : m_column(column) {\n\t\t\tassert(m_column.m_width > m_column.m_indent);\n\t\t\tassert(m_column.m_initialIndent == std::string::npos || m_column.m_width > m_column.m_initialIndent);\n\t\t\tcalcLength();\n\t\t\tif (m_len == 0)\n\t\t\t\tm_stringIndex++; // Empty string\n\t\t}\n\n\t\tauto operator *() const -> std::string {\n\t\t\tassert(m_stringIndex < m_column.m_strings.size());\n\t\t\tassert(m_pos <= m_end);\n\t\t\treturn addIndentAndSuffix(line().substr(m_pos, m_len));\n\t\t}\n\n\t\tauto operator ++() -> iterator& {\n\t\t\tm_pos += m_len;\n\t\t\tif (m_pos < line().size() && line()[m_pos] == '\\n')\n\t\t\t\tm_pos += 1;\n\t\t\telse\n\t\t\t\twhile (m_pos < line().size() && isWhitespace(line()[m_pos]))\n\t\t\t\t\t++m_pos;\n\n\t\t\tif (m_pos == line().size()) {\n\t\t\t\tm_pos = 0;\n\t\t\t\t++m_stringIndex;\n\t\t\t}\n\t\t\tif (m_stringIndex < m_column.m_strings.size())\n\t\t\t\tcalcLength();\n\t\t\treturn *this;\n\t\t}\n\t\tauto operator ++(int) -> iterator {\n\t\t\titerator prev(*this);\n\t\t\toperator++();\n\t\t\treturn prev;\n\t\t}\n\n\t\tauto operator ==(iterator const& other) const -> bool {\n\t\t\treturn\n\t\t\t\tm_pos == other.m_pos &&\n\t\t\t\tm_stringIndex == other.m_stringIndex &&\n\t\t\t\t&m_column == &other.m_column;\n\t\t}\n\t\tauto operator !=(iterator const& other) const -> bool {\n\t\t\treturn !operator==(other);\n\t\t}\n\t};\n\tusing const_iterator = iterator;\n\n\texplicit Column(std::string const& text) { m_strings.push_back(text); }\n\n\tauto width(size_t newWidth) -> Column& {\n\t\tassert(newWidth > 0);\n\t\tm_width = newWidth;\n\t\treturn *this;\n\t}\n\tauto indent(size_t newIndent) -> Column& {\n\t\tm_indent = newIndent;\n\t\treturn *this;\n\t}\n\tauto initialIndent(size_t newIndent) -> Column& {\n\t\tm_initialIndent = newIndent;\n\t\treturn *this;\n\t}\n\n\tauto width() const -> size_t { return m_width; }\n\tauto begin() const -> iterator { return iterator(*this); }\n\tauto end() const -> iterator { return { *this, m_strings.size() }; }\n\n\tinline friend std::ostream& operator << (std::ostream& os, Column const& col) {\n\t\tbool first = true;\n\t\tfor (auto line : col) {\n\t\t\tif (first)\n\t\t\t\tfirst = false;\n\t\t\telse\n\t\t\t\tos << \"\\n\";\n\t\t\tos << line;\n\t\t}\n\t\treturn os;\n\t}\n\n\tauto operator + (Column const& other)->Columns;\n\n\tauto toString() const -> std::string {\n\t\tstd::ostringstream oss;\n\t\toss << *this;\n\t\treturn oss.str();\n\t}\n};\n\nclass Spacer : public Column {\n\npublic:\n\texplicit Spacer(size_t spaceWidth) : Column(\"\") {\n\t\twidth(spaceWidth);\n\t}\n};\n\nclass Columns {\n\tstd::vector<Column> m_columns;\n\npublic:\n\n\tclass iterator {\n\t\tfriend Columns;\n\t\tstruct EndTag {};\n\n\t\tstd::vector<Column> const& m_columns;\n\t\tstd::vector<Column::iterator> m_iterators;\n\t\tsize_t m_activeIterators;\n\n\t\titerator(Columns const& columns, EndTag)\n\t\t\t: m_columns(columns.m_columns),\n\t\t\tm_activeIterators(0) {\n\t\t\tm_iterators.reserve(m_columns.size());\n\n\t\t\tfor (auto const& col : m_columns)\n\t\t\t\tm_iterators.push_back(col.end());\n\t\t}\n\n\tpublic:\n\t\tusing difference_type = std::ptrdiff_t;\n\t\tusing value_type = std::string;\n\t\tusing pointer = value_type * ;\n\t\tusing reference = value_type & ;\n\t\tusing iterator_category = std::forward_iterator_tag;\n\n\t\texplicit iterator(Columns const& columns)\n\t\t\t: m_columns(columns.m_columns),\n\t\t\tm_activeIterators(m_columns.size()) {\n\t\t\tm_iterators.reserve(m_columns.size());\n\n\t\t\tfor (auto const& col : m_columns)\n\t\t\t\tm_iterators.push_back(col.begin());\n\t\t}\n\n\t\tauto operator ==(iterator const& other) const -> bool {\n\t\t\treturn m_iterators == other.m_iterators;\n\t\t}\n\t\tauto operator !=(iterator const& other) const -> bool {\n\t\t\treturn m_iterators != other.m_iterators;\n\t\t}\n\t\tauto operator *() const -> std::string {\n\t\t\tstd::string row, padding;\n\n\t\t\tfor (size_t i = 0; i < m_columns.size(); ++i) {\n\t\t\t\tauto width = m_columns[i].width();\n\t\t\t\tif (m_iterators[i] != m_columns[i].end()) {\n\t\t\t\t\tstd::string col = *m_iterators[i];\n\t\t\t\t\trow += padding + col;\n\t\t\t\t\tif (col.size() < width)\n\t\t\t\t\t\tpadding = std::string(width - col.size(), ' ');\n\t\t\t\t\telse\n\t\t\t\t\t\tpadding = \"\";\n\t\t\t\t} else {\n\t\t\t\t\tpadding += std::string(width, ' ');\n\t\t\t\t}\n\t\t\t}\n\t\t\treturn row;\n\t\t}\n\t\tauto operator ++() -> iterator& {\n\t\t\tfor (size_t i = 0; i < m_columns.size(); ++i) {\n\t\t\t\tif (m_iterators[i] != m_columns[i].end())\n\t\t\t\t\t++m_iterators[i];\n\t\t\t}\n\t\t\treturn *this;\n\t\t}\n\t\tauto operator ++(int) -> iterator {\n\t\t\titerator prev(*this);\n\t\t\toperator++();\n\t\t\treturn prev;\n\t\t}\n\t};\n\tusing const_iterator = iterator;\n\n\tauto begin() const -> iterator { return iterator(*this); }\n\tauto end() const -> iterator { return { *this, iterator::EndTag() }; }\n\n\tauto operator += (Column const& col) -> Columns& {\n\t\tm_columns.push_back(col);\n\t\treturn *this;\n\t}\n\tauto operator + (Column const& col) -> Columns {\n\t\tColumns combined = *this;\n\t\tcombined += col;\n\t\treturn combined;\n\t}\n\n\tinline friend std::ostream& operator << (std::ostream& os, Columns const& cols) {\n\n\t\tbool first = true;\n\t\tfor (auto line : cols) {\n\t\t\tif (first)\n\t\t\t\tfirst = false;\n\t\t\telse\n\t\t\t\tos << \"\\n\";\n\t\t\tos << line;\n\t\t}\n\t\treturn os;\n\t}\n\n\tauto toString() const -> std::string {\n\t\tstd::ostringstream oss;\n\t\toss << *this;\n\t\treturn oss.str();\n\t}\n};\n\ninline auto Column::operator + (Column const& other) -> Columns {\n\tColumns cols;\n\tcols += *this;\n\tcols += other;\n\treturn cols;\n}\n}\n\n}\n}\n\n// ----------- end of #include from clara_textflow.hpp -----------\n// ........... back in clara.hpp\n\n#include <string>\n#include <memory>\n#include <set>\n#include <algorithm>\n\n#if !defined(CATCH_PLATFORM_WINDOWS) && ( defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) )\n#define CATCH_PLATFORM_WINDOWS\n#endif\n\nnamespace Catch { namespace clara {\nnamespace detail {\n\n    // Traits for extracting arg and return type of lambdas (for single argument lambdas)\n    template<typename L>\n    struct UnaryLambdaTraits : UnaryLambdaTraits<decltype( &L::operator() )> {};\n\n    template<typename ClassT, typename ReturnT, typename... Args>\n    struct UnaryLambdaTraits<ReturnT( ClassT::* )( Args... ) const> {\n        static const bool isValid = false;\n    };\n\n    template<typename ClassT, typename ReturnT, typename ArgT>\n    struct UnaryLambdaTraits<ReturnT( ClassT::* )( ArgT ) const> {\n        static const bool isValid = true;\n        using ArgType = typename std::remove_const<typename std::remove_reference<ArgT>::type>::type;\n        using ReturnType = ReturnT;\n    };\n\n    class TokenStream;\n\n    // Transport for raw args (copied from main args, or supplied via init list for testing)\n    class Args {\n        friend TokenStream;\n        std::string m_exeName;\n        std::vector<std::string> m_args;\n\n    public:\n        Args( int argc, char const* const* argv )\n            : m_exeName(argv[0]),\n              m_args(argv + 1, argv + argc) {}\n\n        Args( std::initializer_list<std::string> args )\n        :   m_exeName( *args.begin() ),\n            m_args( args.begin()+1, args.end() )\n        {}\n\n        auto exeName() const -> std::string {\n            return m_exeName;\n        }\n    };\n\n    // Wraps a token coming from a token stream. These may not directly correspond to strings as a single string\n    // may encode an option + its argument if the : or = form is used\n    enum class TokenType {\n        Option, Argument\n    };\n    struct Token {\n        TokenType type;\n        std::string token;\n    };\n\n    inline auto isOptPrefix( char c ) -> bool {\n        return c == '-'\n#ifdef CATCH_PLATFORM_WINDOWS\n            || c == '/'\n#endif\n        ;\n    }\n\n    // Abstracts iterators into args as a stream of tokens, with option arguments uniformly handled\n    class TokenStream {\n        using Iterator = std::vector<std::string>::const_iterator;\n        Iterator it;\n        Iterator itEnd;\n        std::vector<Token> m_tokenBuffer;\n\n        void loadBuffer() {\n            m_tokenBuffer.resize( 0 );\n\n            // Skip any empty strings\n            while( it != itEnd && it->empty() )\n                ++it;\n\n            if( it != itEnd ) {\n                auto const &next = *it;\n                if( isOptPrefix( next[0] ) ) {\n                    auto delimiterPos = next.find_first_of( \" :=\" );\n                    if( delimiterPos != std::string::npos ) {\n                        m_tokenBuffer.push_back( { TokenType::Option, next.substr( 0, delimiterPos ) } );\n                        m_tokenBuffer.push_back( { TokenType::Argument, next.substr( delimiterPos + 1 ) } );\n                    } else {\n                        if( next[1] != '-' && next.size() > 2 ) {\n                            std::string opt = \"- \";\n                            for( size_t i = 1; i < next.size(); ++i ) {\n                                opt[1] = next[i];\n                                m_tokenBuffer.push_back( { TokenType::Option, opt } );\n                            }\n                        } else {\n                            m_tokenBuffer.push_back( { TokenType::Option, next } );\n                        }\n                    }\n                } else {\n                    m_tokenBuffer.push_back( { TokenType::Argument, next } );\n                }\n            }\n        }\n\n    public:\n        explicit TokenStream( Args const &args ) : TokenStream( args.m_args.begin(), args.m_args.end() ) {}\n\n        TokenStream( Iterator it, Iterator itEnd ) : it( it ), itEnd( itEnd ) {\n            loadBuffer();\n        }\n\n        explicit operator bool() const {\n            return !m_tokenBuffer.empty() || it != itEnd;\n        }\n\n        auto count() const -> size_t { return m_tokenBuffer.size() + (itEnd - it); }\n\n        auto operator*() const -> Token {\n            assert( !m_tokenBuffer.empty() );\n            return m_tokenBuffer.front();\n        }\n\n        auto operator->() const -> Token const * {\n            assert( !m_tokenBuffer.empty() );\n            return &m_tokenBuffer.front();\n        }\n\n        auto operator++() -> TokenStream & {\n            if( m_tokenBuffer.size() >= 2 ) {\n                m_tokenBuffer.erase( m_tokenBuffer.begin() );\n            } else {\n                if( it != itEnd )\n                    ++it;\n                loadBuffer();\n            }\n            return *this;\n        }\n    };\n\n    class ResultBase {\n    public:\n        enum Type {\n            Ok, LogicError, RuntimeError\n        };\n\n    protected:\n        ResultBase( Type type ) : m_type( type ) {}\n        virtual ~ResultBase() = default;\n\n        virtual void enforceOk() const = 0;\n\n        Type m_type;\n    };\n\n    template<typename T>\n    class ResultValueBase : public ResultBase {\n    public:\n        auto value() const -> T const & {\n            enforceOk();\n            return m_value;\n        }\n\n    protected:\n        ResultValueBase( Type type ) : ResultBase( type ) {}\n\n        ResultValueBase( ResultValueBase const &other ) : ResultBase( other ) {\n            if( m_type == ResultBase::Ok )\n                new( &m_value ) T( other.m_value );\n        }\n\n        ResultValueBase( Type, T const &value ) : ResultBase( Ok ) {\n            new( &m_value ) T( value );\n        }\n\n        auto operator=( ResultValueBase const &other ) -> ResultValueBase & {\n            if( m_type == ResultBase::Ok )\n                m_value.~T();\n            ResultBase::operator=(other);\n            if( m_type == ResultBase::Ok )\n                new( &m_value ) T( other.m_value );\n            return *this;\n        }\n\n        ~ResultValueBase() override {\n            if( m_type == Ok )\n                m_value.~T();\n        }\n\n        union {\n            T m_value;\n        };\n    };\n\n    template<>\n    class ResultValueBase<void> : public ResultBase {\n    protected:\n        using ResultBase::ResultBase;\n    };\n\n    template<typename T = void>\n    class BasicResult : public ResultValueBase<T> {\n    public:\n        template<typename U>\n        explicit BasicResult( BasicResult<U> const &other )\n        :   ResultValueBase<T>( other.type() ),\n            m_errorMessage( other.errorMessage() )\n        {\n            assert( type() != ResultBase::Ok );\n        }\n\n        template<typename U>\n        static auto ok( U const &value ) -> BasicResult { return { ResultBase::Ok, value }; }\n        static auto ok() -> BasicResult { return { ResultBase::Ok }; }\n        static auto logicError( std::string const &message ) -> BasicResult { return { ResultBase::LogicError, message }; }\n        static auto runtimeError( std::string const &message ) -> BasicResult { return { ResultBase::RuntimeError, message }; }\n\n        explicit operator bool() const { return m_type == ResultBase::Ok; }\n        auto type() const -> ResultBase::Type { return m_type; }\n        auto errorMessage() const -> std::string { return m_errorMessage; }\n\n    protected:\n        void enforceOk() const override {\n\n            // Errors shouldn't reach this point, but if they do\n            // the actual error message will be in m_errorMessage\n            assert( m_type != ResultBase::LogicError );\n            assert( m_type != ResultBase::RuntimeError );\n            if( m_type != ResultBase::Ok )\n                std::abort();\n        }\n\n        std::string m_errorMessage; // Only populated if resultType is an error\n\n        BasicResult( ResultBase::Type type, std::string const &message )\n        :   ResultValueBase<T>(type),\n            m_errorMessage(message)\n        {\n            assert( m_type != ResultBase::Ok );\n        }\n\n        using ResultValueBase<T>::ResultValueBase;\n        using ResultBase::m_type;\n    };\n\n    enum class ParseResultType {\n        Matched, NoMatch, ShortCircuitAll, ShortCircuitSame\n    };\n\n    class ParseState {\n    public:\n\n        ParseState( ParseResultType type, TokenStream const &remainingTokens )\n        : m_type(type),\n          m_remainingTokens( remainingTokens )\n        {}\n\n        auto type() const -> ParseResultType { return m_type; }\n        auto remainingTokens() const -> TokenStream { return m_remainingTokens; }\n\n    private:\n        ParseResultType m_type;\n        TokenStream m_remainingTokens;\n    };\n\n    using Result = BasicResult<void>;\n    using ParserResult = BasicResult<ParseResultType>;\n    using InternalParseResult = BasicResult<ParseState>;\n\n    struct HelpColumns {\n        std::string left;\n        std::string right;\n    };\n\n    template<typename T>\n    inline auto convertInto( std::string const &source, T& target ) -> ParserResult {\n        std::stringstream ss;\n        ss << source;\n        ss >> target;\n        if( ss.fail() )\n            return ParserResult::runtimeError( \"Unable to convert '\" + source + \"' to destination type\" );\n        else\n            return ParserResult::ok( ParseResultType::Matched );\n    }\n    inline auto convertInto( std::string const &source, std::string& target ) -> ParserResult {\n        target = source;\n        return ParserResult::ok( ParseResultType::Matched );\n    }\n    inline auto convertInto( std::string const &source, bool &target ) -> ParserResult {\n        std::string srcLC = source;\n        std::transform( srcLC.begin(), srcLC.end(), srcLC.begin(), []( char c ) { return static_cast<char>( ::tolower(c) ); } );\n        if (srcLC == \"y\" || srcLC == \"1\" || srcLC == \"true\" || srcLC == \"yes\" || srcLC == \"on\")\n            target = true;\n        else if (srcLC == \"n\" || srcLC == \"0\" || srcLC == \"false\" || srcLC == \"no\" || srcLC == \"off\")\n            target = false;\n        else\n            return ParserResult::runtimeError( \"Expected a boolean value but did not recognise: '\" + source + \"'\" );\n        return ParserResult::ok( ParseResultType::Matched );\n    }\n#ifdef CLARA_CONFIG_OPTIONAL_TYPE\n    template<typename T>\n    inline auto convertInto( std::string const &source, CLARA_CONFIG_OPTIONAL_TYPE<T>& target ) -> ParserResult {\n        T temp;\n        auto result = convertInto( source, temp );\n        if( result )\n            target = std::move(temp);\n        return result;\n    }\n#endif // CLARA_CONFIG_OPTIONAL_TYPE\n\n    struct NonCopyable {\n        NonCopyable() = default;\n        NonCopyable( NonCopyable const & ) = delete;\n        NonCopyable( NonCopyable && ) = delete;\n        NonCopyable &operator=( NonCopyable const & ) = delete;\n        NonCopyable &operator=( NonCopyable && ) = delete;\n    };\n\n    struct BoundRef : NonCopyable {\n        virtual ~BoundRef() = default;\n        virtual auto isContainer() const -> bool { return false; }\n        virtual auto isFlag() const -> bool { return false; }\n    };\n    struct BoundValueRefBase : BoundRef {\n        virtual auto setValue( std::string const &arg ) -> ParserResult = 0;\n    };\n    struct BoundFlagRefBase : BoundRef {\n        virtual auto setFlag( bool flag ) -> ParserResult = 0;\n        virtual auto isFlag() const -> bool { return true; }\n    };\n\n    template<typename T>\n    struct BoundValueRef : BoundValueRefBase {\n        T &m_ref;\n\n        explicit BoundValueRef( T &ref ) : m_ref( ref ) {}\n\n        auto setValue( std::string const &arg ) -> ParserResult override {\n            return convertInto( arg, m_ref );\n        }\n    };\n\n    template<typename T>\n    struct BoundValueRef<std::vector<T>> : BoundValueRefBase {\n        std::vector<T> &m_ref;\n\n        explicit BoundValueRef( std::vector<T> &ref ) : m_ref( ref ) {}\n\n        auto isContainer() const -> bool override { return true; }\n\n        auto setValue( std::string const &arg ) -> ParserResult override {\n            T temp;\n            auto result = convertInto( arg, temp );\n            if( result )\n                m_ref.push_back( temp );\n            return result;\n        }\n    };\n\n    struct BoundFlagRef : BoundFlagRefBase {\n        bool &m_ref;\n\n        explicit BoundFlagRef( bool &ref ) : m_ref( ref ) {}\n\n        auto setFlag( bool flag ) -> ParserResult override {\n            m_ref = flag;\n            return ParserResult::ok( ParseResultType::Matched );\n        }\n    };\n\n    template<typename ReturnType>\n    struct LambdaInvoker {\n        static_assert( std::is_same<ReturnType, ParserResult>::value, \"Lambda must return void or clara::ParserResult\" );\n\n        template<typename L, typename ArgType>\n        static auto invoke( L const &lambda, ArgType const &arg ) -> ParserResult {\n            return lambda( arg );\n        }\n    };\n\n    template<>\n    struct LambdaInvoker<void> {\n        template<typename L, typename ArgType>\n        static auto invoke( L const &lambda, ArgType const &arg ) -> ParserResult {\n            lambda( arg );\n            return ParserResult::ok( ParseResultType::Matched );\n        }\n    };\n\n    template<typename ArgType, typename L>\n    inline auto invokeLambda( L const &lambda, std::string const &arg ) -> ParserResult {\n        ArgType temp{};\n        auto result = convertInto( arg, temp );\n        return !result\n           ? result\n           : LambdaInvoker<typename UnaryLambdaTraits<L>::ReturnType>::invoke( lambda, temp );\n    }\n\n    template<typename L>\n    struct BoundLambda : BoundValueRefBase {\n        L m_lambda;\n\n        static_assert( UnaryLambdaTraits<L>::isValid, \"Supplied lambda must take exactly one argument\" );\n        explicit BoundLambda( L const &lambda ) : m_lambda( lambda ) {}\n\n        auto setValue( std::string const &arg ) -> ParserResult override {\n            return invokeLambda<typename UnaryLambdaTraits<L>::ArgType>( m_lambda, arg );\n        }\n    };\n\n    template<typename L>\n    struct BoundFlagLambda : BoundFlagRefBase {\n        L m_lambda;\n\n        static_assert( UnaryLambdaTraits<L>::isValid, \"Supplied lambda must take exactly one argument\" );\n        static_assert( std::is_same<typename UnaryLambdaTraits<L>::ArgType, bool>::value, \"flags must be boolean\" );\n\n        explicit BoundFlagLambda( L const &lambda ) : m_lambda( lambda ) {}\n\n        auto setFlag( bool flag ) -> ParserResult override {\n            return LambdaInvoker<typename UnaryLambdaTraits<L>::ReturnType>::invoke( m_lambda, flag );\n        }\n    };\n\n    enum class Optionality { Optional, Required };\n\n    struct Parser;\n\n    class ParserBase {\n    public:\n        virtual ~ParserBase() = default;\n        virtual auto validate() const -> Result { return Result::ok(); }\n        virtual auto parse( std::string const& exeName, TokenStream const &tokens) const -> InternalParseResult  = 0;\n        virtual auto cardinality() const -> size_t { return 1; }\n\n        auto parse( Args const &args ) const -> InternalParseResult {\n            return parse( args.exeName(), TokenStream( args ) );\n        }\n    };\n\n    template<typename DerivedT>\n    class ComposableParserImpl : public ParserBase {\n    public:\n        template<typename T>\n        auto operator|( T const &other ) const -> Parser;\n\n\t\ttemplate<typename T>\n        auto operator+( T const &other ) const -> Parser;\n    };\n\n    // Common code and state for Args and Opts\n    template<typename DerivedT>\n    class ParserRefImpl : public ComposableParserImpl<DerivedT> {\n    protected:\n        Optionality m_optionality = Optionality::Optional;\n        std::shared_ptr<BoundRef> m_ref;\n        std::string m_hint;\n        std::string m_description;\n\n        explicit ParserRefImpl( std::shared_ptr<BoundRef> const &ref ) : m_ref( ref ) {}\n\n    public:\n        template<typename T>\n        ParserRefImpl( T &ref, std::string const &hint )\n        :   m_ref( std::make_shared<BoundValueRef<T>>( ref ) ),\n            m_hint( hint )\n        {}\n\n        template<typename LambdaT>\n        ParserRefImpl( LambdaT const &ref, std::string const &hint )\n        :   m_ref( std::make_shared<BoundLambda<LambdaT>>( ref ) ),\n            m_hint(hint)\n        {}\n\n        auto operator()( std::string const &description ) -> DerivedT & {\n            m_description = description;\n            return static_cast<DerivedT &>( *this );\n        }\n\n        auto optional() -> DerivedT & {\n            m_optionality = Optionality::Optional;\n            return static_cast<DerivedT &>( *this );\n        };\n\n        auto required() -> DerivedT & {\n            m_optionality = Optionality::Required;\n            return static_cast<DerivedT &>( *this );\n        };\n\n        auto isOptional() const -> bool {\n            return m_optionality == Optionality::Optional;\n        }\n\n        auto cardinality() const -> size_t override {\n            if( m_ref->isContainer() )\n                return 0;\n            else\n                return 1;\n        }\n\n        auto hint() const -> std::string { return m_hint; }\n    };\n\n    class ExeName : public ComposableParserImpl<ExeName> {\n        std::shared_ptr<std::string> m_name;\n        std::shared_ptr<BoundValueRefBase> m_ref;\n\n        template<typename LambdaT>\n        static auto makeRef(LambdaT const &lambda) -> std::shared_ptr<BoundValueRefBase> {\n            return std::make_shared<BoundLambda<LambdaT>>( lambda) ;\n        }\n\n    public:\n        ExeName() : m_name( std::make_shared<std::string>( \"<executable>\" ) ) {}\n\n        explicit ExeName( std::string &ref ) : ExeName() {\n            m_ref = std::make_shared<BoundValueRef<std::string>>( ref );\n        }\n\n        template<typename LambdaT>\n        explicit ExeName( LambdaT const& lambda ) : ExeName() {\n            m_ref = std::make_shared<BoundLambda<LambdaT>>( lambda );\n        }\n\n        // The exe name is not parsed out of the normal tokens, but is handled specially\n        auto parse( std::string const&, TokenStream const &tokens ) const -> InternalParseResult override {\n            return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, tokens ) );\n        }\n\n        auto name() const -> std::string { return *m_name; }\n        auto set( std::string const& newName ) -> ParserResult {\n\n            auto lastSlash = newName.find_last_of( \"\\\\/\" );\n            auto filename = ( lastSlash == std::string::npos )\n                    ? newName\n                    : newName.substr( lastSlash+1 );\n\n            *m_name = filename;\n            if( m_ref )\n                return m_ref->setValue( filename );\n            else\n                return ParserResult::ok( ParseResultType::Matched );\n        }\n    };\n\n    class Arg : public ParserRefImpl<Arg> {\n    public:\n        using ParserRefImpl::ParserRefImpl;\n\n        auto parse( std::string const &, TokenStream const &tokens ) const -> InternalParseResult override {\n            auto validationResult = validate();\n            if( !validationResult )\n                return InternalParseResult( validationResult );\n\n            auto remainingTokens = tokens;\n            auto const &token = *remainingTokens;\n            if( token.type != TokenType::Argument )\n                return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, remainingTokens ) );\n\n            assert( !m_ref->isFlag() );\n            auto valueRef = static_cast<detail::BoundValueRefBase*>( m_ref.get() );\n\n            auto result = valueRef->setValue( remainingTokens->token );\n            if( !result )\n                return InternalParseResult( result );\n            else\n                return InternalParseResult::ok( ParseState( ParseResultType::Matched, ++remainingTokens ) );\n        }\n    };\n\n    inline auto normaliseOpt( std::string const &optName ) -> std::string {\n#ifdef CATCH_PLATFORM_WINDOWS\n        if( optName[0] == '/' )\n            return \"-\" + optName.substr( 1 );\n        else\n#endif\n            return optName;\n    }\n\n    class Opt : public ParserRefImpl<Opt> {\n    protected:\n        std::vector<std::string> m_optNames;\n\n    public:\n        template<typename LambdaT>\n        explicit Opt( LambdaT const &ref ) : ParserRefImpl( std::make_shared<BoundFlagLambda<LambdaT>>( ref ) ) {}\n\n        explicit Opt( bool &ref ) : ParserRefImpl( std::make_shared<BoundFlagRef>( ref ) ) {}\n\n        template<typename LambdaT>\n        Opt( LambdaT const &ref, std::string const &hint ) : ParserRefImpl( ref, hint ) {}\n\n        template<typename T>\n        Opt( T &ref, std::string const &hint ) : ParserRefImpl( ref, hint ) {}\n\n        auto operator[]( std::string const &optName ) -> Opt & {\n            m_optNames.push_back( optName );\n            return *this;\n        }\n\n        auto getHelpColumns() const -> std::vector<HelpColumns> {\n            std::ostringstream oss;\n            bool first = true;\n            for( auto const &opt : m_optNames ) {\n                if (first)\n                    first = false;\n                else\n                    oss << \", \";\n                oss << opt;\n            }\n            if( !m_hint.empty() )\n                oss << \" <\" << m_hint << \">\";\n            return { { oss.str(), m_description } };\n        }\n\n        auto isMatch( std::string const &optToken ) const -> bool {\n            auto normalisedToken = normaliseOpt( optToken );\n            for( auto const &name : m_optNames ) {\n                if( normaliseOpt( name ) == normalisedToken )\n                    return true;\n            }\n            return false;\n        }\n\n        using ParserBase::parse;\n\n        auto parse( std::string const&, TokenStream const &tokens ) const -> InternalParseResult override {\n            auto validationResult = validate();\n            if( !validationResult )\n                return InternalParseResult( validationResult );\n\n            auto remainingTokens = tokens;\n            if( remainingTokens && remainingTokens->type == TokenType::Option ) {\n                auto const &token = *remainingTokens;\n                if( isMatch(token.token ) ) {\n                    if( m_ref->isFlag() ) {\n                        auto flagRef = static_cast<detail::BoundFlagRefBase*>( m_ref.get() );\n                        auto result = flagRef->setFlag( true );\n                        if( !result )\n                            return InternalParseResult( result );\n                        if( result.value() == ParseResultType::ShortCircuitAll )\n                            return InternalParseResult::ok( ParseState( result.value(), remainingTokens ) );\n                    } else {\n                        auto valueRef = static_cast<detail::BoundValueRefBase*>( m_ref.get() );\n                        ++remainingTokens;\n                        if( !remainingTokens )\n                            return InternalParseResult::runtimeError( \"Expected argument following \" + token.token );\n                        auto const &argToken = *remainingTokens;\n                        if( argToken.type != TokenType::Argument )\n                            return InternalParseResult::runtimeError( \"Expected argument following \" + token.token );\n                        auto result = valueRef->setValue( argToken.token );\n                        if( !result )\n                            return InternalParseResult( result );\n                        if( result.value() == ParseResultType::ShortCircuitAll )\n                            return InternalParseResult::ok( ParseState( result.value(), remainingTokens ) );\n                    }\n                    return InternalParseResult::ok( ParseState( ParseResultType::Matched, ++remainingTokens ) );\n                }\n            }\n            return InternalParseResult::ok( ParseState( ParseResultType::NoMatch, remainingTokens ) );\n        }\n\n        auto validate() const -> Result override {\n            if( m_optNames.empty() )\n                return Result::logicError( \"No options supplied to Opt\" );\n            for( auto const &name : m_optNames ) {\n                if( name.empty() )\n                    return Result::logicError( \"Option name cannot be empty\" );\n#ifdef CATCH_PLATFORM_WINDOWS\n                if( name[0] != '-' && name[0] != '/' )\n                    return Result::logicError( \"Option name must begin with '-' or '/'\" );\n#else\n                if( name[0] != '-' )\n                    return Result::logicError( \"Option name must begin with '-'\" );\n#endif\n            }\n            return ParserRefImpl::validate();\n        }\n    };\n\n    struct Help : Opt {\n        Help( bool &showHelpFlag )\n        :   Opt([&]( bool flag ) {\n                showHelpFlag = flag;\n                return ParserResult::ok( ParseResultType::ShortCircuitAll );\n            })\n        {\n            static_cast<Opt &>( *this )\n                    (\"display usage information\")\n                    [\"-?\"][\"-h\"][\"--help\"]\n                    .optional();\n        }\n    };\n\n    struct Parser : ParserBase {\n\n        mutable ExeName m_exeName;\n        std::vector<Opt> m_options;\n        std::vector<Arg> m_args;\n\n        auto operator|=( ExeName const &exeName ) -> Parser & {\n            m_exeName = exeName;\n            return *this;\n        }\n\n        auto operator|=( Arg const &arg ) -> Parser & {\n            m_args.push_back(arg);\n            return *this;\n        }\n\n        auto operator|=( Opt const &opt ) -> Parser & {\n            m_options.push_back(opt);\n            return *this;\n        }\n\n        auto operator|=( Parser const &other ) -> Parser & {\n            m_options.insert(m_options.end(), other.m_options.begin(), other.m_options.end());\n            m_args.insert(m_args.end(), other.m_args.begin(), other.m_args.end());\n            return *this;\n        }\n\n        template<typename T>\n        auto operator|( T const &other ) const -> Parser {\n            return Parser( *this ) |= other;\n        }\n\n        // Forward deprecated interface with '+' instead of '|'\n        template<typename T>\n        auto operator+=( T const &other ) -> Parser & { return operator|=( other ); }\n        template<typename T>\n        auto operator+( T const &other ) const -> Parser { return operator|( other ); }\n\n        auto getHelpColumns() const -> std::vector<HelpColumns> {\n            std::vector<HelpColumns> cols;\n            for (auto const &o : m_options) {\n                auto childCols = o.getHelpColumns();\n                cols.insert( cols.end(), childCols.begin(), childCols.end() );\n            }\n            return cols;\n        }\n\n        void writeToStream( std::ostream &os ) const {\n            if (!m_exeName.name().empty()) {\n                os << \"usage:\\n\" << \"  \" << m_exeName.name() << \" \";\n                bool required = true, first = true;\n                for( auto const &arg : m_args ) {\n                    if (first)\n                        first = false;\n                    else\n                        os << \" \";\n                    if( arg.isOptional() && required ) {\n                        os << \"[\";\n                        required = false;\n                    }\n                    os << \"<\" << arg.hint() << \">\";\n                    if( arg.cardinality() == 0 )\n                        os << \" ... \";\n                }\n                if( !required )\n                    os << \"]\";\n                if( !m_options.empty() )\n                    os << \" options\";\n                os << \"\\n\\nwhere options are:\" << std::endl;\n            }\n\n            auto rows = getHelpColumns();\n            size_t consoleWidth = CATCH_CLARA_CONFIG_CONSOLE_WIDTH;\n            size_t optWidth = 0;\n            for( auto const &cols : rows )\n                optWidth = (std::max)(optWidth, cols.left.size() + 2);\n\n            optWidth = (std::min)(optWidth, consoleWidth/2);\n\n            for( auto const &cols : rows ) {\n                auto row =\n                        TextFlow::Column( cols.left ).width( optWidth ).indent( 2 ) +\n                        TextFlow::Spacer(4) +\n                        TextFlow::Column( cols.right ).width( consoleWidth - 7 - optWidth );\n                os << row << std::endl;\n            }\n        }\n\n        friend auto operator<<( std::ostream &os, Parser const &parser ) -> std::ostream& {\n            parser.writeToStream( os );\n            return os;\n        }\n\n        auto validate() const -> Result override {\n            for( auto const &opt : m_options ) {\n                auto result = opt.validate();\n                if( !result )\n                    return result;\n            }\n            for( auto const &arg : m_args ) {\n                auto result = arg.validate();\n                if( !result )\n                    return result;\n            }\n            return Result::ok();\n        }\n\n        using ParserBase::parse;\n\n        auto parse( std::string const& exeName, TokenStream const &tokens ) const -> InternalParseResult override {\n\n            struct ParserInfo {\n                ParserBase const* parser = nullptr;\n                size_t count = 0;\n            };\n            const size_t totalParsers = m_options.size() + m_args.size();\n            assert( totalParsers < 512 );\n            // ParserInfo parseInfos[totalParsers]; // <-- this is what we really want to do\n            ParserInfo parseInfos[512];\n\n            {\n                size_t i = 0;\n                for (auto const &opt : m_options) parseInfos[i++].parser = &opt;\n                for (auto const &arg : m_args) parseInfos[i++].parser = &arg;\n            }\n\n            m_exeName.set( exeName );\n\n            auto result = InternalParseResult::ok( ParseState( ParseResultType::NoMatch, tokens ) );\n            while( result.value().remainingTokens() ) {\n                bool tokenParsed = false;\n\n                for( size_t i = 0; i < totalParsers; ++i ) {\n                    auto&  parseInfo = parseInfos[i];\n                    if( parseInfo.parser->cardinality() == 0 || parseInfo.count < parseInfo.parser->cardinality() ) {\n                        result = parseInfo.parser->parse(exeName, result.value().remainingTokens());\n                        if (!result)\n                            return result;\n                        if (result.value().type() != ParseResultType::NoMatch) {\n                            tokenParsed = true;\n                            ++parseInfo.count;\n                            break;\n                        }\n                    }\n                }\n\n                if( result.value().type() == ParseResultType::ShortCircuitAll )\n                    return result;\n                if( !tokenParsed )\n                    return InternalParseResult::runtimeError( \"Unrecognised token: \" + result.value().remainingTokens()->token );\n            }\n            // !TBD Check missing required options\n            return result;\n        }\n    };\n\n    template<typename DerivedT>\n    template<typename T>\n    auto ComposableParserImpl<DerivedT>::operator|( T const &other ) const -> Parser {\n        return Parser() | static_cast<DerivedT const &>( *this ) | other;\n    }\n} // namespace detail\n\n// A Combined parser\nusing detail::Parser;\n\n// A parser for options\nusing detail::Opt;\n\n// A parser for arguments\nusing detail::Arg;\n\n// Wrapper for argc, argv from main()\nusing detail::Args;\n\n// Specifies the name of the executable\nusing detail::ExeName;\n\n// Convenience wrapper for option parser that specifies the help option\nusing detail::Help;\n\n// enum of result types from a parse\nusing detail::ParseResultType;\n\n// Result type for parser operation\nusing detail::ParserResult;\n\n}} // namespace Catch::clara\n\n// end clara.hpp\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n\n// Restore Clara's value for console width, if present\n#ifdef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH\n#define CATCH_CLARA_TEXTFLOW_CONFIG_CONSOLE_WIDTH CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH\n#undef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH\n#endif\n\n// end catch_clara.h\nnamespace Catch {\n\n    clara::Parser makeCommandLineParser( ConfigData& config );\n\n} // end namespace Catch\n\n// end catch_commandline.h\n#include <fstream>\n#include <ctime>\n\nnamespace Catch {\n\n    clara::Parser makeCommandLineParser( ConfigData& config ) {\n\n        using namespace clara;\n\n        auto const setWarning = [&]( std::string const& warning ) {\n                auto warningSet = [&]() {\n                    if( warning == \"NoAssertions\" )\n                        return WarnAbout::NoAssertions;\n\n                    if ( warning == \"NoTests\" )\n                        return WarnAbout::NoTests;\n\n                    return WarnAbout::Nothing;\n                }();\n\n                if (warningSet == WarnAbout::Nothing)\n                    return ParserResult::runtimeError( \"Unrecognised warning: '\" + warning + \"'\" );\n                config.warnings = static_cast<WarnAbout::What>( config.warnings | warningSet );\n                return ParserResult::ok( ParseResultType::Matched );\n            };\n        auto const loadTestNamesFromFile = [&]( std::string const& filename ) {\n                std::ifstream f( filename.c_str() );\n                if( !f.is_open() )\n                    return ParserResult::runtimeError( \"Unable to load input file: '\" + filename + \"'\" );\n\n                std::string line;\n                while( std::getline( f, line ) ) {\n                    line = trim(line);\n                    if( !line.empty() && !startsWith( line, '#' ) ) {\n                        if( !startsWith( line, '\"' ) )\n                            line = '\"' + line + '\"';\n                        config.testsOrTags.push_back( line + ',' );\n                    }\n                }\n                return ParserResult::ok( ParseResultType::Matched );\n            };\n        auto const setTestOrder = [&]( std::string const& order ) {\n                if( startsWith( \"declared\", order ) )\n                    config.runOrder = RunTests::InDeclarationOrder;\n                else if( startsWith( \"lexical\", order ) )\n                    config.runOrder = RunTests::InLexicographicalOrder;\n                else if( startsWith( \"random\", order ) )\n                    config.runOrder = RunTests::InRandomOrder;\n                else\n                    return clara::ParserResult::runtimeError( \"Unrecognised ordering: '\" + order + \"'\" );\n                return ParserResult::ok( ParseResultType::Matched );\n            };\n        auto const setRngSeed = [&]( std::string const& seed ) {\n                if( seed != \"time\" )\n                    return clara::detail::convertInto( seed, config.rngSeed );\n                config.rngSeed = static_cast<unsigned int>( std::time(nullptr) );\n                return ParserResult::ok( ParseResultType::Matched );\n            };\n        auto const setColourUsage = [&]( std::string const& useColour ) {\n                    auto mode = toLower( useColour );\n\n                    if( mode == \"yes\" )\n                        config.useColour = UseColour::Yes;\n                    else if( mode == \"no\" )\n                        config.useColour = UseColour::No;\n                    else if( mode == \"auto\" )\n                        config.useColour = UseColour::Auto;\n                    else\n                        return ParserResult::runtimeError( \"colour mode must be one of: auto, yes or no. '\" + useColour + \"' not recognised\" );\n                return ParserResult::ok( ParseResultType::Matched );\n            };\n        auto const setWaitForKeypress = [&]( std::string const& keypress ) {\n                auto keypressLc = toLower( keypress );\n                if( keypressLc == \"start\" )\n                    config.waitForKeypress = WaitForKeypress::BeforeStart;\n                else if( keypressLc == \"exit\" )\n                    config.waitForKeypress = WaitForKeypress::BeforeExit;\n                else if( keypressLc == \"both\" )\n                    config.waitForKeypress = WaitForKeypress::BeforeStartAndExit;\n                else\n                    return ParserResult::runtimeError( \"keypress argument must be one of: start, exit or both. '\" + keypress + \"' not recognised\" );\n            return ParserResult::ok( ParseResultType::Matched );\n            };\n        auto const setVerbosity = [&]( std::string const& verbosity ) {\n            auto lcVerbosity = toLower( verbosity );\n            if( lcVerbosity == \"quiet\" )\n                config.verbosity = Verbosity::Quiet;\n            else if( lcVerbosity == \"normal\" )\n                config.verbosity = Verbosity::Normal;\n            else if( lcVerbosity == \"high\" )\n                config.verbosity = Verbosity::High;\n            else\n                return ParserResult::runtimeError( \"Unrecognised verbosity, '\" + verbosity + \"'\" );\n            return ParserResult::ok( ParseResultType::Matched );\n        };\n        auto const setReporter = [&]( std::string const& reporter ) {\n            IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories();\n\n            auto lcReporter = toLower( reporter );\n            auto result = factories.find( lcReporter );\n\n            if( factories.end() != result )\n                config.reporterName = lcReporter;\n            else\n                return ParserResult::runtimeError( \"Unrecognized reporter, '\" + reporter + \"'. Check available with --list-reporters\" );\n            return ParserResult::ok( ParseResultType::Matched );\n        };\n\n        auto cli\n            = ExeName( config.processName )\n            | Help( config.showHelp )\n            | Opt( config.listTests )\n                [\"-l\"][\"--list-tests\"]\n                ( \"list all/matching test cases\" )\n            | Opt( config.listTags )\n                [\"-t\"][\"--list-tags\"]\n                ( \"list all/matching tags\" )\n            | Opt( config.showSuccessfulTests )\n                [\"-s\"][\"--success\"]\n                ( \"include successful tests in output\" )\n            | Opt( config.shouldDebugBreak )\n                [\"-b\"][\"--break\"]\n                ( \"break into debugger on failure\" )\n            | Opt( config.noThrow )\n                [\"-e\"][\"--nothrow\"]\n                ( \"skip exception tests\" )\n            | Opt( config.showInvisibles )\n                [\"-i\"][\"--invisibles\"]\n                ( \"show invisibles (tabs, newlines)\" )\n            | Opt( config.outputFilename, \"filename\" )\n                [\"-o\"][\"--out\"]\n                ( \"output filename\" )\n            | Opt( setReporter, \"name\" )\n                [\"-r\"][\"--reporter\"]\n                ( \"reporter to use (defaults to console)\" )\n            | Opt( config.name, \"name\" )\n                [\"-n\"][\"--name\"]\n                ( \"suite name\" )\n            | Opt( [&]( bool ){ config.abortAfter = 1; } )\n                [\"-a\"][\"--abort\"]\n                ( \"abort at first failure\" )\n            | Opt( [&]( int x ){ config.abortAfter = x; }, \"no. failures\" )\n                [\"-x\"][\"--abortx\"]\n                ( \"abort after x failures\" )\n            | Opt( setWarning, \"warning name\" )\n                [\"-w\"][\"--warn\"]\n                ( \"enable warnings\" )\n            | Opt( [&]( bool flag ) { config.showDurations = flag ? ShowDurations::Always : ShowDurations::Never; }, \"yes|no\" )\n                [\"-d\"][\"--durations\"]\n                ( \"show test durations\" )\n            | Opt( loadTestNamesFromFile, \"filename\" )\n                [\"-f\"][\"--input-file\"]\n                ( \"load test names to run from a file\" )\n            | Opt( config.filenamesAsTags )\n                [\"-#\"][\"--filenames-as-tags\"]\n                ( \"adds a tag for the filename\" )\n            | Opt( config.sectionsToRun, \"section name\" )\n                [\"-c\"][\"--section\"]\n                ( \"specify section to run\" )\n            | Opt( setVerbosity, \"quiet|normal|high\" )\n                [\"-v\"][\"--verbosity\"]\n                ( \"set output verbosity\" )\n            | Opt( config.listTestNamesOnly )\n                [\"--list-test-names-only\"]\n                ( \"list all/matching test cases names only\" )\n            | Opt( config.listReporters )\n                [\"--list-reporters\"]\n                ( \"list all reporters\" )\n            | Opt( setTestOrder, \"decl|lex|rand\" )\n                [\"--order\"]\n                ( \"test case order (defaults to decl)\" )\n            | Opt( setRngSeed, \"'time'|number\" )\n                [\"--rng-seed\"]\n                ( \"set a specific seed for random numbers\" )\n            | Opt( setColourUsage, \"yes|no\" )\n                [\"--use-colour\"]\n                ( \"should output be colourised\" )\n            | Opt( config.libIdentify )\n                [\"--libidentify\"]\n                ( \"report name and version according to libidentify standard\" )\n            | Opt( setWaitForKeypress, \"start|exit|both\" )\n                [\"--wait-for-keypress\"]\n                ( \"waits for a keypress before exiting\" )\n            | Opt( config.benchmarkResolutionMultiple, \"multiplier\" )\n                [\"--benchmark-resolution-multiple\"]\n                ( \"multiple of clock resolution to run benchmarks\" )\n\n            | Arg( config.testsOrTags, \"test name|pattern|tags\" )\n                ( \"which test or tests to use\" );\n\n        return cli;\n    }\n\n} // end namespace Catch\n// end catch_commandline.cpp\n// start catch_common.cpp\n\n#include <cstring>\n#include <ostream>\n\nnamespace Catch {\n\n    bool SourceLineInfo::empty() const noexcept {\n        return file[0] == '\\0';\n    }\n    bool SourceLineInfo::operator == ( SourceLineInfo const& other ) const noexcept {\n        return line == other.line && (file == other.file || std::strcmp(file, other.file) == 0);\n    }\n    bool SourceLineInfo::operator < ( SourceLineInfo const& other ) const noexcept {\n        // We can assume that the same file will usually have the same pointer.\n        // Thus, if the pointers are the same, there is no point in calling the strcmp\n        return line < other.line || ( line == other.line && file != other.file && (std::strcmp(file, other.file) < 0));\n    }\n\n    std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) {\n#ifndef __GNUG__\n        os << info.file << '(' << info.line << ')';\n#else\n        os << info.file << ':' << info.line;\n#endif\n        return os;\n    }\n\n    std::string StreamEndStop::operator+() const {\n        return std::string();\n    }\n\n    NonCopyable::NonCopyable() = default;\n    NonCopyable::~NonCopyable() = default;\n\n}\n// end catch_common.cpp\n// start catch_config.cpp\n\nnamespace Catch {\n\n    Config::Config( ConfigData const& data )\n    :   m_data( data ),\n        m_stream( openStream() )\n    {\n        TestSpecParser parser(ITagAliasRegistry::get());\n        if (data.testsOrTags.empty()) {\n            parser.parse(\"~[.]\"); // All not hidden tests\n        }\n        else {\n            m_hasTestFilters = true;\n            for( auto const& testOrTags : data.testsOrTags )\n                parser.parse( testOrTags );\n        }\n        m_testSpec = parser.testSpec();\n    }\n\n    std::string const& Config::getFilename() const {\n        return m_data.outputFilename ;\n    }\n\n    bool Config::listTests() const          { return m_data.listTests; }\n    bool Config::listTestNamesOnly() const  { return m_data.listTestNamesOnly; }\n    bool Config::listTags() const           { return m_data.listTags; }\n    bool Config::listReporters() const      { return m_data.listReporters; }\n\n    std::string Config::getProcessName() const { return m_data.processName; }\n    std::string const& Config::getReporterName() const { return m_data.reporterName; }\n\n    std::vector<std::string> const& Config::getTestsOrTags() const { return m_data.testsOrTags; }\n    std::vector<std::string> const& Config::getSectionsToRun() const { return m_data.sectionsToRun; }\n\n    TestSpec const& Config::testSpec() const { return m_testSpec; }\n    bool Config::hasTestFilters() const { return m_hasTestFilters; }\n\n    bool Config::showHelp() const { return m_data.showHelp; }\n\n    // IConfig interface\n    bool Config::allowThrows() const                   { return !m_data.noThrow; }\n    std::ostream& Config::stream() const               { return m_stream->stream(); }\n    std::string Config::name() const                   { return m_data.name.empty() ? m_data.processName : m_data.name; }\n    bool Config::includeSuccessfulResults() const      { return m_data.showSuccessfulTests; }\n    bool Config::warnAboutMissingAssertions() const    { return !!(m_data.warnings & WarnAbout::NoAssertions); }\n    bool Config::warnAboutNoTests() const              { return !!(m_data.warnings & WarnAbout::NoTests); }\n    ShowDurations::OrNot Config::showDurations() const { return m_data.showDurations; }\n    RunTests::InWhatOrder Config::runOrder() const     { return m_data.runOrder; }\n    unsigned int Config::rngSeed() const               { return m_data.rngSeed; }\n    int Config::benchmarkResolutionMultiple() const    { return m_data.benchmarkResolutionMultiple; }\n    UseColour::YesOrNo Config::useColour() const       { return m_data.useColour; }\n    bool Config::shouldDebugBreak() const              { return m_data.shouldDebugBreak; }\n    int Config::abortAfter() const                     { return m_data.abortAfter; }\n    bool Config::showInvisibles() const                { return m_data.showInvisibles; }\n    Verbosity Config::verbosity() const                { return m_data.verbosity; }\n\n    IStream const* Config::openStream() {\n        return Catch::makeStream(m_data.outputFilename);\n    }\n\n} // end namespace Catch\n// end catch_config.cpp\n// start catch_console_colour.cpp\n\n#if defined(__clang__)\n#    pragma clang diagnostic push\n#    pragma clang diagnostic ignored \"-Wexit-time-destructors\"\n#endif\n\n// start catch_errno_guard.h\n\nnamespace Catch {\n\n    class ErrnoGuard {\n    public:\n        ErrnoGuard();\n        ~ErrnoGuard();\n    private:\n        int m_oldErrno;\n    };\n\n}\n\n// end catch_errno_guard.h\n#include <sstream>\n\nnamespace Catch {\n    namespace {\n\n        struct IColourImpl {\n            virtual ~IColourImpl() = default;\n            virtual void use( Colour::Code _colourCode ) = 0;\n        };\n\n        struct NoColourImpl : IColourImpl {\n            void use( Colour::Code ) {}\n\n            static IColourImpl* instance() {\n                static NoColourImpl s_instance;\n                return &s_instance;\n            }\n        };\n\n    } // anon namespace\n} // namespace Catch\n\n#if !defined( CATCH_CONFIG_COLOUR_NONE ) && !defined( CATCH_CONFIG_COLOUR_WINDOWS ) && !defined( CATCH_CONFIG_COLOUR_ANSI )\n#   ifdef CATCH_PLATFORM_WINDOWS\n#       define CATCH_CONFIG_COLOUR_WINDOWS\n#   else\n#       define CATCH_CONFIG_COLOUR_ANSI\n#   endif\n#endif\n\n#if defined ( CATCH_CONFIG_COLOUR_WINDOWS ) /////////////////////////////////////////\n\nnamespace Catch {\nnamespace {\n\n    class Win32ColourImpl : public IColourImpl {\n    public:\n        Win32ColourImpl() : stdoutHandle( GetStdHandle(STD_OUTPUT_HANDLE) )\n        {\n            CONSOLE_SCREEN_BUFFER_INFO csbiInfo;\n            GetConsoleScreenBufferInfo( stdoutHandle, &csbiInfo );\n            originalForegroundAttributes = csbiInfo.wAttributes & ~( BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY );\n            originalBackgroundAttributes = csbiInfo.wAttributes & ~( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY );\n        }\n\n        virtual void use( Colour::Code _colourCode ) override {\n            switch( _colourCode ) {\n                case Colour::None:      return setTextAttribute( originalForegroundAttributes );\n                case Colour::White:     return setTextAttribute( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE );\n                case Colour::Red:       return setTextAttribute( FOREGROUND_RED );\n                case Colour::Green:     return setTextAttribute( FOREGROUND_GREEN );\n                case Colour::Blue:      return setTextAttribute( FOREGROUND_BLUE );\n                case Colour::Cyan:      return setTextAttribute( FOREGROUND_BLUE | FOREGROUND_GREEN );\n                case Colour::Yellow:    return setTextAttribute( FOREGROUND_RED | FOREGROUND_GREEN );\n                case Colour::Grey:      return setTextAttribute( 0 );\n\n                case Colour::LightGrey:     return setTextAttribute( FOREGROUND_INTENSITY );\n                case Colour::BrightRed:     return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_RED );\n                case Colour::BrightGreen:   return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN );\n                case Colour::BrightWhite:   return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE );\n                case Colour::BrightYellow:  return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_RED | FOREGROUND_GREEN );\n\n                case Colour::Bright: CATCH_INTERNAL_ERROR( \"not a colour\" );\n\n                default:\n                    CATCH_ERROR( \"Unknown colour requested\" );\n            }\n        }\n\n    private:\n        void setTextAttribute( WORD _textAttribute ) {\n            SetConsoleTextAttribute( stdoutHandle, _textAttribute | originalBackgroundAttributes );\n        }\n        HANDLE stdoutHandle;\n        WORD originalForegroundAttributes;\n        WORD originalBackgroundAttributes;\n    };\n\n    IColourImpl* platformColourInstance() {\n        static Win32ColourImpl s_instance;\n\n        IConfigPtr config = getCurrentContext().getConfig();\n        UseColour::YesOrNo colourMode = config\n            ? config->useColour()\n            : UseColour::Auto;\n        if( colourMode == UseColour::Auto )\n            colourMode = UseColour::Yes;\n        return colourMode == UseColour::Yes\n            ? &s_instance\n            : NoColourImpl::instance();\n    }\n\n} // end anon namespace\n} // end namespace Catch\n\n#elif defined( CATCH_CONFIG_COLOUR_ANSI ) //////////////////////////////////////\n\n#include <unistd.h>\n\nnamespace Catch {\nnamespace {\n\n    // use POSIX/ ANSI console terminal codes\n    // Thanks to Adam Strzelecki for original contribution\n    // (http://github.com/nanoant)\n    // https://github.com/philsquared/Catch/pull/131\n    class PosixColourImpl : public IColourImpl {\n    public:\n        virtual void use( Colour::Code _colourCode ) override {\n            switch( _colourCode ) {\n                case Colour::None:\n                case Colour::White:     return setColour( \"[0m\" );\n                case Colour::Red:       return setColour( \"[0;31m\" );\n                case Colour::Green:     return setColour( \"[0;32m\" );\n                case Colour::Blue:      return setColour( \"[0;34m\" );\n                case Colour::Cyan:      return setColour( \"[0;36m\" );\n                case Colour::Yellow:    return setColour( \"[0;33m\" );\n                case Colour::Grey:      return setColour( \"[1;30m\" );\n\n                case Colour::LightGrey:     return setColour( \"[0;37m\" );\n                case Colour::BrightRed:     return setColour( \"[1;31m\" );\n                case Colour::BrightGreen:   return setColour( \"[1;32m\" );\n                case Colour::BrightWhite:   return setColour( \"[1;37m\" );\n                case Colour::BrightYellow:  return setColour( \"[1;33m\" );\n\n                case Colour::Bright: CATCH_INTERNAL_ERROR( \"not a colour\" );\n                default: CATCH_INTERNAL_ERROR( \"Unknown colour requested\" );\n            }\n        }\n        static IColourImpl* instance() {\n            static PosixColourImpl s_instance;\n            return &s_instance;\n        }\n\n    private:\n        void setColour( const char* _escapeCode ) {\n            Catch::cout() << '\\033' << _escapeCode;\n        }\n    };\n\n    bool useColourOnPlatform() {\n        return\n#ifdef CATCH_PLATFORM_MAC\n            !isDebuggerActive() &&\n#endif\n#if !(defined(__DJGPP__) && defined(__STRICT_ANSI__))\n            isatty(STDOUT_FILENO)\n#else\n            false\n#endif\n            ;\n    }\n    IColourImpl* platformColourInstance() {\n        ErrnoGuard guard;\n        IConfigPtr config = getCurrentContext().getConfig();\n        UseColour::YesOrNo colourMode = config\n            ? config->useColour()\n            : UseColour::Auto;\n        if( colourMode == UseColour::Auto )\n            colourMode = useColourOnPlatform()\n                ? UseColour::Yes\n                : UseColour::No;\n        return colourMode == UseColour::Yes\n            ? PosixColourImpl::instance()\n            : NoColourImpl::instance();\n    }\n\n} // end anon namespace\n} // end namespace Catch\n\n#else  // not Windows or ANSI ///////////////////////////////////////////////\n\nnamespace Catch {\n\n    static IColourImpl* platformColourInstance() { return NoColourImpl::instance(); }\n\n} // end namespace Catch\n\n#endif // Windows/ ANSI/ None\n\nnamespace Catch {\n\n    Colour::Colour( Code _colourCode ) { use( _colourCode ); }\n    Colour::Colour( Colour&& rhs ) noexcept {\n        m_moved = rhs.m_moved;\n        rhs.m_moved = true;\n    }\n    Colour& Colour::operator=( Colour&& rhs ) noexcept {\n        m_moved = rhs.m_moved;\n        rhs.m_moved  = true;\n        return *this;\n    }\n\n    Colour::~Colour(){ if( !m_moved ) use( None ); }\n\n    void Colour::use( Code _colourCode ) {\n        static IColourImpl* impl = platformColourInstance();\n        impl->use( _colourCode );\n    }\n\n    std::ostream& operator << ( std::ostream& os, Colour const& ) {\n        return os;\n    }\n\n} // end namespace Catch\n\n#if defined(__clang__)\n#    pragma clang diagnostic pop\n#endif\n\n// end catch_console_colour.cpp\n// start catch_context.cpp\n\nnamespace Catch {\n\n    class Context : public IMutableContext, NonCopyable {\n\n    public: // IContext\n        virtual IResultCapture* getResultCapture() override {\n            return m_resultCapture;\n        }\n        virtual IRunner* getRunner() override {\n            return m_runner;\n        }\n\n        virtual IConfigPtr const& getConfig() const override {\n            return m_config;\n        }\n\n        virtual ~Context() override;\n\n    public: // IMutableContext\n        virtual void setResultCapture( IResultCapture* resultCapture ) override {\n            m_resultCapture = resultCapture;\n        }\n        virtual void setRunner( IRunner* runner ) override {\n            m_runner = runner;\n        }\n        virtual void setConfig( IConfigPtr const& config ) override {\n            m_config = config;\n        }\n\n        friend IMutableContext& getCurrentMutableContext();\n\n    private:\n        IConfigPtr m_config;\n        IRunner* m_runner = nullptr;\n        IResultCapture* m_resultCapture = nullptr;\n    };\n\n    IMutableContext *IMutableContext::currentContext = nullptr;\n\n    void IMutableContext::createContext()\n    {\n        currentContext = new Context();\n    }\n\n    void cleanUpContext() {\n        delete IMutableContext::currentContext;\n        IMutableContext::currentContext = nullptr;\n    }\n    IContext::~IContext() = default;\n    IMutableContext::~IMutableContext() = default;\n    Context::~Context() = default;\n}\n// end catch_context.cpp\n// start catch_debug_console.cpp\n\n// start catch_debug_console.h\n\n#include <string>\n\nnamespace Catch {\n    void writeToDebugConsole( std::string const& text );\n}\n\n// end catch_debug_console.h\n#ifdef CATCH_PLATFORM_WINDOWS\n\n    namespace Catch {\n        void writeToDebugConsole( std::string const& text ) {\n            ::OutputDebugStringA( text.c_str() );\n        }\n    }\n\n#else\n\n    namespace Catch {\n        void writeToDebugConsole( std::string const& text ) {\n            // !TBD: Need a version for Mac/ XCode and other IDEs\n            Catch::cout() << text;\n        }\n    }\n\n#endif // Platform\n// end catch_debug_console.cpp\n// start catch_debugger.cpp\n\n#ifdef CATCH_PLATFORM_MAC\n\n#  include <assert.h>\n#  include <stdbool.h>\n#  include <sys/types.h>\n#  include <unistd.h>\n#  include <sys/sysctl.h>\n#  include <cstddef>\n#  include <ostream>\n\nnamespace Catch {\n\n        // The following function is taken directly from the following technical note:\n        // http://developer.apple.com/library/mac/#qa/qa2004/qa1361.html\n\n        // Returns true if the current process is being debugged (either\n        // running under the debugger or has a debugger attached post facto).\n        bool isDebuggerActive(){\n\n            int                 mib[4];\n            struct kinfo_proc   info;\n            std::size_t         size;\n\n            // Initialize the flags so that, if sysctl fails for some bizarre\n            // reason, we get a predictable result.\n\n            info.kp_proc.p_flag = 0;\n\n            // Initialize mib, which tells sysctl the info we want, in this case\n            // we're looking for information about a specific process ID.\n\n            mib[0] = CTL_KERN;\n            mib[1] = KERN_PROC;\n            mib[2] = KERN_PROC_PID;\n            mib[3] = getpid();\n\n            // Call sysctl.\n\n            size = sizeof(info);\n            if( sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, nullptr, 0) != 0 ) {\n                Catch::cerr() << \"\\n** Call to sysctl failed - unable to determine if debugger is active **\\n\" << std::endl;\n                return false;\n            }\n\n            // We're being debugged if the P_TRACED flag is set.\n\n            return ( (info.kp_proc.p_flag & P_TRACED) != 0 );\n        }\n    } // namespace Catch\n\n#elif defined(CATCH_PLATFORM_LINUX)\n    #include <fstream>\n    #include <string>\n\n    namespace Catch{\n        // The standard POSIX way of detecting a debugger is to attempt to\n        // ptrace() the process, but this needs to be done from a child and not\n        // this process itself to still allow attaching to this process later\n        // if wanted, so is rather heavy. Under Linux we have the PID of the\n        // \"debugger\" (which doesn't need to be gdb, of course, it could also\n        // be strace, for example) in /proc/$PID/status, so just get it from\n        // there instead.\n        bool isDebuggerActive(){\n            // Libstdc++ has a bug, where std::ifstream sets errno to 0\n            // This way our users can properly assert over errno values\n            ErrnoGuard guard;\n            std::ifstream in(\"/proc/self/status\");\n            for( std::string line; std::getline(in, line); ) {\n                static const int PREFIX_LEN = 11;\n                if( line.compare(0, PREFIX_LEN, \"TracerPid:\\t\") == 0 ) {\n                    // We're traced if the PID is not 0 and no other PID starts\n                    // with 0 digit, so it's enough to check for just a single\n                    // character.\n                    return line.length() > PREFIX_LEN && line[PREFIX_LEN] != '0';\n                }\n            }\n\n            return false;\n        }\n    } // namespace Catch\n#elif defined(_MSC_VER)\n    extern \"C\" __declspec(dllimport) int __stdcall IsDebuggerPresent();\n    namespace Catch {\n        bool isDebuggerActive() {\n            return IsDebuggerPresent() != 0;\n        }\n    }\n#elif defined(__MINGW32__)\n    extern \"C\" __declspec(dllimport) int __stdcall IsDebuggerPresent();\n    namespace Catch {\n        bool isDebuggerActive() {\n            return IsDebuggerPresent() != 0;\n        }\n    }\n#else\n    namespace Catch {\n       bool isDebuggerActive() { return false; }\n    }\n#endif // Platform\n// end catch_debugger.cpp\n// start catch_decomposer.cpp\n\nnamespace Catch {\n\n    ITransientExpression::~ITransientExpression() = default;\n\n    void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ) {\n        if( lhs.size() + rhs.size() < 40 &&\n                lhs.find('\\n') == std::string::npos &&\n                rhs.find('\\n') == std::string::npos )\n            os << lhs << \" \" << op << \" \" << rhs;\n        else\n            os << lhs << \"\\n\" << op << \"\\n\" << rhs;\n    }\n}\n// end catch_decomposer.cpp\n// start catch_enforce.cpp\n\nnamespace Catch {\n#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) && !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS_CUSTOM_HANDLER)\n    [[noreturn]]\n    void throw_exception(std::exception const& e) {\n        Catch::cerr() << \"Catch will terminate because it needed to throw an exception.\\n\"\n                      << \"The message was: \" << e.what() << '\\n';\n        std::terminate();\n    }\n#endif\n} // namespace Catch;\n// end catch_enforce.cpp\n// start catch_errno_guard.cpp\n\n#include <cerrno>\n\nnamespace Catch {\n        ErrnoGuard::ErrnoGuard():m_oldErrno(errno){}\n        ErrnoGuard::~ErrnoGuard() { errno = m_oldErrno; }\n}\n// end catch_errno_guard.cpp\n// start catch_exception_translator_registry.cpp\n\n// start catch_exception_translator_registry.h\n\n#include <vector>\n#include <string>\n#include <memory>\n\nnamespace Catch {\n\n    class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry {\n    public:\n        ~ExceptionTranslatorRegistry();\n        virtual void registerTranslator( const IExceptionTranslator* translator );\n        virtual std::string translateActiveException() const override;\n        std::string tryTranslators() const;\n\n    private:\n        std::vector<std::unique_ptr<IExceptionTranslator const>> m_translators;\n    };\n}\n\n// end catch_exception_translator_registry.h\n#ifdef __OBJC__\n#import \"Foundation/Foundation.h\"\n#endif\n\nnamespace Catch {\n\n    ExceptionTranslatorRegistry::~ExceptionTranslatorRegistry() {\n    }\n\n    void ExceptionTranslatorRegistry::registerTranslator( const IExceptionTranslator* translator ) {\n        m_translators.push_back( std::unique_ptr<const IExceptionTranslator>( translator ) );\n    }\n\n#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)\n    std::string ExceptionTranslatorRegistry::translateActiveException() const {\n        try {\n#ifdef __OBJC__\n            // In Objective-C try objective-c exceptions first\n            @try {\n                return tryTranslators();\n            }\n            @catch (NSException *exception) {\n                return Catch::Detail::stringify( [exception description] );\n            }\n#else\n            // Compiling a mixed mode project with MSVC means that CLR\n            // exceptions will be caught in (...) as well. However, these\n            // do not fill-in std::current_exception and thus lead to crash\n            // when attempting rethrow.\n            // /EHa switch also causes structured exceptions to be caught\n            // here, but they fill-in current_exception properly, so\n            // at worst the output should be a little weird, instead of\n            // causing a crash.\n            if (std::current_exception() == nullptr) {\n                return \"Non C++ exception. Possibly a CLR exception.\";\n            }\n            return tryTranslators();\n#endif\n        }\n        catch( TestFailureException& ) {\n            std::rethrow_exception(std::current_exception());\n        }\n        catch( std::exception& ex ) {\n            return ex.what();\n        }\n        catch( std::string& msg ) {\n            return msg;\n        }\n        catch( const char* msg ) {\n            return msg;\n        }\n        catch(...) {\n            return \"Unknown exception\";\n        }\n    }\n\n#else // ^^ Exceptions are enabled // Exceptions are disabled vv\n    std::string ExceptionTranslatorRegistry::translateActiveException() const {\n        CATCH_INTERNAL_ERROR(\"Attempted to translate active exception under CATCH_CONFIG_DISABLE_EXCEPTIONS!\");\n    }\n#endif\n\n    std::string ExceptionTranslatorRegistry::tryTranslators() const {\n        if( m_translators.empty() )\n            std::rethrow_exception(std::current_exception());\n        else\n            return m_translators[0]->translate( m_translators.begin()+1, m_translators.end() );\n    }\n}\n// end catch_exception_translator_registry.cpp\n// start catch_fatal_condition.cpp\n\n#if defined(__GNUC__)\n#    pragma GCC diagnostic push\n#    pragma GCC diagnostic ignored \"-Wmissing-field-initializers\"\n#endif\n\n#if defined( CATCH_CONFIG_WINDOWS_SEH ) || defined( CATCH_CONFIG_POSIX_SIGNALS )\n\nnamespace {\n    // Report the error condition\n    void reportFatal( char const * const message ) {\n        Catch::getCurrentContext().getResultCapture()->handleFatalErrorCondition( message );\n    }\n}\n\n#endif // signals/SEH handling\n\n#if defined( CATCH_CONFIG_WINDOWS_SEH )\n\nnamespace Catch {\n    struct SignalDefs { DWORD id; const char* name; };\n\n    // There is no 1-1 mapping between signals and windows exceptions.\n    // Windows can easily distinguish between SO and SigSegV,\n    // but SigInt, SigTerm, etc are handled differently.\n    static SignalDefs signalDefs[] = {\n        { EXCEPTION_ILLEGAL_INSTRUCTION,  \"SIGILL - Illegal instruction signal\" },\n        { EXCEPTION_STACK_OVERFLOW, \"SIGSEGV - Stack overflow\" },\n        { EXCEPTION_ACCESS_VIOLATION, \"SIGSEGV - Segmentation violation signal\" },\n        { EXCEPTION_INT_DIVIDE_BY_ZERO, \"Divide by zero error\" },\n    };\n\n    LONG CALLBACK FatalConditionHandler::handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) {\n        for (auto const& def : signalDefs) {\n            if (ExceptionInfo->ExceptionRecord->ExceptionCode == def.id) {\n                reportFatal(def.name);\n            }\n        }\n        // If its not an exception we care about, pass it along.\n        // This stops us from eating debugger breaks etc.\n        return EXCEPTION_CONTINUE_SEARCH;\n    }\n\n    FatalConditionHandler::FatalConditionHandler() {\n        isSet = true;\n        // 32k seems enough for Catch to handle stack overflow,\n        // but the value was found experimentally, so there is no strong guarantee\n        guaranteeSize = 32 * 1024;\n        exceptionHandlerHandle = nullptr;\n        // Register as first handler in current chain\n        exceptionHandlerHandle = AddVectoredExceptionHandler(1, handleVectoredException);\n        // Pass in guarantee size to be filled\n        SetThreadStackGuarantee(&guaranteeSize);\n    }\n\n    void FatalConditionHandler::reset() {\n        if (isSet) {\n            RemoveVectoredExceptionHandler(exceptionHandlerHandle);\n            SetThreadStackGuarantee(&guaranteeSize);\n            exceptionHandlerHandle = nullptr;\n            isSet = false;\n        }\n    }\n\n    FatalConditionHandler::~FatalConditionHandler() {\n        reset();\n    }\n\nbool FatalConditionHandler::isSet = false;\nULONG FatalConditionHandler::guaranteeSize = 0;\nPVOID FatalConditionHandler::exceptionHandlerHandle = nullptr;\n\n} // namespace Catch\n\n#elif defined( CATCH_CONFIG_POSIX_SIGNALS )\n\nnamespace Catch {\n\n    struct SignalDefs {\n        int id;\n        const char* name;\n    };\n\n    // 32kb for the alternate stack seems to be sufficient. However, this value\n    // is experimentally determined, so that's not guaranteed.\n    constexpr static std::size_t sigStackSize = 32768 >= MINSIGSTKSZ ? 32768 : MINSIGSTKSZ;\n\n    static SignalDefs signalDefs[] = {\n        { SIGINT,  \"SIGINT - Terminal interrupt signal\" },\n        { SIGILL,  \"SIGILL - Illegal instruction signal\" },\n        { SIGFPE,  \"SIGFPE - Floating point error signal\" },\n        { SIGSEGV, \"SIGSEGV - Segmentation violation signal\" },\n        { SIGTERM, \"SIGTERM - Termination request signal\" },\n        { SIGABRT, \"SIGABRT - Abort (abnormal termination) signal\" }\n    };\n\n    void FatalConditionHandler::handleSignal( int sig ) {\n        char const * name = \"<unknown signal>\";\n        for (auto const& def : signalDefs) {\n            if (sig == def.id) {\n                name = def.name;\n                break;\n            }\n        }\n        reset();\n        reportFatal(name);\n        raise( sig );\n    }\n\n    FatalConditionHandler::FatalConditionHandler() {\n        isSet = true;\n        stack_t sigStack;\n        sigStack.ss_sp = altStackMem;\n        sigStack.ss_size = sigStackSize;\n        sigStack.ss_flags = 0;\n        sigaltstack(&sigStack, &oldSigStack);\n        struct sigaction sa = { };\n\n        sa.sa_handler = handleSignal;\n        sa.sa_flags = SA_ONSTACK;\n        for (std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i) {\n            sigaction(signalDefs[i].id, &sa, &oldSigActions[i]);\n        }\n    }\n\n    FatalConditionHandler::~FatalConditionHandler() {\n        reset();\n    }\n\n    void FatalConditionHandler::reset() {\n        if( isSet ) {\n            // Set signals back to previous values -- hopefully nobody overwrote them in the meantime\n            for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i ) {\n                sigaction(signalDefs[i].id, &oldSigActions[i], nullptr);\n            }\n            // Return the old stack\n            sigaltstack(&oldSigStack, nullptr);\n            isSet = false;\n        }\n    }\n\n    bool FatalConditionHandler::isSet = false;\n    struct sigaction FatalConditionHandler::oldSigActions[sizeof(signalDefs)/sizeof(SignalDefs)] = {};\n    stack_t FatalConditionHandler::oldSigStack = {};\n    char FatalConditionHandler::altStackMem[sigStackSize] = {};\n\n} // namespace Catch\n\n#else\n\nnamespace Catch {\n    void FatalConditionHandler::reset() {}\n}\n\n#endif // signals/SEH handling\n\n#if defined(__GNUC__)\n#    pragma GCC diagnostic pop\n#endif\n// end catch_fatal_condition.cpp\n// start catch_generators.cpp\n\n// start catch_random_number_generator.h\n\n#include <algorithm>\n#include <random>\n\nnamespace Catch {\n\n    struct IConfig;\n\n    std::mt19937& rng();\n    void seedRng( IConfig const& config );\n    unsigned int rngSeed();\n\n}\n\n// end catch_random_number_generator.h\n#include <limits>\n#include <set>\n\nnamespace Catch {\n\nIGeneratorTracker::~IGeneratorTracker() {}\n\nnamespace Generators {\n\n    GeneratorBase::~GeneratorBase() {}\n\n    std::vector<size_t> randomiseIndices( size_t selectionSize, size_t sourceSize ) {\n\n        assert( selectionSize <= sourceSize );\n        std::vector<size_t> indices;\n        indices.reserve( selectionSize );\n        std::uniform_int_distribution<size_t> uid( 0, sourceSize-1 );\n\n        std::set<size_t> seen;\n        // !TBD: improve this algorithm\n        while( indices.size() < selectionSize ) {\n            auto index = uid( rng() );\n            if( seen.insert( index ).second )\n                indices.push_back( index );\n        }\n        return indices;\n    }\n\n    auto acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker& {\n        return getResultCapture().acquireGeneratorTracker( lineInfo );\n    }\n\n    template<>\n    auto all<int>() -> Generator<int> {\n        return range( std::numeric_limits<int>::min(), std::numeric_limits<int>::max() );\n    }\n\n} // namespace Generators\n} // namespace Catch\n// end catch_generators.cpp\n// start catch_interfaces_capture.cpp\n\nnamespace Catch {\n    IResultCapture::~IResultCapture() = default;\n}\n// end catch_interfaces_capture.cpp\n// start catch_interfaces_config.cpp\n\nnamespace Catch {\n    IConfig::~IConfig() = default;\n}\n// end catch_interfaces_config.cpp\n// start catch_interfaces_exception.cpp\n\nnamespace Catch {\n    IExceptionTranslator::~IExceptionTranslator() = default;\n    IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() = default;\n}\n// end catch_interfaces_exception.cpp\n// start catch_interfaces_registry_hub.cpp\n\nnamespace Catch {\n    IRegistryHub::~IRegistryHub() = default;\n    IMutableRegistryHub::~IMutableRegistryHub() = default;\n}\n// end catch_interfaces_registry_hub.cpp\n// start catch_interfaces_reporter.cpp\n\n// start catch_reporter_listening.h\n\nnamespace Catch {\n\n    class ListeningReporter : public IStreamingReporter {\n        using Reporters = std::vector<IStreamingReporterPtr>;\n        Reporters m_listeners;\n        IStreamingReporterPtr m_reporter = nullptr;\n        ReporterPreferences m_preferences;\n\n    public:\n        ListeningReporter();\n\n        void addListener( IStreamingReporterPtr&& listener );\n        void addReporter( IStreamingReporterPtr&& reporter );\n\n    public: // IStreamingReporter\n\n        ReporterPreferences getPreferences() const override;\n\n        void noMatchingTestCases( std::string const& spec ) override;\n\n        static std::set<Verbosity> getSupportedVerbosities();\n\n        void benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) override;\n        void benchmarkEnded( BenchmarkStats const& benchmarkStats ) override;\n\n        void testRunStarting( TestRunInfo const& testRunInfo ) override;\n        void testGroupStarting( GroupInfo const& groupInfo ) override;\n        void testCaseStarting( TestCaseInfo const& testInfo ) override;\n        void sectionStarting( SectionInfo const& sectionInfo ) override;\n        void assertionStarting( AssertionInfo const& assertionInfo ) override;\n\n        // The return value indicates if the messages buffer should be cleared:\n        bool assertionEnded( AssertionStats const& assertionStats ) override;\n        void sectionEnded( SectionStats const& sectionStats ) override;\n        void testCaseEnded( TestCaseStats const& testCaseStats ) override;\n        void testGroupEnded( TestGroupStats const& testGroupStats ) override;\n        void testRunEnded( TestRunStats const& testRunStats ) override;\n\n        void skipTest( TestCaseInfo const& testInfo ) override;\n        bool isMulti() const override;\n\n    };\n\n} // end namespace Catch\n\n// end catch_reporter_listening.h\nnamespace Catch {\n\n    ReporterConfig::ReporterConfig( IConfigPtr const& _fullConfig )\n    :   m_stream( &_fullConfig->stream() ), m_fullConfig( _fullConfig ) {}\n\n    ReporterConfig::ReporterConfig( IConfigPtr const& _fullConfig, std::ostream& _stream )\n    :   m_stream( &_stream ), m_fullConfig( _fullConfig ) {}\n\n    std::ostream& ReporterConfig::stream() const { return *m_stream; }\n    IConfigPtr ReporterConfig::fullConfig() const { return m_fullConfig; }\n\n    TestRunInfo::TestRunInfo( std::string const& _name ) : name( _name ) {}\n\n    GroupInfo::GroupInfo(  std::string const& _name,\n                           std::size_t _groupIndex,\n                           std::size_t _groupsCount )\n    :   name( _name ),\n        groupIndex( _groupIndex ),\n        groupsCounts( _groupsCount )\n    {}\n\n     AssertionStats::AssertionStats( AssertionResult const& _assertionResult,\n                                     std::vector<MessageInfo> const& _infoMessages,\n                                     Totals const& _totals )\n    :   assertionResult( _assertionResult ),\n        infoMessages( _infoMessages ),\n        totals( _totals )\n    {\n        assertionResult.m_resultData.lazyExpression.m_transientExpression = _assertionResult.m_resultData.lazyExpression.m_transientExpression;\n\n        if( assertionResult.hasMessage() ) {\n            // Copy message into messages list.\n            // !TBD This should have been done earlier, somewhere\n            MessageBuilder builder( assertionResult.getTestMacroName(), assertionResult.getSourceInfo(), assertionResult.getResultType() );\n            builder << assertionResult.getMessage();\n            builder.m_info.message = builder.m_stream.str();\n\n            infoMessages.push_back( builder.m_info );\n        }\n    }\n\n     AssertionStats::~AssertionStats() = default;\n\n    SectionStats::SectionStats(  SectionInfo const& _sectionInfo,\n                                 Counts const& _assertions,\n                                 double _durationInSeconds,\n                                 bool _missingAssertions )\n    :   sectionInfo( _sectionInfo ),\n        assertions( _assertions ),\n        durationInSeconds( _durationInSeconds ),\n        missingAssertions( _missingAssertions )\n    {}\n\n    SectionStats::~SectionStats() = default;\n\n    TestCaseStats::TestCaseStats(  TestCaseInfo const& _testInfo,\n                                   Totals const& _totals,\n                                   std::string const& _stdOut,\n                                   std::string const& _stdErr,\n                                   bool _aborting )\n    : testInfo( _testInfo ),\n        totals( _totals ),\n        stdOut( _stdOut ),\n        stdErr( _stdErr ),\n        aborting( _aborting )\n    {}\n\n    TestCaseStats::~TestCaseStats() = default;\n\n    TestGroupStats::TestGroupStats( GroupInfo const& _groupInfo,\n                                    Totals const& _totals,\n                                    bool _aborting )\n    :   groupInfo( _groupInfo ),\n        totals( _totals ),\n        aborting( _aborting )\n    {}\n\n    TestGroupStats::TestGroupStats( GroupInfo const& _groupInfo )\n    :   groupInfo( _groupInfo ),\n        aborting( false )\n    {}\n\n    TestGroupStats::~TestGroupStats() = default;\n\n    TestRunStats::TestRunStats(   TestRunInfo const& _runInfo,\n                    Totals const& _totals,\n                    bool _aborting )\n    :   runInfo( _runInfo ),\n        totals( _totals ),\n        aborting( _aborting )\n    {}\n\n    TestRunStats::~TestRunStats() = default;\n\n    void IStreamingReporter::fatalErrorEncountered( StringRef ) {}\n    bool IStreamingReporter::isMulti() const { return false; }\n\n    IReporterFactory::~IReporterFactory() = default;\n    IReporterRegistry::~IReporterRegistry() = default;\n\n} // end namespace Catch\n// end catch_interfaces_reporter.cpp\n// start catch_interfaces_runner.cpp\n\nnamespace Catch {\n    IRunner::~IRunner() = default;\n}\n// end catch_interfaces_runner.cpp\n// start catch_interfaces_testcase.cpp\n\nnamespace Catch {\n    ITestInvoker::~ITestInvoker() = default;\n    ITestCaseRegistry::~ITestCaseRegistry() = default;\n}\n// end catch_interfaces_testcase.cpp\n// start catch_leak_detector.cpp\n\n#ifdef CATCH_CONFIG_WINDOWS_CRTDBG\n#include <crtdbg.h>\n\nnamespace Catch {\n\n    LeakDetector::LeakDetector() {\n        int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG);\n        flag |= _CRTDBG_LEAK_CHECK_DF;\n        flag |= _CRTDBG_ALLOC_MEM_DF;\n        _CrtSetDbgFlag(flag);\n        _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG);\n        _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);\n        // Change this to leaking allocation's number to break there\n        _CrtSetBreakAlloc(-1);\n    }\n}\n\n#else\n\n    Catch::LeakDetector::LeakDetector() {}\n\n#endif\n\nCatch::LeakDetector::~LeakDetector() {\n    Catch::cleanUp();\n}\n// end catch_leak_detector.cpp\n// start catch_list.cpp\n\n// start catch_list.h\n\n#include <set>\n\nnamespace Catch {\n\n    std::size_t listTests( Config const& config );\n\n    std::size_t listTestsNamesOnly( Config const& config );\n\n    struct TagInfo {\n        void add( std::string const& spelling );\n        std::string all() const;\n\n        std::set<std::string> spellings;\n        std::size_t count = 0;\n    };\n\n    std::size_t listTags( Config const& config );\n\n    std::size_t listReporters();\n\n    Option<std::size_t> list( Config const& config );\n\n} // end namespace Catch\n\n// end catch_list.h\n// start catch_text.h\n\nnamespace Catch {\n    using namespace clara::TextFlow;\n}\n\n// end catch_text.h\n#include <limits>\n#include <algorithm>\n#include <iomanip>\n\nnamespace Catch {\n\n    std::size_t listTests( Config const& config ) {\n        TestSpec testSpec = config.testSpec();\n        if( config.hasTestFilters() )\n            Catch::cout() << \"Matching test cases:\\n\";\n        else {\n            Catch::cout() << \"All available test cases:\\n\";\n        }\n\n        auto matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config );\n        for( auto const& testCaseInfo : matchedTestCases ) {\n            Colour::Code colour = testCaseInfo.isHidden()\n                ? Colour::SecondaryText\n                : Colour::None;\n            Colour colourGuard( colour );\n\n            Catch::cout() << Column( testCaseInfo.name ).initialIndent( 2 ).indent( 4 ) << \"\\n\";\n            if( config.verbosity() >= Verbosity::High ) {\n                Catch::cout() << Column( Catch::Detail::stringify( testCaseInfo.lineInfo ) ).indent(4) << std::endl;\n                std::string description = testCaseInfo.description;\n                if( description.empty() )\n                    description = \"(NO DESCRIPTION)\";\n                Catch::cout() << Column( description ).indent(4) << std::endl;\n            }\n            if( !testCaseInfo.tags.empty() )\n                Catch::cout() << Column( testCaseInfo.tagsAsString() ).indent( 6 ) << \"\\n\";\n        }\n\n        if( !config.hasTestFilters() )\n            Catch::cout() << pluralise( matchedTestCases.size(), \"test case\" ) << '\\n' << std::endl;\n        else\n            Catch::cout() << pluralise( matchedTestCases.size(), \"matching test case\" ) << '\\n' << std::endl;\n        return matchedTestCases.size();\n    }\n\n    std::size_t listTestsNamesOnly( Config const& config ) {\n        TestSpec testSpec = config.testSpec();\n        std::size_t matchedTests = 0;\n        std::vector<TestCase> matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config );\n        for( auto const& testCaseInfo : matchedTestCases ) {\n            matchedTests++;\n            if( startsWith( testCaseInfo.name, '#' ) )\n               Catch::cout() << '\"' << testCaseInfo.name << '\"';\n            else\n               Catch::cout() << testCaseInfo.name;\n            if ( config.verbosity() >= Verbosity::High )\n                Catch::cout() << \"\\t@\" << testCaseInfo.lineInfo;\n            Catch::cout() << std::endl;\n        }\n        return matchedTests;\n    }\n\n    void TagInfo::add( std::string const& spelling ) {\n        ++count;\n        spellings.insert( spelling );\n    }\n\n    std::string TagInfo::all() const {\n        std::string out;\n        for( auto const& spelling : spellings )\n            out += \"[\" + spelling + \"]\";\n        return out;\n    }\n\n    std::size_t listTags( Config const& config ) {\n        TestSpec testSpec = config.testSpec();\n        if( config.hasTestFilters() )\n            Catch::cout() << \"Tags for matching test cases:\\n\";\n        else {\n            Catch::cout() << \"All available tags:\\n\";\n        }\n\n        std::map<std::string, TagInfo> tagCounts;\n\n        std::vector<TestCase> matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config );\n        for( auto const& testCase : matchedTestCases ) {\n            for( auto const& tagName : testCase.getTestCaseInfo().tags ) {\n                std::string lcaseTagName = toLower( tagName );\n                auto countIt = tagCounts.find( lcaseTagName );\n                if( countIt == tagCounts.end() )\n                    countIt = tagCounts.insert( std::make_pair( lcaseTagName, TagInfo() ) ).first;\n                countIt->second.add( tagName );\n            }\n        }\n\n        for( auto const& tagCount : tagCounts ) {\n            ReusableStringStream rss;\n            rss << \"  \" << std::setw(2) << tagCount.second.count << \"  \";\n            auto str = rss.str();\n            auto wrapper = Column( tagCount.second.all() )\n                                                    .initialIndent( 0 )\n                                                    .indent( str.size() )\n                                                    .width( CATCH_CONFIG_CONSOLE_WIDTH-10 );\n            Catch::cout() << str << wrapper << '\\n';\n        }\n        Catch::cout() << pluralise( tagCounts.size(), \"tag\" ) << '\\n' << std::endl;\n        return tagCounts.size();\n    }\n\n    std::size_t listReporters() {\n        Catch::cout() << \"Available reporters:\\n\";\n        IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories();\n        std::size_t maxNameLen = 0;\n        for( auto const& factoryKvp : factories )\n            maxNameLen = (std::max)( maxNameLen, factoryKvp.first.size() );\n\n        for( auto const& factoryKvp : factories ) {\n            Catch::cout()\n                    << Column( factoryKvp.first + \":\" )\n                            .indent(2)\n                            .width( 5+maxNameLen )\n                    +  Column( factoryKvp.second->getDescription() )\n                            .initialIndent(0)\n                            .indent(2)\n                            .width( CATCH_CONFIG_CONSOLE_WIDTH - maxNameLen-8 )\n                    << \"\\n\";\n        }\n        Catch::cout() << std::endl;\n        return factories.size();\n    }\n\n    Option<std::size_t> list( Config const& config ) {\n        Option<std::size_t> listedCount;\n        if( config.listTests() )\n            listedCount = listedCount.valueOr(0) + listTests( config );\n        if( config.listTestNamesOnly() )\n            listedCount = listedCount.valueOr(0) + listTestsNamesOnly( config );\n        if( config.listTags() )\n            listedCount = listedCount.valueOr(0) + listTags( config );\n        if( config.listReporters() )\n            listedCount = listedCount.valueOr(0) + listReporters();\n        return listedCount;\n    }\n\n} // end namespace Catch\n// end catch_list.cpp\n// start catch_matchers.cpp\n\nnamespace Catch {\nnamespace Matchers {\n    namespace Impl {\n\n        std::string MatcherUntypedBase::toString() const {\n            if( m_cachedToString.empty() )\n                m_cachedToString = describe();\n            return m_cachedToString;\n        }\n\n        MatcherUntypedBase::~MatcherUntypedBase() = default;\n\n    } // namespace Impl\n} // namespace Matchers\n\nusing namespace Matchers;\nusing Matchers::Impl::MatcherBase;\n\n} // namespace Catch\n// end catch_matchers.cpp\n// start catch_matchers_floating.cpp\n\n// start catch_polyfills.hpp\n\nnamespace Catch {\n    bool isnan(float f);\n    bool isnan(double d);\n}\n\n// end catch_polyfills.hpp\n// start catch_to_string.hpp\n\n#include <string>\n\nnamespace Catch {\n    template <typename T>\n    std::string to_string(T const& t) {\n#if defined(CATCH_CONFIG_CPP11_TO_STRING)\n        return std::to_string(t);\n#else\n        ReusableStringStream rss;\n        rss << t;\n        return rss.str();\n#endif\n    }\n} // end namespace Catch\n\n// end catch_to_string.hpp\n#include <cstdlib>\n#include <cstdint>\n#include <cstring>\n\nnamespace Catch {\nnamespace Matchers {\nnamespace Floating {\nenum class FloatingPointKind : uint8_t {\n    Float,\n    Double\n};\n}\n}\n}\n\nnamespace {\n\ntemplate <typename T>\nstruct Converter;\n\ntemplate <>\nstruct Converter<float> {\n    static_assert(sizeof(float) == sizeof(int32_t), \"Important ULP matcher assumption violated\");\n    Converter(float f) {\n        std::memcpy(&i, &f, sizeof(f));\n    }\n    int32_t i;\n};\n\ntemplate <>\nstruct Converter<double> {\n    static_assert(sizeof(double) == sizeof(int64_t), \"Important ULP matcher assumption violated\");\n    Converter(double d) {\n        std::memcpy(&i, &d, sizeof(d));\n    }\n    int64_t i;\n};\n\ntemplate <typename T>\nauto convert(T t) -> Converter<T> {\n    return Converter<T>(t);\n}\n\ntemplate <typename FP>\nbool almostEqualUlps(FP lhs, FP rhs, int maxUlpDiff) {\n    // Comparison with NaN should always be false.\n    // This way we can rule it out before getting into the ugly details\n    if (Catch::isnan(lhs) || Catch::isnan(rhs)) {\n        return false;\n    }\n\n    auto lc = convert(lhs);\n    auto rc = convert(rhs);\n\n    if ((lc.i < 0) != (rc.i < 0)) {\n        // Potentially we can have +0 and -0\n        return lhs == rhs;\n    }\n\n    auto ulpDiff = std::abs(lc.i - rc.i);\n    return ulpDiff <= maxUlpDiff;\n}\n\n}\n\nnamespace Catch {\nnamespace Matchers {\nnamespace Floating {\n    WithinAbsMatcher::WithinAbsMatcher(double target, double margin)\n        :m_target{ target }, m_margin{ margin } {\n        CATCH_ENFORCE(margin >= 0, \"Invalid margin: \" << margin << '.'\n            << \" Margin has to be non-negative.\");\n    }\n\n    // Performs equivalent check of std::fabs(lhs - rhs) <= margin\n    // But without the subtraction to allow for INFINITY in comparison\n    bool WithinAbsMatcher::match(double const& matchee) const {\n        return (matchee + m_margin >= m_target) && (m_target + m_margin >= matchee);\n    }\n\n    std::string WithinAbsMatcher::describe() const {\n        return \"is within \" + ::Catch::Detail::stringify(m_margin) + \" of \" + ::Catch::Detail::stringify(m_target);\n    }\n\n    WithinUlpsMatcher::WithinUlpsMatcher(double target, int ulps, FloatingPointKind baseType)\n        :m_target{ target }, m_ulps{ ulps }, m_type{ baseType } {\n        CATCH_ENFORCE(ulps >= 0, \"Invalid ULP setting: \" << ulps << '.'\n            << \" ULPs have to be non-negative.\");\n    }\n\n#if defined(__clang__)\n#pragma clang diagnostic push\n// Clang <3.5 reports on the default branch in the switch below\n#pragma clang diagnostic ignored \"-Wunreachable-code\"\n#endif\n\n    bool WithinUlpsMatcher::match(double const& matchee) const {\n        switch (m_type) {\n        case FloatingPointKind::Float:\n            return almostEqualUlps<float>(static_cast<float>(matchee), static_cast<float>(m_target), m_ulps);\n        case FloatingPointKind::Double:\n            return almostEqualUlps<double>(matchee, m_target, m_ulps);\n        default:\n            CATCH_INTERNAL_ERROR( \"Unknown FloatingPointKind value\" );\n        }\n    }\n\n#if defined(__clang__)\n#pragma clang diagnostic pop\n#endif\n\n    std::string WithinUlpsMatcher::describe() const {\n        return \"is within \" + Catch::to_string(m_ulps) + \" ULPs of \" + ::Catch::Detail::stringify(m_target) + ((m_type == FloatingPointKind::Float)? \"f\" : \"\");\n    }\n\n}// namespace Floating\n\nFloating::WithinUlpsMatcher WithinULP(double target, int maxUlpDiff) {\n    return Floating::WithinUlpsMatcher(target, maxUlpDiff, Floating::FloatingPointKind::Double);\n}\n\nFloating::WithinUlpsMatcher WithinULP(float target, int maxUlpDiff) {\n    return Floating::WithinUlpsMatcher(target, maxUlpDiff, Floating::FloatingPointKind::Float);\n}\n\nFloating::WithinAbsMatcher WithinAbs(double target, double margin) {\n    return Floating::WithinAbsMatcher(target, margin);\n}\n\n} // namespace Matchers\n} // namespace Catch\n\n// end catch_matchers_floating.cpp\n// start catch_matchers_generic.cpp\n\nstd::string Catch::Matchers::Generic::Detail::finalizeDescription(const std::string& desc) {\n    if (desc.empty()) {\n        return \"matches undescribed predicate\";\n    } else {\n        return \"matches predicate: \\\"\" + desc + '\"';\n    }\n}\n// end catch_matchers_generic.cpp\n// start catch_matchers_string.cpp\n\n#include <regex>\n\nnamespace Catch {\nnamespace Matchers {\n\n    namespace StdString {\n\n        CasedString::CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity )\n        :   m_caseSensitivity( caseSensitivity ),\n            m_str( adjustString( str ) )\n        {}\n        std::string CasedString::adjustString( std::string const& str ) const {\n            return m_caseSensitivity == CaseSensitive::No\n                   ? toLower( str )\n                   : str;\n        }\n        std::string CasedString::caseSensitivitySuffix() const {\n            return m_caseSensitivity == CaseSensitive::No\n                   ? \" (case insensitive)\"\n                   : std::string();\n        }\n\n        StringMatcherBase::StringMatcherBase( std::string const& operation, CasedString const& comparator )\n        : m_comparator( comparator ),\n          m_operation( operation ) {\n        }\n\n        std::string StringMatcherBase::describe() const {\n            std::string description;\n            description.reserve(5 + m_operation.size() + m_comparator.m_str.size() +\n                                        m_comparator.caseSensitivitySuffix().size());\n            description += m_operation;\n            description += \": \\\"\";\n            description += m_comparator.m_str;\n            description += \"\\\"\";\n            description += m_comparator.caseSensitivitySuffix();\n            return description;\n        }\n\n        EqualsMatcher::EqualsMatcher( CasedString const& comparator ) : StringMatcherBase( \"equals\", comparator ) {}\n\n        bool EqualsMatcher::match( std::string const& source ) const {\n            return m_comparator.adjustString( source ) == m_comparator.m_str;\n        }\n\n        ContainsMatcher::ContainsMatcher( CasedString const& comparator ) : StringMatcherBase( \"contains\", comparator ) {}\n\n        bool ContainsMatcher::match( std::string const& source ) const {\n            return contains( m_comparator.adjustString( source ), m_comparator.m_str );\n        }\n\n        StartsWithMatcher::StartsWithMatcher( CasedString const& comparator ) : StringMatcherBase( \"starts with\", comparator ) {}\n\n        bool StartsWithMatcher::match( std::string const& source ) const {\n            return startsWith( m_comparator.adjustString( source ), m_comparator.m_str );\n        }\n\n        EndsWithMatcher::EndsWithMatcher( CasedString const& comparator ) : StringMatcherBase( \"ends with\", comparator ) {}\n\n        bool EndsWithMatcher::match( std::string const& source ) const {\n            return endsWith( m_comparator.adjustString( source ), m_comparator.m_str );\n        }\n\n        RegexMatcher::RegexMatcher(std::string regex, CaseSensitive::Choice caseSensitivity): m_regex(std::move(regex)), m_caseSensitivity(caseSensitivity) {}\n\n        bool RegexMatcher::match(std::string const& matchee) const {\n            auto flags = std::regex::ECMAScript; // ECMAScript is the default syntax option anyway\n            if (m_caseSensitivity == CaseSensitive::Choice::No) {\n                flags |= std::regex::icase;\n            }\n            auto reg = std::regex(m_regex, flags);\n            return std::regex_match(matchee, reg);\n        }\n\n        std::string RegexMatcher::describe() const {\n            return \"matches \" + ::Catch::Detail::stringify(m_regex) + ((m_caseSensitivity == CaseSensitive::Choice::Yes)? \" case sensitively\" : \" case insensitively\");\n        }\n\n    } // namespace StdString\n\n    StdString::EqualsMatcher Equals( std::string const& str, CaseSensitive::Choice caseSensitivity ) {\n        return StdString::EqualsMatcher( StdString::CasedString( str, caseSensitivity) );\n    }\n    StdString::ContainsMatcher Contains( std::string const& str, CaseSensitive::Choice caseSensitivity ) {\n        return StdString::ContainsMatcher( StdString::CasedString( str, caseSensitivity) );\n    }\n    StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSensitive::Choice caseSensitivity ) {\n        return StdString::EndsWithMatcher( StdString::CasedString( str, caseSensitivity) );\n    }\n    StdString::StartsWithMatcher StartsWith( std::string const& str, CaseSensitive::Choice caseSensitivity ) {\n        return StdString::StartsWithMatcher( StdString::CasedString( str, caseSensitivity) );\n    }\n\n    StdString::RegexMatcher Matches(std::string const& regex, CaseSensitive::Choice caseSensitivity) {\n        return StdString::RegexMatcher(regex, caseSensitivity);\n    }\n\n} // namespace Matchers\n} // namespace Catch\n// end catch_matchers_string.cpp\n// start catch_message.cpp\n\n// start catch_uncaught_exceptions.h\n\nnamespace Catch {\n    bool uncaught_exceptions();\n} // end namespace Catch\n\n// end catch_uncaught_exceptions.h\n#include <cassert>\n#include <stack>\n\nnamespace Catch {\n\n    MessageInfo::MessageInfo(   StringRef const& _macroName,\n                                SourceLineInfo const& _lineInfo,\n                                ResultWas::OfType _type )\n    :   macroName( _macroName ),\n        lineInfo( _lineInfo ),\n        type( _type ),\n        sequence( ++globalCount )\n    {}\n\n    bool MessageInfo::operator==( MessageInfo const& other ) const {\n        return sequence == other.sequence;\n    }\n\n    bool MessageInfo::operator<( MessageInfo const& other ) const {\n        return sequence < other.sequence;\n    }\n\n    // This may need protecting if threading support is added\n    unsigned int MessageInfo::globalCount = 0;\n\n    ////////////////////////////////////////////////////////////////////////////\n\n    Catch::MessageBuilder::MessageBuilder( StringRef const& macroName,\n                                           SourceLineInfo const& lineInfo,\n                                           ResultWas::OfType type )\n        :m_info(macroName, lineInfo, type) {}\n\n    ////////////////////////////////////////////////////////////////////////////\n\n    ScopedMessage::ScopedMessage( MessageBuilder const& builder )\n    : m_info( builder.m_info )\n    {\n        m_info.message = builder.m_stream.str();\n        getResultCapture().pushScopedMessage( m_info );\n    }\n\n    ScopedMessage::~ScopedMessage() {\n        if ( !uncaught_exceptions() ){\n            getResultCapture().popScopedMessage(m_info);\n        }\n    }\n\n    Capturer::Capturer( StringRef macroName, SourceLineInfo const& lineInfo, ResultWas::OfType resultType, StringRef names ) {\n        auto trimmed = [&] (size_t start, size_t end) {\n            while (names[start] == ',' || isspace(names[start])) {\n                ++start;\n            }\n            while (names[end] == ',' || isspace(names[end])) {\n                --end;\n            }\n            return names.substr(start, end - start + 1);\n        };\n\n        size_t start = 0;\n        std::stack<char> openings;\n        for (size_t pos = 0; pos < names.size(); ++pos) {\n            char c = names[pos];\n            switch (c) {\n            case '[':\n            case '{':\n            case '(':\n            // It is basically impossible to disambiguate between\n            // comparison and start of template args in this context\n//            case '<':\n                openings.push(c);\n                break;\n            case ']':\n            case '}':\n            case ')':\n//           case '>':\n                openings.pop();\n                break;\n            case ',':\n                if (start != pos && openings.size() == 0) {\n                    m_messages.emplace_back(macroName, lineInfo, resultType);\n                    m_messages.back().message = trimmed(start, pos);\n                    m_messages.back().message += \" := \";\n                    start = pos;\n                }\n            }\n        }\n        assert(openings.size() == 0 && \"Mismatched openings\");\n        m_messages.emplace_back(macroName, lineInfo, resultType);\n        m_messages.back().message = trimmed(start, names.size() - 1);\n        m_messages.back().message += \" := \";\n    }\n    Capturer::~Capturer() {\n        if ( !uncaught_exceptions() ){\n            assert( m_captured == m_messages.size() );\n            for( size_t i = 0; i < m_captured; ++i  )\n                m_resultCapture.popScopedMessage( m_messages[i] );\n        }\n    }\n\n    void Capturer::captureValue( size_t index, std::string const& value ) {\n        assert( index < m_messages.size() );\n        m_messages[index].message += value;\n        m_resultCapture.pushScopedMessage( m_messages[index] );\n        m_captured++;\n    }\n\n} // end namespace Catch\n// end catch_message.cpp\n// start catch_output_redirect.cpp\n\n// start catch_output_redirect.h\n#ifndef TWOBLUECUBES_CATCH_OUTPUT_REDIRECT_H\n#define TWOBLUECUBES_CATCH_OUTPUT_REDIRECT_H\n\n#include <cstdio>\n#include <iosfwd>\n#include <string>\n\nnamespace Catch {\n\n    class RedirectedStream {\n        std::ostream& m_originalStream;\n        std::ostream& m_redirectionStream;\n        std::streambuf* m_prevBuf;\n\n    public:\n        RedirectedStream( std::ostream& originalStream, std::ostream& redirectionStream );\n        ~RedirectedStream();\n    };\n\n    class RedirectedStdOut {\n        ReusableStringStream m_rss;\n        RedirectedStream m_cout;\n    public:\n        RedirectedStdOut();\n        auto str() const -> std::string;\n    };\n\n    // StdErr has two constituent streams in C++, std::cerr and std::clog\n    // This means that we need to redirect 2 streams into 1 to keep proper\n    // order of writes\n    class RedirectedStdErr {\n        ReusableStringStream m_rss;\n        RedirectedStream m_cerr;\n        RedirectedStream m_clog;\n    public:\n        RedirectedStdErr();\n        auto str() const -> std::string;\n    };\n\n#if defined(CATCH_CONFIG_NEW_CAPTURE)\n\n    // Windows's implementation of std::tmpfile is terrible (it tries\n    // to create a file inside system folder, thus requiring elevated\n    // privileges for the binary), so we have to use tmpnam(_s) and\n    // create the file ourselves there.\n    class TempFile {\n    public:\n        TempFile(TempFile const&) = delete;\n        TempFile& operator=(TempFile const&) = delete;\n        TempFile(TempFile&&) = delete;\n        TempFile& operator=(TempFile&&) = delete;\n\n        TempFile();\n        ~TempFile();\n\n        std::FILE* getFile();\n        std::string getContents();\n\n    private:\n        std::FILE* m_file = nullptr;\n    #if defined(_MSC_VER)\n        char m_buffer[L_tmpnam] = { 0 };\n    #endif\n    };\n\n    class OutputRedirect {\n    public:\n        OutputRedirect(OutputRedirect const&) = delete;\n        OutputRedirect& operator=(OutputRedirect const&) = delete;\n        OutputRedirect(OutputRedirect&&) = delete;\n        OutputRedirect& operator=(OutputRedirect&&) = delete;\n\n        OutputRedirect(std::string& stdout_dest, std::string& stderr_dest);\n        ~OutputRedirect();\n\n    private:\n        int m_originalStdout = -1;\n        int m_originalStderr = -1;\n        TempFile m_stdoutFile;\n        TempFile m_stderrFile;\n        std::string& m_stdoutDest;\n        std::string& m_stderrDest;\n    };\n\n#endif\n\n} // end namespace Catch\n\n#endif // TWOBLUECUBES_CATCH_OUTPUT_REDIRECT_H\n// end catch_output_redirect.h\n#include <cstdio>\n#include <cstring>\n#include <fstream>\n#include <sstream>\n#include <stdexcept>\n\n#if defined(CATCH_CONFIG_NEW_CAPTURE)\n    #if defined(_MSC_VER)\n    #include <io.h>      //_dup and _dup2\n    #define dup _dup\n    #define dup2 _dup2\n    #define fileno _fileno\n    #else\n    #include <unistd.h>  // dup and dup2\n    #endif\n#endif\n\nnamespace Catch {\n\n    RedirectedStream::RedirectedStream( std::ostream& originalStream, std::ostream& redirectionStream )\n    :   m_originalStream( originalStream ),\n        m_redirectionStream( redirectionStream ),\n        m_prevBuf( m_originalStream.rdbuf() )\n    {\n        m_originalStream.rdbuf( m_redirectionStream.rdbuf() );\n    }\n\n    RedirectedStream::~RedirectedStream() {\n        m_originalStream.rdbuf( m_prevBuf );\n    }\n\n    RedirectedStdOut::RedirectedStdOut() : m_cout( Catch::cout(), m_rss.get() ) {}\n    auto RedirectedStdOut::str() const -> std::string { return m_rss.str(); }\n\n    RedirectedStdErr::RedirectedStdErr()\n    :   m_cerr( Catch::cerr(), m_rss.get() ),\n        m_clog( Catch::clog(), m_rss.get() )\n    {}\n    auto RedirectedStdErr::str() const -> std::string { return m_rss.str(); }\n\n#if defined(CATCH_CONFIG_NEW_CAPTURE)\n\n#if defined(_MSC_VER)\n    TempFile::TempFile() {\n        if (tmpnam_s(m_buffer)) {\n            CATCH_RUNTIME_ERROR(\"Could not get a temp filename\");\n        }\n        if (fopen_s(&m_file, m_buffer, \"w\")) {\n            char buffer[100];\n            if (strerror_s(buffer, errno)) {\n                CATCH_RUNTIME_ERROR(\"Could not translate errno to a string\");\n            }\n            CATCH_RUNTIME_ERROR(\"Could not open the temp file: '\" << m_buffer << \"' because: \" << buffer);\n        }\n    }\n#else\n    TempFile::TempFile() {\n        m_file = std::tmpfile();\n        if (!m_file) {\n            CATCH_RUNTIME_ERROR(\"Could not create a temp file.\");\n        }\n    }\n\n#endif\n\n    TempFile::~TempFile() {\n         // TBD: What to do about errors here?\n         std::fclose(m_file);\n         // We manually create the file on Windows only, on Linux\n         // it will be autodeleted\n#if defined(_MSC_VER)\n         std::remove(m_buffer);\n#endif\n    }\n\n    FILE* TempFile::getFile() {\n        return m_file;\n    }\n\n    std::string TempFile::getContents() {\n        std::stringstream sstr;\n        char buffer[100] = {};\n        std::rewind(m_file);\n        while (std::fgets(buffer, sizeof(buffer), m_file)) {\n            sstr << buffer;\n        }\n        return sstr.str();\n    }\n\n    OutputRedirect::OutputRedirect(std::string& stdout_dest, std::string& stderr_dest) :\n        m_originalStdout(dup(1)),\n        m_originalStderr(dup(2)),\n        m_stdoutDest(stdout_dest),\n        m_stderrDest(stderr_dest) {\n        dup2(fileno(m_stdoutFile.getFile()), 1);\n        dup2(fileno(m_stderrFile.getFile()), 2);\n    }\n\n    OutputRedirect::~OutputRedirect() {\n        Catch::cout() << std::flush;\n        fflush(stdout);\n        // Since we support overriding these streams, we flush cerr\n        // even though std::cerr is unbuffered\n        Catch::cerr() << std::flush;\n        Catch::clog() << std::flush;\n        fflush(stderr);\n\n        dup2(m_originalStdout, 1);\n        dup2(m_originalStderr, 2);\n\n        m_stdoutDest += m_stdoutFile.getContents();\n        m_stderrDest += m_stderrFile.getContents();\n    }\n\n#endif // CATCH_CONFIG_NEW_CAPTURE\n\n} // namespace Catch\n\n#if defined(CATCH_CONFIG_NEW_CAPTURE)\n    #if defined(_MSC_VER)\n    #undef dup\n    #undef dup2\n    #undef fileno\n    #endif\n#endif\n// end catch_output_redirect.cpp\n// start catch_polyfills.cpp\n\n#include <cmath>\n\nnamespace Catch {\n\n#if !defined(CATCH_CONFIG_POLYFILL_ISNAN)\n    bool isnan(float f) {\n        return std::isnan(f);\n    }\n    bool isnan(double d) {\n        return std::isnan(d);\n    }\n#else\n    // For now we only use this for embarcadero\n    bool isnan(float f) {\n        return std::_isnan(f);\n    }\n    bool isnan(double d) {\n        return std::_isnan(d);\n    }\n#endif\n\n} // end namespace Catch\n// end catch_polyfills.cpp\n// start catch_random_number_generator.cpp\n\nnamespace Catch {\n\n    std::mt19937& rng() {\n        static std::mt19937 s_rng;\n        return s_rng;\n    }\n\n    void seedRng( IConfig const& config ) {\n        if( config.rngSeed() != 0 ) {\n            std::srand( config.rngSeed() );\n            rng().seed( config.rngSeed() );\n        }\n    }\n\n    unsigned int rngSeed() {\n        return getCurrentContext().getConfig()->rngSeed();\n    }\n}\n// end catch_random_number_generator.cpp\n// start catch_registry_hub.cpp\n\n// start catch_test_case_registry_impl.h\n\n#include <vector>\n#include <set>\n#include <algorithm>\n#include <ios>\n\nnamespace Catch {\n\n    class TestCase;\n    struct IConfig;\n\n    std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases );\n    bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config );\n\n    void enforceNoDuplicateTestCases( std::vector<TestCase> const& functions );\n\n    std::vector<TestCase> filterTests( std::vector<TestCase> const& testCases, TestSpec const& testSpec, IConfig const& config );\n    std::vector<TestCase> const& getAllTestCasesSorted( IConfig const& config );\n\n    class TestRegistry : public ITestCaseRegistry {\n    public:\n        virtual ~TestRegistry() = default;\n\n        virtual void registerTest( TestCase const& testCase );\n\n        std::vector<TestCase> const& getAllTests() const override;\n        std::vector<TestCase> const& getAllTestsSorted( IConfig const& config ) const override;\n\n    private:\n        std::vector<TestCase> m_functions;\n        mutable RunTests::InWhatOrder m_currentSortOrder = RunTests::InDeclarationOrder;\n        mutable std::vector<TestCase> m_sortedFunctions;\n        std::size_t m_unnamedCount = 0;\n        std::ios_base::Init m_ostreamInit; // Forces cout/ cerr to be initialised\n    };\n\n    ///////////////////////////////////////////////////////////////////////////\n\n    class TestInvokerAsFunction : public ITestInvoker {\n        void(*m_testAsFunction)();\n    public:\n        TestInvokerAsFunction( void(*testAsFunction)() ) noexcept;\n\n        void invoke() const override;\n    };\n\n    std::string extractClassName( StringRef const& classOrQualifiedMethodName );\n\n    ///////////////////////////////////////////////////////////////////////////\n\n} // end namespace Catch\n\n// end catch_test_case_registry_impl.h\n// start catch_reporter_registry.h\n\n#include <map>\n\nnamespace Catch {\n\n    class ReporterRegistry : public IReporterRegistry {\n\n    public:\n\n        ~ReporterRegistry() override;\n\n        IStreamingReporterPtr create( std::string const& name, IConfigPtr const& config ) const override;\n\n        void registerReporter( std::string const& name, IReporterFactoryPtr const& factory );\n        void registerListener( IReporterFactoryPtr const& factory );\n\n        FactoryMap const& getFactories() const override;\n        Listeners const& getListeners() const override;\n\n    private:\n        FactoryMap m_factories;\n        Listeners m_listeners;\n    };\n}\n\n// end catch_reporter_registry.h\n// start catch_tag_alias_registry.h\n\n// start catch_tag_alias.h\n\n#include <string>\n\nnamespace Catch {\n\n    struct TagAlias {\n        TagAlias(std::string const& _tag, SourceLineInfo _lineInfo);\n\n        std::string tag;\n        SourceLineInfo lineInfo;\n    };\n\n} // end namespace Catch\n\n// end catch_tag_alias.h\n#include <map>\n\nnamespace Catch {\n\n    class TagAliasRegistry : public ITagAliasRegistry {\n    public:\n        ~TagAliasRegistry() override;\n        TagAlias const* find( std::string const& alias ) const override;\n        std::string expandAliases( std::string const& unexpandedTestSpec ) const override;\n        void add( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo );\n\n    private:\n        std::map<std::string, TagAlias> m_registry;\n    };\n\n} // end namespace Catch\n\n// end catch_tag_alias_registry.h\n// start catch_startup_exception_registry.h\n\n#include <vector>\n#include <exception>\n\nnamespace Catch {\n\n    class StartupExceptionRegistry {\n    public:\n        void add(std::exception_ptr const& exception) noexcept;\n        std::vector<std::exception_ptr> const& getExceptions() const noexcept;\n    private:\n        std::vector<std::exception_ptr> m_exceptions;\n    };\n\n} // end namespace Catch\n\n// end catch_startup_exception_registry.h\n// start catch_singletons.hpp\n\nnamespace Catch {\n\n    struct ISingleton {\n        virtual ~ISingleton();\n    };\n\n    void addSingleton( ISingleton* singleton );\n    void cleanupSingletons();\n\n    template<typename SingletonImplT, typename InterfaceT = SingletonImplT, typename MutableInterfaceT = InterfaceT>\n    class Singleton : SingletonImplT, public ISingleton {\n\n        static auto getInternal() -> Singleton* {\n            static Singleton* s_instance = nullptr;\n            if( !s_instance ) {\n                s_instance = new Singleton;\n                addSingleton( s_instance );\n            }\n            return s_instance;\n        }\n\n    public:\n        static auto get() -> InterfaceT const& {\n            return *getInternal();\n        }\n        static auto getMutable() -> MutableInterfaceT& {\n            return *getInternal();\n        }\n    };\n\n} // namespace Catch\n\n// end catch_singletons.hpp\nnamespace Catch {\n\n    namespace {\n\n        class RegistryHub : public IRegistryHub, public IMutableRegistryHub,\n                            private NonCopyable {\n\n        public: // IRegistryHub\n            RegistryHub() = default;\n            IReporterRegistry const& getReporterRegistry() const override {\n                return m_reporterRegistry;\n            }\n            ITestCaseRegistry const& getTestCaseRegistry() const override {\n                return m_testCaseRegistry;\n            }\n            IExceptionTranslatorRegistry const& getExceptionTranslatorRegistry() const override {\n                return m_exceptionTranslatorRegistry;\n            }\n            ITagAliasRegistry const& getTagAliasRegistry() const override {\n                return m_tagAliasRegistry;\n            }\n            StartupExceptionRegistry const& getStartupExceptionRegistry() const override {\n                return m_exceptionRegistry;\n            }\n\n        public: // IMutableRegistryHub\n            void registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) override {\n                m_reporterRegistry.registerReporter( name, factory );\n            }\n            void registerListener( IReporterFactoryPtr const& factory ) override {\n                m_reporterRegistry.registerListener( factory );\n            }\n            void registerTest( TestCase const& testInfo ) override {\n                m_testCaseRegistry.registerTest( testInfo );\n            }\n            void registerTranslator( const IExceptionTranslator* translator ) override {\n                m_exceptionTranslatorRegistry.registerTranslator( translator );\n            }\n            void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) override {\n                m_tagAliasRegistry.add( alias, tag, lineInfo );\n            }\n            void registerStartupException() noexcept override {\n                m_exceptionRegistry.add(std::current_exception());\n            }\n\n        private:\n            TestRegistry m_testCaseRegistry;\n            ReporterRegistry m_reporterRegistry;\n            ExceptionTranslatorRegistry m_exceptionTranslatorRegistry;\n            TagAliasRegistry m_tagAliasRegistry;\n            StartupExceptionRegistry m_exceptionRegistry;\n        };\n    }\n\n    using RegistryHubSingleton = Singleton<RegistryHub, IRegistryHub, IMutableRegistryHub>;\n\n    IRegistryHub const& getRegistryHub() {\n        return RegistryHubSingleton::get();\n    }\n    IMutableRegistryHub& getMutableRegistryHub() {\n        return RegistryHubSingleton::getMutable();\n    }\n    void cleanUp() {\n        cleanupSingletons();\n        cleanUpContext();\n    }\n    std::string translateActiveException() {\n        return getRegistryHub().getExceptionTranslatorRegistry().translateActiveException();\n    }\n\n} // end namespace Catch\n// end catch_registry_hub.cpp\n// start catch_reporter_registry.cpp\n\nnamespace Catch {\n\n    ReporterRegistry::~ReporterRegistry() = default;\n\n    IStreamingReporterPtr ReporterRegistry::create( std::string const& name, IConfigPtr const& config ) const {\n        auto it =  m_factories.find( name );\n        if( it == m_factories.end() )\n            return nullptr;\n        return it->second->create( ReporterConfig( config ) );\n    }\n\n    void ReporterRegistry::registerReporter( std::string const& name, IReporterFactoryPtr const& factory ) {\n        m_factories.emplace(name, factory);\n    }\n    void ReporterRegistry::registerListener( IReporterFactoryPtr const& factory ) {\n        m_listeners.push_back( factory );\n    }\n\n    IReporterRegistry::FactoryMap const& ReporterRegistry::getFactories() const {\n        return m_factories;\n    }\n    IReporterRegistry::Listeners const& ReporterRegistry::getListeners() const {\n        return m_listeners;\n    }\n\n}\n// end catch_reporter_registry.cpp\n// start catch_result_type.cpp\n\nnamespace Catch {\n\n    bool isOk( ResultWas::OfType resultType ) {\n        return ( resultType & ResultWas::FailureBit ) == 0;\n    }\n    bool isJustInfo( int flags ) {\n        return flags == ResultWas::Info;\n    }\n\n    ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ) {\n        return static_cast<ResultDisposition::Flags>( static_cast<int>( lhs ) | static_cast<int>( rhs ) );\n    }\n\n    bool shouldContinueOnFailure( int flags )    { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; }\n    bool shouldSuppressFailure( int flags )      { return ( flags & ResultDisposition::SuppressFail ) != 0; }\n\n} // end namespace Catch\n// end catch_result_type.cpp\n// start catch_run_context.cpp\n\n#include <cassert>\n#include <algorithm>\n#include <sstream>\n\nnamespace Catch {\n\n    namespace Generators {\n        struct GeneratorTracker : TestCaseTracking::TrackerBase, IGeneratorTracker {\n            size_t m_index = static_cast<size_t>( -1 );\n            GeneratorBasePtr m_generator;\n\n            GeneratorTracker( TestCaseTracking::NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent )\n            :   TrackerBase( nameAndLocation, ctx, parent )\n            {}\n            ~GeneratorTracker();\n\n            static GeneratorTracker& acquire( TrackerContext& ctx, TestCaseTracking::NameAndLocation const& nameAndLocation ) {\n                std::shared_ptr<GeneratorTracker> tracker;\n\n                ITracker& currentTracker = ctx.currentTracker();\n                if( TestCaseTracking::ITrackerPtr childTracker = currentTracker.findChild( nameAndLocation ) ) {\n                    assert( childTracker );\n                    assert( childTracker->isIndexTracker() );\n                    tracker = std::static_pointer_cast<GeneratorTracker>( childTracker );\n                }\n                else {\n                    tracker = std::make_shared<GeneratorTracker>( nameAndLocation, ctx, &currentTracker );\n                    currentTracker.addChild( tracker );\n                }\n\n                if( !ctx.completedCycle() && !tracker->isComplete() ) {\n                    if( tracker->m_runState != ExecutingChildren && tracker->m_runState != NeedsAnotherRun )\n                        tracker->moveNext();\n                    tracker->open();\n                }\n\n                return *tracker;\n            }\n\n            void moveNext() {\n                m_index++;\n                m_children.clear();\n            }\n\n            // TrackerBase interface\n            bool isIndexTracker() const override { return true; }\n            auto hasGenerator() const -> bool override {\n                return !!m_generator;\n            }\n            void close() override {\n                TrackerBase::close();\n                if( m_runState == CompletedSuccessfully && m_index < m_generator->size()-1 )\n                    m_runState = Executing;\n            }\n\n            // IGeneratorTracker interface\n            auto getGenerator() const -> GeneratorBasePtr const& override {\n                return m_generator;\n            }\n            void setGenerator( GeneratorBasePtr&& generator ) override {\n                m_generator = std::move( generator );\n            }\n            auto getIndex() const -> size_t override {\n                return m_index;\n            }\n        };\n        GeneratorTracker::~GeneratorTracker() {}\n    }\n\n    RunContext::RunContext(IConfigPtr const& _config, IStreamingReporterPtr&& reporter)\n    :   m_runInfo(_config->name()),\n        m_context(getCurrentMutableContext()),\n        m_config(_config),\n        m_reporter(std::move(reporter)),\n        m_lastAssertionInfo{ StringRef(), SourceLineInfo(\"\",0), StringRef(), ResultDisposition::Normal },\n        m_includeSuccessfulResults( m_config->includeSuccessfulResults() || m_reporter->getPreferences().shouldReportAllAssertions )\n    {\n        m_context.setRunner(this);\n        m_context.setConfig(m_config);\n        m_context.setResultCapture(this);\n        m_reporter->testRunStarting(m_runInfo);\n    }\n\n    RunContext::~RunContext() {\n        m_reporter->testRunEnded(TestRunStats(m_runInfo, m_totals, aborting()));\n    }\n\n    void RunContext::testGroupStarting(std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount) {\n        m_reporter->testGroupStarting(GroupInfo(testSpec, groupIndex, groupsCount));\n    }\n\n    void RunContext::testGroupEnded(std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount) {\n        m_reporter->testGroupEnded(TestGroupStats(GroupInfo(testSpec, groupIndex, groupsCount), totals, aborting()));\n    }\n\n    Totals RunContext::runTest(TestCase const& testCase) {\n        Totals prevTotals = m_totals;\n\n        std::string redirectedCout;\n        std::string redirectedCerr;\n\n        auto const& testInfo = testCase.getTestCaseInfo();\n\n        m_reporter->testCaseStarting(testInfo);\n\n        m_activeTestCase = &testCase;\n\n        ITracker& rootTracker = m_trackerContext.startRun();\n        assert(rootTracker.isSectionTracker());\n        static_cast<SectionTracker&>(rootTracker).addInitialFilters(m_config->getSectionsToRun());\n        do {\n            m_trackerContext.startCycle();\n            m_testCaseTracker = &SectionTracker::acquire(m_trackerContext, TestCaseTracking::NameAndLocation(testInfo.name, testInfo.lineInfo));\n            runCurrentTest(redirectedCout, redirectedCerr);\n        } while (!m_testCaseTracker->isSuccessfullyCompleted() && !aborting());\n\n        Totals deltaTotals = m_totals.delta(prevTotals);\n        if (testInfo.expectedToFail() && deltaTotals.testCases.passed > 0) {\n            deltaTotals.assertions.failed++;\n            deltaTotals.testCases.passed--;\n            deltaTotals.testCases.failed++;\n        }\n        m_totals.testCases += deltaTotals.testCases;\n        m_reporter->testCaseEnded(TestCaseStats(testInfo,\n                                  deltaTotals,\n                                  redirectedCout,\n                                  redirectedCerr,\n                                  aborting()));\n\n        m_activeTestCase = nullptr;\n        m_testCaseTracker = nullptr;\n\n        return deltaTotals;\n    }\n\n    IConfigPtr RunContext::config() const {\n        return m_config;\n    }\n\n    IStreamingReporter& RunContext::reporter() const {\n        return *m_reporter;\n    }\n\n    void RunContext::assertionEnded(AssertionResult const & result) {\n        if (result.getResultType() == ResultWas::Ok) {\n            m_totals.assertions.passed++;\n            m_lastAssertionPassed = true;\n        } else if (!result.isOk()) {\n            m_lastAssertionPassed = false;\n            if( m_activeTestCase->getTestCaseInfo().okToFail() )\n                m_totals.assertions.failedButOk++;\n            else\n                m_totals.assertions.failed++;\n        }\n        else {\n            m_lastAssertionPassed = true;\n        }\n\n        // We have no use for the return value (whether messages should be cleared), because messages were made scoped\n        // and should be let to clear themselves out.\n        static_cast<void>(m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals)));\n\n        // Reset working state\n        resetAssertionInfo();\n        m_lastResult = result;\n    }\n    void RunContext::resetAssertionInfo() {\n        m_lastAssertionInfo.macroName = StringRef();\n        m_lastAssertionInfo.capturedExpression = \"{Unknown expression after the reported line}\"_sr;\n    }\n\n    bool RunContext::sectionStarted(SectionInfo const & sectionInfo, Counts & assertions) {\n        ITracker& sectionTracker = SectionTracker::acquire(m_trackerContext, TestCaseTracking::NameAndLocation(sectionInfo.name, sectionInfo.lineInfo));\n        if (!sectionTracker.isOpen())\n            return false;\n        m_activeSections.push_back(&sectionTracker);\n\n        m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo;\n\n        m_reporter->sectionStarting(sectionInfo);\n\n        assertions = m_totals.assertions;\n\n        return true;\n    }\n    auto RunContext::acquireGeneratorTracker( SourceLineInfo const& lineInfo ) -> IGeneratorTracker& {\n        using namespace Generators;\n        GeneratorTracker& tracker = GeneratorTracker::acquire( m_trackerContext, TestCaseTracking::NameAndLocation( \"generator\", lineInfo ) );\n        assert( tracker.isOpen() );\n        m_lastAssertionInfo.lineInfo = lineInfo;\n        return tracker;\n    }\n\n    bool RunContext::testForMissingAssertions(Counts& assertions) {\n        if (assertions.total() != 0)\n            return false;\n        if (!m_config->warnAboutMissingAssertions())\n            return false;\n        if (m_trackerContext.currentTracker().hasChildren())\n            return false;\n        m_totals.assertions.failed++;\n        assertions.failed++;\n        return true;\n    }\n\n    void RunContext::sectionEnded(SectionEndInfo const & endInfo) {\n        Counts assertions = m_totals.assertions - endInfo.prevAssertions;\n        bool missingAssertions = testForMissingAssertions(assertions);\n\n        if (!m_activeSections.empty()) {\n            m_activeSections.back()->close();\n            m_activeSections.pop_back();\n        }\n\n        m_reporter->sectionEnded(SectionStats(endInfo.sectionInfo, assertions, endInfo.durationInSeconds, missingAssertions));\n        m_messages.clear();\n    }\n\n    void RunContext::sectionEndedEarly(SectionEndInfo const & endInfo) {\n        if (m_unfinishedSections.empty())\n            m_activeSections.back()->fail();\n        else\n            m_activeSections.back()->close();\n        m_activeSections.pop_back();\n\n        m_unfinishedSections.push_back(endInfo);\n    }\n    void RunContext::benchmarkStarting( BenchmarkInfo const& info ) {\n        m_reporter->benchmarkStarting( info );\n    }\n    void RunContext::benchmarkEnded( BenchmarkStats const& stats ) {\n        m_reporter->benchmarkEnded( stats );\n    }\n\n    void RunContext::pushScopedMessage(MessageInfo const & message) {\n        m_messages.push_back(message);\n    }\n\n    void RunContext::popScopedMessage(MessageInfo const & message) {\n        m_messages.erase(std::remove(m_messages.begin(), m_messages.end(), message), m_messages.end());\n    }\n\n    std::string RunContext::getCurrentTestName() const {\n        return m_activeTestCase\n            ? m_activeTestCase->getTestCaseInfo().name\n            : std::string();\n    }\n\n    const AssertionResult * RunContext::getLastResult() const {\n        return &(*m_lastResult);\n    }\n\n    void RunContext::exceptionEarlyReported() {\n        m_shouldReportUnexpected = false;\n    }\n\n    void RunContext::handleFatalErrorCondition( StringRef message ) {\n        // First notify reporter that bad things happened\n        m_reporter->fatalErrorEncountered(message);\n\n        // Don't rebuild the result -- the stringification itself can cause more fatal errors\n        // Instead, fake a result data.\n        AssertionResultData tempResult( ResultWas::FatalErrorCondition, { false } );\n        tempResult.message = message;\n        AssertionResult result(m_lastAssertionInfo, tempResult);\n\n        assertionEnded(result);\n\n        handleUnfinishedSections();\n\n        // Recreate section for test case (as we will lose the one that was in scope)\n        auto const& testCaseInfo = m_activeTestCase->getTestCaseInfo();\n        SectionInfo testCaseSection(testCaseInfo.lineInfo, testCaseInfo.name);\n\n        Counts assertions;\n        assertions.failed = 1;\n        SectionStats testCaseSectionStats(testCaseSection, assertions, 0, false);\n        m_reporter->sectionEnded(testCaseSectionStats);\n\n        auto const& testInfo = m_activeTestCase->getTestCaseInfo();\n\n        Totals deltaTotals;\n        deltaTotals.testCases.failed = 1;\n        deltaTotals.assertions.failed = 1;\n        m_reporter->testCaseEnded(TestCaseStats(testInfo,\n                                  deltaTotals,\n                                  std::string(),\n                                  std::string(),\n                                  false));\n        m_totals.testCases.failed++;\n        testGroupEnded(std::string(), m_totals, 1, 1);\n        m_reporter->testRunEnded(TestRunStats(m_runInfo, m_totals, false));\n    }\n\n    bool RunContext::lastAssertionPassed() {\n         return m_lastAssertionPassed;\n    }\n\n    void RunContext::assertionPassed() {\n        m_lastAssertionPassed = true;\n        ++m_totals.assertions.passed;\n        resetAssertionInfo();\n    }\n\n    bool RunContext::aborting() const {\n        return m_totals.assertions.failed >= static_cast<std::size_t>(m_config->abortAfter());\n    }\n\n    void RunContext::runCurrentTest(std::string & redirectedCout, std::string & redirectedCerr) {\n        auto const& testCaseInfo = m_activeTestCase->getTestCaseInfo();\n        SectionInfo testCaseSection(testCaseInfo.lineInfo, testCaseInfo.name);\n        m_reporter->sectionStarting(testCaseSection);\n        Counts prevAssertions = m_totals.assertions;\n        double duration = 0;\n        m_shouldReportUnexpected = true;\n        m_lastAssertionInfo = { \"TEST_CASE\"_sr, testCaseInfo.lineInfo, StringRef(), ResultDisposition::Normal };\n\n        seedRng(*m_config);\n\n        Timer timer;\n        CATCH_TRY {\n            if (m_reporter->getPreferences().shouldRedirectStdOut) {\n#if !defined(CATCH_CONFIG_EXPERIMENTAL_REDIRECT)\n                RedirectedStdOut redirectedStdOut;\n                RedirectedStdErr redirectedStdErr;\n\n                timer.start();\n                invokeActiveTestCase();\n                redirectedCout += redirectedStdOut.str();\n                redirectedCerr += redirectedStdErr.str();\n#else\n                OutputRedirect r(redirectedCout, redirectedCerr);\n                timer.start();\n                invokeActiveTestCase();\n#endif\n            } else {\n                timer.start();\n                invokeActiveTestCase();\n            }\n            duration = timer.getElapsedSeconds();\n        } CATCH_CATCH_ANON (TestFailureException&) {\n            // This just means the test was aborted due to failure\n        } CATCH_CATCH_ALL {\n            // Under CATCH_CONFIG_FAST_COMPILE, unexpected exceptions under REQUIRE assertions\n            // are reported without translation at the point of origin.\n            if( m_shouldReportUnexpected ) {\n                AssertionReaction dummyReaction;\n                handleUnexpectedInflightException( m_lastAssertionInfo, translateActiveException(), dummyReaction );\n            }\n        }\n        Counts assertions = m_totals.assertions - prevAssertions;\n        bool missingAssertions = testForMissingAssertions(assertions);\n\n        m_testCaseTracker->close();\n        handleUnfinishedSections();\n        m_messages.clear();\n\n        SectionStats testCaseSectionStats(testCaseSection, assertions, duration, missingAssertions);\n        m_reporter->sectionEnded(testCaseSectionStats);\n    }\n\n    void RunContext::invokeActiveTestCase() {\n        FatalConditionHandler fatalConditionHandler; // Handle signals\n        m_activeTestCase->invoke();\n        fatalConditionHandler.reset();\n    }\n\n    void RunContext::handleUnfinishedSections() {\n        // If sections ended prematurely due to an exception we stored their\n        // infos here so we can tear them down outside the unwind process.\n        for (auto it = m_unfinishedSections.rbegin(),\n             itEnd = m_unfinishedSections.rend();\n             it != itEnd;\n             ++it)\n            sectionEnded(*it);\n        m_unfinishedSections.clear();\n    }\n\n    void RunContext::handleExpr(\n        AssertionInfo const& info,\n        ITransientExpression const& expr,\n        AssertionReaction& reaction\n    ) {\n        m_reporter->assertionStarting( info );\n\n        bool negated = isFalseTest( info.resultDisposition );\n        bool result = expr.getResult() != negated;\n\n        if( result ) {\n            if (!m_includeSuccessfulResults) {\n                assertionPassed();\n            }\n            else {\n                reportExpr(info, ResultWas::Ok, &expr, negated);\n            }\n        }\n        else {\n            reportExpr(info, ResultWas::ExpressionFailed, &expr, negated );\n            populateReaction( reaction );\n        }\n    }\n    void RunContext::reportExpr(\n            AssertionInfo const &info,\n            ResultWas::OfType resultType,\n            ITransientExpression const *expr,\n            bool negated ) {\n\n        m_lastAssertionInfo = info;\n        AssertionResultData data( resultType, LazyExpression( negated ) );\n\n        AssertionResult assertionResult{ info, data };\n        assertionResult.m_resultData.lazyExpression.m_transientExpression = expr;\n\n        assertionEnded( assertionResult );\n    }\n\n    void RunContext::handleMessage(\n            AssertionInfo const& info,\n            ResultWas::OfType resultType,\n            StringRef const& message,\n            AssertionReaction& reaction\n    ) {\n        m_reporter->assertionStarting( info );\n\n        m_lastAssertionInfo = info;\n\n        AssertionResultData data( resultType, LazyExpression( false ) );\n        data.message = message;\n        AssertionResult assertionResult{ m_lastAssertionInfo, data };\n        assertionEnded( assertionResult );\n        if( !assertionResult.isOk() )\n            populateReaction( reaction );\n    }\n    void RunContext::handleUnexpectedExceptionNotThrown(\n            AssertionInfo const& info,\n            AssertionReaction& reaction\n    ) {\n        handleNonExpr(info, Catch::ResultWas::DidntThrowException, reaction);\n    }\n\n    void RunContext::handleUnexpectedInflightException(\n            AssertionInfo const& info,\n            std::string const& message,\n            AssertionReaction& reaction\n    ) {\n        m_lastAssertionInfo = info;\n\n        AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) );\n        data.message = message;\n        AssertionResult assertionResult{ info, data };\n        assertionEnded( assertionResult );\n        populateReaction( reaction );\n    }\n\n    void RunContext::populateReaction( AssertionReaction& reaction ) {\n        reaction.shouldDebugBreak = m_config->shouldDebugBreak();\n        reaction.shouldThrow = aborting() || (m_lastAssertionInfo.resultDisposition & ResultDisposition::Normal);\n    }\n\n    void RunContext::handleIncomplete(\n            AssertionInfo const& info\n    ) {\n        m_lastAssertionInfo = info;\n\n        AssertionResultData data( ResultWas::ThrewException, LazyExpression( false ) );\n        data.message = \"Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE\";\n        AssertionResult assertionResult{ info, data };\n        assertionEnded( assertionResult );\n    }\n    void RunContext::handleNonExpr(\n            AssertionInfo const &info,\n            ResultWas::OfType resultType,\n            AssertionReaction &reaction\n    ) {\n        m_lastAssertionInfo = info;\n\n        AssertionResultData data( resultType, LazyExpression( false ) );\n        AssertionResult assertionResult{ info, data };\n        assertionEnded( assertionResult );\n\n        if( !assertionResult.isOk() )\n            populateReaction( reaction );\n    }\n\n    IResultCapture& getResultCapture() {\n        if (auto* capture = getCurrentContext().getResultCapture())\n            return *capture;\n        else\n            CATCH_INTERNAL_ERROR(\"No result capture instance\");\n    }\n}\n// end catch_run_context.cpp\n// start catch_section.cpp\n\nnamespace Catch {\n\n    Section::Section( SectionInfo const& info )\n    :   m_info( info ),\n        m_sectionIncluded( getResultCapture().sectionStarted( m_info, m_assertions ) )\n    {\n        m_timer.start();\n    }\n\n    Section::~Section() {\n        if( m_sectionIncluded ) {\n            SectionEndInfo endInfo{ m_info, m_assertions, m_timer.getElapsedSeconds() };\n            if( uncaught_exceptions() )\n                getResultCapture().sectionEndedEarly( endInfo );\n            else\n                getResultCapture().sectionEnded( endInfo );\n        }\n    }\n\n    // This indicates whether the section should be executed or not\n    Section::operator bool() const {\n        return m_sectionIncluded;\n    }\n\n} // end namespace Catch\n// end catch_section.cpp\n// start catch_section_info.cpp\n\nnamespace Catch {\n\n    SectionInfo::SectionInfo\n        (   SourceLineInfo const& _lineInfo,\n            std::string const& _name )\n    :   name( _name ),\n        lineInfo( _lineInfo )\n    {}\n\n} // end namespace Catch\n// end catch_section_info.cpp\n// start catch_session.cpp\n\n// start catch_session.h\n\n#include <memory>\n\nnamespace Catch {\n\n    class Session : NonCopyable {\n    public:\n\n        Session();\n        ~Session() override;\n\n        void showHelp() const;\n        void libIdentify();\n\n        int applyCommandLine( int argc, char const * const * argv );\n    #if defined(CATCH_CONFIG_WCHAR) && defined(WIN32) && defined(UNICODE)\n        int applyCommandLine( int argc, wchar_t const * const * argv );\n    #endif\n\n        void useConfigData( ConfigData const& configData );\n\n        template<typename CharT>\n        int run(int argc, CharT const * const argv[]) {\n            if (m_startupExceptions)\n                return 1;\n            int returnCode = applyCommandLine(argc, argv);\n            if (returnCode == 0)\n                returnCode = run();\n            return returnCode;\n        }\n\n        int run();\n\n        clara::Parser const& cli() const;\n        void cli( clara::Parser const& newParser );\n        ConfigData& configData();\n        Config& config();\n    private:\n        int runInternal();\n\n        clara::Parser m_cli;\n        ConfigData m_configData;\n        std::shared_ptr<Config> m_config;\n        bool m_startupExceptions = false;\n    };\n\n} // end namespace Catch\n\n// end catch_session.h\n// start catch_version.h\n\n#include <iosfwd>\n\nnamespace Catch {\n\n    // Versioning information\n    struct Version {\n        Version( Version const& ) = delete;\n        Version& operator=( Version const& ) = delete;\n        Version(    unsigned int _majorVersion,\n                    unsigned int _minorVersion,\n                    unsigned int _patchNumber,\n                    char const * const _branchName,\n                    unsigned int _buildNumber );\n\n        unsigned int const majorVersion;\n        unsigned int const minorVersion;\n        unsigned int const patchNumber;\n\n        // buildNumber is only used if branchName is not null\n        char const * const branchName;\n        unsigned int const buildNumber;\n\n        friend std::ostream& operator << ( std::ostream& os, Version const& version );\n    };\n\n    Version const& libraryVersion();\n}\n\n// end catch_version.h\n#include <cstdlib>\n#include <iomanip>\n\nnamespace Catch {\n\n    namespace {\n        const int MaxExitCode = 255;\n\n        IStreamingReporterPtr createReporter(std::string const& reporterName, IConfigPtr const& config) {\n            auto reporter = Catch::getRegistryHub().getReporterRegistry().create(reporterName, config);\n            CATCH_ENFORCE(reporter, \"No reporter registered with name: '\" << reporterName << \"'\");\n\n            return reporter;\n        }\n\n        IStreamingReporterPtr makeReporter(std::shared_ptr<Config> const& config) {\n            if (Catch::getRegistryHub().getReporterRegistry().getListeners().empty()) {\n                return createReporter(config->getReporterName(), config);\n            }\n\n            auto multi = std::unique_ptr<ListeningReporter>(new ListeningReporter);\n\n            auto const& listeners = Catch::getRegistryHub().getReporterRegistry().getListeners();\n            for (auto const& listener : listeners) {\n                multi->addListener(listener->create(Catch::ReporterConfig(config)));\n            }\n            multi->addReporter(createReporter(config->getReporterName(), config));\n            return std::move(multi);\n        }\n\n        Catch::Totals runTests(std::shared_ptr<Config> const& config) {\n            auto reporter = makeReporter(config);\n\n            RunContext context(config, std::move(reporter));\n\n            Totals totals;\n\n            context.testGroupStarting(config->name(), 1, 1);\n\n            TestSpec testSpec = config->testSpec();\n\n            auto const& allTestCases = getAllTestCasesSorted(*config);\n            for (auto const& testCase : allTestCases) {\n                if (!context.aborting() && matchTest(testCase, testSpec, *config))\n                    totals += context.runTest(testCase);\n                else\n                    context.reporter().skipTest(testCase);\n            }\n\n            if (config->warnAboutNoTests() && totals.testCases.total() == 0) {\n                ReusableStringStream testConfig;\n\n                bool first = true;\n                for (const auto& input : config->getTestsOrTags()) {\n                    if (!first) { testConfig << ' '; }\n                    first = false;\n                    testConfig << input;\n                }\n\n                context.reporter().noMatchingTestCases(testConfig.str());\n                totals.error = -1;\n            }\n\n            context.testGroupEnded(config->name(), totals, 1, 1);\n            return totals;\n        }\n\n        void applyFilenamesAsTags(Catch::IConfig const& config) {\n            auto& tests = const_cast<std::vector<TestCase>&>(getAllTestCasesSorted(config));\n            for (auto& testCase : tests) {\n                auto tags = testCase.tags;\n\n                std::string filename = testCase.lineInfo.file;\n                auto lastSlash = filename.find_last_of(\"\\\\/\");\n                if (lastSlash != std::string::npos) {\n                    filename.erase(0, lastSlash);\n                    filename[0] = '#';\n                }\n\n                auto lastDot = filename.find_last_of('.');\n                if (lastDot != std::string::npos) {\n                    filename.erase(lastDot);\n                }\n\n                tags.push_back(std::move(filename));\n                setTags(testCase, tags);\n            }\n        }\n\n    } // anon namespace\n\n    Session::Session() {\n        static bool alreadyInstantiated = false;\n        if( alreadyInstantiated ) {\n            CATCH_TRY { CATCH_INTERNAL_ERROR( \"Only one instance of Catch::Session can ever be used\" ); }\n            CATCH_CATCH_ALL { getMutableRegistryHub().registerStartupException(); }\n        }\n\n        // There cannot be exceptions at startup in no-exception mode.\n#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)\n        const auto& exceptions = getRegistryHub().getStartupExceptionRegistry().getExceptions();\n        if ( !exceptions.empty() ) {\n            m_startupExceptions = true;\n            Colour colourGuard( Colour::Red );\n            Catch::cerr() << \"Errors occurred during startup!\" << '\\n';\n            // iterate over all exceptions and notify user\n            for ( const auto& ex_ptr : exceptions ) {\n                try {\n                    std::rethrow_exception(ex_ptr);\n                } catch ( std::exception const& ex ) {\n                    Catch::cerr() << Column( ex.what() ).indent(2) << '\\n';\n                }\n            }\n        }\n#endif\n\n        alreadyInstantiated = true;\n        m_cli = makeCommandLineParser( m_configData );\n    }\n    Session::~Session() {\n        Catch::cleanUp();\n    }\n\n    void Session::showHelp() const {\n        Catch::cout()\n                << \"\\nCatch v\" << libraryVersion() << \"\\n\"\n                << m_cli << std::endl\n                << \"For more detailed usage please see the project docs\\n\" << std::endl;\n    }\n    void Session::libIdentify() {\n        Catch::cout()\n                << std::left << std::setw(16) << \"description: \" << \"A Catch test executable\\n\"\n                << std::left << std::setw(16) << \"category: \" << \"testframework\\n\"\n                << std::left << std::setw(16) << \"framework: \" << \"Catch Test\\n\"\n                << std::left << std::setw(16) << \"version: \" << libraryVersion() << std::endl;\n    }\n\n    int Session::applyCommandLine( int argc, char const * const * argv ) {\n        if( m_startupExceptions )\n            return 1;\n\n        auto result = m_cli.parse( clara::Args( argc, argv ) );\n        if( !result ) {\n            Catch::cerr()\n                << Colour( Colour::Red )\n                << \"\\nError(s) in input:\\n\"\n                << Column( result.errorMessage() ).indent( 2 )\n                << \"\\n\\n\";\n            Catch::cerr() << \"Run with -? for usage\\n\" << std::endl;\n            return MaxExitCode;\n        }\n\n        if( m_configData.showHelp )\n            showHelp();\n        if( m_configData.libIdentify )\n            libIdentify();\n        m_config.reset();\n        return 0;\n    }\n\n#if defined(CATCH_CONFIG_WCHAR) && defined(WIN32) && defined(UNICODE)\n    int Session::applyCommandLine( int argc, wchar_t const * const * argv ) {\n\n        char **utf8Argv = new char *[ argc ];\n\n        for ( int i = 0; i < argc; ++i ) {\n            int bufSize = WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, NULL, 0, NULL, NULL );\n\n            utf8Argv[ i ] = new char[ bufSize ];\n\n            WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, utf8Argv[i], bufSize, NULL, NULL );\n        }\n\n        int returnCode = applyCommandLine( argc, utf8Argv );\n\n        for ( int i = 0; i < argc; ++i )\n            delete [] utf8Argv[ i ];\n\n        delete [] utf8Argv;\n\n        return returnCode;\n    }\n#endif\n\n    void Session::useConfigData( ConfigData const& configData ) {\n        m_configData = configData;\n        m_config.reset();\n    }\n\n    int Session::run() {\n        if( ( m_configData.waitForKeypress & WaitForKeypress::BeforeStart ) != 0 ) {\n            Catch::cout() << \"...waiting for enter/ return before starting\" << std::endl;\n            static_cast<void>(std::getchar());\n        }\n        int exitCode = runInternal();\n        if( ( m_configData.waitForKeypress & WaitForKeypress::BeforeExit ) != 0 ) {\n            Catch::cout() << \"...waiting for enter/ return before exiting, with code: \" << exitCode << std::endl;\n            static_cast<void>(std::getchar());\n        }\n        return exitCode;\n    }\n\n    clara::Parser const& Session::cli() const {\n        return m_cli;\n    }\n    void Session::cli( clara::Parser const& newParser ) {\n        m_cli = newParser;\n    }\n    ConfigData& Session::configData() {\n        return m_configData;\n    }\n    Config& Session::config() {\n        if( !m_config )\n            m_config = std::make_shared<Config>( m_configData );\n        return *m_config;\n    }\n\n    int Session::runInternal() {\n        if( m_startupExceptions )\n            return 1;\n\n        if (m_configData.showHelp || m_configData.libIdentify) {\n            return 0;\n        }\n\n        CATCH_TRY {\n            config(); // Force config to be constructed\n\n            seedRng( *m_config );\n\n            if( m_configData.filenamesAsTags )\n                applyFilenamesAsTags( *m_config );\n\n            // Handle list request\n            if( Option<std::size_t> listed = list( config() ) )\n                return static_cast<int>( *listed );\n\n            auto totals = runTests( m_config );\n            // Note that on unices only the lower 8 bits are usually used, clamping\n            // the return value to 255 prevents false negative when some multiple\n            // of 256 tests has failed\n            return (std::min) (MaxExitCode, (std::max) (totals.error, static_cast<int>(totals.assertions.failed)));\n        }\n#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)\n        catch( std::exception& ex ) {\n            Catch::cerr() << ex.what() << std::endl;\n            return MaxExitCode;\n        }\n#endif\n    }\n\n} // end namespace Catch\n// end catch_session.cpp\n// start catch_singletons.cpp\n\n#include <vector>\n\nnamespace Catch {\n\n    namespace {\n        static auto getSingletons() -> std::vector<ISingleton*>*& {\n            static std::vector<ISingleton*>* g_singletons = nullptr;\n            if( !g_singletons )\n                g_singletons = new std::vector<ISingleton*>();\n            return g_singletons;\n        }\n    }\n\n    ISingleton::~ISingleton() {}\n\n    void addSingleton(ISingleton* singleton ) {\n        getSingletons()->push_back( singleton );\n    }\n    void cleanupSingletons() {\n        auto& singletons = getSingletons();\n        for( auto singleton : *singletons )\n            delete singleton;\n        delete singletons;\n        singletons = nullptr;\n    }\n\n} // namespace Catch\n// end catch_singletons.cpp\n// start catch_startup_exception_registry.cpp\n\nnamespace Catch {\nvoid StartupExceptionRegistry::add( std::exception_ptr const& exception ) noexcept {\n        CATCH_TRY {\n            m_exceptions.push_back(exception);\n        } CATCH_CATCH_ALL {\n            // If we run out of memory during start-up there's really not a lot more we can do about it\n            std::terminate();\n        }\n    }\n\n    std::vector<std::exception_ptr> const& StartupExceptionRegistry::getExceptions() const noexcept {\n        return m_exceptions;\n    }\n\n} // end namespace Catch\n// end catch_startup_exception_registry.cpp\n// start catch_stream.cpp\n\n#include <cstdio>\n#include <iostream>\n#include <fstream>\n#include <sstream>\n#include <vector>\n#include <memory>\n\nnamespace Catch {\n\n    Catch::IStream::~IStream() = default;\n\n    namespace detail { namespace {\n        template<typename WriterF, std::size_t bufferSize=256>\n        class StreamBufImpl : public std::streambuf {\n            char data[bufferSize];\n            WriterF m_writer;\n\n        public:\n            StreamBufImpl() {\n                setp( data, data + sizeof(data) );\n            }\n\n            ~StreamBufImpl() noexcept {\n                StreamBufImpl::sync();\n            }\n\n        private:\n            int overflow( int c ) override {\n                sync();\n\n                if( c != EOF ) {\n                    if( pbase() == epptr() )\n                        m_writer( std::string( 1, static_cast<char>( c ) ) );\n                    else\n                        sputc( static_cast<char>( c ) );\n                }\n                return 0;\n            }\n\n            int sync() override {\n                if( pbase() != pptr() ) {\n                    m_writer( std::string( pbase(), static_cast<std::string::size_type>( pptr() - pbase() ) ) );\n                    setp( pbase(), epptr() );\n                }\n                return 0;\n            }\n        };\n\n        ///////////////////////////////////////////////////////////////////////////\n\n        struct OutputDebugWriter {\n\n            void operator()( std::string const&str ) {\n                writeToDebugConsole( str );\n            }\n        };\n\n        ///////////////////////////////////////////////////////////////////////////\n\n        class FileStream : public IStream {\n            mutable std::ofstream m_ofs;\n        public:\n            FileStream( StringRef filename ) {\n                m_ofs.open( filename.c_str() );\n                CATCH_ENFORCE( !m_ofs.fail(), \"Unable to open file: '\" << filename << \"'\" );\n            }\n            ~FileStream() override = default;\n        public: // IStream\n            std::ostream& stream() const override {\n                return m_ofs;\n            }\n        };\n\n        ///////////////////////////////////////////////////////////////////////////\n\n        class CoutStream : public IStream {\n            mutable std::ostream m_os;\n        public:\n            // Store the streambuf from cout up-front because\n            // cout may get redirected when running tests\n            CoutStream() : m_os( Catch::cout().rdbuf() ) {}\n            ~CoutStream() override = default;\n\n        public: // IStream\n            std::ostream& stream() const override { return m_os; }\n        };\n\n        ///////////////////////////////////////////////////////////////////////////\n\n        class DebugOutStream : public IStream {\n            std::unique_ptr<StreamBufImpl<OutputDebugWriter>> m_streamBuf;\n            mutable std::ostream m_os;\n        public:\n            DebugOutStream()\n            :   m_streamBuf( new StreamBufImpl<OutputDebugWriter>() ),\n                m_os( m_streamBuf.get() )\n            {}\n\n            ~DebugOutStream() override = default;\n\n        public: // IStream\n            std::ostream& stream() const override { return m_os; }\n        };\n\n    }} // namespace anon::detail\n\n    ///////////////////////////////////////////////////////////////////////////\n\n    auto makeStream( StringRef const &filename ) -> IStream const* {\n        if( filename.empty() )\n            return new detail::CoutStream();\n        else if( filename[0] == '%' ) {\n            if( filename == \"%debug\" )\n                return new detail::DebugOutStream();\n            else\n                CATCH_ERROR( \"Unrecognised stream: '\" << filename << \"'\" );\n        }\n        else\n            return new detail::FileStream( filename );\n    }\n\n    // This class encapsulates the idea of a pool of ostringstreams that can be reused.\n    struct StringStreams {\n        std::vector<std::unique_ptr<std::ostringstream>> m_streams;\n        std::vector<std::size_t> m_unused;\n        std::ostringstream m_referenceStream; // Used for copy state/ flags from\n\n        auto add() -> std::size_t {\n            if( m_unused.empty() ) {\n                m_streams.push_back( std::unique_ptr<std::ostringstream>( new std::ostringstream ) );\n                return m_streams.size()-1;\n            }\n            else {\n                auto index = m_unused.back();\n                m_unused.pop_back();\n                return index;\n            }\n        }\n\n        void release( std::size_t index ) {\n            m_streams[index]->copyfmt( m_referenceStream ); // Restore initial flags and other state\n            m_unused.push_back(index);\n        }\n    };\n\n    ReusableStringStream::ReusableStringStream()\n    :   m_index( Singleton<StringStreams>::getMutable().add() ),\n        m_oss( Singleton<StringStreams>::getMutable().m_streams[m_index].get() )\n    {}\n\n    ReusableStringStream::~ReusableStringStream() {\n        static_cast<std::ostringstream*>( m_oss )->str(\"\");\n        m_oss->clear();\n        Singleton<StringStreams>::getMutable().release( m_index );\n    }\n\n    auto ReusableStringStream::str() const -> std::string {\n        return static_cast<std::ostringstream*>( m_oss )->str();\n    }\n\n    ///////////////////////////////////////////////////////////////////////////\n\n#ifndef CATCH_CONFIG_NOSTDOUT // If you #define this you must implement these functions\n    std::ostream& cout() { return std::cout; }\n    std::ostream& cerr() { return std::cerr; }\n    std::ostream& clog() { return std::clog; }\n#endif\n}\n// end catch_stream.cpp\n// start catch_string_manip.cpp\n\n#include <algorithm>\n#include <ostream>\n#include <cstring>\n#include <cctype>\n\nnamespace Catch {\n\n    namespace {\n        char toLowerCh(char c) {\n            return static_cast<char>( std::tolower( c ) );\n        }\n    }\n\n    bool startsWith( std::string const& s, std::string const& prefix ) {\n        return s.size() >= prefix.size() && std::equal(prefix.begin(), prefix.end(), s.begin());\n    }\n    bool startsWith( std::string const& s, char prefix ) {\n        return !s.empty() && s[0] == prefix;\n    }\n    bool endsWith( std::string const& s, std::string const& suffix ) {\n        return s.size() >= suffix.size() && std::equal(suffix.rbegin(), suffix.rend(), s.rbegin());\n    }\n    bool endsWith( std::string const& s, char suffix ) {\n        return !s.empty() && s[s.size()-1] == suffix;\n    }\n    bool contains( std::string const& s, std::string const& infix ) {\n        return s.find( infix ) != std::string::npos;\n    }\n    void toLowerInPlace( std::string& s ) {\n        std::transform( s.begin(), s.end(), s.begin(), toLowerCh );\n    }\n    std::string toLower( std::string const& s ) {\n        std::string lc = s;\n        toLowerInPlace( lc );\n        return lc;\n    }\n    std::string trim( std::string const& str ) {\n        static char const* whitespaceChars = \"\\n\\r\\t \";\n        std::string::size_type start = str.find_first_not_of( whitespaceChars );\n        std::string::size_type end = str.find_last_not_of( whitespaceChars );\n\n        return start != std::string::npos ? str.substr( start, 1+end-start ) : std::string();\n    }\n\n    bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ) {\n        bool replaced = false;\n        std::size_t i = str.find( replaceThis );\n        while( i != std::string::npos ) {\n            replaced = true;\n            str = str.substr( 0, i ) + withThis + str.substr( i+replaceThis.size() );\n            if( i < str.size()-withThis.size() )\n                i = str.find( replaceThis, i+withThis.size() );\n            else\n                i = std::string::npos;\n        }\n        return replaced;\n    }\n\n    pluralise::pluralise( std::size_t count, std::string const& label )\n    :   m_count( count ),\n        m_label( label )\n    {}\n\n    std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ) {\n        os << pluraliser.m_count << ' ' << pluraliser.m_label;\n        if( pluraliser.m_count != 1 )\n            os << 's';\n        return os;\n    }\n\n}\n// end catch_string_manip.cpp\n// start catch_stringref.cpp\n\n#if defined(__clang__)\n#    pragma clang diagnostic push\n#    pragma clang diagnostic ignored \"-Wexit-time-destructors\"\n#endif\n\n#include <ostream>\n#include <cstring>\n#include <cstdint>\n\nnamespace {\n    const uint32_t byte_2_lead = 0xC0;\n    const uint32_t byte_3_lead = 0xE0;\n    const uint32_t byte_4_lead = 0xF0;\n}\n\nnamespace Catch {\n    StringRef::StringRef( char const* rawChars ) noexcept\n    : StringRef( rawChars, static_cast<StringRef::size_type>(std::strlen(rawChars) ) )\n    {}\n\n    StringRef::operator std::string() const {\n        return std::string( m_start, m_size );\n    }\n\n    void StringRef::swap( StringRef& other ) noexcept {\n        std::swap( m_start, other.m_start );\n        std::swap( m_size, other.m_size );\n        std::swap( m_data, other.m_data );\n    }\n\n    auto StringRef::c_str() const -> char const* {\n        if( isSubstring() )\n           const_cast<StringRef*>( this )->takeOwnership();\n        return m_start;\n    }\n    auto StringRef::currentData() const noexcept -> char const* {\n        return m_start;\n    }\n\n    auto StringRef::isOwned() const noexcept -> bool {\n        return m_data != nullptr;\n    }\n    auto StringRef::isSubstring() const noexcept -> bool {\n        return m_start[m_size] != '\\0';\n    }\n\n    void StringRef::takeOwnership() {\n        if( !isOwned() ) {\n            m_data = new char[m_size+1];\n            memcpy( m_data, m_start, m_size );\n            m_data[m_size] = '\\0';\n            m_start = m_data;\n        }\n    }\n    auto StringRef::substr( size_type start, size_type size ) const noexcept -> StringRef {\n        if( start < m_size )\n            return StringRef( m_start+start, size );\n        else\n            return StringRef();\n    }\n    auto StringRef::operator == ( StringRef const& other ) const noexcept -> bool {\n        return\n            size() == other.size() &&\n            (std::strncmp( m_start, other.m_start, size() ) == 0);\n    }\n    auto StringRef::operator != ( StringRef const& other ) const noexcept -> bool {\n        return !operator==( other );\n    }\n\n    auto StringRef::operator[](size_type index) const noexcept -> char {\n        return m_start[index];\n    }\n\n    auto StringRef::numberOfCharacters() const noexcept -> size_type {\n        size_type noChars = m_size;\n        // Make adjustments for uft encodings\n        for( size_type i=0; i < m_size; ++i ) {\n            char c = m_start[i];\n            if( ( c & byte_2_lead ) == byte_2_lead ) {\n                noChars--;\n                if (( c & byte_3_lead ) == byte_3_lead )\n                    noChars--;\n                if( ( c & byte_4_lead ) == byte_4_lead )\n                    noChars--;\n            }\n        }\n        return noChars;\n    }\n\n    auto operator + ( StringRef const& lhs, StringRef const& rhs ) -> std::string {\n        std::string str;\n        str.reserve( lhs.size() + rhs.size() );\n        str += lhs;\n        str += rhs;\n        return str;\n    }\n    auto operator + ( StringRef const& lhs, const char* rhs ) -> std::string {\n        return std::string( lhs ) + std::string( rhs );\n    }\n    auto operator + ( char const* lhs, StringRef const& rhs ) -> std::string {\n        return std::string( lhs ) + std::string( rhs );\n    }\n\n    auto operator << ( std::ostream& os, StringRef const& str ) -> std::ostream& {\n        return os.write(str.currentData(), str.size());\n    }\n\n    auto operator+=( std::string& lhs, StringRef const& rhs ) -> std::string& {\n        lhs.append(rhs.currentData(), rhs.size());\n        return lhs;\n    }\n\n} // namespace Catch\n\n#if defined(__clang__)\n#    pragma clang diagnostic pop\n#endif\n// end catch_stringref.cpp\n// start catch_tag_alias.cpp\n\nnamespace Catch {\n    TagAlias::TagAlias(std::string const & _tag, SourceLineInfo _lineInfo): tag(_tag), lineInfo(_lineInfo) {}\n}\n// end catch_tag_alias.cpp\n// start catch_tag_alias_autoregistrar.cpp\n\nnamespace Catch {\n\n    RegistrarForTagAliases::RegistrarForTagAliases(char const* alias, char const* tag, SourceLineInfo const& lineInfo) {\n        CATCH_TRY {\n            getMutableRegistryHub().registerTagAlias(alias, tag, lineInfo);\n        } CATCH_CATCH_ALL {\n            // Do not throw when constructing global objects, instead register the exception to be processed later\n            getMutableRegistryHub().registerStartupException();\n        }\n    }\n\n}\n// end catch_tag_alias_autoregistrar.cpp\n// start catch_tag_alias_registry.cpp\n\n#include <sstream>\n\nnamespace Catch {\n\n    TagAliasRegistry::~TagAliasRegistry() {}\n\n    TagAlias const* TagAliasRegistry::find( std::string const& alias ) const {\n        auto it = m_registry.find( alias );\n        if( it != m_registry.end() )\n            return &(it->second);\n        else\n            return nullptr;\n    }\n\n    std::string TagAliasRegistry::expandAliases( std::string const& unexpandedTestSpec ) const {\n        std::string expandedTestSpec = unexpandedTestSpec;\n        for( auto const& registryKvp : m_registry ) {\n            std::size_t pos = expandedTestSpec.find( registryKvp.first );\n            if( pos != std::string::npos ) {\n                expandedTestSpec =  expandedTestSpec.substr( 0, pos ) +\n                                    registryKvp.second.tag +\n                                    expandedTestSpec.substr( pos + registryKvp.first.size() );\n            }\n        }\n        return expandedTestSpec;\n    }\n\n    void TagAliasRegistry::add( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) {\n        CATCH_ENFORCE( startsWith(alias, \"[@\") && endsWith(alias, ']'),\n                      \"error: tag alias, '\" << alias << \"' is not of the form [@alias name].\\n\" << lineInfo );\n\n        CATCH_ENFORCE( m_registry.insert(std::make_pair(alias, TagAlias(tag, lineInfo))).second,\n                      \"error: tag alias, '\" << alias << \"' already registered.\\n\"\n                      << \"\\tFirst seen at: \" << find(alias)->lineInfo << \"\\n\"\n                      << \"\\tRedefined at: \" << lineInfo );\n    }\n\n    ITagAliasRegistry::~ITagAliasRegistry() {}\n\n    ITagAliasRegistry const& ITagAliasRegistry::get() {\n        return getRegistryHub().getTagAliasRegistry();\n    }\n\n} // end namespace Catch\n// end catch_tag_alias_registry.cpp\n// start catch_test_case_info.cpp\n\n#include <cctype>\n#include <exception>\n#include <algorithm>\n#include <sstream>\n\nnamespace Catch {\n\n    namespace {\n        TestCaseInfo::SpecialProperties parseSpecialTag( std::string const& tag ) {\n            if( startsWith( tag, '.' ) ||\n                tag == \"!hide\" )\n                return TestCaseInfo::IsHidden;\n            else if( tag == \"!throws\" )\n                return TestCaseInfo::Throws;\n            else if( tag == \"!shouldfail\" )\n                return TestCaseInfo::ShouldFail;\n            else if( tag == \"!mayfail\" )\n                return TestCaseInfo::MayFail;\n            else if( tag == \"!nonportable\" )\n                return TestCaseInfo::NonPortable;\n            else if( tag == \"!benchmark\" )\n                return static_cast<TestCaseInfo::SpecialProperties>( TestCaseInfo::Benchmark | TestCaseInfo::IsHidden );\n            else\n                return TestCaseInfo::None;\n        }\n        bool isReservedTag( std::string const& tag ) {\n            return parseSpecialTag( tag ) == TestCaseInfo::None && tag.size() > 0 && !std::isalnum( static_cast<unsigned char>(tag[0]) );\n        }\n        void enforceNotReservedTag( std::string const& tag, SourceLineInfo const& _lineInfo ) {\n            CATCH_ENFORCE( !isReservedTag(tag),\n                          \"Tag name: [\" << tag << \"] is not allowed.\\n\"\n                          << \"Tag names starting with non alpha-numeric characters are reserved\\n\"\n                          << _lineInfo );\n        }\n    }\n\n    TestCase makeTestCase(  ITestInvoker* _testCase,\n                            std::string const& _className,\n                            NameAndTags const& nameAndTags,\n                            SourceLineInfo const& _lineInfo )\n    {\n        bool isHidden = false;\n\n        // Parse out tags\n        std::vector<std::string> tags;\n        std::string desc, tag;\n        bool inTag = false;\n        std::string _descOrTags = nameAndTags.tags;\n        for (char c : _descOrTags) {\n            if( !inTag ) {\n                if( c == '[' )\n                    inTag = true;\n                else\n                    desc += c;\n            }\n            else {\n                if( c == ']' ) {\n                    TestCaseInfo::SpecialProperties prop = parseSpecialTag( tag );\n                    if( ( prop & TestCaseInfo::IsHidden ) != 0 )\n                        isHidden = true;\n                    else if( prop == TestCaseInfo::None )\n                        enforceNotReservedTag( tag, _lineInfo );\n\n                    tags.push_back( tag );\n                    tag.clear();\n                    inTag = false;\n                }\n                else\n                    tag += c;\n            }\n        }\n        if( isHidden ) {\n            tags.push_back( \".\" );\n        }\n\n        TestCaseInfo info( nameAndTags.name, _className, desc, tags, _lineInfo );\n        return TestCase( _testCase, std::move(info) );\n    }\n\n    void setTags( TestCaseInfo& testCaseInfo, std::vector<std::string> tags ) {\n        std::sort(begin(tags), end(tags));\n        tags.erase(std::unique(begin(tags), end(tags)), end(tags));\n        testCaseInfo.lcaseTags.clear();\n\n        for( auto const& tag : tags ) {\n            std::string lcaseTag = toLower( tag );\n            testCaseInfo.properties = static_cast<TestCaseInfo::SpecialProperties>( testCaseInfo.properties | parseSpecialTag( lcaseTag ) );\n            testCaseInfo.lcaseTags.push_back( lcaseTag );\n        }\n        testCaseInfo.tags = std::move(tags);\n    }\n\n    TestCaseInfo::TestCaseInfo( std::string const& _name,\n                                std::string const& _className,\n                                std::string const& _description,\n                                std::vector<std::string> const& _tags,\n                                SourceLineInfo const& _lineInfo )\n    :   name( _name ),\n        className( _className ),\n        description( _description ),\n        lineInfo( _lineInfo ),\n        properties( None )\n    {\n        setTags( *this, _tags );\n    }\n\n    bool TestCaseInfo::isHidden() const {\n        return ( properties & IsHidden ) != 0;\n    }\n    bool TestCaseInfo::throws() const {\n        return ( properties & Throws ) != 0;\n    }\n    bool TestCaseInfo::okToFail() const {\n        return ( properties & (ShouldFail | MayFail ) ) != 0;\n    }\n    bool TestCaseInfo::expectedToFail() const {\n        return ( properties & (ShouldFail ) ) != 0;\n    }\n\n    std::string TestCaseInfo::tagsAsString() const {\n        std::string ret;\n        // '[' and ']' per tag\n        std::size_t full_size = 2 * tags.size();\n        for (const auto& tag : tags) {\n            full_size += tag.size();\n        }\n        ret.reserve(full_size);\n        for (const auto& tag : tags) {\n            ret.push_back('[');\n            ret.append(tag);\n            ret.push_back(']');\n        }\n\n        return ret;\n    }\n\n    TestCase::TestCase( ITestInvoker* testCase, TestCaseInfo&& info ) : TestCaseInfo( std::move(info) ), test( testCase ) {}\n\n    TestCase TestCase::withName( std::string const& _newName ) const {\n        TestCase other( *this );\n        other.name = _newName;\n        return other;\n    }\n\n    void TestCase::invoke() const {\n        test->invoke();\n    }\n\n    bool TestCase::operator == ( TestCase const& other ) const {\n        return  test.get() == other.test.get() &&\n                name == other.name &&\n                className == other.className;\n    }\n\n    bool TestCase::operator < ( TestCase const& other ) const {\n        return name < other.name;\n    }\n\n    TestCaseInfo const& TestCase::getTestCaseInfo() const\n    {\n        return *this;\n    }\n\n} // end namespace Catch\n// end catch_test_case_info.cpp\n// start catch_test_case_registry_impl.cpp\n\n#include <sstream>\n\nnamespace Catch {\n\n    std::vector<TestCase> sortTests( IConfig const& config, std::vector<TestCase> const& unsortedTestCases ) {\n\n        std::vector<TestCase> sorted = unsortedTestCases;\n\n        switch( config.runOrder() ) {\n            case RunTests::InLexicographicalOrder:\n                std::sort( sorted.begin(), sorted.end() );\n                break;\n            case RunTests::InRandomOrder:\n                seedRng( config );\n                std::shuffle( sorted.begin(), sorted.end(), rng() );\n                break;\n            case RunTests::InDeclarationOrder:\n                // already in declaration order\n                break;\n        }\n        return sorted;\n    }\n    bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ) {\n        return testSpec.matches( testCase ) && ( config.allowThrows() || !testCase.throws() );\n    }\n\n    void enforceNoDuplicateTestCases( std::vector<TestCase> const& functions ) {\n        std::set<TestCase> seenFunctions;\n        for( auto const& function : functions ) {\n            auto prev = seenFunctions.insert( function );\n            CATCH_ENFORCE( prev.second,\n                    \"error: TEST_CASE( \\\"\" << function.name << \"\\\" ) already defined.\\n\"\n                    << \"\\tFirst seen at \" << prev.first->getTestCaseInfo().lineInfo << \"\\n\"\n                    << \"\\tRedefined at \" << function.getTestCaseInfo().lineInfo );\n        }\n    }\n\n    std::vector<TestCase> filterTests( std::vector<TestCase> const& testCases, TestSpec const& testSpec, IConfig const& config ) {\n        std::vector<TestCase> filtered;\n        filtered.reserve( testCases.size() );\n        for( auto const& testCase : testCases )\n            if( matchTest( testCase, testSpec, config ) )\n                filtered.push_back( testCase );\n        return filtered;\n    }\n    std::vector<TestCase> const& getAllTestCasesSorted( IConfig const& config ) {\n        return getRegistryHub().getTestCaseRegistry().getAllTestsSorted( config );\n    }\n\n    void TestRegistry::registerTest( TestCase const& testCase ) {\n        std::string name = testCase.getTestCaseInfo().name;\n        if( name.empty() ) {\n            ReusableStringStream rss;\n            rss << \"Anonymous test case \" << ++m_unnamedCount;\n            return registerTest( testCase.withName( rss.str() ) );\n        }\n        m_functions.push_back( testCase );\n    }\n\n    std::vector<TestCase> const& TestRegistry::getAllTests() const {\n        return m_functions;\n    }\n    std::vector<TestCase> const& TestRegistry::getAllTestsSorted( IConfig const& config ) const {\n        if( m_sortedFunctions.empty() )\n            enforceNoDuplicateTestCases( m_functions );\n\n        if(  m_currentSortOrder != config.runOrder() || m_sortedFunctions.empty() ) {\n            m_sortedFunctions = sortTests( config, m_functions );\n            m_currentSortOrder = config.runOrder();\n        }\n        return m_sortedFunctions;\n    }\n\n    ///////////////////////////////////////////////////////////////////////////\n    TestInvokerAsFunction::TestInvokerAsFunction( void(*testAsFunction)() ) noexcept : m_testAsFunction( testAsFunction ) {}\n\n    void TestInvokerAsFunction::invoke() const {\n        m_testAsFunction();\n    }\n\n    std::string extractClassName( StringRef const& classOrQualifiedMethodName ) {\n        std::string className = classOrQualifiedMethodName;\n        if( startsWith( className, '&' ) )\n        {\n            std::size_t lastColons = className.rfind( \"::\" );\n            std::size_t penultimateColons = className.rfind( \"::\", lastColons-1 );\n            if( penultimateColons == std::string::npos )\n                penultimateColons = 1;\n            className = className.substr( penultimateColons, lastColons-penultimateColons );\n        }\n        return className;\n    }\n\n} // end namespace Catch\n// end catch_test_case_registry_impl.cpp\n// start catch_test_case_tracker.cpp\n\n#include <algorithm>\n#include <cassert>\n#include <stdexcept>\n#include <memory>\n#include <sstream>\n\n#if defined(__clang__)\n#    pragma clang diagnostic push\n#    pragma clang diagnostic ignored \"-Wexit-time-destructors\"\n#endif\n\nnamespace Catch {\nnamespace TestCaseTracking {\n\n    NameAndLocation::NameAndLocation( std::string const& _name, SourceLineInfo const& _location )\n    :   name( _name ),\n        location( _location )\n    {}\n\n    ITracker::~ITracker() = default;\n\n    TrackerContext& TrackerContext::instance() {\n        static TrackerContext s_instance;\n        return s_instance;\n    }\n\n    ITracker& TrackerContext::startRun() {\n        m_rootTracker = std::make_shared<SectionTracker>( NameAndLocation( \"{root}\", CATCH_INTERNAL_LINEINFO ), *this, nullptr );\n        m_currentTracker = nullptr;\n        m_runState = Executing;\n        return *m_rootTracker;\n    }\n\n    void TrackerContext::endRun() {\n        m_rootTracker.reset();\n        m_currentTracker = nullptr;\n        m_runState = NotStarted;\n    }\n\n    void TrackerContext::startCycle() {\n        m_currentTracker = m_rootTracker.get();\n        m_runState = Executing;\n    }\n    void TrackerContext::completeCycle() {\n        m_runState = CompletedCycle;\n    }\n\n    bool TrackerContext::completedCycle() const {\n        return m_runState == CompletedCycle;\n    }\n    ITracker& TrackerContext::currentTracker() {\n        return *m_currentTracker;\n    }\n    void TrackerContext::setCurrentTracker( ITracker* tracker ) {\n        m_currentTracker = tracker;\n    }\n\n    TrackerBase::TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent )\n    :   m_nameAndLocation( nameAndLocation ),\n        m_ctx( ctx ),\n        m_parent( parent )\n    {}\n\n    NameAndLocation const& TrackerBase::nameAndLocation() const {\n        return m_nameAndLocation;\n    }\n    bool TrackerBase::isComplete() const {\n        return m_runState == CompletedSuccessfully || m_runState == Failed;\n    }\n    bool TrackerBase::isSuccessfullyCompleted() const {\n        return m_runState == CompletedSuccessfully;\n    }\n    bool TrackerBase::isOpen() const {\n        return m_runState != NotStarted && !isComplete();\n    }\n    bool TrackerBase::hasChildren() const {\n        return !m_children.empty();\n    }\n\n    void TrackerBase::addChild( ITrackerPtr const& child ) {\n        m_children.push_back( child );\n    }\n\n    ITrackerPtr TrackerBase::findChild( NameAndLocation const& nameAndLocation ) {\n        auto it = std::find_if( m_children.begin(), m_children.end(),\n            [&nameAndLocation]( ITrackerPtr const& tracker ){\n                return\n                    tracker->nameAndLocation().location == nameAndLocation.location &&\n                    tracker->nameAndLocation().name == nameAndLocation.name;\n            } );\n        return( it != m_children.end() )\n            ? *it\n            : nullptr;\n    }\n    ITracker& TrackerBase::parent() {\n        assert( m_parent ); // Should always be non-null except for root\n        return *m_parent;\n    }\n\n    void TrackerBase::openChild() {\n        if( m_runState != ExecutingChildren ) {\n            m_runState = ExecutingChildren;\n            if( m_parent )\n                m_parent->openChild();\n        }\n    }\n\n    bool TrackerBase::isSectionTracker() const { return false; }\n    bool TrackerBase::isIndexTracker() const { return false; }\n\n    void TrackerBase::open() {\n        m_runState = Executing;\n        moveToThis();\n        if( m_parent )\n            m_parent->openChild();\n    }\n\n    void TrackerBase::close() {\n\n        // Close any still open children (e.g. generators)\n        while( &m_ctx.currentTracker() != this )\n            m_ctx.currentTracker().close();\n\n        switch( m_runState ) {\n            case NeedsAnotherRun:\n                break;\n\n            case Executing:\n                m_runState = CompletedSuccessfully;\n                break;\n            case ExecutingChildren:\n                if( m_children.empty() || m_children.back()->isComplete() )\n                    m_runState = CompletedSuccessfully;\n                break;\n\n            case NotStarted:\n            case CompletedSuccessfully:\n            case Failed:\n                CATCH_INTERNAL_ERROR( \"Illogical state: \" << m_runState );\n\n            default:\n                CATCH_INTERNAL_ERROR( \"Unknown state: \" << m_runState );\n        }\n        moveToParent();\n        m_ctx.completeCycle();\n    }\n    void TrackerBase::fail() {\n        m_runState = Failed;\n        if( m_parent )\n            m_parent->markAsNeedingAnotherRun();\n        moveToParent();\n        m_ctx.completeCycle();\n    }\n    void TrackerBase::markAsNeedingAnotherRun() {\n        m_runState = NeedsAnotherRun;\n    }\n\n    void TrackerBase::moveToParent() {\n        assert( m_parent );\n        m_ctx.setCurrentTracker( m_parent );\n    }\n    void TrackerBase::moveToThis() {\n        m_ctx.setCurrentTracker( this );\n    }\n\n    SectionTracker::SectionTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent )\n    :   TrackerBase( nameAndLocation, ctx, parent )\n    {\n        if( parent ) {\n            while( !parent->isSectionTracker() )\n                parent = &parent->parent();\n\n            SectionTracker& parentSection = static_cast<SectionTracker&>( *parent );\n            addNextFilters( parentSection.m_filters );\n        }\n    }\n\n    bool SectionTracker::isSectionTracker() const { return true; }\n\n    SectionTracker& SectionTracker::acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation ) {\n        std::shared_ptr<SectionTracker> section;\n\n        ITracker& currentTracker = ctx.currentTracker();\n        if( ITrackerPtr childTracker = currentTracker.findChild( nameAndLocation ) ) {\n            assert( childTracker );\n            assert( childTracker->isSectionTracker() );\n            section = std::static_pointer_cast<SectionTracker>( childTracker );\n        }\n        else {\n            section = std::make_shared<SectionTracker>( nameAndLocation, ctx, &currentTracker );\n            currentTracker.addChild( section );\n        }\n        if( !ctx.completedCycle() )\n            section->tryOpen();\n        return *section;\n    }\n\n    void SectionTracker::tryOpen() {\n        if( !isComplete() && (m_filters.empty() || m_filters[0].empty() ||  m_filters[0] == m_nameAndLocation.name ) )\n            open();\n    }\n\n    void SectionTracker::addInitialFilters( std::vector<std::string> const& filters ) {\n        if( !filters.empty() ) {\n            m_filters.push_back(\"\"); // Root - should never be consulted\n            m_filters.push_back(\"\"); // Test Case - not a section filter\n            m_filters.insert( m_filters.end(), filters.begin(), filters.end() );\n        }\n    }\n    void SectionTracker::addNextFilters( std::vector<std::string> const& filters ) {\n        if( filters.size() > 1 )\n            m_filters.insert( m_filters.end(), ++filters.begin(), filters.end() );\n    }\n\n    IndexTracker::IndexTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent, int size )\n    :   TrackerBase( nameAndLocation, ctx, parent ),\n        m_size( size )\n    {}\n\n    bool IndexTracker::isIndexTracker() const { return true; }\n\n    IndexTracker& IndexTracker::acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation, int size ) {\n        std::shared_ptr<IndexTracker> tracker;\n\n        ITracker& currentTracker = ctx.currentTracker();\n        if( ITrackerPtr childTracker = currentTracker.findChild( nameAndLocation ) ) {\n            assert( childTracker );\n            assert( childTracker->isIndexTracker() );\n            tracker = std::static_pointer_cast<IndexTracker>( childTracker );\n        }\n        else {\n            tracker = std::make_shared<IndexTracker>( nameAndLocation, ctx, &currentTracker, size );\n            currentTracker.addChild( tracker );\n        }\n\n        if( !ctx.completedCycle() && !tracker->isComplete() ) {\n            if( tracker->m_runState != ExecutingChildren && tracker->m_runState != NeedsAnotherRun )\n                tracker->moveNext();\n            tracker->open();\n        }\n\n        return *tracker;\n    }\n\n    int IndexTracker::index() const { return m_index; }\n\n    void IndexTracker::moveNext() {\n        m_index++;\n        m_children.clear();\n    }\n\n    void IndexTracker::close() {\n        TrackerBase::close();\n        if( m_runState == CompletedSuccessfully && m_index < m_size-1 )\n            m_runState = Executing;\n    }\n\n} // namespace TestCaseTracking\n\nusing TestCaseTracking::ITracker;\nusing TestCaseTracking::TrackerContext;\nusing TestCaseTracking::SectionTracker;\nusing TestCaseTracking::IndexTracker;\n\n} // namespace Catch\n\n#if defined(__clang__)\n#    pragma clang diagnostic pop\n#endif\n// end catch_test_case_tracker.cpp\n// start catch_test_registry.cpp\n\nnamespace Catch {\n\n    auto makeTestInvoker( void(*testAsFunction)() ) noexcept -> ITestInvoker* {\n        return new(std::nothrow) TestInvokerAsFunction( testAsFunction );\n    }\n\n    NameAndTags::NameAndTags( StringRef const& name_ , StringRef const& tags_ ) noexcept : name( name_ ), tags( tags_ ) {}\n\n    AutoReg::AutoReg( ITestInvoker* invoker, SourceLineInfo const& lineInfo, StringRef const& classOrMethod, NameAndTags const& nameAndTags ) noexcept {\n        CATCH_TRY {\n            getMutableRegistryHub()\n                    .registerTest(\n                        makeTestCase(\n                            invoker,\n                            extractClassName( classOrMethod ),\n                            nameAndTags,\n                            lineInfo));\n        } CATCH_CATCH_ALL {\n            // Do not throw when constructing global objects, instead register the exception to be processed later\n            getMutableRegistryHub().registerStartupException();\n        }\n    }\n\n    AutoReg::~AutoReg() = default;\n}\n// end catch_test_registry.cpp\n// start catch_test_spec.cpp\n\n#include <algorithm>\n#include <string>\n#include <vector>\n#include <memory>\n\nnamespace Catch {\n\n    TestSpec::Pattern::~Pattern() = default;\n    TestSpec::NamePattern::~NamePattern() = default;\n    TestSpec::TagPattern::~TagPattern() = default;\n    TestSpec::ExcludedPattern::~ExcludedPattern() = default;\n\n    TestSpec::NamePattern::NamePattern( std::string const& name )\n    : m_wildcardPattern( toLower( name ), CaseSensitive::No )\n    {}\n    bool TestSpec::NamePattern::matches( TestCaseInfo const& testCase ) const {\n        return m_wildcardPattern.matches( toLower( testCase.name ) );\n    }\n\n    TestSpec::TagPattern::TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {}\n    bool TestSpec::TagPattern::matches( TestCaseInfo const& testCase ) const {\n        return std::find(begin(testCase.lcaseTags),\n                         end(testCase.lcaseTags),\n                         m_tag) != end(testCase.lcaseTags);\n    }\n\n    TestSpec::ExcludedPattern::ExcludedPattern( PatternPtr const& underlyingPattern ) : m_underlyingPattern( underlyingPattern ) {}\n    bool TestSpec::ExcludedPattern::matches( TestCaseInfo const& testCase ) const { return !m_underlyingPattern->matches( testCase ); }\n\n    bool TestSpec::Filter::matches( TestCaseInfo const& testCase ) const {\n        // All patterns in a filter must match for the filter to be a match\n        for( auto const& pattern : m_patterns ) {\n            if( !pattern->matches( testCase ) )\n                return false;\n        }\n        return true;\n    }\n\n    bool TestSpec::hasFilters() const {\n        return !m_filters.empty();\n    }\n    bool TestSpec::matches( TestCaseInfo const& testCase ) const {\n        // A TestSpec matches if any filter matches\n        for( auto const& filter : m_filters )\n            if( filter.matches( testCase ) )\n                return true;\n        return false;\n    }\n}\n// end catch_test_spec.cpp\n// start catch_test_spec_parser.cpp\n\nnamespace Catch {\n\n    TestSpecParser::TestSpecParser( ITagAliasRegistry const& tagAliases ) : m_tagAliases( &tagAliases ) {}\n\n    TestSpecParser& TestSpecParser::parse( std::string const& arg ) {\n        m_mode = None;\n        m_exclusion = false;\n        m_start = std::string::npos;\n        m_arg = m_tagAliases->expandAliases( arg );\n        m_escapeChars.clear();\n        for( m_pos = 0; m_pos < m_arg.size(); ++m_pos )\n            visitChar( m_arg[m_pos] );\n        if( m_mode == Name )\n            addPattern<TestSpec::NamePattern>();\n        return *this;\n    }\n    TestSpec TestSpecParser::testSpec() {\n        addFilter();\n        return m_testSpec;\n    }\n\n    void TestSpecParser::visitChar( char c ) {\n        if( m_mode == None ) {\n            switch( c ) {\n            case ' ': return;\n            case '~': m_exclusion = true; return;\n            case '[': return startNewMode( Tag, ++m_pos );\n            case '\"': return startNewMode( QuotedName, ++m_pos );\n            case '\\\\': return escape();\n            default: startNewMode( Name, m_pos ); break;\n            }\n        }\n        if( m_mode == Name ) {\n            if( c == ',' ) {\n                addPattern<TestSpec::NamePattern>();\n                addFilter();\n            }\n            else if( c == '[' ) {\n                if( subString() == \"exclude:\" )\n                    m_exclusion = true;\n                else\n                    addPattern<TestSpec::NamePattern>();\n                startNewMode( Tag, ++m_pos );\n            }\n            else if( c == '\\\\' )\n                escape();\n        }\n        else if( m_mode == EscapedName )\n            m_mode = Name;\n        else if( m_mode == QuotedName && c == '\"' )\n            addPattern<TestSpec::NamePattern>();\n        else if( m_mode == Tag && c == ']' )\n            addPattern<TestSpec::TagPattern>();\n    }\n    void TestSpecParser::startNewMode( Mode mode, std::size_t start ) {\n        m_mode = mode;\n        m_start = start;\n    }\n    void TestSpecParser::escape() {\n        if( m_mode == None )\n            m_start = m_pos;\n        m_mode = EscapedName;\n        m_escapeChars.push_back( m_pos );\n    }\n    std::string TestSpecParser::subString() const { return m_arg.substr( m_start, m_pos - m_start ); }\n\n    void TestSpecParser::addFilter() {\n        if( !m_currentFilter.m_patterns.empty() ) {\n            m_testSpec.m_filters.push_back( m_currentFilter );\n            m_currentFilter = TestSpec::Filter();\n        }\n    }\n\n    TestSpec parseTestSpec( std::string const& arg ) {\n        return TestSpecParser( ITagAliasRegistry::get() ).parse( arg ).testSpec();\n    }\n\n} // namespace Catch\n// end catch_test_spec_parser.cpp\n// start catch_timer.cpp\n\n#include <chrono>\n\nstatic const uint64_t nanosecondsInSecond = 1000000000;\n\nnamespace Catch {\n\n    auto getCurrentNanosecondsSinceEpoch() -> uint64_t {\n        return std::chrono::duration_cast<std::chrono::nanoseconds>( std::chrono::high_resolution_clock::now().time_since_epoch() ).count();\n    }\n\n    namespace {\n        auto estimateClockResolution() -> uint64_t {\n            uint64_t sum = 0;\n            static const uint64_t iterations = 1000000;\n\n            auto startTime = getCurrentNanosecondsSinceEpoch();\n\n            for( std::size_t i = 0; i < iterations; ++i ) {\n\n                uint64_t ticks;\n                uint64_t baseTicks = getCurrentNanosecondsSinceEpoch();\n                do {\n                    ticks = getCurrentNanosecondsSinceEpoch();\n                } while( ticks == baseTicks );\n\n                auto delta = ticks - baseTicks;\n                sum += delta;\n\n                // If we have been calibrating for over 3 seconds -- the clock\n                // is terrible and we should move on.\n                // TBD: How to signal that the measured resolution is probably wrong?\n                if (ticks > startTime + 3 * nanosecondsInSecond) {\n                    return sum / i;\n                }\n            }\n\n            // We're just taking the mean, here. To do better we could take the std. dev and exclude outliers\n            // - and potentially do more iterations if there's a high variance.\n            return sum/iterations;\n        }\n    }\n    auto getEstimatedClockResolution() -> uint64_t {\n        static auto s_resolution = estimateClockResolution();\n        return s_resolution;\n    }\n\n    void Timer::start() {\n       m_nanoseconds = getCurrentNanosecondsSinceEpoch();\n    }\n    auto Timer::getElapsedNanoseconds() const -> uint64_t {\n        return getCurrentNanosecondsSinceEpoch() - m_nanoseconds;\n    }\n    auto Timer::getElapsedMicroseconds() const -> uint64_t {\n        return getElapsedNanoseconds()/1000;\n    }\n    auto Timer::getElapsedMilliseconds() const -> unsigned int {\n        return static_cast<unsigned int>(getElapsedMicroseconds()/1000);\n    }\n    auto Timer::getElapsedSeconds() const -> double {\n        return getElapsedMicroseconds()/1000000.0;\n    }\n\n} // namespace Catch\n// end catch_timer.cpp\n// start catch_tostring.cpp\n\n#if defined(__clang__)\n#    pragma clang diagnostic push\n#    pragma clang diagnostic ignored \"-Wexit-time-destructors\"\n#    pragma clang diagnostic ignored \"-Wglobal-constructors\"\n#endif\n\n// Enable specific decls locally\n#if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER)\n#define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER\n#endif\n\n#include <cmath>\n#include <iomanip>\n\nnamespace Catch {\n\nnamespace Detail {\n\n    const std::string unprintableString = \"{?}\";\n\n    namespace {\n        const int hexThreshold = 255;\n\n        struct Endianness {\n            enum Arch { Big, Little };\n\n            static Arch which() {\n                union _{\n                    int asInt;\n                    char asChar[sizeof (int)];\n                } u;\n\n                u.asInt = 1;\n                return ( u.asChar[sizeof(int)-1] == 1 ) ? Big : Little;\n            }\n        };\n    }\n\n    std::string rawMemoryToString( const void *object, std::size_t size ) {\n        // Reverse order for little endian architectures\n        int i = 0, end = static_cast<int>( size ), inc = 1;\n        if( Endianness::which() == Endianness::Little ) {\n            i = end-1;\n            end = inc = -1;\n        }\n\n        unsigned char const *bytes = static_cast<unsigned char const *>(object);\n        ReusableStringStream rss;\n        rss << \"0x\" << std::setfill('0') << std::hex;\n        for( ; i != end; i += inc )\n             rss << std::setw(2) << static_cast<unsigned>(bytes[i]);\n       return rss.str();\n    }\n}\n\ntemplate<typename T>\nstd::string fpToString( T value, int precision ) {\n    if (Catch::isnan(value)) {\n        return \"nan\";\n    }\n\n    ReusableStringStream rss;\n    rss << std::setprecision( precision )\n        << std::fixed\n        << value;\n    std::string d = rss.str();\n    std::size_t i = d.find_last_not_of( '0' );\n    if( i != std::string::npos && i != d.size()-1 ) {\n        if( d[i] == '.' )\n            i++;\n        d = d.substr( 0, i+1 );\n    }\n    return d;\n}\n\n//// ======================================================= ////\n//\n//   Out-of-line defs for full specialization of StringMaker\n//\n//// ======================================================= ////\n\nstd::string StringMaker<std::string>::convert(const std::string& str) {\n    if (!getCurrentContext().getConfig()->showInvisibles()) {\n        return '\"' + str + '\"';\n    }\n\n    std::string s(\"\\\"\");\n    for (char c : str) {\n        switch (c) {\n        case '\\n':\n            s.append(\"\\\\n\");\n            break;\n        case '\\t':\n            s.append(\"\\\\t\");\n            break;\n        default:\n            s.push_back(c);\n            break;\n        }\n    }\n    s.append(\"\\\"\");\n    return s;\n}\n\n#ifdef CATCH_CONFIG_CPP17_STRING_VIEW\nstd::string StringMaker<std::string_view>::convert(std::string_view str) {\n    return ::Catch::Detail::stringify(std::string{ str });\n}\n#endif\n\nstd::string StringMaker<char const*>::convert(char const* str) {\n    if (str) {\n        return ::Catch::Detail::stringify(std::string{ str });\n    } else {\n        return{ \"{null string}\" };\n    }\n}\nstd::string StringMaker<char*>::convert(char* str) {\n    if (str) {\n        return ::Catch::Detail::stringify(std::string{ str });\n    } else {\n        return{ \"{null string}\" };\n    }\n}\n\n#ifdef CATCH_CONFIG_WCHAR\nstd::string StringMaker<std::wstring>::convert(const std::wstring& wstr) {\n    std::string s;\n    s.reserve(wstr.size());\n    for (auto c : wstr) {\n        s += (c <= 0xff) ? static_cast<char>(c) : '?';\n    }\n    return ::Catch::Detail::stringify(s);\n}\n\n# ifdef CATCH_CONFIG_CPP17_STRING_VIEW\nstd::string StringMaker<std::wstring_view>::convert(std::wstring_view str) {\n    return StringMaker<std::wstring>::convert(std::wstring(str));\n}\n# endif\n\nstd::string StringMaker<wchar_t const*>::convert(wchar_t const * str) {\n    if (str) {\n        return ::Catch::Detail::stringify(std::wstring{ str });\n    } else {\n        return{ \"{null string}\" };\n    }\n}\nstd::string StringMaker<wchar_t *>::convert(wchar_t * str) {\n    if (str) {\n        return ::Catch::Detail::stringify(std::wstring{ str });\n    } else {\n        return{ \"{null string}\" };\n    }\n}\n#endif\n\nstd::string StringMaker<int>::convert(int value) {\n    return ::Catch::Detail::stringify(static_cast<long long>(value));\n}\nstd::string StringMaker<long>::convert(long value) {\n    return ::Catch::Detail::stringify(static_cast<long long>(value));\n}\nstd::string StringMaker<long long>::convert(long long value) {\n    ReusableStringStream rss;\n    rss << value;\n    if (value > Detail::hexThreshold) {\n        rss << \" (0x\" << std::hex << value << ')';\n    }\n    return rss.str();\n}\n\nstd::string StringMaker<unsigned int>::convert(unsigned int value) {\n    return ::Catch::Detail::stringify(static_cast<unsigned long long>(value));\n}\nstd::string StringMaker<unsigned long>::convert(unsigned long value) {\n    return ::Catch::Detail::stringify(static_cast<unsigned long long>(value));\n}\nstd::string StringMaker<unsigned long long>::convert(unsigned long long value) {\n    ReusableStringStream rss;\n    rss << value;\n    if (value > Detail::hexThreshold) {\n        rss << \" (0x\" << std::hex << value << ')';\n    }\n    return rss.str();\n}\n\nstd::string StringMaker<bool>::convert(bool b) {\n    return b ? \"true\" : \"false\";\n}\n\nstd::string StringMaker<signed char>::convert(signed char value) {\n    if (value == '\\r') {\n        return \"'\\\\r'\";\n    } else if (value == '\\f') {\n        return \"'\\\\f'\";\n    } else if (value == '\\n') {\n        return \"'\\\\n'\";\n    } else if (value == '\\t') {\n        return \"'\\\\t'\";\n    } else if ('\\0' <= value && value < ' ') {\n        return ::Catch::Detail::stringify(static_cast<unsigned int>(value));\n    } else {\n        char chstr[] = \"' '\";\n        chstr[1] = value;\n        return chstr;\n    }\n}\nstd::string StringMaker<char>::convert(char c) {\n    return ::Catch::Detail::stringify(static_cast<signed char>(c));\n}\nstd::string StringMaker<unsigned char>::convert(unsigned char c) {\n    return ::Catch::Detail::stringify(static_cast<char>(c));\n}\n\nstd::string StringMaker<std::nullptr_t>::convert(std::nullptr_t) {\n    return \"nullptr\";\n}\n\nstd::string StringMaker<float>::convert(float value) {\n    return fpToString(value, 5) + 'f';\n}\nstd::string StringMaker<double>::convert(double value) {\n    return fpToString(value, 10);\n}\n\nstd::string ratio_string<std::atto>::symbol() { return \"a\"; }\nstd::string ratio_string<std::femto>::symbol() { return \"f\"; }\nstd::string ratio_string<std::pico>::symbol() { return \"p\"; }\nstd::string ratio_string<std::nano>::symbol() { return \"n\"; }\nstd::string ratio_string<std::micro>::symbol() { return \"u\"; }\nstd::string ratio_string<std::milli>::symbol() { return \"m\"; }\n\n} // end namespace Catch\n\n#if defined(__clang__)\n#    pragma clang diagnostic pop\n#endif\n\n// end catch_tostring.cpp\n// start catch_totals.cpp\n\nnamespace Catch {\n\n    Counts Counts::operator - ( Counts const& other ) const {\n        Counts diff;\n        diff.passed = passed - other.passed;\n        diff.failed = failed - other.failed;\n        diff.failedButOk = failedButOk - other.failedButOk;\n        return diff;\n    }\n\n    Counts& Counts::operator += ( Counts const& other ) {\n        passed += other.passed;\n        failed += other.failed;\n        failedButOk += other.failedButOk;\n        return *this;\n    }\n\n    std::size_t Counts::total() const {\n        return passed + failed + failedButOk;\n    }\n    bool Counts::allPassed() const {\n        return failed == 0 && failedButOk == 0;\n    }\n    bool Counts::allOk() const {\n        return failed == 0;\n    }\n\n    Totals Totals::operator - ( Totals const& other ) const {\n        Totals diff;\n        diff.assertions = assertions - other.assertions;\n        diff.testCases = testCases - other.testCases;\n        return diff;\n    }\n\n    Totals& Totals::operator += ( Totals const& other ) {\n        assertions += other.assertions;\n        testCases += other.testCases;\n        return *this;\n    }\n\n    Totals Totals::delta( Totals const& prevTotals ) const {\n        Totals diff = *this - prevTotals;\n        if( diff.assertions.failed > 0 )\n            ++diff.testCases.failed;\n        else if( diff.assertions.failedButOk > 0 )\n            ++diff.testCases.failedButOk;\n        else\n            ++diff.testCases.passed;\n        return diff;\n    }\n\n}\n// end catch_totals.cpp\n// start catch_uncaught_exceptions.cpp\n\n#include <exception>\n\nnamespace Catch {\n    bool uncaught_exceptions() {\n#if defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS)\n        return std::uncaught_exceptions() > 0;\n#else\n        return std::uncaught_exception();\n#endif\n  }\n} // end namespace Catch\n// end catch_uncaught_exceptions.cpp\n// start catch_version.cpp\n\n#include <ostream>\n\nnamespace Catch {\n\n    Version::Version\n        (   unsigned int _majorVersion,\n            unsigned int _minorVersion,\n            unsigned int _patchNumber,\n            char const * const _branchName,\n            unsigned int _buildNumber )\n    :   majorVersion( _majorVersion ),\n        minorVersion( _minorVersion ),\n        patchNumber( _patchNumber ),\n        branchName( _branchName ),\n        buildNumber( _buildNumber )\n    {}\n\n    std::ostream& operator << ( std::ostream& os, Version const& version ) {\n        os  << version.majorVersion << '.'\n            << version.minorVersion << '.'\n            << version.patchNumber;\n        // branchName is never null -> 0th char is \\0 if it is empty\n        if (version.branchName[0]) {\n            os << '-' << version.branchName\n               << '.' << version.buildNumber;\n        }\n        return os;\n    }\n\n    Version const& libraryVersion() {\n        static Version version( 2, 5, 0, \"\", 0 );\n        return version;\n    }\n\n}\n// end catch_version.cpp\n// start catch_wildcard_pattern.cpp\n\n#include <sstream>\n\nnamespace Catch {\n\n    WildcardPattern::WildcardPattern( std::string const& pattern,\n                                      CaseSensitive::Choice caseSensitivity )\n    :   m_caseSensitivity( caseSensitivity ),\n        m_pattern( adjustCase( pattern ) )\n    {\n        if( startsWith( m_pattern, '*' ) ) {\n            m_pattern = m_pattern.substr( 1 );\n            m_wildcard = WildcardAtStart;\n        }\n        if( endsWith( m_pattern, '*' ) ) {\n            m_pattern = m_pattern.substr( 0, m_pattern.size()-1 );\n            m_wildcard = static_cast<WildcardPosition>( m_wildcard | WildcardAtEnd );\n        }\n    }\n\n    bool WildcardPattern::matches( std::string const& str ) const {\n        switch( m_wildcard ) {\n            case NoWildcard:\n                return m_pattern == adjustCase( str );\n            case WildcardAtStart:\n                return endsWith( adjustCase( str ), m_pattern );\n            case WildcardAtEnd:\n                return startsWith( adjustCase( str ), m_pattern );\n            case WildcardAtBothEnds:\n                return contains( adjustCase( str ), m_pattern );\n            default:\n                CATCH_INTERNAL_ERROR( \"Unknown enum\" );\n        }\n    }\n\n    std::string WildcardPattern::adjustCase( std::string const& str ) const {\n        return m_caseSensitivity == CaseSensitive::No ? toLower( str ) : str;\n    }\n}\n// end catch_wildcard_pattern.cpp\n// start catch_xmlwriter.cpp\n\n#include <iomanip>\n\nusing uchar = unsigned char;\n\nnamespace Catch {\n\nnamespace {\n\n    size_t trailingBytes(unsigned char c) {\n        if ((c & 0xE0) == 0xC0) {\n            return 2;\n        }\n        if ((c & 0xF0) == 0xE0) {\n            return 3;\n        }\n        if ((c & 0xF8) == 0xF0) {\n            return 4;\n        }\n        CATCH_INTERNAL_ERROR(\"Invalid multibyte utf-8 start byte encountered\");\n    }\n\n    uint32_t headerValue(unsigned char c) {\n        if ((c & 0xE0) == 0xC0) {\n            return c & 0x1F;\n        }\n        if ((c & 0xF0) == 0xE0) {\n            return c & 0x0F;\n        }\n        if ((c & 0xF8) == 0xF0) {\n            return c & 0x07;\n        }\n        CATCH_INTERNAL_ERROR(\"Invalid multibyte utf-8 start byte encountered\");\n    }\n\n    void hexEscapeChar(std::ostream& os, unsigned char c) {\n        os << \"\\\\x\"\n            << std::uppercase << std::hex << std::setfill('0') << std::setw(2)\n            << static_cast<int>(c);\n    }\n\n} // anonymous namespace\n\n    XmlEncode::XmlEncode( std::string const& str, ForWhat forWhat )\n    :   m_str( str ),\n        m_forWhat( forWhat )\n    {}\n\n    void XmlEncode::encodeTo( std::ostream& os ) const {\n        // Apostrophe escaping not necessary if we always use \" to write attributes\n        // (see: http://www.w3.org/TR/xml/#syntax)\n\n        for( std::size_t idx = 0; idx < m_str.size(); ++ idx ) {\n            uchar c = m_str[idx];\n            switch (c) {\n            case '<':   os << \"&lt;\"; break;\n            case '&':   os << \"&amp;\"; break;\n\n            case '>':\n                // See: http://www.w3.org/TR/xml/#syntax\n                if (idx > 2 && m_str[idx - 1] == ']' && m_str[idx - 2] == ']')\n                    os << \"&gt;\";\n                else\n                    os << c;\n                break;\n\n            case '\\\"':\n                if (m_forWhat == ForAttributes)\n                    os << \"&quot;\";\n                else\n                    os << c;\n                break;\n\n            default:\n                // Check for control characters and invalid utf-8\n\n                // Escape control characters in standard ascii\n                // see http://stackoverflow.com/questions/404107/why-are-control-characters-illegal-in-xml-1-0\n                if (c < 0x09 || (c > 0x0D && c < 0x20) || c == 0x7F) {\n                    hexEscapeChar(os, c);\n                    break;\n                }\n\n                // Plain ASCII: Write it to stream\n                if (c < 0x7F) {\n                    os << c;\n                    break;\n                }\n\n                // UTF-8 territory\n                // Check if the encoding is valid and if it is not, hex escape bytes.\n                // Important: We do not check the exact decoded values for validity, only the encoding format\n                // First check that this bytes is a valid lead byte:\n                // This means that it is not encoded as 1111 1XXX\n                // Or as 10XX XXXX\n                if (c <  0xC0 ||\n                    c >= 0xF8) {\n                    hexEscapeChar(os, c);\n                    break;\n                }\n\n                auto encBytes = trailingBytes(c);\n                // Are there enough bytes left to avoid accessing out-of-bounds memory?\n                if (idx + encBytes - 1 >= m_str.size()) {\n                    hexEscapeChar(os, c);\n                    break;\n                }\n                // The header is valid, check data\n                // The next encBytes bytes must together be a valid utf-8\n                // This means: bitpattern 10XX XXXX and the extracted value is sane (ish)\n                bool valid = true;\n                uint32_t value = headerValue(c);\n                for (std::size_t n = 1; n < encBytes; ++n) {\n                    uchar nc = m_str[idx + n];\n                    valid &= ((nc & 0xC0) == 0x80);\n                    value = (value << 6) | (nc & 0x3F);\n                }\n\n                if (\n                    // Wrong bit pattern of following bytes\n                    (!valid) ||\n                    // Overlong encodings\n                    (value < 0x80) ||\n                    (0x80 <= value && value < 0x800   && encBytes > 2) ||\n                    (0x800 < value && value < 0x10000 && encBytes > 3) ||\n                    // Encoded value out of range\n                    (value >= 0x110000)\n                    ) {\n                    hexEscapeChar(os, c);\n                    break;\n                }\n\n                // If we got here, this is in fact a valid(ish) utf-8 sequence\n                for (std::size_t n = 0; n < encBytes; ++n) {\n                    os << m_str[idx + n];\n                }\n                idx += encBytes - 1;\n                break;\n            }\n        }\n    }\n\n    std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode ) {\n        xmlEncode.encodeTo( os );\n        return os;\n    }\n\n    XmlWriter::ScopedElement::ScopedElement( XmlWriter* writer )\n    :   m_writer( writer )\n    {}\n\n    XmlWriter::ScopedElement::ScopedElement( ScopedElement&& other ) noexcept\n    :   m_writer( other.m_writer ){\n        other.m_writer = nullptr;\n    }\n    XmlWriter::ScopedElement& XmlWriter::ScopedElement::operator=( ScopedElement&& other ) noexcept {\n        if ( m_writer ) {\n            m_writer->endElement();\n        }\n        m_writer = other.m_writer;\n        other.m_writer = nullptr;\n        return *this;\n    }\n\n    XmlWriter::ScopedElement::~ScopedElement() {\n        if( m_writer )\n            m_writer->endElement();\n    }\n\n    XmlWriter::ScopedElement& XmlWriter::ScopedElement::writeText( std::string const& text, bool indent ) {\n        m_writer->writeText( text, indent );\n        return *this;\n    }\n\n    XmlWriter::XmlWriter( std::ostream& os ) : m_os( os )\n    {\n        writeDeclaration();\n    }\n\n    XmlWriter::~XmlWriter() {\n        while( !m_tags.empty() )\n            endElement();\n    }\n\n    XmlWriter& XmlWriter::startElement( std::string const& name ) {\n        ensureTagClosed();\n        newlineIfNecessary();\n        m_os << m_indent << '<' << name;\n        m_tags.push_back( name );\n        m_indent += \"  \";\n        m_tagIsOpen = true;\n        return *this;\n    }\n\n    XmlWriter::ScopedElement XmlWriter::scopedElement( std::string const& name ) {\n        ScopedElement scoped( this );\n        startElement( name );\n        return scoped;\n    }\n\n    XmlWriter& XmlWriter::endElement() {\n        newlineIfNecessary();\n        m_indent = m_indent.substr( 0, m_indent.size()-2 );\n        if( m_tagIsOpen ) {\n            m_os << \"/>\";\n            m_tagIsOpen = false;\n        }\n        else {\n            m_os << m_indent << \"</\" << m_tags.back() << \">\";\n        }\n        m_os << std::endl;\n        m_tags.pop_back();\n        return *this;\n    }\n\n    XmlWriter& XmlWriter::writeAttribute( std::string const& name, std::string const& attribute ) {\n        if( !name.empty() && !attribute.empty() )\n            m_os << ' ' << name << \"=\\\"\" << XmlEncode( attribute, XmlEncode::ForAttributes ) << '\"';\n        return *this;\n    }\n\n    XmlWriter& XmlWriter::writeAttribute( std::string const& name, bool attribute ) {\n        m_os << ' ' << name << \"=\\\"\" << ( attribute ? \"true\" : \"false\" ) << '\"';\n        return *this;\n    }\n\n    XmlWriter& XmlWriter::writeText( std::string const& text, bool indent ) {\n        if( !text.empty() ){\n            bool tagWasOpen = m_tagIsOpen;\n            ensureTagClosed();\n            if( tagWasOpen && indent )\n                m_os << m_indent;\n            m_os << XmlEncode( text );\n            m_needsNewline = true;\n        }\n        return *this;\n    }\n\n    XmlWriter& XmlWriter::writeComment( std::string const& text ) {\n        ensureTagClosed();\n        m_os << m_indent << \"<!--\" << text << \"-->\";\n        m_needsNewline = true;\n        return *this;\n    }\n\n    void XmlWriter::writeStylesheetRef( std::string const& url ) {\n        m_os << \"<?xml-stylesheet type=\\\"text/xsl\\\" href=\\\"\" << url << \"\\\"?>\\n\";\n    }\n\n    XmlWriter& XmlWriter::writeBlankLine() {\n        ensureTagClosed();\n        m_os << '\\n';\n        return *this;\n    }\n\n    void XmlWriter::ensureTagClosed() {\n        if( m_tagIsOpen ) {\n            m_os << \">\" << std::endl;\n            m_tagIsOpen = false;\n        }\n    }\n\n    void XmlWriter::writeDeclaration() {\n        m_os << \"<?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?>\\n\";\n    }\n\n    void XmlWriter::newlineIfNecessary() {\n        if( m_needsNewline ) {\n            m_os << std::endl;\n            m_needsNewline = false;\n        }\n    }\n}\n// end catch_xmlwriter.cpp\n// start catch_reporter_bases.cpp\n\n#include <cstring>\n#include <cfloat>\n#include <cstdio>\n#include <cassert>\n#include <memory>\n\nnamespace Catch {\n    void prepareExpandedExpression(AssertionResult& result) {\n        result.getExpandedExpression();\n    }\n\n    // Because formatting using c++ streams is stateful, drop down to C is required\n    // Alternatively we could use stringstream, but its performance is... not good.\n    std::string getFormattedDuration( double duration ) {\n        // Max exponent + 1 is required to represent the whole part\n        // + 1 for decimal point\n        // + 3 for the 3 decimal places\n        // + 1 for null terminator\n        const std::size_t maxDoubleSize = DBL_MAX_10_EXP + 1 + 1 + 3 + 1;\n        char buffer[maxDoubleSize];\n\n        // Save previous errno, to prevent sprintf from overwriting it\n        ErrnoGuard guard;\n#ifdef _MSC_VER\n        sprintf_s(buffer, \"%.3f\", duration);\n#else\n        sprintf(buffer, \"%.3f\", duration);\n#endif\n        return std::string(buffer);\n    }\n\n    TestEventListenerBase::TestEventListenerBase(ReporterConfig const & _config)\n        :StreamingReporterBase(_config) {}\n\n    std::set<Verbosity> TestEventListenerBase::getSupportedVerbosities() {\n        return { Verbosity::Quiet, Verbosity::Normal, Verbosity::High };\n    }\n\n    void TestEventListenerBase::assertionStarting(AssertionInfo const &) {}\n\n    bool TestEventListenerBase::assertionEnded(AssertionStats const &) {\n        return false;\n    }\n\n} // end namespace Catch\n// end catch_reporter_bases.cpp\n// start catch_reporter_compact.cpp\n\nnamespace {\n\n#ifdef CATCH_PLATFORM_MAC\n    const char* failedString() { return \"FAILED\"; }\n    const char* passedString() { return \"PASSED\"; }\n#else\n    const char* failedString() { return \"failed\"; }\n    const char* passedString() { return \"passed\"; }\n#endif\n\n    // Colour::LightGrey\n    Catch::Colour::Code dimColour() { return Catch::Colour::FileName; }\n\n    std::string bothOrAll( std::size_t count ) {\n        return count == 1 ? std::string() :\n               count == 2 ? \"both \" : \"all \" ;\n    }\n\n} // anon namespace\n\nnamespace Catch {\nnamespace {\n// Colour, message variants:\n// - white: No tests ran.\n// -   red: Failed [both/all] N test cases, failed [both/all] M assertions.\n// - white: Passed [both/all] N test cases (no assertions).\n// -   red: Failed N tests cases, failed M assertions.\n// - green: Passed [both/all] N tests cases with M assertions.\nvoid printTotals(std::ostream& out, const Totals& totals) {\n    if (totals.testCases.total() == 0) {\n        out << \"No tests ran.\";\n    } else if (totals.testCases.failed == totals.testCases.total()) {\n        Colour colour(Colour::ResultError);\n        const std::string qualify_assertions_failed =\n            totals.assertions.failed == totals.assertions.total() ?\n            bothOrAll(totals.assertions.failed) : std::string();\n        out <<\n            \"Failed \" << bothOrAll(totals.testCases.failed)\n            << pluralise(totals.testCases.failed, \"test case\") << \", \"\n            \"failed \" << qualify_assertions_failed <<\n            pluralise(totals.assertions.failed, \"assertion\") << '.';\n    } else if (totals.assertions.total() == 0) {\n        out <<\n            \"Passed \" << bothOrAll(totals.testCases.total())\n            << pluralise(totals.testCases.total(), \"test case\")\n            << \" (no assertions).\";\n    } else if (totals.assertions.failed) {\n        Colour colour(Colour::ResultError);\n        out <<\n            \"Failed \" << pluralise(totals.testCases.failed, \"test case\") << \", \"\n            \"failed \" << pluralise(totals.assertions.failed, \"assertion\") << '.';\n    } else {\n        Colour colour(Colour::ResultSuccess);\n        out <<\n            \"Passed \" << bothOrAll(totals.testCases.passed)\n            << pluralise(totals.testCases.passed, \"test case\") <<\n            \" with \" << pluralise(totals.assertions.passed, \"assertion\") << '.';\n    }\n}\n\n// Implementation of CompactReporter formatting\nclass AssertionPrinter {\npublic:\n    AssertionPrinter& operator= (AssertionPrinter const&) = delete;\n    AssertionPrinter(AssertionPrinter const&) = delete;\n    AssertionPrinter(std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages)\n        : stream(_stream)\n        , result(_stats.assertionResult)\n        , messages(_stats.infoMessages)\n        , itMessage(_stats.infoMessages.begin())\n        , printInfoMessages(_printInfoMessages) {}\n\n    void print() {\n        printSourceInfo();\n\n        itMessage = messages.begin();\n\n        switch (result.getResultType()) {\n        case ResultWas::Ok:\n            printResultType(Colour::ResultSuccess, passedString());\n            printOriginalExpression();\n            printReconstructedExpression();\n            if (!result.hasExpression())\n                printRemainingMessages(Colour::None);\n            else\n                printRemainingMessages();\n            break;\n        case ResultWas::ExpressionFailed:\n            if (result.isOk())\n                printResultType(Colour::ResultSuccess, failedString() + std::string(\" - but was ok\"));\n            else\n                printResultType(Colour::Error, failedString());\n            printOriginalExpression();\n            printReconstructedExpression();\n            printRemainingMessages();\n            break;\n        case ResultWas::ThrewException:\n            printResultType(Colour::Error, failedString());\n            printIssue(\"unexpected exception with message:\");\n            printMessage();\n            printExpressionWas();\n            printRemainingMessages();\n            break;\n        case ResultWas::FatalErrorCondition:\n            printResultType(Colour::Error, failedString());\n            printIssue(\"fatal error condition with message:\");\n            printMessage();\n            printExpressionWas();\n            printRemainingMessages();\n            break;\n        case ResultWas::DidntThrowException:\n            printResultType(Colour::Error, failedString());\n            printIssue(\"expected exception, got none\");\n            printExpressionWas();\n            printRemainingMessages();\n            break;\n        case ResultWas::Info:\n            printResultType(Colour::None, \"info\");\n            printMessage();\n            printRemainingMessages();\n            break;\n        case ResultWas::Warning:\n            printResultType(Colour::None, \"warning\");\n            printMessage();\n            printRemainingMessages();\n            break;\n        case ResultWas::ExplicitFailure:\n            printResultType(Colour::Error, failedString());\n            printIssue(\"explicitly\");\n            printRemainingMessages(Colour::None);\n            break;\n            // These cases are here to prevent compiler warnings\n        case ResultWas::Unknown:\n        case ResultWas::FailureBit:\n        case ResultWas::Exception:\n            printResultType(Colour::Error, \"** internal error **\");\n            break;\n        }\n    }\n\nprivate:\n    void printSourceInfo() const {\n        Colour colourGuard(Colour::FileName);\n        stream << result.getSourceInfo() << ':';\n    }\n\n    void printResultType(Colour::Code colour, std::string const& passOrFail) const {\n        if (!passOrFail.empty()) {\n            {\n                Colour colourGuard(colour);\n                stream << ' ' << passOrFail;\n            }\n            stream << ':';\n        }\n    }\n\n    void printIssue(std::string const& issue) const {\n        stream << ' ' << issue;\n    }\n\n    void printExpressionWas() {\n        if (result.hasExpression()) {\n            stream << ';';\n            {\n                Colour colour(dimColour());\n                stream << \" expression was:\";\n            }\n            printOriginalExpression();\n        }\n    }\n\n    void printOriginalExpression() const {\n        if (result.hasExpression()) {\n            stream << ' ' << result.getExpression();\n        }\n    }\n\n    void printReconstructedExpression() const {\n        if (result.hasExpandedExpression()) {\n            {\n                Colour colour(dimColour());\n                stream << \" for: \";\n            }\n            stream << result.getExpandedExpression();\n        }\n    }\n\n    void printMessage() {\n        if (itMessage != messages.end()) {\n            stream << \" '\" << itMessage->message << '\\'';\n            ++itMessage;\n        }\n    }\n\n    void printRemainingMessages(Colour::Code colour = dimColour()) {\n        if (itMessage == messages.end())\n            return;\n\n        // using messages.end() directly yields (or auto) compilation error:\n        std::vector<MessageInfo>::const_iterator itEnd = messages.end();\n        const std::size_t N = static_cast<std::size_t>(std::distance(itMessage, itEnd));\n\n        {\n            Colour colourGuard(colour);\n            stream << \" with \" << pluralise(N, \"message\") << ':';\n        }\n\n        for (; itMessage != itEnd; ) {\n            // If this assertion is a warning ignore any INFO messages\n            if (printInfoMessages || itMessage->type != ResultWas::Info) {\n                stream << \" '\" << itMessage->message << '\\'';\n                if (++itMessage != itEnd) {\n                    Colour colourGuard(dimColour());\n                    stream << \" and\";\n                }\n            }\n        }\n    }\n\nprivate:\n    std::ostream& stream;\n    AssertionResult const& result;\n    std::vector<MessageInfo> messages;\n    std::vector<MessageInfo>::const_iterator itMessage;\n    bool printInfoMessages;\n};\n\n} // anon namespace\n\n        std::string CompactReporter::getDescription() {\n            return \"Reports test results on a single line, suitable for IDEs\";\n        }\n\n        ReporterPreferences CompactReporter::getPreferences() const {\n            return m_reporterPrefs;\n        }\n\n        void CompactReporter::noMatchingTestCases( std::string const& spec ) {\n            stream << \"No test cases matched '\" << spec << '\\'' << std::endl;\n        }\n\n        void CompactReporter::assertionStarting( AssertionInfo const& ) {}\n\n        bool CompactReporter::assertionEnded( AssertionStats const& _assertionStats ) {\n            AssertionResult const& result = _assertionStats.assertionResult;\n\n            bool printInfoMessages = true;\n\n            // Drop out if result was successful and we're not printing those\n            if( !m_config->includeSuccessfulResults() && result.isOk() ) {\n                if( result.getResultType() != ResultWas::Warning )\n                    return false;\n                printInfoMessages = false;\n            }\n\n            AssertionPrinter printer( stream, _assertionStats, printInfoMessages );\n            printer.print();\n\n            stream << std::endl;\n            return true;\n        }\n\n        void CompactReporter::sectionEnded(SectionStats const& _sectionStats) {\n            if (m_config->showDurations() == ShowDurations::Always) {\n                stream << getFormattedDuration(_sectionStats.durationInSeconds) << \" s: \" << _sectionStats.sectionInfo.name << std::endl;\n            }\n        }\n\n        void CompactReporter::testRunEnded( TestRunStats const& _testRunStats ) {\n            printTotals( stream, _testRunStats.totals );\n            stream << '\\n' << std::endl;\n            StreamingReporterBase::testRunEnded( _testRunStats );\n        }\n\n        CompactReporter::~CompactReporter() {}\n\n    CATCH_REGISTER_REPORTER( \"compact\", CompactReporter )\n\n} // end namespace Catch\n// end catch_reporter_compact.cpp\n// start catch_reporter_console.cpp\n\n#include <cfloat>\n#include <cstdio>\n\n#if defined(_MSC_VER)\n#pragma warning(push)\n#pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch\n // Note that 4062 (not all labels are handled\n // and default is missing) is enabled\n#endif\n\nnamespace Catch {\n\nnamespace {\n\n// Formatter impl for ConsoleReporter\nclass ConsoleAssertionPrinter {\npublic:\n    ConsoleAssertionPrinter& operator= (ConsoleAssertionPrinter const&) = delete;\n    ConsoleAssertionPrinter(ConsoleAssertionPrinter const&) = delete;\n    ConsoleAssertionPrinter(std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages)\n        : stream(_stream),\n        stats(_stats),\n        result(_stats.assertionResult),\n        colour(Colour::None),\n        message(result.getMessage()),\n        messages(_stats.infoMessages),\n        printInfoMessages(_printInfoMessages) {\n        switch (result.getResultType()) {\n        case ResultWas::Ok:\n            colour = Colour::Success;\n            passOrFail = \"PASSED\";\n            //if( result.hasMessage() )\n            if (_stats.infoMessages.size() == 1)\n                messageLabel = \"with message\";\n            if (_stats.infoMessages.size() > 1)\n                messageLabel = \"with messages\";\n            break;\n        case ResultWas::ExpressionFailed:\n            if (result.isOk()) {\n                colour = Colour::Success;\n                passOrFail = \"FAILED - but was ok\";\n            } else {\n                colour = Colour::Error;\n                passOrFail = \"FAILED\";\n            }\n            if (_stats.infoMessages.size() == 1)\n                messageLabel = \"with message\";\n            if (_stats.infoMessages.size() > 1)\n                messageLabel = \"with messages\";\n            break;\n        case ResultWas::ThrewException:\n            colour = Colour::Error;\n            passOrFail = \"FAILED\";\n            messageLabel = \"due to unexpected exception with \";\n            if (_stats.infoMessages.size() == 1)\n                messageLabel += \"message\";\n            if (_stats.infoMessages.size() > 1)\n                messageLabel += \"messages\";\n            break;\n        case ResultWas::FatalErrorCondition:\n            colour = Colour::Error;\n            passOrFail = \"FAILED\";\n            messageLabel = \"due to a fatal error condition\";\n            break;\n        case ResultWas::DidntThrowException:\n            colour = Colour::Error;\n            passOrFail = \"FAILED\";\n            messageLabel = \"because no exception was thrown where one was expected\";\n            break;\n        case ResultWas::Info:\n            messageLabel = \"info\";\n            break;\n        case ResultWas::Warning:\n            messageLabel = \"warning\";\n            break;\n        case ResultWas::ExplicitFailure:\n            passOrFail = \"FAILED\";\n            colour = Colour::Error;\n            if (_stats.infoMessages.size() == 1)\n                messageLabel = \"explicitly with message\";\n            if (_stats.infoMessages.size() > 1)\n                messageLabel = \"explicitly with messages\";\n            break;\n            // These cases are here to prevent compiler warnings\n        case ResultWas::Unknown:\n        case ResultWas::FailureBit:\n        case ResultWas::Exception:\n            passOrFail = \"** internal error **\";\n            colour = Colour::Error;\n            break;\n        }\n    }\n\n    void print() const {\n        printSourceInfo();\n        if (stats.totals.assertions.total() > 0) {\n            printResultType();\n            printOriginalExpression();\n            printReconstructedExpression();\n        } else {\n            stream << '\\n';\n        }\n        printMessage();\n    }\n\nprivate:\n    void printResultType() const {\n        if (!passOrFail.empty()) {\n            Colour colourGuard(colour);\n            stream << passOrFail << \":\\n\";\n        }\n    }\n    void printOriginalExpression() const {\n        if (result.hasExpression()) {\n            Colour colourGuard(Colour::OriginalExpression);\n            stream << \"  \";\n            stream << result.getExpressionInMacro();\n            stream << '\\n';\n        }\n    }\n    void printReconstructedExpression() const {\n        if (result.hasExpandedExpression()) {\n            stream << \"with expansion:\\n\";\n            Colour colourGuard(Colour::ReconstructedExpression);\n            stream << Column(result.getExpandedExpression()).indent(2) << '\\n';\n        }\n    }\n    void printMessage() const {\n        if (!messageLabel.empty())\n            stream << messageLabel << ':' << '\\n';\n        for (auto const& msg : messages) {\n            // If this assertion is a warning ignore any INFO messages\n            if (printInfoMessages || msg.type != ResultWas::Info)\n                stream << Column(msg.message).indent(2) << '\\n';\n        }\n    }\n    void printSourceInfo() const {\n        Colour colourGuard(Colour::FileName);\n        stream << result.getSourceInfo() << \": \";\n    }\n\n    std::ostream& stream;\n    AssertionStats const& stats;\n    AssertionResult const& result;\n    Colour::Code colour;\n    std::string passOrFail;\n    std::string messageLabel;\n    std::string message;\n    std::vector<MessageInfo> messages;\n    bool printInfoMessages;\n};\n\nstd::size_t makeRatio(std::size_t number, std::size_t total) {\n    std::size_t ratio = total > 0 ? CATCH_CONFIG_CONSOLE_WIDTH * number / total : 0;\n    return (ratio == 0 && number > 0) ? 1 : ratio;\n}\n\nstd::size_t& findMax(std::size_t& i, std::size_t& j, std::size_t& k) {\n    if (i > j && i > k)\n        return i;\n    else if (j > k)\n        return j;\n    else\n        return k;\n}\n\nstruct ColumnInfo {\n    enum Justification { Left, Right };\n    std::string name;\n    int width;\n    Justification justification;\n};\nstruct ColumnBreak {};\nstruct RowBreak {};\n\nclass Duration {\n    enum class Unit {\n        Auto,\n        Nanoseconds,\n        Microseconds,\n        Milliseconds,\n        Seconds,\n        Minutes\n    };\n    static const uint64_t s_nanosecondsInAMicrosecond = 1000;\n    static const uint64_t s_nanosecondsInAMillisecond = 1000 * s_nanosecondsInAMicrosecond;\n    static const uint64_t s_nanosecondsInASecond = 1000 * s_nanosecondsInAMillisecond;\n    static const uint64_t s_nanosecondsInAMinute = 60 * s_nanosecondsInASecond;\n\n    uint64_t m_inNanoseconds;\n    Unit m_units;\n\npublic:\n    explicit Duration(uint64_t inNanoseconds, Unit units = Unit::Auto)\n        : m_inNanoseconds(inNanoseconds),\n        m_units(units) {\n        if (m_units == Unit::Auto) {\n            if (m_inNanoseconds < s_nanosecondsInAMicrosecond)\n                m_units = Unit::Nanoseconds;\n            else if (m_inNanoseconds < s_nanosecondsInAMillisecond)\n                m_units = Unit::Microseconds;\n            else if (m_inNanoseconds < s_nanosecondsInASecond)\n                m_units = Unit::Milliseconds;\n            else if (m_inNanoseconds < s_nanosecondsInAMinute)\n                m_units = Unit::Seconds;\n            else\n                m_units = Unit::Minutes;\n        }\n\n    }\n\n    auto value() const -> double {\n        switch (m_units) {\n        case Unit::Microseconds:\n            return m_inNanoseconds / static_cast<double>(s_nanosecondsInAMicrosecond);\n        case Unit::Milliseconds:\n            return m_inNanoseconds / static_cast<double>(s_nanosecondsInAMillisecond);\n        case Unit::Seconds:\n            return m_inNanoseconds / static_cast<double>(s_nanosecondsInASecond);\n        case Unit::Minutes:\n            return m_inNanoseconds / static_cast<double>(s_nanosecondsInAMinute);\n        default:\n            return static_cast<double>(m_inNanoseconds);\n        }\n    }\n    auto unitsAsString() const -> std::string {\n        switch (m_units) {\n        case Unit::Nanoseconds:\n            return \"ns\";\n        case Unit::Microseconds:\n            return \"µs\";\n        case Unit::Milliseconds:\n            return \"ms\";\n        case Unit::Seconds:\n            return \"s\";\n        case Unit::Minutes:\n            return \"m\";\n        default:\n            return \"** internal error **\";\n        }\n\n    }\n    friend auto operator << (std::ostream& os, Duration const& duration) -> std::ostream& {\n        return os << duration.value() << \" \" << duration.unitsAsString();\n    }\n};\n} // end anon namespace\n\nclass TablePrinter {\n    std::ostream& m_os;\n    std::vector<ColumnInfo> m_columnInfos;\n    std::ostringstream m_oss;\n    int m_currentColumn = -1;\n    bool m_isOpen = false;\n\npublic:\n    TablePrinter( std::ostream& os, std::vector<ColumnInfo> columnInfos )\n    :   m_os( os ),\n        m_columnInfos( std::move( columnInfos ) ) {}\n\n    auto columnInfos() const -> std::vector<ColumnInfo> const& {\n        return m_columnInfos;\n    }\n\n    void open() {\n        if (!m_isOpen) {\n            m_isOpen = true;\n            *this << RowBreak();\n            for (auto const& info : m_columnInfos)\n                *this << info.name << ColumnBreak();\n            *this << RowBreak();\n            m_os << Catch::getLineOfChars<'-'>() << \"\\n\";\n        }\n    }\n    void close() {\n        if (m_isOpen) {\n            *this << RowBreak();\n            m_os << std::endl;\n            m_isOpen = false;\n        }\n    }\n\n    template<typename T>\n    friend TablePrinter& operator << (TablePrinter& tp, T const& value) {\n        tp.m_oss << value;\n        return tp;\n    }\n\n    friend TablePrinter& operator << (TablePrinter& tp, ColumnBreak) {\n        auto colStr = tp.m_oss.str();\n        // This takes account of utf8 encodings\n        auto strSize = Catch::StringRef(colStr).numberOfCharacters();\n        tp.m_oss.str(\"\");\n        tp.open();\n        if (tp.m_currentColumn == static_cast<int>(tp.m_columnInfos.size() - 1)) {\n            tp.m_currentColumn = -1;\n            tp.m_os << \"\\n\";\n        }\n        tp.m_currentColumn++;\n\n        auto colInfo = tp.m_columnInfos[tp.m_currentColumn];\n        auto padding = (strSize + 2 < static_cast<std::size_t>(colInfo.width))\n            ? std::string(colInfo.width - (strSize + 2), ' ')\n            : std::string();\n        if (colInfo.justification == ColumnInfo::Left)\n            tp.m_os << colStr << padding << \" \";\n        else\n            tp.m_os << padding << colStr << \" \";\n        return tp;\n    }\n\n    friend TablePrinter& operator << (TablePrinter& tp, RowBreak) {\n        if (tp.m_currentColumn > 0) {\n            tp.m_os << \"\\n\";\n            tp.m_currentColumn = -1;\n        }\n        return tp;\n    }\n};\n\nConsoleReporter::ConsoleReporter(ReporterConfig const& config)\n    : StreamingReporterBase(config),\n    m_tablePrinter(new TablePrinter(config.stream(),\n    {\n        { \"benchmark name\", CATCH_CONFIG_CONSOLE_WIDTH - 32, ColumnInfo::Left },\n        { \"iters\", 8, ColumnInfo::Right },\n        { \"elapsed ns\", 14, ColumnInfo::Right },\n        { \"average\", 14, ColumnInfo::Right }\n    })) {}\nConsoleReporter::~ConsoleReporter() = default;\n\nstd::string ConsoleReporter::getDescription() {\n    return \"Reports test results as plain lines of text\";\n}\n\nvoid ConsoleReporter::noMatchingTestCases(std::string const& spec) {\n    stream << \"No test cases matched '\" << spec << '\\'' << std::endl;\n}\n\nvoid ConsoleReporter::assertionStarting(AssertionInfo const&) {}\n\nbool ConsoleReporter::assertionEnded(AssertionStats const& _assertionStats) {\n    AssertionResult const& result = _assertionStats.assertionResult;\n\n    bool includeResults = m_config->includeSuccessfulResults() || !result.isOk();\n\n    // Drop out if result was successful but we're not printing them.\n    if (!includeResults && result.getResultType() != ResultWas::Warning)\n        return false;\n\n    lazyPrint();\n\n    ConsoleAssertionPrinter printer(stream, _assertionStats, includeResults);\n    printer.print();\n    stream << std::endl;\n    return true;\n}\n\nvoid ConsoleReporter::sectionStarting(SectionInfo const& _sectionInfo) {\n    m_headerPrinted = false;\n    StreamingReporterBase::sectionStarting(_sectionInfo);\n}\nvoid ConsoleReporter::sectionEnded(SectionStats const& _sectionStats) {\n    m_tablePrinter->close();\n    if (_sectionStats.missingAssertions) {\n        lazyPrint();\n        Colour colour(Colour::ResultError);\n        if (m_sectionStack.size() > 1)\n            stream << \"\\nNo assertions in section\";\n        else\n            stream << \"\\nNo assertions in test case\";\n        stream << \" '\" << _sectionStats.sectionInfo.name << \"'\\n\" << std::endl;\n    }\n    if (m_config->showDurations() == ShowDurations::Always) {\n        stream << getFormattedDuration(_sectionStats.durationInSeconds) << \" s: \" << _sectionStats.sectionInfo.name << std::endl;\n    }\n    if (m_headerPrinted) {\n        m_headerPrinted = false;\n    }\n    StreamingReporterBase::sectionEnded(_sectionStats);\n}\n\nvoid ConsoleReporter::benchmarkStarting(BenchmarkInfo const& info) {\n    lazyPrintWithoutClosingBenchmarkTable();\n\n    auto nameCol = Column( info.name ).width( static_cast<std::size_t>( m_tablePrinter->columnInfos()[0].width - 2 ) );\n\n    bool firstLine = true;\n    for (auto line : nameCol) {\n        if (!firstLine)\n            (*m_tablePrinter) << ColumnBreak() << ColumnBreak() << ColumnBreak();\n        else\n            firstLine = false;\n\n        (*m_tablePrinter) << line << ColumnBreak();\n    }\n}\nvoid ConsoleReporter::benchmarkEnded(BenchmarkStats const& stats) {\n    Duration average(stats.elapsedTimeInNanoseconds / stats.iterations);\n    (*m_tablePrinter)\n        << stats.iterations << ColumnBreak()\n        << stats.elapsedTimeInNanoseconds << ColumnBreak()\n        << average << ColumnBreak();\n}\n\nvoid ConsoleReporter::testCaseEnded(TestCaseStats const& _testCaseStats) {\n    m_tablePrinter->close();\n    StreamingReporterBase::testCaseEnded(_testCaseStats);\n    m_headerPrinted = false;\n}\nvoid ConsoleReporter::testGroupEnded(TestGroupStats const& _testGroupStats) {\n    if (currentGroupInfo.used) {\n        printSummaryDivider();\n        stream << \"Summary for group '\" << _testGroupStats.groupInfo.name << \"':\\n\";\n        printTotals(_testGroupStats.totals);\n        stream << '\\n' << std::endl;\n    }\n    StreamingReporterBase::testGroupEnded(_testGroupStats);\n}\nvoid ConsoleReporter::testRunEnded(TestRunStats const& _testRunStats) {\n    printTotalsDivider(_testRunStats.totals);\n    printTotals(_testRunStats.totals);\n    stream << std::endl;\n    StreamingReporterBase::testRunEnded(_testRunStats);\n}\n\nvoid ConsoleReporter::lazyPrint() {\n\n    m_tablePrinter->close();\n    lazyPrintWithoutClosingBenchmarkTable();\n}\n\nvoid ConsoleReporter::lazyPrintWithoutClosingBenchmarkTable() {\n\n    if (!currentTestRunInfo.used)\n        lazyPrintRunInfo();\n    if (!currentGroupInfo.used)\n        lazyPrintGroupInfo();\n\n    if (!m_headerPrinted) {\n        printTestCaseAndSectionHeader();\n        m_headerPrinted = true;\n    }\n}\nvoid ConsoleReporter::lazyPrintRunInfo() {\n    stream << '\\n' << getLineOfChars<'~'>() << '\\n';\n    Colour colour(Colour::SecondaryText);\n    stream << currentTestRunInfo->name\n        << \" is a Catch v\" << libraryVersion() << \" host application.\\n\"\n        << \"Run with -? for options\\n\\n\";\n\n    if (m_config->rngSeed() != 0)\n        stream << \"Randomness seeded to: \" << m_config->rngSeed() << \"\\n\\n\";\n\n    currentTestRunInfo.used = true;\n}\nvoid ConsoleReporter::lazyPrintGroupInfo() {\n    if (!currentGroupInfo->name.empty() && currentGroupInfo->groupsCounts > 1) {\n        printClosedHeader(\"Group: \" + currentGroupInfo->name);\n        currentGroupInfo.used = true;\n    }\n}\nvoid ConsoleReporter::printTestCaseAndSectionHeader() {\n    assert(!m_sectionStack.empty());\n    printOpenHeader(currentTestCaseInfo->name);\n\n    if (m_sectionStack.size() > 1) {\n        Colour colourGuard(Colour::Headers);\n\n        auto\n            it = m_sectionStack.begin() + 1, // Skip first section (test case)\n            itEnd = m_sectionStack.end();\n        for (; it != itEnd; ++it)\n            printHeaderString(it->name, 2);\n    }\n\n    SourceLineInfo lineInfo = m_sectionStack.back().lineInfo;\n\n    if (!lineInfo.empty()) {\n        stream << getLineOfChars<'-'>() << '\\n';\n        Colour colourGuard(Colour::FileName);\n        stream << lineInfo << '\\n';\n    }\n    stream << getLineOfChars<'.'>() << '\\n' << std::endl;\n}\n\nvoid ConsoleReporter::printClosedHeader(std::string const& _name) {\n    printOpenHeader(_name);\n    stream << getLineOfChars<'.'>() << '\\n';\n}\nvoid ConsoleReporter::printOpenHeader(std::string const& _name) {\n    stream << getLineOfChars<'-'>() << '\\n';\n    {\n        Colour colourGuard(Colour::Headers);\n        printHeaderString(_name);\n    }\n}\n\n// if string has a : in first line will set indent to follow it on\n// subsequent lines\nvoid ConsoleReporter::printHeaderString(std::string const& _string, std::size_t indent) {\n    std::size_t i = _string.find(\": \");\n    if (i != std::string::npos)\n        i += 2;\n    else\n        i = 0;\n    stream << Column(_string).indent(indent + i).initialIndent(indent) << '\\n';\n}\n\nstruct SummaryColumn {\n\n    SummaryColumn( std::string _label, Colour::Code _colour )\n    :   label( std::move( _label ) ),\n        colour( _colour ) {}\n    SummaryColumn addRow( std::size_t count ) {\n        ReusableStringStream rss;\n        rss << count;\n        std::string row = rss.str();\n        for (auto& oldRow : rows) {\n            while (oldRow.size() < row.size())\n                oldRow = ' ' + oldRow;\n            while (oldRow.size() > row.size())\n                row = ' ' + row;\n        }\n        rows.push_back(row);\n        return *this;\n    }\n\n    std::string label;\n    Colour::Code colour;\n    std::vector<std::string> rows;\n\n};\n\nvoid ConsoleReporter::printTotals( Totals const& totals ) {\n    if (totals.testCases.total() == 0) {\n        stream << Colour(Colour::Warning) << \"No tests ran\\n\";\n    } else if (totals.assertions.total() > 0 && totals.testCases.allPassed()) {\n        stream << Colour(Colour::ResultSuccess) << \"All tests passed\";\n        stream << \" (\"\n            << pluralise(totals.assertions.passed, \"assertion\") << \" in \"\n            << pluralise(totals.testCases.passed, \"test case\") << ')'\n            << '\\n';\n    } else {\n\n        std::vector<SummaryColumn> columns;\n        columns.push_back(SummaryColumn(\"\", Colour::None)\n                          .addRow(totals.testCases.total())\n                          .addRow(totals.assertions.total()));\n        columns.push_back(SummaryColumn(\"passed\", Colour::Success)\n                          .addRow(totals.testCases.passed)\n                          .addRow(totals.assertions.passed));\n        columns.push_back(SummaryColumn(\"failed\", Colour::ResultError)\n                          .addRow(totals.testCases.failed)\n                          .addRow(totals.assertions.failed));\n        columns.push_back(SummaryColumn(\"failed as expected\", Colour::ResultExpectedFailure)\n                          .addRow(totals.testCases.failedButOk)\n                          .addRow(totals.assertions.failedButOk));\n\n        printSummaryRow(\"test cases\", columns, 0);\n        printSummaryRow(\"assertions\", columns, 1);\n    }\n}\nvoid ConsoleReporter::printSummaryRow(std::string const& label, std::vector<SummaryColumn> const& cols, std::size_t row) {\n    for (auto col : cols) {\n        std::string value = col.rows[row];\n        if (col.label.empty()) {\n            stream << label << \": \";\n            if (value != \"0\")\n                stream << value;\n            else\n                stream << Colour(Colour::Warning) << \"- none -\";\n        } else if (value != \"0\") {\n            stream << Colour(Colour::LightGrey) << \" | \";\n            stream << Colour(col.colour)\n                << value << ' ' << col.label;\n        }\n    }\n    stream << '\\n';\n}\n\nvoid ConsoleReporter::printTotalsDivider(Totals const& totals) {\n    if (totals.testCases.total() > 0) {\n        std::size_t failedRatio = makeRatio(totals.testCases.failed, totals.testCases.total());\n        std::size_t failedButOkRatio = makeRatio(totals.testCases.failedButOk, totals.testCases.total());\n        std::size_t passedRatio = makeRatio(totals.testCases.passed, totals.testCases.total());\n        while (failedRatio + failedButOkRatio + passedRatio < CATCH_CONFIG_CONSOLE_WIDTH - 1)\n            findMax(failedRatio, failedButOkRatio, passedRatio)++;\n        while (failedRatio + failedButOkRatio + passedRatio > CATCH_CONFIG_CONSOLE_WIDTH - 1)\n            findMax(failedRatio, failedButOkRatio, passedRatio)--;\n\n        stream << Colour(Colour::Error) << std::string(failedRatio, '=');\n        stream << Colour(Colour::ResultExpectedFailure) << std::string(failedButOkRatio, '=');\n        if (totals.testCases.allPassed())\n            stream << Colour(Colour::ResultSuccess) << std::string(passedRatio, '=');\n        else\n            stream << Colour(Colour::Success) << std::string(passedRatio, '=');\n    } else {\n        stream << Colour(Colour::Warning) << std::string(CATCH_CONFIG_CONSOLE_WIDTH - 1, '=');\n    }\n    stream << '\\n';\n}\nvoid ConsoleReporter::printSummaryDivider() {\n    stream << getLineOfChars<'-'>() << '\\n';\n}\n\nCATCH_REGISTER_REPORTER(\"console\", ConsoleReporter)\n\n} // end namespace Catch\n\n#if defined(_MSC_VER)\n#pragma warning(pop)\n#endif\n// end catch_reporter_console.cpp\n// start catch_reporter_junit.cpp\n\n#include <cassert>\n#include <sstream>\n#include <ctime>\n#include <algorithm>\n\nnamespace Catch {\n\n    namespace {\n        std::string getCurrentTimestamp() {\n            // Beware, this is not reentrant because of backward compatibility issues\n            // Also, UTC only, again because of backward compatibility (%z is C++11)\n            time_t rawtime;\n            std::time(&rawtime);\n            auto const timeStampSize = sizeof(\"2017-01-16T17:06:45Z\");\n\n#ifdef _MSC_VER\n            std::tm timeInfo = {};\n            gmtime_s(&timeInfo, &rawtime);\n#else\n            std::tm* timeInfo;\n            timeInfo = std::gmtime(&rawtime);\n#endif\n\n            char timeStamp[timeStampSize];\n            const char * const fmt = \"%Y-%m-%dT%H:%M:%SZ\";\n\n#ifdef _MSC_VER\n            std::strftime(timeStamp, timeStampSize, fmt, &timeInfo);\n#else\n            std::strftime(timeStamp, timeStampSize, fmt, timeInfo);\n#endif\n            return std::string(timeStamp);\n        }\n\n        std::string fileNameTag(const std::vector<std::string> &tags) {\n            auto it = std::find_if(begin(tags),\n                                   end(tags),\n                                   [] (std::string const& tag) {return tag.front() == '#'; });\n            if (it != tags.end())\n                return it->substr(1);\n            return std::string();\n        }\n    } // anonymous namespace\n\n    JunitReporter::JunitReporter( ReporterConfig const& _config )\n        :   CumulativeReporterBase( _config ),\n            xml( _config.stream() )\n        {\n            m_reporterPrefs.shouldRedirectStdOut = true;\n            m_reporterPrefs.shouldReportAllAssertions = true;\n        }\n\n    JunitReporter::~JunitReporter() {}\n\n    std::string JunitReporter::getDescription() {\n        return \"Reports test results in an XML format that looks like Ant's junitreport target\";\n    }\n\n    void JunitReporter::noMatchingTestCases( std::string const& /*spec*/ ) {}\n\n    void JunitReporter::testRunStarting( TestRunInfo const& runInfo )  {\n        CumulativeReporterBase::testRunStarting( runInfo );\n        xml.startElement( \"testsuites\" );\n    }\n\n    void JunitReporter::testGroupStarting( GroupInfo const& groupInfo ) {\n        suiteTimer.start();\n        stdOutForSuite.clear();\n        stdErrForSuite.clear();\n        unexpectedExceptions = 0;\n        CumulativeReporterBase::testGroupStarting( groupInfo );\n    }\n\n    void JunitReporter::testCaseStarting( TestCaseInfo const& testCaseInfo ) {\n        m_okToFail = testCaseInfo.okToFail();\n    }\n\n    bool JunitReporter::assertionEnded( AssertionStats const& assertionStats ) {\n        if( assertionStats.assertionResult.getResultType() == ResultWas::ThrewException && !m_okToFail )\n            unexpectedExceptions++;\n        return CumulativeReporterBase::assertionEnded( assertionStats );\n    }\n\n    void JunitReporter::testCaseEnded( TestCaseStats const& testCaseStats ) {\n        stdOutForSuite += testCaseStats.stdOut;\n        stdErrForSuite += testCaseStats.stdErr;\n        CumulativeReporterBase::testCaseEnded( testCaseStats );\n    }\n\n    void JunitReporter::testGroupEnded( TestGroupStats const& testGroupStats ) {\n        double suiteTime = suiteTimer.getElapsedSeconds();\n        CumulativeReporterBase::testGroupEnded( testGroupStats );\n        writeGroup( *m_testGroups.back(), suiteTime );\n    }\n\n    void JunitReporter::testRunEndedCumulative() {\n        xml.endElement();\n    }\n\n    void JunitReporter::writeGroup( TestGroupNode const& groupNode, double suiteTime ) {\n        XmlWriter::ScopedElement e = xml.scopedElement( \"testsuite\" );\n        TestGroupStats const& stats = groupNode.value;\n        xml.writeAttribute( \"name\", stats.groupInfo.name );\n        xml.writeAttribute( \"errors\", unexpectedExceptions );\n        xml.writeAttribute( \"failures\", stats.totals.assertions.failed-unexpectedExceptions );\n        xml.writeAttribute( \"tests\", stats.totals.assertions.total() );\n        xml.writeAttribute( \"hostname\", \"tbd\" ); // !TBD\n        if( m_config->showDurations() == ShowDurations::Never )\n            xml.writeAttribute( \"time\", \"\" );\n        else\n            xml.writeAttribute( \"time\", suiteTime );\n        xml.writeAttribute( \"timestamp\", getCurrentTimestamp() );\n\n        // Write test cases\n        for( auto const& child : groupNode.children )\n            writeTestCase( *child );\n\n        xml.scopedElement( \"system-out\" ).writeText( trim( stdOutForSuite ), false );\n        xml.scopedElement( \"system-err\" ).writeText( trim( stdErrForSuite ), false );\n    }\n\n    void JunitReporter::writeTestCase( TestCaseNode const& testCaseNode ) {\n        TestCaseStats const& stats = testCaseNode.value;\n\n        // All test cases have exactly one section - which represents the\n        // test case itself. That section may have 0-n nested sections\n        assert( testCaseNode.children.size() == 1 );\n        SectionNode const& rootSection = *testCaseNode.children.front();\n\n        std::string className = stats.testInfo.className;\n\n        if( className.empty() ) {\n            className = fileNameTag(stats.testInfo.tags);\n            if ( className.empty() )\n                className = \"global\";\n        }\n\n        if ( !m_config->name().empty() )\n            className = m_config->name() + \".\" + className;\n\n        writeSection( className, \"\", rootSection );\n    }\n\n    void JunitReporter::writeSection(  std::string const& className,\n                        std::string const& rootName,\n                        SectionNode const& sectionNode ) {\n        std::string name = trim( sectionNode.stats.sectionInfo.name );\n        if( !rootName.empty() )\n            name = rootName + '/' + name;\n\n        if( !sectionNode.assertions.empty() ||\n            !sectionNode.stdOut.empty() ||\n            !sectionNode.stdErr.empty() ) {\n            XmlWriter::ScopedElement e = xml.scopedElement( \"testcase\" );\n            if( className.empty() ) {\n                xml.writeAttribute( \"classname\", name );\n                xml.writeAttribute( \"name\", \"root\" );\n            }\n            else {\n                xml.writeAttribute( \"classname\", className );\n                xml.writeAttribute( \"name\", name );\n            }\n            xml.writeAttribute( \"time\", ::Catch::Detail::stringify( sectionNode.stats.durationInSeconds ) );\n\n            writeAssertions( sectionNode );\n\n            if( !sectionNode.stdOut.empty() )\n                xml.scopedElement( \"system-out\" ).writeText( trim( sectionNode.stdOut ), false );\n            if( !sectionNode.stdErr.empty() )\n                xml.scopedElement( \"system-err\" ).writeText( trim( sectionNode.stdErr ), false );\n        }\n        for( auto const& childNode : sectionNode.childSections )\n            if( className.empty() )\n                writeSection( name, \"\", *childNode );\n            else\n                writeSection( className, name, *childNode );\n    }\n\n    void JunitReporter::writeAssertions( SectionNode const& sectionNode ) {\n        for( auto const& assertion : sectionNode.assertions )\n            writeAssertion( assertion );\n    }\n\n    void JunitReporter::writeAssertion( AssertionStats const& stats ) {\n        AssertionResult const& result = stats.assertionResult;\n        if( !result.isOk() ) {\n            std::string elementName;\n            switch( result.getResultType() ) {\n                case ResultWas::ThrewException:\n                case ResultWas::FatalErrorCondition:\n                    elementName = \"error\";\n                    break;\n                case ResultWas::ExplicitFailure:\n                    elementName = \"failure\";\n                    break;\n                case ResultWas::ExpressionFailed:\n                    elementName = \"failure\";\n                    break;\n                case ResultWas::DidntThrowException:\n                    elementName = \"failure\";\n                    break;\n\n                // We should never see these here:\n                case ResultWas::Info:\n                case ResultWas::Warning:\n                case ResultWas::Ok:\n                case ResultWas::Unknown:\n                case ResultWas::FailureBit:\n                case ResultWas::Exception:\n                    elementName = \"internalError\";\n                    break;\n            }\n\n            XmlWriter::ScopedElement e = xml.scopedElement( elementName );\n\n            xml.writeAttribute( \"message\", result.getExpandedExpression() );\n            xml.writeAttribute( \"type\", result.getTestMacroName() );\n\n            ReusableStringStream rss;\n            if( !result.getMessage().empty() )\n                rss << result.getMessage() << '\\n';\n            for( auto const& msg : stats.infoMessages )\n                if( msg.type == ResultWas::Info )\n                    rss << msg.message << '\\n';\n\n            rss << \"at \" << result.getSourceInfo();\n            xml.writeText( rss.str(), false );\n        }\n    }\n\n    CATCH_REGISTER_REPORTER( \"junit\", JunitReporter )\n\n} // end namespace Catch\n// end catch_reporter_junit.cpp\n// start catch_reporter_listening.cpp\n\n#include <cassert>\n\nnamespace Catch {\n\n    ListeningReporter::ListeningReporter() {\n        // We will assume that listeners will always want all assertions\n        m_preferences.shouldReportAllAssertions = true;\n    }\n\n    void ListeningReporter::addListener( IStreamingReporterPtr&& listener ) {\n        m_listeners.push_back( std::move( listener ) );\n    }\n\n    void ListeningReporter::addReporter(IStreamingReporterPtr&& reporter) {\n        assert(!m_reporter && \"Listening reporter can wrap only 1 real reporter\");\n        m_reporter = std::move( reporter );\n        m_preferences.shouldRedirectStdOut = m_reporter->getPreferences().shouldRedirectStdOut;\n    }\n\n    ReporterPreferences ListeningReporter::getPreferences() const {\n        return m_preferences;\n    }\n\n    std::set<Verbosity> ListeningReporter::getSupportedVerbosities() {\n        return std::set<Verbosity>{ };\n    }\n\n    void ListeningReporter::noMatchingTestCases( std::string const& spec ) {\n        for ( auto const& listener : m_listeners ) {\n            listener->noMatchingTestCases( spec );\n        }\n        m_reporter->noMatchingTestCases( spec );\n    }\n\n    void ListeningReporter::benchmarkStarting( BenchmarkInfo const& benchmarkInfo ) {\n        for ( auto const& listener : m_listeners ) {\n            listener->benchmarkStarting( benchmarkInfo );\n        }\n        m_reporter->benchmarkStarting( benchmarkInfo );\n    }\n    void ListeningReporter::benchmarkEnded( BenchmarkStats const& benchmarkStats ) {\n        for ( auto const& listener : m_listeners ) {\n            listener->benchmarkEnded( benchmarkStats );\n        }\n        m_reporter->benchmarkEnded( benchmarkStats );\n    }\n\n    void ListeningReporter::testRunStarting( TestRunInfo const& testRunInfo ) {\n        for ( auto const& listener : m_listeners ) {\n            listener->testRunStarting( testRunInfo );\n        }\n        m_reporter->testRunStarting( testRunInfo );\n    }\n\n    void ListeningReporter::testGroupStarting( GroupInfo const& groupInfo ) {\n        for ( auto const& listener : m_listeners ) {\n            listener->testGroupStarting( groupInfo );\n        }\n        m_reporter->testGroupStarting( groupInfo );\n    }\n\n    void ListeningReporter::testCaseStarting( TestCaseInfo const& testInfo ) {\n        for ( auto const& listener : m_listeners ) {\n            listener->testCaseStarting( testInfo );\n        }\n        m_reporter->testCaseStarting( testInfo );\n    }\n\n    void ListeningReporter::sectionStarting( SectionInfo const& sectionInfo ) {\n        for ( auto const& listener : m_listeners ) {\n            listener->sectionStarting( sectionInfo );\n        }\n        m_reporter->sectionStarting( sectionInfo );\n    }\n\n    void ListeningReporter::assertionStarting( AssertionInfo const& assertionInfo ) {\n        for ( auto const& listener : m_listeners ) {\n            listener->assertionStarting( assertionInfo );\n        }\n        m_reporter->assertionStarting( assertionInfo );\n    }\n\n    // The return value indicates if the messages buffer should be cleared:\n    bool ListeningReporter::assertionEnded( AssertionStats const& assertionStats ) {\n        for( auto const& listener : m_listeners ) {\n            static_cast<void>( listener->assertionEnded( assertionStats ) );\n        }\n        return m_reporter->assertionEnded( assertionStats );\n    }\n\n    void ListeningReporter::sectionEnded( SectionStats const& sectionStats ) {\n        for ( auto const& listener : m_listeners ) {\n            listener->sectionEnded( sectionStats );\n        }\n        m_reporter->sectionEnded( sectionStats );\n    }\n\n    void ListeningReporter::testCaseEnded( TestCaseStats const& testCaseStats ) {\n        for ( auto const& listener : m_listeners ) {\n            listener->testCaseEnded( testCaseStats );\n        }\n        m_reporter->testCaseEnded( testCaseStats );\n    }\n\n    void ListeningReporter::testGroupEnded( TestGroupStats const& testGroupStats ) {\n        for ( auto const& listener : m_listeners ) {\n            listener->testGroupEnded( testGroupStats );\n        }\n        m_reporter->testGroupEnded( testGroupStats );\n    }\n\n    void ListeningReporter::testRunEnded( TestRunStats const& testRunStats ) {\n        for ( auto const& listener : m_listeners ) {\n            listener->testRunEnded( testRunStats );\n        }\n        m_reporter->testRunEnded( testRunStats );\n    }\n\n    void ListeningReporter::skipTest( TestCaseInfo const& testInfo ) {\n        for ( auto const& listener : m_listeners ) {\n            listener->skipTest( testInfo );\n        }\n        m_reporter->skipTest( testInfo );\n    }\n\n    bool ListeningReporter::isMulti() const {\n        return true;\n    }\n\n} // end namespace Catch\n// end catch_reporter_listening.cpp\n// start catch_reporter_xml.cpp\n\n#if defined(_MSC_VER)\n#pragma warning(push)\n#pragma warning(disable:4061) // Not all labels are EXPLICITLY handled in switch\n                              // Note that 4062 (not all labels are handled\n                              // and default is missing) is enabled\n#endif\n\nnamespace Catch {\n    XmlReporter::XmlReporter( ReporterConfig const& _config )\n    :   StreamingReporterBase( _config ),\n        m_xml(_config.stream())\n    {\n        m_reporterPrefs.shouldRedirectStdOut = true;\n        m_reporterPrefs.shouldReportAllAssertions = true;\n    }\n\n    XmlReporter::~XmlReporter() = default;\n\n    std::string XmlReporter::getDescription() {\n        return \"Reports test results as an XML document\";\n    }\n\n    std::string XmlReporter::getStylesheetRef() const {\n        return std::string();\n    }\n\n    void XmlReporter::writeSourceInfo( SourceLineInfo const& sourceInfo ) {\n        m_xml\n            .writeAttribute( \"filename\", sourceInfo.file )\n            .writeAttribute( \"line\", sourceInfo.line );\n    }\n\n    void XmlReporter::noMatchingTestCases( std::string const& s ) {\n        StreamingReporterBase::noMatchingTestCases( s );\n    }\n\n    void XmlReporter::testRunStarting( TestRunInfo const& testInfo ) {\n        StreamingReporterBase::testRunStarting( testInfo );\n        std::string stylesheetRef = getStylesheetRef();\n        if( !stylesheetRef.empty() )\n            m_xml.writeStylesheetRef( stylesheetRef );\n        m_xml.startElement( \"Catch\" );\n        if( !m_config->name().empty() )\n            m_xml.writeAttribute( \"name\", m_config->name() );\n        if( m_config->rngSeed() != 0 )\n            m_xml.scopedElement( \"Randomness\" )\n                .writeAttribute( \"seed\", m_config->rngSeed() );\n    }\n\n    void XmlReporter::testGroupStarting( GroupInfo const& groupInfo ) {\n        StreamingReporterBase::testGroupStarting( groupInfo );\n        m_xml.startElement( \"Group\" )\n            .writeAttribute( \"name\", groupInfo.name );\n    }\n\n    void XmlReporter::testCaseStarting( TestCaseInfo const& testInfo ) {\n        StreamingReporterBase::testCaseStarting(testInfo);\n        m_xml.startElement( \"TestCase\" )\n            .writeAttribute( \"name\", trim( testInfo.name ) )\n            .writeAttribute( \"description\", testInfo.description )\n            .writeAttribute( \"tags\", testInfo.tagsAsString() );\n\n        writeSourceInfo( testInfo.lineInfo );\n\n        if ( m_config->showDurations() == ShowDurations::Always )\n            m_testCaseTimer.start();\n        m_xml.ensureTagClosed();\n    }\n\n    void XmlReporter::sectionStarting( SectionInfo const& sectionInfo ) {\n        StreamingReporterBase::sectionStarting( sectionInfo );\n        if( m_sectionDepth++ > 0 ) {\n            m_xml.startElement( \"Section\" )\n                .writeAttribute( \"name\", trim( sectionInfo.name ) );\n            writeSourceInfo( sectionInfo.lineInfo );\n            m_xml.ensureTagClosed();\n        }\n    }\n\n    void XmlReporter::assertionStarting( AssertionInfo const& ) { }\n\n    bool XmlReporter::assertionEnded( AssertionStats const& assertionStats ) {\n\n        AssertionResult const& result = assertionStats.assertionResult;\n\n        bool includeResults = m_config->includeSuccessfulResults() || !result.isOk();\n\n        if( includeResults || result.getResultType() == ResultWas::Warning ) {\n            // Print any info messages in <Info> tags.\n            for( auto const& msg : assertionStats.infoMessages ) {\n                if( msg.type == ResultWas::Info && includeResults ) {\n                    m_xml.scopedElement( \"Info\" )\n                            .writeText( msg.message );\n                } else if ( msg.type == ResultWas::Warning ) {\n                    m_xml.scopedElement( \"Warning\" )\n                            .writeText( msg.message );\n                }\n            }\n        }\n\n        // Drop out if result was successful but we're not printing them.\n        if( !includeResults && result.getResultType() != ResultWas::Warning )\n            return true;\n\n        // Print the expression if there is one.\n        if( result.hasExpression() ) {\n            m_xml.startElement( \"Expression\" )\n                .writeAttribute( \"success\", result.succeeded() )\n                .writeAttribute( \"type\", result.getTestMacroName() );\n\n            writeSourceInfo( result.getSourceInfo() );\n\n            m_xml.scopedElement( \"Original\" )\n                .writeText( result.getExpression() );\n            m_xml.scopedElement( \"Expanded\" )\n                .writeText( result.getExpandedExpression() );\n        }\n\n        // And... Print a result applicable to each result type.\n        switch( result.getResultType() ) {\n            case ResultWas::ThrewException:\n                m_xml.startElement( \"Exception\" );\n                writeSourceInfo( result.getSourceInfo() );\n                m_xml.writeText( result.getMessage() );\n                m_xml.endElement();\n                break;\n            case ResultWas::FatalErrorCondition:\n                m_xml.startElement( \"FatalErrorCondition\" );\n                writeSourceInfo( result.getSourceInfo() );\n                m_xml.writeText( result.getMessage() );\n                m_xml.endElement();\n                break;\n            case ResultWas::Info:\n                m_xml.scopedElement( \"Info\" )\n                    .writeText( result.getMessage() );\n                break;\n            case ResultWas::Warning:\n                // Warning will already have been written\n                break;\n            case ResultWas::ExplicitFailure:\n                m_xml.startElement( \"Failure\" );\n                writeSourceInfo( result.getSourceInfo() );\n                m_xml.writeText( result.getMessage() );\n                m_xml.endElement();\n                break;\n            default:\n                break;\n        }\n\n        if( result.hasExpression() )\n            m_xml.endElement();\n\n        return true;\n    }\n\n    void XmlReporter::sectionEnded( SectionStats const& sectionStats ) {\n        StreamingReporterBase::sectionEnded( sectionStats );\n        if( --m_sectionDepth > 0 ) {\n            XmlWriter::ScopedElement e = m_xml.scopedElement( \"OverallResults\" );\n            e.writeAttribute( \"successes\", sectionStats.assertions.passed );\n            e.writeAttribute( \"failures\", sectionStats.assertions.failed );\n            e.writeAttribute( \"expectedFailures\", sectionStats.assertions.failedButOk );\n\n            if ( m_config->showDurations() == ShowDurations::Always )\n                e.writeAttribute( \"durationInSeconds\", sectionStats.durationInSeconds );\n\n            m_xml.endElement();\n        }\n    }\n\n    void XmlReporter::testCaseEnded( TestCaseStats const& testCaseStats ) {\n        StreamingReporterBase::testCaseEnded( testCaseStats );\n        XmlWriter::ScopedElement e = m_xml.scopedElement( \"OverallResult\" );\n        e.writeAttribute( \"success\", testCaseStats.totals.assertions.allOk() );\n\n        if ( m_config->showDurations() == ShowDurations::Always )\n            e.writeAttribute( \"durationInSeconds\", m_testCaseTimer.getElapsedSeconds() );\n\n        if( !testCaseStats.stdOut.empty() )\n            m_xml.scopedElement( \"StdOut\" ).writeText( trim( testCaseStats.stdOut ), false );\n        if( !testCaseStats.stdErr.empty() )\n            m_xml.scopedElement( \"StdErr\" ).writeText( trim( testCaseStats.stdErr ), false );\n\n        m_xml.endElement();\n    }\n\n    void XmlReporter::testGroupEnded( TestGroupStats const& testGroupStats ) {\n        StreamingReporterBase::testGroupEnded( testGroupStats );\n        // TODO: Check testGroupStats.aborting and act accordingly.\n        m_xml.scopedElement( \"OverallResults\" )\n            .writeAttribute( \"successes\", testGroupStats.totals.assertions.passed )\n            .writeAttribute( \"failures\", testGroupStats.totals.assertions.failed )\n            .writeAttribute( \"expectedFailures\", testGroupStats.totals.assertions.failedButOk );\n        m_xml.endElement();\n    }\n\n    void XmlReporter::testRunEnded( TestRunStats const& testRunStats ) {\n        StreamingReporterBase::testRunEnded( testRunStats );\n        m_xml.scopedElement( \"OverallResults\" )\n            .writeAttribute( \"successes\", testRunStats.totals.assertions.passed )\n            .writeAttribute( \"failures\", testRunStats.totals.assertions.failed )\n            .writeAttribute( \"expectedFailures\", testRunStats.totals.assertions.failedButOk );\n        m_xml.endElement();\n    }\n\n    CATCH_REGISTER_REPORTER( \"xml\", XmlReporter )\n\n} // end namespace Catch\n\n#if defined(_MSC_VER)\n#pragma warning(pop)\n#endif\n// end catch_reporter_xml.cpp\n\nnamespace Catch {\n    LeakDetector leakDetector;\n}\n\n#ifdef __clang__\n#pragma clang diagnostic pop\n#endif\n\n// end catch_impl.hpp\n#endif\n\n#ifdef CATCH_CONFIG_MAIN\n// start catch_default_main.hpp\n\n#ifndef __OBJC__\n\n#if defined(CATCH_CONFIG_WCHAR) && defined(WIN32) && defined(_UNICODE) && !defined(DO_NOT_USE_WMAIN)\n// Standard C/C++ Win32 Unicode wmain entry point\nextern \"C\" int wmain (int argc, wchar_t * argv[], wchar_t * []) {\n#else\n// Standard C/C++ main entry point\nint main (int argc, char * argv[]) {\n#endif\n\n    return Catch::Session().run( argc, argv );\n}\n\n#else // __OBJC__\n\n// Objective-C entry point\nint main (int argc, char * const argv[]) {\n#if !CATCH_ARC_ENABLED\n    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];\n#endif\n\n    Catch::registerTestMethods();\n    int result = Catch::Session().run( argc, (char**)argv );\n\n#if !CATCH_ARC_ENABLED\n    [pool drain];\n#endif\n\n    return result;\n}\n\n#endif // __OBJC__\n\n// end catch_default_main.hpp\n#endif\n\n#if !defined(CATCH_CONFIG_IMPL_ONLY)\n\n#ifdef CLARA_CONFIG_MAIN_NOT_DEFINED\n#  undef CLARA_CONFIG_MAIN\n#endif\n\n#if !defined(CATCH_CONFIG_DISABLE)\n//////\n// If this config identifier is defined then all CATCH macros are prefixed with CATCH_\n#ifdef CATCH_CONFIG_PREFIX_ALL\n\n#define CATCH_REQUIRE( ... ) INTERNAL_CATCH_TEST( \"CATCH_REQUIRE\", Catch::ResultDisposition::Normal, __VA_ARGS__ )\n#define CATCH_REQUIRE_FALSE( ... ) INTERNAL_CATCH_TEST( \"CATCH_REQUIRE_FALSE\", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, __VA_ARGS__ )\n\n#define CATCH_REQUIRE_THROWS( ... ) INTERNAL_CATCH_THROWS( \"CATCH_REQUIRE_THROWS\", Catch::ResultDisposition::Normal, \"\", __VA_ARGS__ )\n#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( \"CATCH_REQUIRE_THROWS_AS\", exceptionType, Catch::ResultDisposition::Normal, expr )\n#define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( \"CATCH_REQUIRE_THROWS_WITH\", Catch::ResultDisposition::Normal, matcher, expr )\n#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)\n#define CATCH_REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( \"CATCH_REQUIRE_THROWS_MATCHES\", exceptionType, Catch::ResultDisposition::Normal, matcher, expr )\n#endif// CATCH_CONFIG_DISABLE_MATCHERS\n#define CATCH_REQUIRE_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( \"CATCH_REQUIRE_NOTHROW\", Catch::ResultDisposition::Normal, __VA_ARGS__ )\n\n#define CATCH_CHECK( ... ) INTERNAL_CATCH_TEST( \"CATCH_CHECK\", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )\n#define CATCH_CHECK_FALSE( ... ) INTERNAL_CATCH_TEST( \"CATCH_CHECK_FALSE\", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, __VA_ARGS__ )\n#define CATCH_CHECKED_IF( ... ) INTERNAL_CATCH_IF( \"CATCH_CHECKED_IF\", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )\n#define CATCH_CHECKED_ELSE( ... ) INTERNAL_CATCH_ELSE( \"CATCH_CHECKED_ELSE\", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )\n#define CATCH_CHECK_NOFAIL( ... ) INTERNAL_CATCH_TEST( \"CATCH_CHECK_NOFAIL\", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ )\n\n#define CATCH_CHECK_THROWS( ... )  INTERNAL_CATCH_THROWS( \"CATCH_CHECK_THROWS\", Catch::ResultDisposition::ContinueOnFailure, \"\", __VA_ARGS__ )\n#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( \"CATCH_CHECK_THROWS_AS\", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr )\n#define CATCH_CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( \"CATCH_CHECK_THROWS_WITH\", Catch::ResultDisposition::ContinueOnFailure, matcher, expr )\n#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)\n#define CATCH_CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( \"CATCH_CHECK_THROWS_MATCHES\", exceptionType, Catch::ResultDisposition::ContinueOnFailure, matcher, expr )\n#endif // CATCH_CONFIG_DISABLE_MATCHERS\n#define CATCH_CHECK_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( \"CATCH_CHECK_NOTHROW\", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )\n\n#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)\n#define CATCH_CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( \"CATCH_CHECK_THAT\", matcher, Catch::ResultDisposition::ContinueOnFailure, arg )\n\n#define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( \"CATCH_REQUIRE_THAT\", matcher, Catch::ResultDisposition::Normal, arg )\n#endif // CATCH_CONFIG_DISABLE_MATCHERS\n\n#define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( \"CATCH_INFO\", msg )\n#define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( \"CATCH_WARN\", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg )\n#define CATCH_CAPTURE( ... ) INTERNAL_CATCH_CAPTURE( INTERNAL_CATCH_UNIQUE_NAME(capturer), \"CATCH_CAPTURE\",__VA_ARGS__ )\n\n#define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )\n#define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ )\n#define CATCH_METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ )\n#define CATCH_REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ )\n#define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )\n#define CATCH_DYNAMIC_SECTION( ... ) INTERNAL_CATCH_DYNAMIC_SECTION( __VA_ARGS__ )\n#define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( \"CATCH_FAIL\", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ )\n#define CATCH_FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( \"CATCH_FAIL_CHECK\", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )\n#define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( \"CATCH_SUCCEED\", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )\n\n#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE()\n\n#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR\n#define CATCH_TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ )\n#define CATCH_TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ )\n#else\n#define CATCH_TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) )\n#define CATCH_TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) )\n#endif\n\n#if !defined(CATCH_CONFIG_RUNTIME_STATIC_REQUIRE)\n#define CATCH_STATIC_REQUIRE( ... )       static_assert(   __VA_ARGS__ ,      #__VA_ARGS__ );     CATCH_SUCCEED( #__VA_ARGS__ )\n#define CATCH_STATIC_REQUIRE_FALSE( ... ) static_assert( !(__VA_ARGS__), \"!(\" #__VA_ARGS__ \")\" ); CATCH_SUCCEED( #__VA_ARGS__ )\n#else\n#define CATCH_STATIC_REQUIRE( ... )       CATCH_REQUIRE( __VA_ARGS__ )\n#define CATCH_STATIC_REQUIRE_FALSE( ... ) CATCH_REQUIRE_FALSE( __VA_ARGS__ )\n#endif\n\n// \"BDD-style\" convenience wrappers\n#define CATCH_SCENARIO( ... ) CATCH_TEST_CASE( \"Scenario: \" __VA_ARGS__ )\n#define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, \"Scenario: \" __VA_ARGS__ )\n#define CATCH_GIVEN( desc )     INTERNAL_CATCH_DYNAMIC_SECTION( \"    Given: \" << desc )\n#define CATCH_AND_GIVEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( \"And given: \" << desc )\n#define CATCH_WHEN( desc )      INTERNAL_CATCH_DYNAMIC_SECTION( \"     When: \" << desc )\n#define CATCH_AND_WHEN( desc )  INTERNAL_CATCH_DYNAMIC_SECTION( \" And when: \" << desc )\n#define CATCH_THEN( desc )      INTERNAL_CATCH_DYNAMIC_SECTION( \"     Then: \" << desc )\n#define CATCH_AND_THEN( desc )  INTERNAL_CATCH_DYNAMIC_SECTION( \"      And: \" << desc )\n\n// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required\n#else\n\n#define REQUIRE( ... ) INTERNAL_CATCH_TEST( \"REQUIRE\", Catch::ResultDisposition::Normal, __VA_ARGS__  )\n#define REQUIRE_FALSE( ... ) INTERNAL_CATCH_TEST( \"REQUIRE_FALSE\", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, __VA_ARGS__ )\n\n#define REQUIRE_THROWS( ... ) INTERNAL_CATCH_THROWS( \"REQUIRE_THROWS\", Catch::ResultDisposition::Normal, __VA_ARGS__ )\n#define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( \"REQUIRE_THROWS_AS\", exceptionType, Catch::ResultDisposition::Normal, expr )\n#define REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( \"REQUIRE_THROWS_WITH\", Catch::ResultDisposition::Normal, matcher, expr )\n#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)\n#define REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( \"REQUIRE_THROWS_MATCHES\", exceptionType, Catch::ResultDisposition::Normal, matcher, expr )\n#endif // CATCH_CONFIG_DISABLE_MATCHERS\n#define REQUIRE_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( \"REQUIRE_NOTHROW\", Catch::ResultDisposition::Normal, __VA_ARGS__ )\n\n#define CHECK( ... ) INTERNAL_CATCH_TEST( \"CHECK\", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )\n#define CHECK_FALSE( ... ) INTERNAL_CATCH_TEST( \"CHECK_FALSE\", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, __VA_ARGS__ )\n#define CHECKED_IF( ... ) INTERNAL_CATCH_IF( \"CHECKED_IF\", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )\n#define CHECKED_ELSE( ... ) INTERNAL_CATCH_ELSE( \"CHECKED_ELSE\", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )\n#define CHECK_NOFAIL( ... ) INTERNAL_CATCH_TEST( \"CHECK_NOFAIL\", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, __VA_ARGS__ )\n\n#define CHECK_THROWS( ... )  INTERNAL_CATCH_THROWS( \"CHECK_THROWS\", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )\n#define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( \"CHECK_THROWS_AS\", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr )\n#define CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS_STR_MATCHES( \"CHECK_THROWS_WITH\", Catch::ResultDisposition::ContinueOnFailure, matcher, expr )\n#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)\n#define CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) INTERNAL_CATCH_THROWS_MATCHES( \"CHECK_THROWS_MATCHES\", exceptionType, Catch::ResultDisposition::ContinueOnFailure, matcher, expr )\n#endif // CATCH_CONFIG_DISABLE_MATCHERS\n#define CHECK_NOTHROW( ... ) INTERNAL_CATCH_NO_THROW( \"CHECK_NOTHROW\", Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )\n\n#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)\n#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( \"CHECK_THAT\", matcher, Catch::ResultDisposition::ContinueOnFailure, arg )\n\n#define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( \"REQUIRE_THAT\", matcher, Catch::ResultDisposition::Normal, arg )\n#endif // CATCH_CONFIG_DISABLE_MATCHERS\n\n#define INFO( msg ) INTERNAL_CATCH_INFO( \"INFO\", msg )\n#define WARN( msg ) INTERNAL_CATCH_MSG( \"WARN\", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg )\n#define CAPTURE( ... ) INTERNAL_CATCH_CAPTURE( INTERNAL_CATCH_UNIQUE_NAME(capturer), \"CAPTURE\",__VA_ARGS__ )\n\n#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ )\n#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ )\n#define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ )\n#define REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ )\n#define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ )\n#define DYNAMIC_SECTION( ... ) INTERNAL_CATCH_DYNAMIC_SECTION( __VA_ARGS__ )\n#define FAIL( ... ) INTERNAL_CATCH_MSG( \"FAIL\", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ )\n#define FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( \"FAIL_CHECK\", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )\n#define SUCCEED( ... ) INTERNAL_CATCH_MSG( \"SUCCEED\", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ )\n#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE()\n\n#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR\n#define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ )\n#define TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ )\n#else\n#define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE( __VA_ARGS__ ) )\n#define TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD( className, __VA_ARGS__ ) )\n#endif\n\n#if !defined(CATCH_CONFIG_RUNTIME_STATIC_REQUIRE)\n#define STATIC_REQUIRE( ... )       static_assert(   __VA_ARGS__,  #__VA_ARGS__ ); SUCCEED( #__VA_ARGS__ )\n#define STATIC_REQUIRE_FALSE( ... ) static_assert( !(__VA_ARGS__), \"!(\" #__VA_ARGS__ \")\" ); SUCCEED( \"!(\" #__VA_ARGS__ \")\" )\n#else\n#define STATIC_REQUIRE( ... )       REQUIRE( __VA_ARGS__ )\n#define STATIC_REQUIRE_FALSE( ... ) REQUIRE_FALSE( __VA_ARGS__ )\n#endif\n\n#endif\n\n#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature )\n\n// \"BDD-style\" convenience wrappers\n#define SCENARIO( ... ) TEST_CASE( \"Scenario: \" __VA_ARGS__ )\n#define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, \"Scenario: \" __VA_ARGS__ )\n\n#define GIVEN( desc )     INTERNAL_CATCH_DYNAMIC_SECTION( \"    Given: \" << desc )\n#define AND_GIVEN( desc ) INTERNAL_CATCH_DYNAMIC_SECTION( \"And given: \" << desc )\n#define WHEN( desc )      INTERNAL_CATCH_DYNAMIC_SECTION( \"     When: \" << desc )\n#define AND_WHEN( desc )  INTERNAL_CATCH_DYNAMIC_SECTION( \" And when: \" << desc )\n#define THEN( desc )      INTERNAL_CATCH_DYNAMIC_SECTION( \"     Then: \" << desc )\n#define AND_THEN( desc )  INTERNAL_CATCH_DYNAMIC_SECTION( \"      And: \" << desc )\n\nusing Catch::Detail::Approx;\n\n#else // CATCH_CONFIG_DISABLE\n\n//////\n// If this config identifier is defined then all CATCH macros are prefixed with CATCH_\n#ifdef CATCH_CONFIG_PREFIX_ALL\n\n#define CATCH_REQUIRE( ... )        (void)(0)\n#define CATCH_REQUIRE_FALSE( ... )  (void)(0)\n\n#define CATCH_REQUIRE_THROWS( ... ) (void)(0)\n#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) (void)(0)\n#define CATCH_REQUIRE_THROWS_WITH( expr, matcher )     (void)(0)\n#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)\n#define CATCH_REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0)\n#endif// CATCH_CONFIG_DISABLE_MATCHERS\n#define CATCH_REQUIRE_NOTHROW( ... ) (void)(0)\n\n#define CATCH_CHECK( ... )         (void)(0)\n#define CATCH_CHECK_FALSE( ... )   (void)(0)\n#define CATCH_CHECKED_IF( ... )    if (__VA_ARGS__)\n#define CATCH_CHECKED_ELSE( ... )  if (!(__VA_ARGS__))\n#define CATCH_CHECK_NOFAIL( ... )  (void)(0)\n\n#define CATCH_CHECK_THROWS( ... )  (void)(0)\n#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) (void)(0)\n#define CATCH_CHECK_THROWS_WITH( expr, matcher )     (void)(0)\n#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)\n#define CATCH_CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0)\n#endif // CATCH_CONFIG_DISABLE_MATCHERS\n#define CATCH_CHECK_NOTHROW( ... ) (void)(0)\n\n#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)\n#define CATCH_CHECK_THAT( arg, matcher )   (void)(0)\n\n#define CATCH_REQUIRE_THAT( arg, matcher ) (void)(0)\n#endif // CATCH_CONFIG_DISABLE_MATCHERS\n\n#define CATCH_INFO( msg )    (void)(0)\n#define CATCH_WARN( msg )    (void)(0)\n#define CATCH_CAPTURE( msg ) (void)(0)\n\n#define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ))\n#define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ))\n#define CATCH_METHOD_AS_TEST_CASE( method, ... )\n#define CATCH_REGISTER_TEST_CASE( Function, ... ) (void)(0)\n#define CATCH_SECTION( ... )\n#define CATCH_DYNAMIC_SECTION( ... )\n#define CATCH_FAIL( ... ) (void)(0)\n#define CATCH_FAIL_CHECK( ... ) (void)(0)\n#define CATCH_SUCCEED( ... ) (void)(0)\n\n#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ))\n\n#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR\n#define CATCH_TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) )\n#define CATCH_TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), className )\n#else\n#define CATCH_TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) ) )\n#define CATCH_TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), className ) )\n#endif\n\n// \"BDD-style\" convenience wrappers\n#define CATCH_SCENARIO( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ))\n#define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), className )\n#define CATCH_GIVEN( desc )\n#define CATCH_AND_GIVEN( desc )\n#define CATCH_WHEN( desc )\n#define CATCH_AND_WHEN( desc )\n#define CATCH_THEN( desc )\n#define CATCH_AND_THEN( desc )\n\n#define CATCH_STATIC_REQUIRE( ... )       (void)(0)\n#define CATCH_STATIC_REQUIRE_FALSE( ... ) (void)(0)\n\n// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required\n#else\n\n#define REQUIRE( ... )       (void)(0)\n#define REQUIRE_FALSE( ... ) (void)(0)\n\n#define REQUIRE_THROWS( ... ) (void)(0)\n#define REQUIRE_THROWS_AS( expr, exceptionType ) (void)(0)\n#define REQUIRE_THROWS_WITH( expr, matcher ) (void)(0)\n#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)\n#define REQUIRE_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0)\n#endif // CATCH_CONFIG_DISABLE_MATCHERS\n#define REQUIRE_NOTHROW( ... ) (void)(0)\n\n#define CHECK( ... ) (void)(0)\n#define CHECK_FALSE( ... ) (void)(0)\n#define CHECKED_IF( ... ) if (__VA_ARGS__)\n#define CHECKED_ELSE( ... ) if (!(__VA_ARGS__))\n#define CHECK_NOFAIL( ... ) (void)(0)\n\n#define CHECK_THROWS( ... )  (void)(0)\n#define CHECK_THROWS_AS( expr, exceptionType ) (void)(0)\n#define CHECK_THROWS_WITH( expr, matcher ) (void)(0)\n#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)\n#define CHECK_THROWS_MATCHES( expr, exceptionType, matcher ) (void)(0)\n#endif // CATCH_CONFIG_DISABLE_MATCHERS\n#define CHECK_NOTHROW( ... ) (void)(0)\n\n#if !defined(CATCH_CONFIG_DISABLE_MATCHERS)\n#define CHECK_THAT( arg, matcher ) (void)(0)\n\n#define REQUIRE_THAT( arg, matcher ) (void)(0)\n#endif // CATCH_CONFIG_DISABLE_MATCHERS\n\n#define INFO( msg ) (void)(0)\n#define WARN( msg ) (void)(0)\n#define CAPTURE( msg ) (void)(0)\n\n#define TEST_CASE( ... )  INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ))\n#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ))\n#define METHOD_AS_TEST_CASE( method, ... )\n#define REGISTER_TEST_CASE( Function, ... ) (void)(0)\n#define SECTION( ... )\n#define DYNAMIC_SECTION( ... )\n#define FAIL( ... ) (void)(0)\n#define FAIL_CHECK( ... ) (void)(0)\n#define SUCCEED( ... ) (void)(0)\n#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ))\n\n#ifndef CATCH_CONFIG_TRADITIONAL_MSVC_PREPROCESSOR\n#define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) )\n#define TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), className )\n#else\n#define TEMPLATE_TEST_CASE( ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ) ) )\n#define TEMPLATE_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_EXPAND_VARGS( INTERNAL_CATCH_TEMPLATE_TEST_CASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_M_P_L_A_T_E____T_E_S_T____ ), className ) )\n#endif\n\n#define STATIC_REQUIRE( ... )       (void)(0)\n#define STATIC_REQUIRE_FALSE( ... ) (void)(0)\n\n#endif\n\n#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION_NO_REG( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature )\n\n// \"BDD-style\" convenience wrappers\n#define SCENARIO( ... ) INTERNAL_CATCH_TESTCASE_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ) )\n#define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TESTCASE_METHOD_NO_REGISTRATION(INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), className )\n\n#define GIVEN( desc )\n#define AND_GIVEN( desc )\n#define WHEN( desc )\n#define AND_WHEN( desc )\n#define THEN( desc )\n#define AND_THEN( desc )\n\nusing Catch::Detail::Approx;\n\n#endif\n\n#endif // ! CATCH_CONFIG_IMPL_ONLY\n\n// start catch_reenable_warnings.h\n\n\n#ifdef __clang__\n#    ifdef __ICC // icpc defines the __clang__ macro\n#        pragma warning(pop)\n#    else\n#        pragma clang diagnostic pop\n#    endif\n#elif defined __GNUC__\n#    pragma GCC diagnostic pop\n#endif\n\n// end catch_reenable_warnings.h\n// end catch.hpp\n#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED\n\n"
  },
  {
    "path": "05-unit-testing/catch2-vendored/CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 3.5)\n\n# Set the project name\nproject (catch2_unit_test)\n\n\nset(CMAKE_CXX_STANDARD 11)\n\n# add the CMakeFile that defines catch2\nadd_subdirectory(3rd_party/catch2)\n\n# Add an library for the example classes\nadd_library(example_unit_test\n    Reverse.cpp\n    Palindrome.cpp\n)\n\n\n#############################################\n# Unit tests\n\n# enable CTest testing\nenable_testing()\n\n# Add a testing executable\nadd_executable(unit_tests unit_tests.cpp)\n\ntarget_link_libraries(unit_tests\n    example_unit_test\n    Catch2::Test\n)\n\nadd_test(test_all unit_tests)\n"
  },
  {
    "path": "05-unit-testing/catch2-vendored/Palindrome.cpp",
    "content": "#include \"Palindrome.h\"\n\nbool Palindrome::isPalindrome(const std::string& toCheck)\n{\n\n    if (toCheck == std::string(toCheck.rbegin(), toCheck.rend())) {\n        return true;\n    }\n\n    return false;\n}\n"
  },
  {
    "path": "05-unit-testing/catch2-vendored/Palindrome.h",
    "content": "#ifndef __PALINDROME_H__\n#define __PALINDROME_H__\n\n#include <string>\n\n/**\n * Trivial class to check if a string is a palindrome.\n */\nclass Palindrome\n{\npublic:\n    bool isPalindrome(const std::string& toCheck);\n};\n\n#endif\n"
  },
  {
    "path": "05-unit-testing/catch2-vendored/README.adoc",
    "content": "= Catch2 Unit Testing Framework\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n\n# Introduction\n\nUsing link:https://cmake.org/Wiki/CMake/Testing_With_CTest[CTest] you can generate\na `make test` target to run automated unit-tests. This example shows how to\nfind the https://github.com/catchorg/Catch2[catch2 framework],\ncreate tests and run them.\n\nThe files in this tutorial are below:\n\n```\n$ tree\n.\n├── 3rd_party\n│   └── catch2\n│       ├── catch2\n│       │   └── catch.hpp\n│       └── CMakeLists.txt\n├── CMakeLists.txt\n├── Reverse.h\n├── Reverse.cpp\n├── Palindrome.h\n├── Palindrome.cpp\n├── unit_tests.cpp\n```\n\n  * link:3rd_party/catch2/catch2/catch.hpp[] - Vendored copy of the https://github.com/catchorg/Catch2/blob/v2.5.0/single_include/catch2/catch.hpp[single header version of catch2]\n  * link:3rd_party/catch2/CMakeLists.txt[] - CMake file to make Catch2 available as a library\n  * link:CMakeLists.txt[] - Contains the CMake commands you wish to run\n  * link:Reverse.h[] / link:Reverse.cpp[.cpp] - Class to reverse a string\n  * link:Palindrome.h[] / link:Palindrome.cpp[.cpp] - Class to test if a string is a palindrome\n  * link:unit_test.cpp[] - Unit Tests using catch2 unit test framework\n\n# Requirements\n\nA C++11 compatible compiler\n\n# Concepts\n\n## Vendoring catch2\n\nAs catch2 is available as a single header file I have downloaded it and checked it into my repository. This mean\nthat I don't have any external dependencies when building my project. This is one of the\nhttps://github.com/catchorg/Catch2/blob/master/docs/tutorial.md#getting-catch2[simplest] ways to use Catch2.\n\n## Catch2 Interface Library\n\nThe CMakeLists in the catch2 directory creates an `INTERFACE` library and `ALIAS` library to make it\neasy to add Catch2 to your executable.\n\n[source,cmake]\n----\nadd_library(Catch2 INTERFACE)\nadd_library(Catch2::Test ALIAS Catch2)\ntarget_include_directories(Catch2 INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})\n----\n\n## Build with C++11\n\nAs Catch2 requires C++11 to build, I have used the `CMAKE_CXX_STANDARD` to set C++11. As described\nin earlier examples you can use other methods to set this standard.\n\n## Enabling testing\n\nTo enable testing you must include the following line in your top level CMakeLists.txt\n\n[source,cmake]\n----\nenable_testing()\n----\n\nThis will enable testing for the current folder and all folders below it.\n\n## Adding a testing executable\n\nThe requirement for this step will depend on your unit-test framework. In the example\nof catch2, you can create binary(s) which includes all the unit tests that you want to run.\n\n[source,cmake]\n----\nadd_executable(unit_tests unit_tests.cpp)\n\ntarget_link_libraries(unit_tests\n    example_unit_test\n    Catch2::Test\n)\n----\n\nIn the above code, a unit test binary is added, which links against the catch2 `ALIAS` target created earlier.\n\n## Add A test\n\nTo add a test you call the link:https://cmake.org/cmake/help/v3.0/command/add_test.html[`add_test()`] function.\nThis will create a named test which will run the supplied command.\n\n[source,cmake]\n----\nadd_test(test_all unit_tests)\n----\n\nIn this example, we create a test called `test_all` which will run the executable\ncreated by the `unit_tests` executable created from the call to `add_executable`\n\n# Building the Example\n\n[source,bash]\n----\n$ mkdir build\n\n$ cd build/\n\n$ cmake ..\n-- The C compiler identification is GNU 5.4.0\n-- The CXX compiler identification is GNU 5.4.0\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Detecting C compile features\n-- Detecting C compile features - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Detecting CXX compile features\n-- Detecting CXX compile features - done\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /data/code/cmake-examples/05-unit-testing/catch2-vendored/build\n\n\n$ make\nScanning dependencies of target example_unit_test\n[ 20%] Building CXX object CMakeFiles/example_unit_test.dir/Reverse.cpp.o\n[ 40%] Building CXX object CMakeFiles/example_unit_test.dir/Palindrome.cpp.o\n[ 60%] Linking CXX static library libexample_unit_test.a\n[ 60%] Built target example_unit_test\nScanning dependencies of target unit_tests\n[ 80%] Building CXX object CMakeFiles/unit_tests.dir/unit_tests.cpp.o\n[100%] Linking CXX executable unit_tests\n[100%] Built target unit_tests\n\n\n$ make test\nRunning tests...\nTest project /data/code/cmake-examples/05-unit-testing/catch2-vendored/build\n    Start 1: test_all\n1/1 Test #1: test_all .........................   Passed    0.00 sec\n\n100% tests passed, 0 tests failed out of 1\n\nTotal Test time (real) =   0.00 sec\n----\n\nIf the code is changed and it causes the unit tests to produce an error.\nThen when running the tests you will see the following output.\n\n[source,bash]\n----\nRunning tests...\nTest project /data/code/cmake-examples/05-unit-testing/catch2-vendored/build\n    Start 1: test_all\n1/1 Test #1: test_all .........................***Failed    0.00 sec\n\n0% tests passed, 1 tests failed out of 1\n\nTotal Test time (real) =   0.00 sec\n\nThe following tests FAILED:\n    1 - test_all (Failed)\nErrors while running CTest\nMakefile:61: recipe for target 'test' failed\nmake: *** [test] Error 8\n----\n"
  },
  {
    "path": "05-unit-testing/catch2-vendored/Reverse.cpp",
    "content": "#include \"Reverse.h\"\n\nstd::string Reverse::reverse(std::string& toReverse)\n{\n    std::string ret;\n\n    for(std::string::reverse_iterator rit=toReverse.rbegin(); rit!=toReverse.rend(); ++rit)\n    {\n        ret.insert(ret.end(), *rit);\n    }\n    return ret;\n}\n"
  },
  {
    "path": "05-unit-testing/catch2-vendored/Reverse.h",
    "content": "#ifndef __REVERSE_H__\n#define __REVERSE_H__\n\n#include <string>\n\n/**\n * Trivial class whose only function is to reverse a string.\n * Should use std::reverse instead but want to have example with own class\n */\nclass Reverse\n{\npublic:\n    std::string reverse(std::string& toReverse);\n};\n#endif\n"
  },
  {
    "path": "05-unit-testing/catch2-vendored/main.cpp",
    "content": "#include <iostream>\n#include <boost/shared_ptr.hpp>\n#include <boost/filesystem.hpp>\n\nint main(int argc, char *argv[])\n{\n    std::cout << \"Hello Third Party Include!\" << std::endl;\n\n    // use a shared ptr\n    boost::shared_ptr<int> isp(new int(4));\n\n    // trivial use of boost filesystem\n    boost::filesystem::path path = \"/usr/share/cmake/modules\";\n    if(path.is_relative())\n    {\n        std::cout << \"Path is relative\" << std::endl;\n    }\n    else\n    {\n        std::cout << \"Path is not relative\" << std::endl;\n    }\n\n   return 0;\n}\n"
  },
  {
    "path": "05-unit-testing/catch2-vendored/post_test.sh",
    "content": "#!/bin/bash\n\nmake test\n"
  },
  {
    "path": "05-unit-testing/catch2-vendored/unit_tests.cpp",
    "content": "#include <string>\n#include \"Reverse.h\"\n#include \"Palindrome.h\"\n\n#define CATCH_CONFIG_MAIN\n#include \"catch2/catch.hpp\"\n\n\nTEST_CASE( \"simple\" )\n{\n    std::string toRev = \"Hello\";\n\n    Reverse rev;\n    std::string res = rev.reverse(toRev);\n\n    REQUIRE( res == \"olleH\" );\n}\n\nTEST_CASE( \"empty\" )\n{\n    std::string toRev;\n\n    Reverse rev;\n    std::string res = rev.reverse(toRev);\n\n    REQUIRE( res == \"\" );\n}\n\nTEST_CASE( \"is_palindrome\" )\n{\n    std::string pal = \"mom\";\n    Palindrome pally;\n\n    REQUIRE( pally.isPalindrome(pal) == true );\n\n}\n"
  },
  {
    "path": "05-unit-testing/google-test-download/3rd_party/google-test/CMakeLists.txt",
    "content": "# Download and unpack googletest at configure time\n# See: http://crascit.com/2015/07/25/cmake-gtest/\nconfigure_file(CMakeLists.txt.in googletest-download/CMakeLists.txt)\n# Call CMake to download and Google Test\nexecute_process(COMMAND ${CMAKE_COMMAND} -G \"${CMAKE_GENERATOR}\" .\n  RESULT_VARIABLE result\n  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )\nif(result)\n  message(FATAL_ERROR \"CMake step for googletest failed: ${result}\")\nendif()\n# Build the downloaded google test\nexecute_process(COMMAND ${CMAKE_COMMAND} --build .\n  RESULT_VARIABLE result\n  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/googletest-download )\nif(result)\n  message(FATAL_ERROR \"Build step for googletest failed: ${result}\")\nendif()\n\n# Prevent overriding the parent project's compiler/linker\n# settings on Windows\nset(gtest_force_shared_crt ON CACHE BOOL \"\" FORCE)\n# Prevent installation of GTest with your project\nset(INSTALL_GTEST OFF CACHE BOOL \"\" FORCE)\nset(INSTALL_GMOCK OFF CACHE BOOL \"\" FORCE)\n\n# Add googletest directly to our build. This defines\n# the gtest and gtest_main targets.\nadd_subdirectory(${CMAKE_CURRENT_BINARY_DIR}/googletest-src\n                 ${CMAKE_CURRENT_BINARY_DIR}/googletest-build)\n\n# This is a bit of a hack that can be used to get gtest libraries to build in C++11 if you aren't using CMAKE_CXX_STANDARD\n#\n#set(CXX11_FEATURES\n#    cxx_nullptr\n#    cxx_auto_type\n#    cxx_delegating_constructors\n#)\n#target_compile_features(gtest\n#    PRIVATE\n#        ${CXX11_FEATURES}\n#)\n#\n#target_compile_features(gmock_main\n#    PRIVATE\n#        ${CXX11_FEATURES}\n#)\n#\n#target_compile_features(gmock\n#    PRIVATE\n#        ${CXX11_FEATURES}\n#)\n#\n#target_compile_features(gmock_main\n#    PRIVATE\n#        ${CXX11_FEATURES}\n#)\n\n# Add aliases for GTest and GMock libraries\nif(NOT TARGET GTest::GTest)\n    add_library(GTest::GTest ALIAS gtest)\n    add_library(GTest::Main ALIAS gtest_main)\nendif()\n\nif(NOT TARGET GTest::GMock)\n    add_library(GMock::GMock ALIAS gmock)\n    add_library(GMock::Main ALIAS gmock_main)\nendif()\n\n"
  },
  {
    "path": "05-unit-testing/google-test-download/3rd_party/google-test/CMakeLists.txt.in",
    "content": "cmake_minimum_required(VERSION 3.0)\n\nproject(googletest-download NONE)\n\ninclude(ExternalProject)\n\n# Version bfc0ffc8a698072c794ae7299db9cb6866f4c0bc happens to be master when I set this up.\n# To prevent an issue with accidentally installing GTest / GMock with your project you should use a\n# commit after 9469fb687d040b60c8749b7617fee4e77c7f6409\n# Note: This is after the release of v1.8\nExternalProject_Add(googletest\n  URL               https://github.com/google/googletest/archive/bfc0ffc8a698072c794ae7299db9cb6866f4c0bc.tar.gz\n  SOURCE_DIR        \"${CMAKE_CURRENT_BINARY_DIR}/googletest-src\"\n  BINARY_DIR        \"${CMAKE_CURRENT_BINARY_DIR}/googletest-build\"\n  CONFIGURE_COMMAND \"\"\n  BUILD_COMMAND     \"\"\n  INSTALL_COMMAND   \"\"\n  TEST_COMMAND      \"\"\n)\n"
  },
  {
    "path": "05-unit-testing/google-test-download/CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 3.5)\n\n# Set the project name\nproject (google_test_example)\n\n# Add an library for the example classes\nadd_library(example_google_test \n    Reverse.cpp\n    Palindrome.cpp\n)\n\n\n#############################################\n# Unit tests\n\nadd_subdirectory(3rd_party/google-test)\n\n# enable CTest testing\nenable_testing()\n\n# Add a testing executable\nadd_executable(unit_tests unit_tests.cpp)\n\ntarget_link_libraries(unit_tests\n    example_google_test\n    GTest::GTest \n    GTest::Main\n)\n\nadd_test(test_all unit_tests)\n"
  },
  {
    "path": "05-unit-testing/google-test-download/Palindrome.cpp",
    "content": "#include \"Palindrome.h\"\n\nbool Palindrome::isPalindrome(const std::string& toCheck)\n{\n\n    if (toCheck == std::string(toCheck.rbegin(), toCheck.rend())) {\n        return true;\n    }\n\n    return false;\n}\n"
  },
  {
    "path": "05-unit-testing/google-test-download/Palindrome.h",
    "content": "#ifndef __PALINDROME_H__\n#define __PALINDROME_H__\n\n#include <string>\n\n/**\n * Trivial class to check if a string is a palindrome.\n */\nclass Palindrome\n{\npublic:\n    bool isPalindrome(const std::string& toCheck);\n};\n\n#endif\n"
  },
  {
    "path": "05-unit-testing/google-test-download/README.adoc",
    "content": "= Google Test Unit Testing Framework\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n\n# Introduction\n\nUsing link:https://cmake.org/Wiki/CMake/Testing_With_CTest[CTest] you can generate\na `make test` target to run automated unit-tests. This example shows how to\ndownload and build the link:https://github.com/google/googletest[google test] library,\ncreate tests and run them.\n\nThe files in this tutorial are below:\n\n```\n$ tree\n.\n├── 3rd_party\n│   └── google-test\n│       ├── CMakeLists.txt\n│       └── CMakeLists.txt.in\n├── CMakeLists.txt\n├── Reverse.h\n├── Reverse.cpp\n├── Palindrome.h\n├── Palindrome.cpp\n├── unit_tests.cpp\n```\n\n  * link:3rd_party/google-test/CMakeLists.txt[] - CMake commands to build and prepare the google test library\n  * link:3rd_party/google-test/CMakeLists.txt.in[] - Helper script to do the download of google test\n  * link:CMakeLists.txt[] - Contains the CMake commands you wish to run\n  * link:Reverse.h[] / link:Reverse.cpp[.cpp] - Class to reverse a string\n  * link:Palindrome.h[] / link:Palindrome.cpp[.cpp] - Class to test if a string is a palindrome\n  * link:unit_test.cpp[] - Unit Tests using google test unit test framework\n\n# Requirements\n\nAn internet connection. This example will download the google test library the first time you run the CMake configure step. See the \nlink:https://github.com/google/googletest/blob/master/googletest/README.md[google test readme] and link:http://crascit.com/2015/07/25/cmake-gtest/[here] for details. \n\n# Concepts\n\n## Download and Build Google Test\n\n[source,cmake]\n----\nadd_subdirectory(3rd_party/google-test)\n----\n\nThis will add the CMake files which download and build Google Test. This is the recommended way to add google test and there are \nmore details from link:https://github.com/google/googletest/blob/master/googletest/README.md[google test readme] and link:http://crascit.com/2015/07/25/cmake-gtest/[here]\n\nAlternatives to this method include:\n\n  * Use something like `git submodule` to download the source to a folder in your tree and then do `add_subdirectory`\n  * Vendor the google test source code within your repository\n  * Build google test externally and link it using `find_package(GTest)` - Not recommended by the google test authors anymore\n\n## Enabling testing\n\nTo enable testing you must include the following line in your top level CMakeLists.txt\n\n[source,cmake]\n----\nenable_testing()\n----\n\nThis will enable testing for the current folder and all folders below it.\n\n## Adding a testing executable\n\nThe requirement for this step will depend on your unit-test framework. In the example\nof google test, you can create binary(s) which includes all the unit tests that you want to run.\n\n[source,cmake]\n----\nadd_executable(unit_tests unit_tests.cpp)\n\ntarget_link_libraries(unit_tests\n    example_google_test\n    GTest::GTest\n    GTest::main\n)\n----\n\nIn the above code, a unit test binary is added, which links against the google test unit-test-framework using the\nALIAS target setup during the link:3rd_party/google-test/CMakeLists.txt[download and build] of GTest.\n\n## Add A test\n\nTo add a test you call the link:https://cmake.org/cmake/help/v3.0/command/add_test.html[`add_test()`] function.\nThis will create a named test which will run the supplied command.\n\n[source,cmake]\n----\nadd_test(test_all unit_tests)\n----\n\nIn this example, we create a test called `test_all` which will run the executable\ncreated by the `unit_tests` executable created from the call to `add_executable`\n\n# Building the Example\n\n[source,bash]\n----\n$ mkdir build\n\n$ cd build/\n\n$ cmake ..\n-- The C compiler identification is GNU 5.4.0\n-- The CXX compiler identification is GNU 5.4.0\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Detecting C compile features\n-- Detecting C compile features - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Detecting CXX compile features\n-- Detecting CXX compile features - done\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /data/data/code/cmake-examples/05-unit-testing/google-test-download/build/3rd_party/google-test/googletest-download\nScanning dependencies of target googletest\n[ 11%] Creating directories for 'googletest'\n[ 22%] Performing download step (download, verify and extract) for 'googletest'\n-- downloading...\n     src='https://github.com/google/googletest/archive/bfc0ffc8a698072c794ae7299db9cb6866f4c0bc.tar.gz'\n     dst='/data/data/code/cmake-examples/05-unit-testing/google-test-download/build/3rd_party/google-test/googletest-download/googletest-prefix/src/bfc0ffc8a698072c794ae7299db9cb6866f4c0bc.tar.gz'\n     timeout='none'\n-- downloading... done\n-- verifying file...\n     file='/data/data/code/cmake-examples/05-unit-testing/google-test-download/build/3rd_party/google-test/googletest-download/googletest-prefix/src/bfc0ffc8a698072c794ae7299db9cb6866f4c0bc.tar.gz'\n-- verifying file... warning: did not verify file - no URL_HASH specified?\n-- extracting...\n     src='/data/code/cmake-examples/05-unit-testing/google-test-download/build/3rd_party/google-test/googletest-download/googletest-prefix/src/bfc0ffc8a698072c794ae7299db9cb6866f4c0bc.tar.gz'\n     dst='/data/code/cmake-examples/05-unit-testing/google-test-download/build/3rd_party/google-test/googletest-src'\n-- extracting... [tar xfz]\n-- extracting... [analysis]\n-- extracting... [rename]\n-- extracting... [clean up]\n-- extracting... done\n[ 33%] No patch step for 'googletest'\n[ 44%] No update step for 'googletest'\n[ 55%] No configure step for 'googletest'\n[ 66%] No build step for 'googletest'\n[ 77%] No install step for 'googletest'\n[ 88%] No test step for 'googletest'\n[100%] Completed 'googletest'\n[100%] Built target googletest\n-- Found PythonInterp: /usr/bin/python (found version \"2.7.12\") \n-- Looking for pthread.h\n-- Looking for pthread.h - found\n-- Looking for pthread_create\n-- Looking for pthread_create - not found\n-- Check if compiler accepts -pthread\n-- Check if compiler accepts -pthread - yes\n-- Found Threads: TRUE  \n-- Configuring done\n-- Generating done\n-- Build files have been written to: /data/code/cmake-examples/05-unit-testing/google-test-download/build\n\n$ make\nScanning dependencies of target example_google_test\n[  6%] Building CXX object CMakeFiles/example_google_test.dir/Reverse.cpp.o\n[ 12%] Building CXX object CMakeFiles/example_google_test.dir/Palindrome.cpp.o\n[ 18%] Linking CXX static library libexample_google_test.a\n[ 18%] Built target example_google_test\nScanning dependencies of target gtest\n[ 25%] Building CXX object 3rd_party/google-test/googletest-build/googlemock/gtest/CMakeFiles/gtest.dir/src/gtest-all.cc.o\n[ 31%] Linking CXX static library libgtest.a\n[ 31%] Built target gtest\nScanning dependencies of target gtest_main\n[ 37%] Building CXX object 3rd_party/google-test/googletest-build/googlemock/gtest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.o\n[ 43%] Linking CXX static library libgtest_main.a\n[ 43%] Built target gtest_main\nScanning dependencies of target unit_tests\n[ 50%] Building CXX object CMakeFiles/unit_tests.dir/unit_tests.cpp.o\n[ 56%] Linking CXX executable unit_tests\n[ 56%] Built target unit_tests\nScanning dependencies of target gmock_main\n[ 62%] Building CXX object 3rd_party/google-test/googletest-build/googlemock/CMakeFiles/gmock_main.dir/__/googletest/src/gtest-all.cc.o\n[ 68%] Building CXX object 3rd_party/google-test/googletest-build/googlemock/CMakeFiles/gmock_main.dir/src/gmock-all.cc.o\n[ 75%] Building CXX object 3rd_party/google-test/googletest-build/googlemock/CMakeFiles/gmock_main.dir/src/gmock_main.cc.o\n[ 81%] Linking CXX static library libgmock_main.a\n[ 81%] Built target gmock_main\nScanning dependencies of target gmock\n[ 87%] Building CXX object 3rd_party/google-test/googletest-build/googlemock/CMakeFiles/gmock.dir/__/googletest/src/gtest-all.cc.o\n[ 93%] Building CXX object 3rd_party/google-test/googletest-build/googlemock/CMakeFiles/gmock.dir/src/gmock-all.cc.o\n[100%] Linking CXX static library libgmock.a\n[100%] Built target gmock\n\n$ make test\nRunning tests...\nTest project /data/code/cmake-examples/05-unit-testing/google-test-download/build\n    Start 1: test_all\n1/1 Test #1: test_all .........................   Passed    0.00 sec\n\n100% tests passed, 0 tests failed out of 1\n\nTotal Test time (real) =   0.00 sec\n----\n\nIf the code is changed and it causes the unit tests to produce an error.\nThen when running the tests you will see the following output.\n\n[source,bash]\n----\n$ make test\nRunning tests...\nTest project /data/code/cmake-examples/05-unit-testing/google-test-download/build\n    Start 1: test_all\n1/1 Test #1: test_all .........................***Failed    0.00 sec\n\n0% tests passed, 1 tests failed out of 1\n\nTotal Test time (real) =   0.00 sec\n\nThe following tests FAILED:\n    1 - test_all (Failed)\nErrors while running CTest\nMakefile:72: recipe for target 'test' failed\nmake: *** [test] Error 8\n----\n"
  },
  {
    "path": "05-unit-testing/google-test-download/Reverse.cpp",
    "content": "#include \"Reverse.h\"\n\nstd::string Reverse::reverse(std::string& toReverse)\n{\n    std::string ret;\n\n    for(std::string::reverse_iterator rit=toReverse.rbegin(); rit!=toReverse.rend(); ++rit)\n    {\n        ret.insert(ret.end(), *rit);\n    }\n    return ret;\n}\n"
  },
  {
    "path": "05-unit-testing/google-test-download/Reverse.h",
    "content": "#ifndef __REVERSE_H__\n#define __REVERSE_H__\n\n#include <string>\n\n/**\n * Trivial class whose only function is to reverse a string.\n * Should use std::reverse instead but want to have example with own class\n */\nclass Reverse\n{\npublic:\n    std::string reverse(std::string& toReverse);\n};\n#endif\n"
  },
  {
    "path": "05-unit-testing/google-test-download/main.cpp",
    "content": "#include <iostream>\n#include <boost/shared_ptr.hpp>\n#include <boost/filesystem.hpp>\n\nint main(int argc, char *argv[])\n{\n    std::cout << \"Hello Third Party Include!\" << std::endl;\n\n    // use a shared ptr\n    boost::shared_ptr<int> isp(new int(4));\n\n    // trivial use of boost filesystem\n    boost::filesystem::path path = \"/usr/share/cmake/modules\";\n    if(path.is_relative())\n    {\n        std::cout << \"Path is relative\" << std::endl;\n    }\n    else\n    {\n        std::cout << \"Path is not relative\" << std::endl;\n    }\n\n   return 0;\n}\n"
  },
  {
    "path": "05-unit-testing/google-test-download/post_test.sh",
    "content": "#!/bin/bash\n\necho \"Disabled for now because of issue with libcurl and https\"\nexit 0\n\n#make test\n"
  },
  {
    "path": "05-unit-testing/google-test-download/run_test.sh",
    "content": "#!/bin/bash\n\necho \"Disabled for now because of issue with libcurl and https\"\nexit 0\n"
  },
  {
    "path": "05-unit-testing/google-test-download/unit_tests.cpp",
    "content": "#include <string>\n#include \"Reverse.h\"\n#include \"Palindrome.h\"\n\n#include <gtest/gtest.h>\n\nclass ReverseTests : public ::testing::Test\n{\n};\n\nTEST_F(ReverseTests, simple )\n{\n    std::string toRev = \"Hello\";\n\n    Reverse rev;\n    std::string res = rev.reverse(toRev);\n\n    EXPECT_EQ(res, \"olleH\" );\n\n}\n\nTEST_F(ReverseTests, empty )\n{\n    std::string toRev;\n\n    Reverse rev;\n    std::string res = rev.reverse(toRev);\n\n    EXPECT_EQ(res, \"\" );\n}\n\nTEST_F(ReverseTests,  is_palindrome )\n{\n    std::string pal = \"mom\";\n    Palindrome pally;\n\n    EXPECT_TRUE(pally.isPalindrome(pal));\n\n}\n"
  },
  {
    "path": "06-installer/README.adoc",
    "content": "= Installers\n\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n[[intro]]\nIntroduction\n------------\n\nCMake has the ability to create installers for multiple platforms using a program\ncalled link:https://cmake.org/Wiki/CMake:CPackPackageGenerators[CPack].\nCPack includes the ability to create Linux RPM, deb and gzip distributions\n of both binaries and source code. It also includes the ability to create NSIS files for Microsoft Windows.\n"
  },
  {
    "path": "06-installer/deb/CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 3.5)\n\nproject(cmake_examples_deb)\n\n# set a project version\nset (deb_example_VERSION_MAJOR 0)\nset (deb_example_VERSION_MINOR 2)\nset (deb_example_VERSION_PATCH 2)\nset (deb_example_VERSION \"${deb_example_VERSION_MAJOR}.${deb_example_VERSION_MINOR}.${deb_example_VERSION_PATCH}\")\n\n\n############################################################\n# Create a library\n############################################################\n\n#Generate the shared library from the library sources\nadd_library(cmake_examples_deb SHARED src/Hello.cpp)\n\ntarget_include_directories(cmake_examples_deb\n    PUBLIC\n        ${PROJECT_SOURCE_DIR}/include\n)\n############################################################\n# Create an executable\n############################################################\n\n# Add an executable with the above sources\nadd_executable(cmake_examples_deb_bin src/main.cpp)\n\n# link the new hello_library target with the hello_binary target\ntarget_link_libraries( cmake_examples_deb_bin\n    PUBLIC\n        cmake_examples_deb\n)\n\n############################################################\n# Install\n############################################################\n\n# Binaries\ninstall (TARGETS cmake_examples_deb_bin\n    DESTINATION bin)\n\n# Library\n# Note: may not work on windows\ninstall (TARGETS cmake_examples_deb\n    LIBRARY DESTINATION lib)\n\n# Config\ninstall (FILES cmake-examples.conf\n    DESTINATION etc)\n\n############################################################\n# Create DEB\n############################################################\n\n# Tell CPack to generate a .deb package\nset(CPACK_GENERATOR \"DEB\")\n\n# Set a Package Maintainer.\n# This is required\nset(CPACK_DEBIAN_PACKAGE_MAINTAINER \"Thom Troy\")\n\n# Set a Package Version\nset(CPACK_PACKAGE_VERSION ${deb_example_VERSION})\n\n# Include CPack\ninclude(CPack)\n"
  },
  {
    "path": "06-installer/deb/README.adoc",
    "content": "= Creating deb files\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nThis example shows how to generate a Linux installers using the link:https://www.debian.org/doc/manuals/debian-faq/ch-pkg_basics.en.html[deb]\n format.\n\nThe files in this tutorial are below:\n\n```\n$ tree\n.\n├── cmake-examples.conf\n├── CMakeLists.txt\n├── include\n│   └── Hello.h\n└── src\n    ├── Hello.cpp\n    └── main.cpp\n```\n\n  * link:CMakeLists.txt[] - Contains the CMake commands you wish to run\n  * link:cmake-examples.conf[] - An example configuration file\n  * link:include/Hello.h[] - The header file to include\n  * link:src/Hello.cpp[] - A source file to compile\n  * link:src/main.cpp[] - The source file with main\n\n# Concepts\n\n## CPack Generator\n\nA CPack Generator can be used by a `make package` target to create an installer.\n\nIn the case of Debian packages you can tell CMake to create a generator using the following:\n\n[source,cmake]\n----\nset(CPACK_GENERATOR \"DEB\")\n----\n\nAfter setting various settings to describe the package you must then tell CMake to\ninclude the CPack generator using\n\n[source,cmake]\n----\ninclude(CPack)\n----\n\nOnce included all files that would typically be installed using a  `make install` target\ncan now be packaged into a Debian package.\n\n## Debian Package Settings\n\nVarious settings for the package are exposed by CPack. In this example we set the\nfollowing:\n\n[source,cmake]\n----\n# Set a Package Maintainer.\n# This is required\nset(CPACK_DEBIAN_PACKAGE_MAINTAINER \"Thom Troy\")\n\n# Set a Package Version\nset(CPACK_PACKAGE_VERSION ${deb_example_VERSION})\n----\n\nWhich sets the maintainer and version. More debian specific settings are specified below\nor at link:https://cmake.org/Wiki/CMake:CPackPackageGenerators#Debian_Generator_specific_settings[the CPack Wiki]\n\n[cols=\",\",options=\"header\",]\n|=======================================================================\n|Variable |Info\n|CPACK_DEBIAN_PACKAGE_MAINTAINER |Maintainer information\n\n|CPACK_PACKAGE_DESCRIPTION_SUMMARY |Package short description\n\n|CPACK_PACKAGE_DESCRIPTION |Package description\n\n|CPACK_DEBIAN_PACKAGE_DEPENDS |For advanced users to add custom scripts.\n\n|CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA |The build directory you are currently in.\n\n|CPACK_DEBIAN_PACKAGE_SECTION |Package section (see link:http://packages.debian.org/stable/[here])\n\n|CPACK_DEBIAN_PACKAGE_VERSION |Package version\n|=======================================================================\n\n# Building the Example\n\n[source,bash]\n----\n$ mkdir build\n\n$ cd build/\n\n$ cmake ..\n-- The C compiler identification is GNU 4.8.4\n-- The CXX compiler identification is GNU 4.8.4\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /home/matrim/workspace/cmake-examples/06-installer/deb/build\n\n$ make help\nThe following are some of the valid targets for this Makefile:\n... all (the default if no target is provided)\n... clean\n... depend\n... cmake_examples_deb\n... cmake_examples_deb_bin\n... edit_cache\n... install\n... install/local\n... install/strip\n... list_install_components\n... package\n... package_source\n... rebuild_cache\n... src/Hello.o\n... src/Hello.i\n... src/Hello.s\n... src/main.o\n... src/main.i\n... src/main.s\n\n$ make package\nScanning dependencies of target cmake_examples_deb\n[ 50%] Building CXX object CMakeFiles/cmake_examples_deb.dir/src/Hello.cpp.o\nLinking CXX shared library libcmake_examples_deb.so\n[ 50%] Built target cmake_examples_deb\nScanning dependencies of target cmake_examples_deb_bin\n[100%] Building CXX object CMakeFiles/cmake_examples_deb_bin.dir/src/main.cpp.o\nLinking CXX executable cmake_examples_deb_bin\n[100%] Built target cmake_examples_deb_bin\nRun CPack packaging tool...\nCPack: Create package using DEB\nCPack: Install projects\nCPack: - Run preinstall target for: cmake_examples_deb\nCPack: - Install project: cmake_examples_deb\nCPack: Create package\nCPack: - package: /home/matrim/workspace/cmake-examples/06-installer/deb/build/cmake_examples_deb-0.2.2-Linux.deb generated.\n\n$ ls\nCMakeCache.txt  cmake_examples_deb-0.2.2-Linux.deb  cmake_examples_deb_bin  CMakeFiles  cmake_install.cmake  CPackConfig.cmake  _CPack_Packages  CPackSourceConfig.cmake  install_manifest.txt  libcmake_examples_deb.so  Makefile\n\n----\n"
  },
  {
    "path": "06-installer/deb/cmake-examples.conf",
    "content": "# Sample configuration file that could be installed\n"
  },
  {
    "path": "06-installer/deb/include/Hello.h",
    "content": "#ifndef __HELLO_H__\n#define __HELLO_H__\n\nclass Hello\n{\npublic:\n    void print();\n};\n\n#endif\n"
  },
  {
    "path": "06-installer/deb/post_test.sh",
    "content": "#!/bin/bash\n\nmake package\n"
  },
  {
    "path": "06-installer/deb/src/Hello.cpp",
    "content": "#include <iostream>\n\n#include \"Hello.h\"\n\nvoid Hello::print()\n{\n    std::cout << \"Hello Install!\" << std::endl;\n}\n"
  },
  {
    "path": "06-installer/deb/src/main.cpp",
    "content": "#include \"Hello.h\"\n\nint main(int argc, char *argv[])\n{\n    Hello hi;\n    hi.print();\n    return 0;\n}"
  },
  {
    "path": "07-package-management/A-using-system-provide-packages/README.adoc",
    "content": "= Using System Provided Package Manager\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nUsing your system provided packages is one of the oldest and most common form of package management solutions. For this, you use your systems package installer (e.g. apt, yum) to install libraries and headers into common locations. CMake can then use the `find_package()` function to search for these and make them available to your program. \n\n# Examples\n\nI have already shown how to do this in the link:https://github.com/ttroy50/cmake-examples/tree/master/01-basic/H-third-party-library[third party library] example from the basic section and the link:https://github.com/ttroy50/cmake-examples/tree/master/05-unit-testing/boost[boost unit test] example.\n"
  },
  {
    "path": "07-package-management/B-vendoring-code/README.adoc",
    "content": "= Vendoring Code\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nVendoring code means to include the third party code inside your repository and build it as part of your project. It is a way to ensure that all files required to build your project are part of the development environment.\n\n# Implementation\n\n## Including 3rd Party Code\n\nTypically, this might take the form or a `3rd_party` or `vendor` directory, in which you copy the source of the libraries you want to include. For example, you may do something like:\n\n```\n$ tree\n.\n├── 3rd_party\n│   └── catch2\n│       ├── catch2\n│       │   └── catch.hpp\n│       └── CMakeLists.txt\n├── CMakeLists.txt\n├── src\n│   └── example.cpp\n```\n\n\nIf these projects support CMake directly, it may be possible to do `add_subdirectory()` on the libraries folder and have that project build and be made available to your code. \n\nIf the third party code doesn't support CMake, you may need to create a \"shim\" layer on top of the project to allow it to be build and discovered from CMake.\n\n## Using git to vendor code\n\nA slightly different method to include the third party code can be to use your SCM software to manage the process for you. \n\nIn the case of git, you can use link:https://git-scm.com/book/en/v2/Git-Tools-Submodules[git sub-modules] or link:https://git-scm.com/book/en/v1/Git-Tools-Subtree-Merging[git subtree]. These can pull the correct version of the third party code into your repository on initialisation / update.  \n\n# Examples\n\nA simple example of vendoring code can already be seen in the link:https://github.com/ttroy50/cmake-examples/tree/master/05-unit-testing/catch2-vendored[catch2] testing tutorial.\n"
  },
  {
    "path": "07-package-management/C-external-project-add/README.adoc",
    "content": "= External Project\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nCMake supports downloading and building an external project using the link:https://cmake.org/cmake/help/latest/module/ExternalProject.html[External Project] commands. By adding +ExternalProject_Add+ to your code you can have CMake automatically download a source file from either HTTP or a source control system (e.g. git). \n\nOnce configured an external project will generate a custom target which can be used to control the download, update, build, test, and install phases of the external project.\n\n# Implementation\n\n## Standard\n\nA simple example of an external project is as follows:\n\n[source,cmake]\n----\ninclude(ExternalProject)\nExternalProject_Add(googletest\n  URL    https://github.com/google/googletest/archive/bfc0ffc8a698072c794ae7299db9cb6866f4c0bc.tar.gz_\n)\n----\n\nOnce added you will have a target `googletest` which will attempt to download, build, and install google test when your build your project. \n\n[NOTE]\n====\nThis will attempt to install google test to your standard locations e.g. `/usr/` and may fail if you are not root. To skip the install step you can add a line `INSTALL_COMMAND \"\"`\n====\n\nBy default the project is assumed to work via CMake and external project will know how to build using standard CMake commands. If the external project uses a different build system, you can set the various commands using +INSTALL_COMMAND+, +CONFIGURE_COMMAND+, +BUILD_COMMAND+, etc.\n\n## Alternative\n\nAn alternative method to install packages is to have the ExternalProject command run at CMake configure time. This can cause the download to happen at the configure step and you may then use +add_subdirectory+ to add the project to your code (assuming it uses CMake). An example of this can be found in the link:https://github.com/ttroy50/cmake-examples/tree/master/05-unit-testing/google-test-download[google-test-download] tutorial.\n\nA more generic version of the download code can be found link:https://github.com/Crascit/DownloadProject[here]."
  },
  {
    "path": "07-package-management/D-conan/README.adoc",
    "content": "= Conan\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nlink:https://conan.io[Conan] is an open source, decentralized, and multi-platform package manager that can be used to create and share native libraries and binaries. It supports multiple build systems (CMake, Visual Studio, Makefiles) and OSes (Linux, Windows, and Mac). \n\nConan servers can be installed privately or you can use public servers and packages made available by link:https://bintray.com/conan/conan-center[Jfrog bintray].\n\nFull documentation for conan can be found from link:https://docs.conan.io/en/latest/[here]\n\n# Installing Conan\n\nConan is a python application and can be installed using pip.\n\n[source,bash]\n----\n$ sudo apt-get install python3 python3-pip\n$ pip3 install conan\n$ conan help\nConsumer commands\n  install    Installs the requirements specified in a recipe (conanfile.py or conanfile.txt).\n...\n----\n\nAlternatively, native packages are available for most operating systems. Full details are available link:https://docs.conan.io/en/latest/installation.html[here].\n\n# Conan Profile\n\nIn conan link:https://docs.conan.io/en/latest/reference/profiles.html#profiles[profiles] control information such as the compiler and environments that are available on your system. \n\nTo create a new default profile run\n\n[source,bash]\n----\n$ conan profile new default --detect\nFound gcc 5.4\ngcc>=5, using the major as version\nProfile created with detected settings: /home/devuser/.conan/profiles/default\n----\n\nThe generated profile will look something like:\n\n[source,bash]\n----\n[settings]\nos=Linux\nos_build=Linux\narch=x86_64\narch_build=x86_64\ncompiler=gcc\ncompiler.version=5\ncompiler.libcxx=libstdc++\nbuild_type=Release\n[options]\n[build_requires]\n[env]\n----\n\n\n[NOTE]\n====\nIf you are using GCC compiler >= 5.1, Conan will set the compiler.libcxx to the old ABI for backwards compatibility. You can change this with the following commands:\n\n[source,bash]\n----\n$ conan profile update settings.compiler.libcxx=libstdc++11 default\n----\n\n[source,bash]\n----\n[settings]\nos=Linux\nos_build=Linux\narch=x86_64\narch_build=x86_64\ncompiler=gcc\ncompiler.version=5\ncompiler.libcxx=libstdc++11\nbuild_type=Release\n[options]\n[build_requires]\n[env]\n----\n\nYou can find more information about this link:https://docs.conan.io/en/latest/howtos/manage_gcc_abi.html#manage-gcc-abi[here].\n====\n\nAll examples provided will assume that the ABI being used for libstdc++ is the Cpp11 ABI.\n\n# Finding Packages\n\nRemote repositories can be searched for conan packages. By default the `conan-center` remote is configured. This is located in link:https://bintray.com/conan/conan-center[bintray].\n\n## Searching for Packages\n\nYou can search for packages using the `conan search` command. For example, to search for a package such as link:https://github.com/fmtlib/fmt[fmtlib] you can run:\n\n[source,bash]\n----\n$ conan search fmt* --remote=conan-center\nExisting package recipes:\n\nfmt/4.0.0@bincrafters/stable\nfmt/4.1.0@bincrafters/stable\nfmt/5.0.0@bincrafters/stable\nfmt/5.1.0@bincrafters/stable\nfmt/5.2.0@bincrafters/stable\nfmt/5.2.1@bincrafters/stable\nfmt/5.3.0@bincrafters/stable\n\n----\n\n## Inspecting Packages\n\nYou can then inspect a package using the `conan inspect` command. To inspect one one of the fmt packages from the search command above you can run:\n\n[source,bash]\n----\n$ conan inspect fmt/5.3.0@bincrafters/stable --remote=conan-center\nname: fmt\nversion: 5.3.0\nurl: https://github.com/bincrafters/conan-fmt\nhomepage: https://github.com/fmtlib/fmt\nlicense: MIT\nauthor: Bincrafters <bincrafters@gmail.com>\ndescription: A safe and fast alternative to printf and IOStreams.\ntopics: None\ngenerators: cmake\nexports: ['LICENSE.md']\nexports_sources: ['CMakeLists.txt']\nshort_paths: False\napply_env: True\nbuild_policy: None\nrevision_mode: hash\nsettings: ('os', 'compiler', 'build_type', 'arch')\noptions:\n    fPIC: [True, False]\n    header_only: [True, False]\n    shared: [True, False]\n    with_fmt_alias: [True, False]\ndefault_options:\n    fPIC: True\n    header_only: False\n    shared: False\n    with_fmt_alias: False\n----\n\nThis shows details about the package including what link:https://docs.conan.io/en/latest/using_packages/conanfile_txt.html#options[options] can be set when including the package. In the case of fmtlib there are 4 options which allow you to specify the type of installion you want.\n\n# Examples\n\nThe examples included are:\n\n  - link:i-basic[Basic]. A basic example linking against one library.\n  - link:ii-basic-targets[Using Targets]. The basic example, except using modern CMake targets.\n"
  },
  {
    "path": "07-package-management/D-conan/i-basic/CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 3.5)\nproject (conan_third_party_include)\n\nset(CMAKE_CXX_STANDARD 11)\n\n# Included the conan build information\ninclude(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)\nconan_basic_setup()\n\n# Add an executable\nadd_executable(third_party_include main.cpp)\n\n# link against the fmt target supplied by conan\ntarget_link_libraries(third_party_include\n    PRIVATE\n        ${CONAN_LIBS}\n)"
  },
  {
    "path": "07-package-management/D-conan/i-basic/README.adoc",
    "content": "= Conan Basic Example\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nlink:http://conan.io[Conan] supports downloading libraries and making them available to an application developers. Packages are defined in the link:https://docs.conan.io/en/latest/using_packages/conanfile_txt.html[+conanfile.txt+] file, which defines packages, options, and the link:https://docs.conan.io/en/latest/reference/generators.html#generators-reference[generators] for your project.\n\nThe files in this tutorial are below:\n\n```\n.\n├── CMakeLists.txt\n├── conanfile.txt\n├── main.cpp\n└── README.adoc\n```\n\n  * link:CMakeLists.txt[] - Contains the CMake commands to run\n  * link:conanfile.txt[] - Contains the conan dependencies and options\n  * link:main.cpp[] - Source file of the application.\n\n# Concepts\n\n## conanfile.txt\n\n### requires\n\nThe conanfile.txt defines the required packages you wish to install\n\n[source,ini]\n----\n[requires]\nfmt/5.3.0@bincrafters/stable\n----\n\n\nWhere:\n\n  * `fmt` is the name of the package / library.\n  * `5.3.0` is the version of the package.\n  * `bincrafters` is the owner / builder of the package.\n  * `stable` is channel of the package. Channels provide a to have different variants of packages.\n\n### generators\n\nGenerators define the build systems that you are using and allows Conan to create files with all the information needed to find your libraries and link your program.\n\n[source,ini]\n----\n[generators]\ncmake\n----\n\nThe CMake generator will create the file `conanbuildinfo.cmake` which should be included in your +CMakeLists.txt+ file. This will be a per-user file and should not be committed to your source control system.\n\n## Installing Packages\n\nTo install packages you should run the following:\n\n[source,bash]\n----\n$ mkdir build\n$ cd build\n$ conan install ..\n----\n\nThis will tell conan to read the +conanfile.txt+ from your root folder and install any required package configurations. If the package is not available in your package cache it will be downloaded.\n\nAs per our requires section, `conan install` will download a static library version of fmtlib along with all required headers. On my system with default configuration, this cached library is as follows:\n\n[source,bash]\n----\n$ ls ~/.conan/data/fmt/5.3.0/bincrafters/stable/package/4d887c1c2779c63d2cdd81580698d2e22cb35b29/\nconaninfo.txt  conanmanifest.txt  include  lib  licenses  share\n$ ls ~/.conan/data/fmt/5.3.0/bincrafters/stable/package/4d887c1c2779c63d2cdd81580698d2e22cb35b29/lib\ncmake  libfmt.a\n----\n\nThe install command will also create any temporary files such as the +conanbuildinfo.cmake+ file.\n\n## conanbuildinfo.cmake\n\nAs mentioned the +conanbuildinfo.cmake+ file contains any CMake commands that are required to link against your installed libraries. You must include this file in your CMakeLists.txt as follows\n\n[source,cmake]\n----\ninclude(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)\nconan_basic_setup()\n----\n\nThe +CMAKE_BINARY_DIR+ here is the same build directory that your ran `conan install` in and will eventually run your `cmake` command in. \n\nOnce included the variable +CONAN_LIBS+ is made available which contains the information you need to link against the libraries.\n\n[source,cmake]\n----\n# link against the fmt target supplied by conan\ntarget_link_libraries(third_party_include\n    PRIVATE\n        ${CONAN_LIBS}\n)\n----\n\n# Building the Example\n\n[source,bash]\n----\n$ mkdir build\n\n$ cd build/\n\n$ conan install ..\nConfiguration:\n[settings]\narch=x86_64\narch_build=x86_64\nbuild_type=Release\ncompiler=gcc\ncompiler.libcxx=libstdc++11\ncompiler.version=5\nos=Linux\nos_build=Linux\n[options]\n[build_requires]\n[env]\n\nfmt/5.3.0@bincrafters/stable: Not found in local cache, looking in remotes...\nfmt/5.3.0@bincrafters/stable: Trying with 'conan-center'...\nDownloading conanmanifest.txt\n[==================================================] 166B/166B        \nDownloading conanfile.py\n[==================================================] 2.9KB/2.9KB      \nDownloading conan_export.tgz\n[==================================================] 758B/758B        \nDecompressing conan_export.tgz: 1.98kB [00:00, 504kB/s]                  \nfmt/5.3.0@bincrafters/stable: Downloaded recipe revision 0\nconanfile.txt: Installing package\nRequirements\n    fmt/5.3.0@bincrafters/stable from 'conan-center' - Downloaded\nPackages\n    fmt/5.3.0@bincrafters/stable:4d887c1c2779c63d2cdd81580698d2e22cb35b29 - Download\n\nfmt/5.3.0@bincrafters/stable: Retrieving package 4d887c1c2779c63d2cdd81580698d2e22cb35b29 from remote 'conan-center' \nDownloading conanmanifest.txt\n[==================================================] 1.1KB/1.1KB      \nDownloading conaninfo.txt\n[==================================================] 550B/550B        \nDownloading conan_package.tgz\n[==================================================] 156.2KB/156.2KB  \nDecompressing conan_package.tgz: 161kB [00:00, 13.8MB/s]                   \nfmt/5.3.0@bincrafters/stable: Package installed 4d887c1c2779c63d2cdd81580698d2e22cb35b29\nfmt/5.3.0@bincrafters/stable: Downloaded package revision 0\nconanfile.txt: Generator cmake created conanbuildinfo.cmake\nconanfile.txt: Generator txt created conanbuildinfo.txt\nconanfile.txt: Generated conaninfo.txt\nconanfile.txt: Generated graphinfo\n\n$ cmake ..\n-- The C compiler identification is GNU 5.4.0\n-- The CXX compiler identification is GNU 5.4.0\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Detecting C compile features\n-- Detecting C compile features - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Detecting CXX compile features\n-- Detecting CXX compile features - done\n-- Conan: Adjusting output directories\n-- Conan: Using cmake global configuration\n-- Conan: Adjusting default RPATHs Conan policies\n-- Conan: Adjusting language standard\n-- Current conanbuildinfo.cmake directory: /home/devuser/ws/build\n-- Conan: Compiler GCC>=5, checking major version 5\n-- Conan: Checking correct version: 5\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /home/devuser/ws/build\n\n$ make VERBOSE=1\n/usr/bin/cmake -H/home/devuser/ws -B/home/devuser/ws/build --check-build-system CMakeFiles/Makefile.cmake 0\n/usr/bin/cmake -E cmake_progress_start /home/devuser/ws/build/CMakeFiles /home/devuser/ws/build/CMakeFiles/progress.marks\nmake -f CMakeFiles/Makefile2 all\nmake[1]: Entering directory '/home/devuser/ws/build'\nmake -f CMakeFiles/third_party_include.dir/build.make CMakeFiles/third_party_include.dir/depend\nmake[2]: Entering directory '/home/devuser/ws/build'\ncd /home/devuser/ws/build && /usr/bin/cmake -E cmake_depends \"Unix Makefiles\" /home/devuser/ws /home/devuser/ws /home/devuser/ws/build /home/devuser/ws/build /home/devuser/ws/build/CMakeFiles/third_party_include.dir/DependInfo.cmake --color=\nDependee \"/home/devuser/ws/build/CMakeFiles/third_party_include.dir/DependInfo.cmake\" is newer than depender \"/home/devuser/ws/build/CMakeFiles/third_party_include.dir/depend.internal\".\nDependee \"/home/devuser/ws/build/CMakeFiles/CMakeDirectoryInformation.cmake\" is newer than depender \"/home/devuser/ws/build/CMakeFiles/third_party_include.dir/depend.internal\".\nScanning dependencies of target third_party_include\nmake[2]: Leaving directory '/home/devuser/ws/build'\nmake -f CMakeFiles/third_party_include.dir/build.make CMakeFiles/third_party_include.dir/build\nmake[2]: Entering directory '/home/devuser/ws/build'\n[ 50%] Building CXX object CMakeFiles/third_party_include.dir/main.cpp.o\n/usr/bin/c++    -I/home/devuser/.conan/data/fmt/5.3.0/bincrafters/stable/package/4d887c1c2779c63d2cdd81580698d2e22cb35b29/include  -std=gnu++11 -o CMakeFiles/third_party_include.dir/main.cpp.o -c /home/devuser/ws/main.cpp\n[100%] Linking CXX executable bin/third_party_include\n/usr/bin/cmake -E cmake_link_script CMakeFiles/third_party_include.dir/link.txt --verbose=1\n/usr/bin/c++          CMakeFiles/third_party_include.dir/main.cpp.o  -o bin/third_party_include  -L/home/devuser/.conan/data/fmt/5.3.0/bincrafters/stable/package/4d887c1c2779c63d2cdd81580698d2e22cb35b29/lib -lfmt -Wl,-rpath,/home/devuser/.conan/data/fmt/5.3.0/bincrafters/stable/package/4d887c1c2779c63d2cdd81580698d2e22cb35b29/lib \nmake[2]: Leaving directory '/home/devuser/ws/build'\n[100%] Built target third_party_include\nmake[1]: Leaving directory '/home/devuser/ws/build'\n/usr/bin/cmake -E cmake_progress_start /home/devuser/ws/build/CMakeFiles 0\n\n$ ./bin/third_party_include \nHello, conan. This is fmtlib!\n----\n"
  },
  {
    "path": "07-package-management/D-conan/i-basic/conanfile.txt",
    "content": "[requires]\nfmt/5.3.0@bincrafters/stable\n\n[generators]\ncmake\n"
  },
  {
    "path": "07-package-management/D-conan/i-basic/main.cpp",
    "content": "#include <iostream>\n#include <fmt/format.h>\n\nint main(int argc, char *argv[])\n{\n    fmt::print(\"Hello, {}. This is {}!\\n\", \"conan\", \"fmtlib\");\n    return 0;\n}\n"
  },
  {
    "path": "07-package-management/D-conan/i-basic/run_test.sh",
    "content": "#!/bin/bash\n\nconan_bin=`which conan`\n\nif [ -z $conan_bin ]; then\n    exit 0\nfi\n\nconan profile show default || {\n    conan profile new default --detect\n}\nconan profile update settings.compiler.libcxx=libstdc++11 default\n\necho \"correct version of cmake\"\nmkdir -p build && cd build && conan install .. && cmake .. && make\nif [ $? -ne 0 ]; then\n    echo \"Error running example\"\n    exit 1\nfi\n"
  },
  {
    "path": "07-package-management/D-conan/ii-basic-targets/CMakeLists.txt",
    "content": "cmake_minimum_required(VERSION 3.5)\nproject (conan_third_party_include)\n\nset(CMAKE_CXX_STANDARD 11)\n\n# Included the conan build information\ninclude(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)\nconan_basic_setup(TARGETS)\n\n# Add an executable\nadd_executable(third_party_include main.cpp)\n\n# link against the fmt target supplied by conan\ntarget_link_libraries(third_party_include\n    PRIVATE\n        CONAN_PKG::fmt\n)\n"
  },
  {
    "path": "07-package-management/D-conan/ii-basic-targets/README.adoc",
    "content": "= Conan Basic Example\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nModern CMake recommends to use a target based approach to including libraries. This example shows how to support this using\nconan in an example that is functionally the same as the previous one.\n\nThe files in this tutorial are below:\n\n```\n.\n├── CMakeLists.txt\n├── conanfile.txt\n├── main.cpp\n└── README.adoc\n```\n\n  * link:CMakeLists.txt[] - Contains the CMake commands to run\n  * link:conanfile.txt[] - Contains the conan dependencies and options\n  * link:main.cpp[] - Source file of the application.\n\n# Concepts\n\n## Libraries Targets\n\nAs described in the link:https://github.com/ttroy50/cmake-examples/tree/master/01-basic/H-third-party-library[third party library] example, CMake recommends to use +ALIAS+ targets for third party libraries. An example of\nadding an imported target is\n\n[source,cmake]\n----\n  target_link_libraries( third_party_include\n      PRIVATE\n          Boost::filesystem\n  )\n----\n\n\n## Conan Imported Targets\n\nTo configure conan to use imported targets add the argument +TARGETS+ to the +conan_basic_setup+ function. This will cause conan to create a `CONAN_PKG::pkg_name` target that can be imported as a library.\n\nAn example of this using the `fmt` library is below:\n\n[source,cmake]\n----\n  conan_basic_setup(TARGETS)\n\n  add_executable(third_party_include)\n  \n  target_link_libraries(third_party_include\n      PRIVATE\n          CONAN_PKG::fmt\n  )\n----\n\n# Building the Example\n\n[source,bash]\n----\n$ mkdir build\n\n$ cd build/\n\n$ conan install ..\nConfiguration:\n[settings]\narch=x86_64\narch_build=x86_64\nbuild_type=Release\ncompiler=gcc\ncompiler.libcxx=libstdc++11\ncompiler.version=5\nos=Linux\nos_build=Linux\n[options]\n[build_requires]\n[env]\n\nfmt/5.3.0@bincrafters/stable: Not found in local cache, looking in remotes...\nfmt/5.3.0@bincrafters/stable: Trying with 'conan-center'...\nDownloading conanmanifest.txt\n[==================================================] 166B/166B        \nDownloading conanfile.py\n[==================================================] 2.9KB/2.9KB      \nDownloading conan_export.tgz\n[==================================================] 758B/758B        \nDecompressing conan_export.tgz: 1.98kB [00:00, 504kB/s]                  \nfmt/5.3.0@bincrafters/stable: Downloaded recipe revision 0\nconanfile.txt: Installing package\nRequirements\n    fmt/5.3.0@bincrafters/stable from 'conan-center' - Downloaded\nPackages\n    fmt/5.3.0@bincrafters/stable:4d887c1c2779c63d2cdd81580698d2e22cb35b29 - Download\n\nfmt/5.3.0@bincrafters/stable: Retrieving package 4d887c1c2779c63d2cdd81580698d2e22cb35b29 from remote 'conan-center' \nDownloading conanmanifest.txt\n[==================================================] 1.1KB/1.1KB      \nDownloading conaninfo.txt\n[==================================================] 550B/550B        \nDownloading conan_package.tgz\n[==================================================] 156.2KB/156.2KB  \nDecompressing conan_package.tgz: 161kB [00:00, 13.8MB/s]                   \nfmt/5.3.0@bincrafters/stable: Package installed 4d887c1c2779c63d2cdd81580698d2e22cb35b29\nfmt/5.3.0@bincrafters/stable: Downloaded package revision 0\nconanfile.txt: Generator cmake created conanbuildinfo.cmake\nconanfile.txt: Generator txt created conanbuildinfo.txt\nconanfile.txt: Generated conaninfo.txt\nconanfile.txt: Generated graphinfo\n\n$ cmake ..\n-- The C compiler identification is GNU 5.4.0\n-- The CXX compiler identification is GNU 5.4.0\n-- Check for working C compiler: /usr/bin/cc\n-- Check for working C compiler: /usr/bin/cc -- works\n-- Detecting C compiler ABI info\n-- Detecting C compiler ABI info - done\n-- Detecting C compile features\n-- Detecting C compile features - done\n-- Check for working CXX compiler: /usr/bin/c++\n-- Check for working CXX compiler: /usr/bin/c++ -- works\n-- Detecting CXX compiler ABI info\n-- Detecting CXX compiler ABI info - done\n-- Detecting CXX compile features\n-- Detecting CXX compile features - done\n-- Conan: Adjusting output directories\n-- Conan: Using cmake targets configuration\n-- Library fmt found /home/devuser/.conan/data/fmt/5.3.0/bincrafters/stable/package/4d887c1c2779c63d2cdd81580698d2e22cb35b29/lib/libfmt.a\n-- Conan: Adjusting default RPATHs Conan policies\n-- Conan: Adjusting language standard\n-- Current conanbuildinfo.cmake directory: /data/code/07-package-management/D-conan/ii-basic-targets/build\n-- Conan: Compiler GCC>=5, checking major version 5\n-- Conan: Checking correct version: 5\n-- Configuring done\n-- Generating done\n-- Build files have been written to: /data/code/07-package-management/D-conan/ii-basic-targets/build\n\n\n$ make VERBOSE=1\n/usr/local/bin/cmake -H/data/code/07-package-management/D-conan/ii-basic-targets -B/data/code/07-package-management/D-conan/ii-basic-targets/build --check-build-system CMakeFiles/Makefile.cmake 0\n/usr/local/bin/cmake -E cmake_progress_start /data/code/07-package-management/D-conan/ii-basic-targets/build/CMakeFiles /data/code/07-package-management/D-conan/ii-basic-targets/build/CMakeFiles/progress.marks\nmake -f CMakeFiles/Makefile2 all\nmake[1]: Entering directory '/data/code/07-package-management/D-conan/ii-basic-targets/build'\nmake -f CMakeFiles/third_party_include.dir/build.make CMakeFiles/third_party_include.dir/depend\nmake[2]: Entering directory '/data/code/07-package-management/D-conan/ii-basic-targets/build'\ncd /data/code/07-package-management/D-conan/ii-basic-targets/build && /usr/local/bin/cmake -E cmake_depends \"Unix Makefiles\" /data/code/07-package-management/D-conan/ii-basic-targets /data/code/07-package-management/D-conan/ii-basic-targets /data/code/07-package-management/D-conan/ii-basic-targets/build /data/code/07-package-management/D-conan/ii-basic-targets/build /data/code/07-package-management/D-conan/ii-basic-targets/build/CMakeFiles/third_party_include.dir/DependInfo.cmake --color=\nDependee \"/data/code/07-package-management/D-conan/ii-basic-targets/build/CMakeFiles/third_party_include.dir/DependInfo.cmake\" is newer than depender \"/data/code/07-package-management/D-conan/ii-basic-targets/build/CMakeFiles/third_party_include.dir/depend.internal\".\nDependee \"/data/code/07-package-management/D-conan/ii-basic-targets/build/CMakeFiles/CMakeDirectoryInformation.cmake\" is newer than depender \"/data/code/07-package-management/D-conan/ii-basic-targets/build/CMakeFiles/third_party_include.dir/depend.internal\".\nScanning dependencies of target third_party_include\nmake[2]: Leaving directory '/data/code/07-package-management/D-conan/ii-basic-targets/build'\nmake -f CMakeFiles/third_party_include.dir/build.make CMakeFiles/third_party_include.dir/build\nmake[2]: Entering directory '/data/code/07-package-management/D-conan/ii-basic-targets/build'\n[ 50%] Building CXX object CMakeFiles/third_party_include.dir/main.cpp.o\n/usr/bin/c++   -isystem /home/devuser/.conan/data/fmt/5.3.0/bincrafters/stable/package/4d887c1c2779c63d2cdd81580698d2e22cb35b29/include  -std=gnu++11 -o CMakeFiles/third_party_include.dir/main.cpp.o -c /data/code/07-package-management/D-conan/ii-basic-targets/main.cpp\n[100%] Linking CXX executable bin/third_party_include\n/usr/local/bin/cmake -E cmake_link_script CMakeFiles/third_party_include.dir/link.txt --verbose=1\n/usr/bin/c++      CMakeFiles/third_party_include.dir/main.cpp.o  -o bin/third_party_include /home/devuser/.conan/data/fmt/5.3.0/bincrafters/stable/package/4d887c1c2779c63d2cdd81580698d2e22cb35b29/lib/libfmt.a \nmake[2]: Leaving directory '/data/code/07-package-management/D-conan/ii-basic-targets/build'\n[100%] Built target third_party_include\nmake[1]: Leaving directory '/data/code/07-package-management/D-conan/ii-basic-targets/build'\n/usr/local/bin/cmake -E cmake_progress_start /data/code/07-package-management/D-conan/ii-basic-targets/build/CMakeFiles 0\n\n/usr/bin/cmake -E cmake_progress_start /home/devuser/ws/build/CMakeFiles 0\n\n$ ./bin/third_party_include \nHello, conan. This is fmtlib!\n----\n"
  },
  {
    "path": "07-package-management/D-conan/ii-basic-targets/conanfile.txt",
    "content": "[requires]\nfmt/5.3.0@bincrafters/stable\n\n[generators]\ncmake\n"
  },
  {
    "path": "07-package-management/D-conan/ii-basic-targets/main.cpp",
    "content": "#include <iostream>\n#include <fmt/format.h>\n\nint main(int argc, char *argv[])\n{\n    fmt::print(\"Hello, {}. This is {}!\\n\", \"conan\", \"fmtlib\");\n    return 0;\n}\n"
  },
  {
    "path": "07-package-management/D-conan/ii-basic-targets/run_test.sh",
    "content": "#!/bin/bash\n\nconan_bin=`which conan`\n\nif [ -z $conan_bin ]; then\n    exit 0\nfi\n\nconan profile show default || {\n    conan profile new default --detect\n}\nconan profile update settings.compiler.libcxx=libstdc++11 default\n\necho \"correct version of cmake\"\nmkdir -p build && cd build && conan install .. && cmake .. && make\nif [ $? -ne 0 ]; then\n    echo \"Error running example\"\n    exit 1\nfi\n"
  },
  {
    "path": "07-package-management/README.adoc",
    "content": "= Package Management\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n[[intro]]\nIntroduction\n------------\n\nFor C++ and CMake there is currently no universally accepted way of managing and packaging dependencies. However, in recent years there have been some new and interesting package management systems made available. While these are separate systems to CMake, most of them have are designed to integrate directly into a CMake based build system.\n\n"
  },
  {
    "path": "LICENSE",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2015 Thom Troy\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n\n"
  },
  {
    "path": "README.adoc",
    "content": "\n= CMake Examples\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Introduction\n\nhttps://cmake.org/[CMake] is a cross-platform open-source meta-build system which\ncan build, test and package software. It can be used to support multiple native build environments including\nmake, Apple's xcode and Microsoft Visual Studio.\n\nThis repository includes some example modern CMake configurations which I have picked up\nwhen exploring it's usage for various projects. The examples are laid out in a tutorial like format.\nThe first examples are very basic and slowly increase in complexity drawing on previous examples to show\nmore complex use cases.\n\nThese examples have been tested on Ubuntu 16.04 but should work under any Linux system that supports CMake v3.5+.\n\nThis branch works with the CMake version 3.5 onwards. \n\n* For examples that use CMake version 2.x see the branch link:https://github.com/ttroy50/cmake-examples/tree/v2-style-includes[v2-style-includes].\n* For examples that use CMake version 3.0 see the branch link:https://github.com/ttroy50/cmake-examples/tree/v3.0-minimum[v3.0-minimum]\n\nimage:https://travis-ci.org/ttroy50/cmake-examples.svg?branch=master[\"Build Status\", link=\"https://travis-ci.org/ttroy50/cmake-examples\"]\n\n# Requirements\n\nThe basic requirements for most examples are:\n\n* CMake v3.5+\n* A c++ compiler (defaults to gcc)\n* make\n\n## Installation on Ubuntu\n\nThe easiest way to install the above on Ubuntu is as follows\n\n[source,bash]\n----\n$ sudo apt-get install build-essential\n$ sudo apt-get install cmake\n----\n\nSome specific examples may require other tools including:\n\n* http://www.boost.org/[boost]\n\n  $ sudo apt-get install libboost-all-dev\n\n* https://github.com/google/protobuf[protobuf]\n\n  $ sudo apt-get install libprotobuf-dev\n  $ sudo apt-get install protobuf-compiler\n\n* http://cppcheck.sourceforge.net/[cppcheck]\n\n  $ sudo apt-get install cppcheck\n\n* http://clang.llvm.org/[clang]\n\n  $ sudo apt-get install clang-3.6\n\n* https://ninja-build.org/[ninja]\n\n  $ sudo apt-get install ninja-build\n\n* link:https://conan.io[conan]\n\n  $ sudo apt-get install python3 python3-pip\n  $ sudo pip3 install conan\n\n## Docker\n\nDocker containers with all requirements and various versions of CMake are generated to help make testing the examples easier. These are available from the docker hub repository link:https://hub.docker.com/r/matrim/cmake-examples/[matrim/cmake-examples].\n\nTo build the full set of cmake-examples test cases you can run:\n\n[source,bash]\n----\ndocker run -it matrim/cmake-examples:3.5.1\ncd ~ \ngit clone https://github.com/ttroy50/cmake-examples.git code\ncd code\n./test.sh\n----\n\nFor more details on build and running the docker containers link:here[dockerfiles].\n\n# Other Links\n\nThere are many CMake tutorials and examples online. The list below includes links\nto some of these which I have found helpful in my CMake journey.\n\n  * https://web.archive.org/web/20160314094326/https://www.kdab.com/~stephen/moderncmake.pdf[Modern CMake Slides]\n  * https://rix0r.nl/blog/2015/08/13/cmake-guide/[rix0r Modern CMake Blog]\n  * https://cmake.org/cmake-tutorial/[Official CMake Tutorial]\n  * https://gitlab.kitware.com/cmake/community/wikis/home[Official CMake Wiki]\n  * https://gitlab.kitware.com/cmake/community/wikis/doc/cmake/Useful-Variables[CMake Useful Variables]\n  * http://derekmolloy.ie/hello-world-introductions-to-cmake/[Derek Molloy - Intro to CMake]\n  * http://techminded.net/blog/modular-c-projects-with-cmake.html[Modular C++ Projects]\n  * https://web.archive.org/web/20190320121339/http://voices.canonical.com/jussi.pakkanen/2013/03/26/a-list-of-common-cmake-antipatterns/[Common CMake Anti-Patterns]\n  * http://baptiste-wicht.com/posts/2014/04/install-use-clang-static-analyzer-cmake.html[Using clang static analyser with CMake]\n  * https://cmake.org/pipermail/cmake/2011-April/043709.html[Static Analysis with CDash] - Includes some info about using CppCheck with CMake\n  * https://samthursfield.wordpress.com/2015/10/20/some-cmake-tips/[CMake Tips]\n  * https://www.johnlamp.net/cmake-tutorial.html[John Lamp - CMake Tutorial]\n  * link:https://docs.conan.io[Conan Documentation]\n"
  },
  {
    "path": "cmake-examples.sublime-project",
    "content": "{\n\t\"folders\":\n\t[\n\t\t{\n\t\t\t\"path\": \".\"\n\t\t}\n\t]\n}\n"
  },
  {
    "path": "dockerfiles/README.adoc",
    "content": "\n= CMake Examples with Docker\n:toc:\n:toc-placement!:\n\ntoc::[]\n\n# Docker\n\nhttps://www.docker.com/[Docker] allows you to package software in a container which contains a filesystem with all dependencies. This allows having containers which include everything needed to run and test our examples. And as a result of packaging all dependencies we can create containers to include different versions of cmake so that it is possible to easily make sure our examples work for many cmake versions.\n\n# Building\n\nTo build a container from the this directory run the following:\n\n[source,bash]\n----\n$ docker build --rm -f <dockerfile> -t <container tag> .\n----\n\nFor example:\n\n[source,bash]\n----\n$ docker build --rm -f ubuntu14.04-cmake-3.5.1 -t matrim/cmake-examples:3.5.1 .\n----\n\nIn this example the tag is created as follows\n\n  <docker user>/<repository>:<cmake version>\n\nThis will tag the container as belong to my repository with the label of the container being the version of cmake installed.\n\n## Pre-build Images\n\nI have pre-build images and pushed them to the https://hub.docker.com[docker hub] in the repository https://hub.docker.com/r/matrim/cmake-examples/[matrim/cmake-examples].\n\nThe current usable images include the following versions of cmake:\n\n* Ubuntu 16.04 with CMake 3.5.1\n\n    $ docker pull docker pull matrim/cmake-examples:3.5.1\n\n* Ubuntu 16.04 with CMake 3.10.3\n\n    $ docker pull docker pull matrim/cmake-examples:3.10.3\n\nSome old images which work with older version of the repository include:\n\n* Ubuntu 14.04 with CMake 2.8.12.2\n\n    $ docker pull docker pull matrim/cmake-examples:2.8.12.2\n\n* Ubuntu 14.04 with CMake 3.4.3\n\n    $ docker pull docker pull matrim/cmake-examples:3.4.3\n\n# Running\n\nWhen run the images will automatically create a non root user called devuser, with a default command to launch a bash shell in the users home directory.\n\nIf you want to set the UID and GID for this user you can pass them in via the environment variables `DEV_UID` and `DEV_GID`\n\nFor example\n\n[source,bash]\n----\ndocker run -e DEV_UID=`id -u` -e DEV_GID=`id -u` -it matrim/cmake-examples:3.5.1\n----\n\n\nTo build the full set of cmake-examples test cases you can run:\n\n[source,bash]\n----\ndocker run -it matrim/cmake-examples:3.5.1\ngit clone https://github.com/ttroy50/cmake-examples.git\ncd cmake-examples\n./test.sh\n----\n\n\nIf you already have a checkout of the cmake-examples you can load the directory as a docker volume.\n\nBelow is an example of loading a volume and automatically running all cmake-example test cases:\n\n[source,bash]\n----\ndocker run --rm -e DEV_UID=`id -u` -e DEV_GID=`id -u` -v /checkout/directory:/data/code -it matrim/cmake-examples:3.5.1 /data/code/test.sh\n----\n"
  },
  {
    "path": "dockerfiles/setup.sh",
    "content": "#!/bin/bash\n# Setup script for the cmake-examples repository\n# Will create a non root user using the UID and GID passed in from environment \n# variables and give them sudo access\n#\nret=false\noutput=`getent passwd devuser 2>&1`\nresult=$?\nif [ $result -ne 0 ] ; then\n    echo \"Creating devuser\"\n    if [ -z $DEV_UID ]; then\n        DEV_UID=1000\n    fi\n\n    if [ -z $DEV_GID ]; then\n        DEV_GID=1000\n    fi\n\n    groupadd -g $DEV_GID devgroup\n    useradd -c 'container user' -u $DEV_UID -g $DEV_GID -d /home/devuser -m devuser\n    echo \"devuser:todo_$DEV_UID_$DEV_GID\" | chpasswd\n    sudo adduser devuser sudo\n    echo \"%sudo ALL=NOPASSWD: ALL\" >> /etc/sudoers\nfi\n\nexec gosu devuser \"$@\"\n"
  },
  {
    "path": "dockerfiles/ubuntu14.04-cmake-3.4.3",
    "content": "# Container for building and testing cmake-examples with cmake v3.4.3\nFROM ubuntu:14.04\nMAINTAINER Thom Troy\n\nRUN apt-get update && apt-get install -y build-essential \\\n    sudo \\\n    libboost-all-dev \\\n    libprotobuf-dev \\\n    protobuf-compiler \\\n    clang-3.6 \\\n    clang-format-3.6 \\\n    ninja-build \\\n    wget \\\n    git \\\n    && apt-get clean \\\n    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* \\\n    && apt-get autoremove -y\n\nRUN cd /usr/local/src \\\n    && wget https://github.com/tianon/gosu/releases/download/1.10/gosu-amd64 \\\n    && mv gosu-amd64 /usr/local/bin/gosu \\\n    && chmod +x /usr/local/bin/gosu\n\nADD setup.sh /setup.sh\nRUN chmod +x /setup.sh\n\nRUN cd /usr/local/src \\ \n    && wget https://cmake.org/files/v3.4/cmake-3.4.3.tar.gz \\\n    && tar xvf cmake-3.4.3.tar.gz \\ \n    && cd cmake-3.4.3 \\\n    && ./bootstrap \\\n    && make \\\n    && make install \\\n    && cd .. \\\n    && rm -rf cmake*\n\n# cppcheck\nRUN cd /usr/local/src \\\n    && wget https://github.com/danmar/cppcheck/archive/1.79.tar.gz \\\n    && tar xvf 1.79.tar.gz \\\n    && cd cppcheck-1.79 \\\n    && mkdir build \\\n    && cd build \\\n    && cmake .. \\\n    && make install \\\n    && cd ../.. && rm -rf cppcheck*\n\n\nCMD [\"/bin/bash\"]\n\nENTRYPOINT [\"/setup.sh\"]\n"
  },
  {
    "path": "dockerfiles/ubuntu14.04-default-2.8.12.2",
    "content": "# Container for building and testing cmake-examples with default cmake v2.8.12.2\nFROM ubuntu:14.04\nMAINTAINER Thom Troy\n\nRUN apt-get update && apt-get install -y build-essential \\\n    sudo \\\n    cmake \\\n    libboost-all-dev \\\n    libprotobuf-dev \\\n    protobuf-compiler \\\n    cppcheck \\\n    clang-3.6 \\\n    clang-format-3.6 \\\n    ninja-build \\\n    wget \\\n    git \\\n    && apt-get clean \\\n    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*\n\n# tini required to handle issue with building deb packages from cmake v2.8\nRUN cd /usr/local/src \\\n    && wget https://github.com/krallin/tini/archive/v0.9.0.tar.gz \\\n    && tar xvf v0.9.0.tar.gz  \\\n    && cd tini-0.9.0 \\\n    && cmake . \\\n    && make \\\n    && make install \\\n    && cd /usr/local/src \\\n    && rm -rf tini-* \\\n    && rm -rf v0.9.0.tar.gz\n\nRUN cd /usr/local/src \\\n    && wget https://github.com/tianon/gosu/releases/download/1.10/gosu-amd64 \\\n    && mv gosu-amd64 /usr/local/bin/gosu \\\n    && chmod +x /usr/local/bin/gosu\n\nADD setup.sh /setup.sh\nRUN chmod +x /setup.sh\n\nCMD [\"/bin/bash\"]\nENTRYPOINT [\"/usr/local/bin/tini\", \"--\", \"/setup.sh\"]\n"
  },
  {
    "path": "dockerfiles/ubuntu16.04-cmake-3.10.3",
    "content": "# Container for building and testing cmake-examples with CMake 3.10.3\nFROM ubuntu:16.04\nMAINTAINER Thom Troy\n\nRUN apt-get update && apt-get install -y build-essential \\\n    sudo \\\n    cmake \\\n    libboost-all-dev \\\n    libprotobuf-dev \\\n    protobuf-compiler \\\n    clang-3.6 \\\n    clang-format-3.6 \\\n    ninja-build \\\n    wget \\\n    git \\\n    python3 \\ \n    python3-pip \\\n    && pip3 install conan \\\n    && apt-get clean \\\n    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*\n\nRUN cd /usr/local/src \\ \n    && wget https://cmake.org/files/v3.10/cmake-3.10.3.tar.gz \\\n    && tar xvf cmake-3.10.3.tar.gz \\ \n    && cd cmake-3.10.3 \\\n    && ./bootstrap \\\n    && make \\\n    && make install \\\n    && cd .. \\\n    && rm -rf cmake*\n\n# cppcheck\nRUN cd /usr/local/src \\\n    && wget https://github.com/danmar/cppcheck/archive/1.79.tar.gz \\\n    && tar xvf 1.79.tar.gz \\\n    && cd cppcheck-1.79 \\\n    && mkdir build \\\n    && cd build \\\n    && cmake .. \\\n    && make install \\\n    && cd ../.. && rm -rf cppcheck*\n\nRUN cd /usr/local/src \\\n    && wget https://github.com/tianon/gosu/releases/download/1.10/gosu-amd64 \\\n    && mv gosu-amd64 /usr/local/bin/gosu \\\n    && chmod +x /usr/local/bin/gosu\n\nADD setup.sh /setup.sh\nRUN chmod +x /setup.sh\n\nCMD [\"/bin/bash\"]\nENTRYPOINT [\"/setup.sh\"]\n"
  },
  {
    "path": "dockerfiles/ubuntu16.04-default-cmake-3.5.1",
    "content": "# Container for building and testing cmake-examples with default cmake v3.5.1\nFROM ubuntu:16.04\nMAINTAINER Thom Troy\n\nRUN apt-get update && apt-get install -y build-essential \\\n    sudo \\\n    cmake \\\n    libboost-all-dev \\\n    libprotobuf-dev \\\n    protobuf-compiler \\\n    clang-3.6 \\\n    clang-format-3.6 \\\n    ninja-build \\\n    wget \\\n    git \\\n    python3 \\ \n    python3-pip \\\n    && pip3 install conan \\\n    && apt-get clean \\\n    && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*\n\n# cppcheck\nRUN cd /usr/local/src \\\n    && wget https://github.com/danmar/cppcheck/archive/1.79.tar.gz \\\n    && tar xvf 1.79.tar.gz \\\n    && cd cppcheck-1.79 \\\n    && mkdir build \\\n    && cd build \\\n    && cmake .. \\\n    && make install \\\n    && cd ../.. && rm -rf cppcheck*\n\nRUN cd /usr/local/src \\\n    && wget https://github.com/tianon/gosu/releases/download/1.10/gosu-amd64 \\\n    && mv gosu-amd64 /usr/local/bin/gosu \\\n    && chmod +x /usr/local/bin/gosu\n\nADD setup.sh /setup.sh\nRUN chmod +x /setup.sh\n\nCMD [\"/bin/bash\"]\nENTRYPOINT [\"/setup.sh\"]\n"
  },
  {
    "path": "test.sh",
    "content": "#!/bin/bash\n\n# print out cmake information to help with debugging.\n\ncmake --version\ncmake --help\n\n# Find the directory this test script is in and then run them from there\nEXAMPLES_DIR=\"$( cd \"$( dirname \"${BASH_SOURCE[0]}\" )\" && pwd )\"\necho \"running examples in $EXAMPLES_DIR\"\n\ncd $EXAMPLES_DIR\n\ndirs=(./01-basic/A-hello-cmake \\\n./01-basic/B-hello-headers \\\n./01-basic/C-static-library \\\n./01-basic/D-shared-library \\\n./01-basic/E-installing \\\n./01-basic/F-build-type \\\n./01-basic/G-compile-flags \\\n./01-basic/H-third-party-library \\\n./01-basic/I-compiling-with-clang \\\n./01-basic/J-building-with-ninja \\\n./01-basic/K-imported-targets \\\n./01-basic/L-cpp-standard/i-common-method \\\n./01-basic/L-cpp-standard/ii-cxx-standard \\\n./01-basic/L-cpp-standard/iii-compile-features \\\n./02-sub-projects/A-basic \\\n./03-code-generation/protobuf \\\n./03-code-generation/configure-files \\\n./04-static-analysis/cppcheck \\\n./04-static-analysis/cppcheck-compile-commands \\\n./04-static-analysis/clang-analyzer \\\n./04-static-analysis/clang-format \\\n./05-unit-testing/boost \\\n./05-unit-testing/google-test-download \\\n./05-unit-testing/catch2-vendored \\\n./06-installer/deb \\\n./07-package-management/D-conan/i-basic \\\n./07-package-management/D-conan/ii-basic-targets \\\n)\n\nROOT_DIR=`pwd`\n\nfor dir in ${dirs[*]}\ndo\n    echo \"\"\n    echo \"\"\n    echo \"Running test for $dir\"\n    cd $ROOT_DIR\n    if [ -d \"$ROOT_DIR/$dir/build\" ]; then\n        echo \"deleting $dir/build\"\n        rm -r $dir/build\n    fi\n\n    if [ -f \"$dir/pre_test.sh\" ]; then\n        echo \"running pre test\"\n        $ROOT_DIR/$dir/pre_test.sh\n        if [ $? -ne 0 ]; then\n            echo \"Error running pre_test for $dir\"\n            exit 1\n        fi\n    fi\n\n    if [ -f \"$dir/run_test.sh\" ]; then\n        echo \"running run_test\"\n        cd $dir && $ROOT_DIR/$dir/run_test.sh\n        if [ $? -ne 0 ]; then\n            echo \"Error running run_test for $dir\"\n            exit 1\n        fi\n    else\n        cd $dir && mkdir -p build && cd build && cmake .. && make\n        if [ $? -ne 0 ]; then\n            echo \"Error running example $dir\"\n            exit 1\n        fi\n    fi\n\n    if [ -f \"$ROOT_DIR/$dir/post_test.sh\" ]; then\n        echo \"running post test\"\n        $ROOT_DIR/$dir/post_test.sh\n        if [ $? -ne 0 ]; then\n            echo \"Error running post_test for $dir\"\n            exit 1\n        fi\n    fi\ndone\n\necho \"\"\necho \"\"\necho \"All Tests Completed\"\n"
  }
]