From 0e671dfa350aa050e4a5f0f1faa6ff40dd08aae0 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 3 Dec 2018 21:01:38 -0500 Subject: [PATCH 001/285] Integrate SonarCloud into travis. Minor travis cleanup. --- .travis.yml | 53 ++++++++++++++++++++++++---------------- sonar-project.properties | 7 ++++++ 2 files changed, 39 insertions(+), 21 deletions(-) create mode 100644 sonar-project.properties diff --git a/.travis.yml b/.travis.yml index 5ecca9b..9d26fba 100644 --- a/.travis.yml +++ b/.travis.yml @@ -7,57 +7,60 @@ matrix: include: # Linux gcc5 - os: linux - env: COMPILER=gcc5 PACKAGES="g++-5 g++-5-multilib g++-multilib" + env: COMPILER=gcc5 TOOLCHAIN=gcc PACKAGES="g++-5 g++-5-multilib g++-multilib" # Linux gcc6 - os: linux - env: COMPILER=gcc6 PACKAGES="g++-6 g++-6-multilib g++-multilib" + env: COMPILER=gcc6 TOOLCHAIN=gcc PACKAGES="g++-6 g++-6-multilib g++-multilib" # Linux gcc7 - os: linux - env: COMPILER=gcc7 PACKAGES="g++-7 g++-7-multilib g++-multilib" + env: COMPILER=gcc7 TOOLCHAIN=gcc PACKAGES="g++-7 g++-7-multilib g++-multilib" # Linux gcc8 - os: linux - env: COMPILER=gcc8 PACKAGES="g++-8 g++-8-multilib g++-multilib" + env: COMPILER=gcc8 TOOLCHAIN=gcc PACKAGES="g++-8 g++-8-multilib g++-multilib" # Linux clang4 - os: linux - env: COMPILER=clang4 PACKAGES="clang-4.0 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + env: COMPILER=clang4 TOOLCHAIN=clang PACKAGES="clang-4.0 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" # Linux clang5 - os: linux - env: COMPILER=clang5 PACKAGES="clang-5.0 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + env: COMPILER=clang5 TOOLCHAIN=clang SONARCLOUD=1 PACKAGES="clang-5.0 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + addons: + sonarcloud: + organization: "nfrechette-github" # Linux clang6 - os: linux - env: COMPILER=clang6 PACKAGES="clang-6.0 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + env: COMPILER=clang6 TOOLCHAIN=clang PACKAGES="clang-6.0 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" # OS X xcode8 - os: osx osx_image: xcode8.3 - env: COMPILER=osx + env: COMPILER=osx TOOLCHAIN=xcode # OS X xcode9 - os: osx osx_image: xcode9.4 - env: COMPILER=osx + env: COMPILER=osx TOOLCHAIN=xcode # OS X xcode10 - os: osx osx_image: xcode10 - env: COMPILER=osx + env: COMPILER=osx TOOLCHAIN=xcode before_install: - - if [ "$COMPILER" = "clang4" ]; then curl -sSL "http://apt.llvm.org/llvm-snapshot.gpg.key" | sudo -E apt-key add - ; fi - - if [ "$COMPILER" = "clang4" ]; then echo "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-4.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - - if [ "$COMPILER" = "clang5" ]; then curl -sSL "http://apt.llvm.org/llvm-snapshot.gpg.key" | sudo -E apt-key add - ; fi - - if [ "$COMPILER" = "clang5" ]; then echo "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-5.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - - if [ "$COMPILER" = "clang6" ]; then curl -sSL "http://apt.llvm.org/llvm-snapshot.gpg.key" | sudo -E apt-key add - ; fi - - if [ "$COMPILER" = "clang6" ]; then echo "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-6.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test" ; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo -E apt-get -yq update ; fi - - if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install ${PACKAGES} ; fi + - if [[ "$TOOLCHAIN" == "clang" ]]; then curl -sSL "http://apt.llvm.org/llvm-snapshot.gpg.key" | sudo -E apt-key add - ; fi + - if [[ "$COMPILER" == "clang4" ]]; then echo "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-4.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi + - if [[ "$COMPILER" == "clang5" ]]; then echo "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-5.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi + - if [[ "$COMPILER" == "clang6" ]]; then echo "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-6.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi + - 'if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then + sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test"; + sudo -E apt-get -yq update; + sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install ${PACKAGES}; + fi' - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew upgrade python || true ; fi script: @@ -65,5 +68,13 @@ script: - python3 make.py -clean -build -unit_test -${COMPILER} -Release -x86 - python3 make.py -clean -build -unit_test -${COMPILER} -Debug -x64 - python3 make.py -clean -build -unit_test -${COMPILER} -Release -x64 - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then python3 make.py -clean -build -ios -Debug ; fi - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then python3 make.py -clean -build -ios -Release; fi + - 'if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + python3 make.py -clean -build -ios -Debug; + python3 make.py -clean -build -ios -Release; + fi' + # Only run sonarcloud on non-PRs + - 'if [[ "$SONARCLOUD" == "1" && "$TRAVIS_PULL_REQUEST" == "false" ]]; then + python3 make.py -clean -${COMPILER} -Release -x64; + build-wrapper-linux-x86-64 --out-dir bw_output python3 make.py -build -${COMPILER} -Release -x64; + sonar-scanner; + fi' diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 0000000..5137c7a --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,7 @@ +sonar.projectKey=nfrechette_sjson-cpp +sonar.projectName=SJSON-cpp +sonar.projectVersion=0.5.0 + +sonar.sources=includes + +sonar.cfamily.build-wrapper-output=bw_output From 377c1f7d1144d1fd5383656932127d0bc7aa26d1 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 3 Dec 2018 21:31:27 -0500 Subject: [PATCH 002/285] Adding SonarCloud badge. --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index f7b8f38..36407eb 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ [![CLA assistant](https://cla-assistant.io/readme/badge/nfrechette/sjson-cpp)](https://cla-assistant.io/nfrechette/sjson-cpp) [![Build status](https://ci.appveyor.com/api/projects/status/oynd3x3d9umjaruf/branch/develop?svg=true)](https://ci.appveyor.com/project/nfrechette/sjson-cpp) [![Build Status](https://travis-ci.org/nfrechette/sjson-cpp.svg?branch=develop)](https://travis-ci.org/nfrechette/sjson-cpp) +[![Sonar Status](https://sonarcloud.io/api/project_badges/measure?project=nfrechette_sjson-cpp&metric=alert_status)](https://sonarcloud.io/dashboard?id=nfrechette_sjson-cpp) [![GitHub (pre-)release](https://img.shields.io/github/release/nfrechette/sjson-cpp/all.svg)](https://github.com/nfrechette/sjson-cpp/releases) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nfrechette/sjson-cpp/master/LICENSE) From da9c243a7e88fef00563280dea22212353c1d19f Mon Sep 17 00:00:00 2001 From: Cody Jones Date: Sat, 8 Dec 2018 08:33:56 -0800 Subject: [PATCH 003/285] Use the argparse module, upgrade to the latest Catch2, and allow specific unit tests to be run. --- .gitmodules | 3 + .travis.yml | 16 +- appveyor.yml | 12 +- external/README.md | 2 +- external/catch-1.9.6/catch.hpp | 11545 --------------------- external/catch2 | 1 + make.py | 153 +- tests/main_android/CMakeLists.txt | 2 +- tests/main_generic/CMakeLists.txt | 8 +- tests/main_ios/CMakeLists.txt | 2 +- tools/release_scripts/test_everything.py | 22 +- 11 files changed, 88 insertions(+), 11678 deletions(-) create mode 100644 .gitmodules delete mode 100644 external/catch-1.9.6/catch.hpp create mode 160000 external/catch2 diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..fe59bc7 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "external/catch2"] + path = external/catch2 + url = https://github.com/catchorg/Catch2 diff --git a/.travis.yml b/.travis.yml index 9d26fba..90e2e80 100644 --- a/.travis.yml +++ b/.travis.yml @@ -64,17 +64,17 @@ before_install: - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew upgrade python || true ; fi script: - - python3 make.py -clean -build -unit_test -${COMPILER} -Debug -x86 - - python3 make.py -clean -build -unit_test -${COMPILER} -Release -x86 - - python3 make.py -clean -build -unit_test -${COMPILER} -Debug -x64 - - python3 make.py -clean -build -unit_test -${COMPILER} -Release -x64 + - python3 make.py -clean -build -unit_test -compiler ${COMPILER} -config Debug -cpu x86 + - python3 make.py -clean -build -unit_test -compiler ${COMPILER} -config Release -cpu x86 + - python3 make.py -clean -build -unit_test -compiler ${COMPILER} -config Debug -cpu x64 + - python3 make.py -clean -build -unit_test -compiler ${COMPILER} -config Release -cpu x64 - 'if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - python3 make.py -clean -build -ios -Debug; - python3 make.py -clean -build -ios -Release; + python3 make.py -clean -build -compiler ios -config Debug; + python3 make.py -clean -build -compiler ios -config Release; fi' # Only run sonarcloud on non-PRs - 'if [[ "$SONARCLOUD" == "1" && "$TRAVIS_PULL_REQUEST" == "false" ]]; then - python3 make.py -clean -${COMPILER} -Release -x64; - build-wrapper-linux-x86-64 --out-dir bw_output python3 make.py -build -${COMPILER} -Release -x64; + python3 make.py -clean -compiler ${COMPILER} -config Release -cpu x64; + build-wrapper-linux-x86-64 --out-dir bw_output python3 make.py -build -compiler ${COMPILER} -config Release -cpu x64; sonar-scanner; fi' diff --git a/appveyor.yml b/appveyor.yml index 37f17b7..f4acd56 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,14 +7,18 @@ image: - Visual Studio 2015 - Visual Studio 2017 +install: +- cmd: >- + git submodule update --init --recursive + build_script: - cmd: >- IF "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" (SET COMPILER=vs2015) ELSE (SET COMPILER=vs2017) - %PYTHON%\\python.exe make.py -clean -build -unit_test -%COMPILER% -Debug -x86 + %PYTHON%\\python.exe make.py -clean -build -unit_test -compiler %COMPILER% -config Debug -cpu x86 - %PYTHON%\\python.exe make.py -clean -build -unit_test -%COMPILER% -Release -x86 + %PYTHON%\\python.exe make.py -clean -build -unit_test -compiler %COMPILER% -config Release -cpu x86 - %PYTHON%\\python.exe make.py -clean -build -unit_test -%COMPILER% -Debug -x64 + %PYTHON%\\python.exe make.py -clean -build -unit_test -compiler %COMPILER% -config Debug -cpu x64 - %PYTHON%\\python.exe make.py -clean -build -unit_test -%COMPILER% -Release -x64 + %PYTHON%\\python.exe make.py -clean -build -unit_test -compiler %COMPILER% -config Release -cpu x64 diff --git a/external/README.md b/external/README.md index 013c756..8666509 100644 --- a/external/README.md +++ b/external/README.md @@ -4,4 +4,4 @@ Good news! There are no external dependencies needed by this library at runtime! ## Catch -[Catch 1.9.6](https://github.com/catchorg/Catch2/releases/tag/v1.9.6) is used by our [unit tests](../tests). You will only need it if you run the unit tests and it is included as-is without modifications. +[Catch2 v2.5.0](https://github.com/catchorg/Catch2/releases/tag/v2.5.0) is used by our [unit tests](../tests). You will only need it if you run the unit tests and it is included as-is without modifications. diff --git a/external/catch-1.9.6/catch.hpp b/external/catch-1.9.6/catch.hpp deleted file mode 100644 index f7681f4..0000000 --- a/external/catch-1.9.6/catch.hpp +++ /dev/null @@ -1,11545 +0,0 @@ -/* - * Catch v1.9.6 - * Generated: 2017-06-27 12:19:54.557875 - * ---------------------------------------------------------- - * This file has been merged from multiple headers. Please don't edit it directly - * Copyright (c) 2012 Two Blue Cubes Ltd. All rights reserved. - * - * Distributed under the Boost Software License, Version 1.0. (See accompanying - * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) - */ -#ifndef TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED -#define TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED - -#define TWOBLUECUBES_CATCH_HPP_INCLUDED - -#ifdef __clang__ -# pragma clang system_header -#elif defined __GNUC__ -# pragma GCC system_header -#endif - -// #included from: internal/catch_suppress_warnings.h - -#ifdef __clang__ -# ifdef __ICC // icpc defines the __clang__ macro -# pragma warning(push) -# pragma warning(disable: 161 1682) -# else // __ICC -# pragma clang diagnostic ignored "-Wglobal-constructors" -# pragma clang diagnostic ignored "-Wvariadic-macros" -# pragma clang diagnostic ignored "-Wc99-extensions" -# pragma clang diagnostic ignored "-Wunused-variable" -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wpadded" -# pragma clang diagnostic ignored "-Wc++98-compat" -# pragma clang diagnostic ignored "-Wc++98-compat-pedantic" -# pragma clang diagnostic ignored "-Wswitch-enum" -# pragma clang diagnostic ignored "-Wcovered-switch-default" -# endif -#elif defined __GNUC__ -# pragma GCC diagnostic ignored "-Wvariadic-macros" -# pragma GCC diagnostic ignored "-Wunused-variable" -# pragma GCC diagnostic ignored "-Wparentheses" - -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wpadded" -#endif -#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER) -# define CATCH_IMPL -#endif - -#ifdef CATCH_IMPL -# ifndef CLARA_CONFIG_MAIN -# define CLARA_CONFIG_MAIN_NOT_DEFINED -# define CLARA_CONFIG_MAIN -# endif -#endif - -// #included from: internal/catch_notimplemented_exception.h -#define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_H_INCLUDED - -// #included from: catch_common.h -#define TWOBLUECUBES_CATCH_COMMON_H_INCLUDED - -// #included from: catch_compiler_capabilities.h -#define TWOBLUECUBES_CATCH_COMPILER_CAPABILITIES_HPP_INCLUDED - -// Detect a number of compiler features - mostly C++11/14 conformance - by compiler -// The following features are defined: -// -// CATCH_CONFIG_CPP11_NULLPTR : is nullptr supported? -// CATCH_CONFIG_CPP11_NOEXCEPT : is noexcept supported? -// CATCH_CONFIG_CPP11_GENERATED_METHODS : The delete and default keywords for compiler generated methods -// CATCH_CONFIG_CPP11_IS_ENUM : std::is_enum is supported? -// CATCH_CONFIG_CPP11_TUPLE : std::tuple is supported -// CATCH_CONFIG_CPP11_LONG_LONG : is long long supported? -// CATCH_CONFIG_CPP11_OVERRIDE : is override supported? -// CATCH_CONFIG_CPP11_UNIQUE_PTR : is unique_ptr supported (otherwise use auto_ptr) -// CATCH_CONFIG_CPP11_SHUFFLE : is std::shuffle supported? -// CATCH_CONFIG_CPP11_TYPE_TRAITS : are type_traits and enable_if supported? - -// CATCH_CONFIG_CPP11_OR_GREATER : Is C++11 supported? - -// CATCH_CONFIG_VARIADIC_MACROS : are variadic macros supported? -// CATCH_CONFIG_COUNTER : is the __COUNTER__ macro supported? -// CATCH_CONFIG_WINDOWS_SEH : is Windows SEH supported? -// CATCH_CONFIG_POSIX_SIGNALS : are POSIX signals supported? -// **************** -// Note to maintainers: if new toggles are added please document them -// in configuration.md, too -// **************** - -// In general each macro has a _NO_ form -// (e.g. CATCH_CONFIG_CPP11_NO_NULLPTR) which disables the feature. -// Many features, at point of detection, define an _INTERNAL_ macro, so they -// can be combined, en-mass, with the _NO_ forms later. - -// All the C++11 features can be disabled with CATCH_CONFIG_NO_CPP11 - -#ifdef __cplusplus - -# if __cplusplus >= 201103L -# define CATCH_CPP11_OR_GREATER -# endif - -# if __cplusplus >= 201402L -# define CATCH_CPP14_OR_GREATER -# endif - -#endif - -#ifdef __clang__ - -# if __has_feature(cxx_nullptr) -# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR -# endif - -# if __has_feature(cxx_noexcept) -# define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT -# endif - -# if defined(CATCH_CPP11_OR_GREATER) -# define CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \ - _Pragma( "clang diagnostic push" ) \ - _Pragma( "clang diagnostic ignored \"-Wexit-time-destructors\"" ) -# define CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \ - _Pragma( "clang diagnostic pop" ) - -# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ - _Pragma( "clang diagnostic push" ) \ - _Pragma( "clang diagnostic ignored \"-Wparentheses\"" ) -# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \ - _Pragma( "clang diagnostic pop" ) -# endif - -#endif // __clang__ - -//////////////////////////////////////////////////////////////////////////////// -// We know some environments not to support full POSIX signals -#if defined(__CYGWIN__) || defined(__QNX__) - -# if !defined(CATCH_CONFIG_POSIX_SIGNALS) -# define CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS -# endif - -#endif - -//////////////////////////////////////////////////////////////////////////////// -// Cygwin -#ifdef __CYGWIN__ - -// Required for some versions of Cygwin to declare gettimeofday -// see: http://stackoverflow.com/questions/36901803/gettimeofday-not-declared-in-this-scope-cygwin -# define _BSD_SOURCE - -#endif // __CYGWIN__ - -//////////////////////////////////////////////////////////////////////////////// -// Borland -#ifdef __BORLANDC__ - -#endif // __BORLANDC__ - -//////////////////////////////////////////////////////////////////////////////// -// EDG -#ifdef __EDG_VERSION__ - -#endif // __EDG_VERSION__ - -//////////////////////////////////////////////////////////////////////////////// -// Digital Mars -#ifdef __DMC__ - -#endif // __DMC__ - -//////////////////////////////////////////////////////////////////////////////// -// GCC -#ifdef __GNUC__ - -# if __GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__) -# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR -# endif - -// - otherwise more recent versions define __cplusplus >= 201103L -// and will get picked up below - -#endif // __GNUC__ - -//////////////////////////////////////////////////////////////////////////////// -// Visual C++ -#ifdef _MSC_VER - -#define CATCH_INTERNAL_CONFIG_WINDOWS_SEH - -#if (_MSC_VER >= 1600) -# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR -# define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR -#endif - -#if (_MSC_VER >= 1900 ) // (VC++ 13 (VS2015)) -#define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT -#define CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS -#define CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE -#define CATCH_INTERNAL_CONFIG_CPP11_TYPE_TRAITS -#endif - -#endif // _MSC_VER - -//////////////////////////////////////////////////////////////////////////////// - -// Use variadic macros if the compiler supports them -#if ( defined _MSC_VER && _MSC_VER > 1400 && !defined __EDGE__) || \ - ( defined __WAVE__ && __WAVE_HAS_VARIADICS ) || \ - ( defined __GNUC__ && __GNUC__ >= 3 ) || \ - ( !defined __cplusplus && __STDC_VERSION__ >= 199901L || __cplusplus >= 201103L ) - -#define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS - -#endif - -// Use __COUNTER__ if the compiler supports it -#if ( defined _MSC_VER && _MSC_VER >= 1300 ) || \ - ( defined __GNUC__ && ( __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3 )) ) || \ - ( defined __clang__ && __clang_major__ >= 3 ) - -#define CATCH_INTERNAL_CONFIG_COUNTER - -#endif - -//////////////////////////////////////////////////////////////////////////////// -// C++ language feature support - -// catch all support for C++11 -#if defined(CATCH_CPP11_OR_GREATER) - -# if !defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR) -# define CATCH_INTERNAL_CONFIG_CPP11_NULLPTR -# endif - -# ifndef CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT -# define CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT -# endif - -# ifndef CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS -# define CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS -# endif - -# ifndef CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM -# define CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM -# endif - -# ifndef CATCH_INTERNAL_CONFIG_CPP11_TUPLE -# define CATCH_INTERNAL_CONFIG_CPP11_TUPLE -# endif - -# ifndef CATCH_INTERNAL_CONFIG_VARIADIC_MACROS -# define CATCH_INTERNAL_CONFIG_VARIADIC_MACROS -# endif - -# if !defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG) -# define CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG -# endif - -# if !defined(CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE) -# define CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE -# endif -# if !defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) -# define CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR -# endif -# if !defined(CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE) -# define CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE -# endif -# if !defined(CATCH_INTERNAL_CONFIG_CPP11_TYPE_TRAITS) -# define CATCH_INTERNAL_CONFIG_CPP11_TYPE_TRAITS -# endif - -#endif // __cplusplus >= 201103L - -// Now set the actual defines based on the above + anything the user has configured -#if defined(CATCH_INTERNAL_CONFIG_CPP11_NULLPTR) && !defined(CATCH_CONFIG_CPP11_NO_NULLPTR) && !defined(CATCH_CONFIG_CPP11_NULLPTR) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_NULLPTR -#endif -#if defined(CATCH_INTERNAL_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_CONFIG_CPP11_NO_NOEXCEPT) && !defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_NOEXCEPT -#endif -#if defined(CATCH_INTERNAL_CONFIG_CPP11_GENERATED_METHODS) && !defined(CATCH_CONFIG_CPP11_NO_GENERATED_METHODS) && !defined(CATCH_CONFIG_CPP11_GENERATED_METHODS) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_GENERATED_METHODS -#endif -#if defined(CATCH_INTERNAL_CONFIG_CPP11_IS_ENUM) && !defined(CATCH_CONFIG_CPP11_NO_IS_ENUM) && !defined(CATCH_CONFIG_CPP11_IS_ENUM) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_IS_ENUM -#endif -#if defined(CATCH_INTERNAL_CONFIG_CPP11_TUPLE) && !defined(CATCH_CONFIG_CPP11_NO_TUPLE) && !defined(CATCH_CONFIG_CPP11_TUPLE) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_TUPLE -#endif -#if defined(CATCH_INTERNAL_CONFIG_VARIADIC_MACROS) && !defined(CATCH_CONFIG_NO_VARIADIC_MACROS) && !defined(CATCH_CONFIG_VARIADIC_MACROS) -# define CATCH_CONFIG_VARIADIC_MACROS -#endif -#if defined(CATCH_INTERNAL_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_CPP11_NO_LONG_LONG) && !defined(CATCH_CONFIG_CPP11_LONG_LONG) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_LONG_LONG -#endif -#if defined(CATCH_INTERNAL_CONFIG_CPP11_OVERRIDE) && !defined(CATCH_CONFIG_CPP11_NO_OVERRIDE) && !defined(CATCH_CONFIG_CPP11_OVERRIDE) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_OVERRIDE -#endif -#if defined(CATCH_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_NO_UNIQUE_PTR) && !defined(CATCH_CONFIG_CPP11_UNIQUE_PTR) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_UNIQUE_PTR -#endif -// Use of __COUNTER__ is suppressed if __JETBRAINS_IDE__ is #defined (meaning we're being parsed by a JetBrains IDE for -// analytics) because, at time of writing, __COUNTER__ is not properly handled by it. -// This does not affect compilation -#if defined(CATCH_INTERNAL_CONFIG_COUNTER) && !defined(CATCH_CONFIG_NO_COUNTER) && !defined(CATCH_CONFIG_COUNTER) && !defined(__JETBRAINS_IDE__) -# define CATCH_CONFIG_COUNTER -#endif -#if defined(CATCH_INTERNAL_CONFIG_CPP11_SHUFFLE) && !defined(CATCH_CONFIG_CPP11_NO_SHUFFLE) && !defined(CATCH_CONFIG_CPP11_SHUFFLE) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_SHUFFLE -#endif -# if defined(CATCH_INTERNAL_CONFIG_CPP11_TYPE_TRAITS) && !defined(CATCH_CONFIG_CPP11_NO_TYPE_TRAITS) && !defined(CATCH_CONFIG_CPP11_TYPE_TRAITS) && !defined(CATCH_CONFIG_NO_CPP11) -# define CATCH_CONFIG_CPP11_TYPE_TRAITS -# endif -#if defined(CATCH_INTERNAL_CONFIG_WINDOWS_SEH) && !defined(CATCH_CONFIG_NO_WINDOWS_SEH) && !defined(CATCH_CONFIG_WINDOWS_SEH) -# define CATCH_CONFIG_WINDOWS_SEH -#endif -// This is set by default, because we assume that unix compilers are posix-signal-compatible by default. -#if !defined(CATCH_INTERNAL_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_NO_POSIX_SIGNALS) && !defined(CATCH_CONFIG_POSIX_SIGNALS) -# define CATCH_CONFIG_POSIX_SIGNALS -#endif - -#if !defined(CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS -# define CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS -#endif -#if !defined(CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS) -# define CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS -# define CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS -#endif - -// noexcept support: -#if defined(CATCH_CONFIG_CPP11_NOEXCEPT) && !defined(CATCH_NOEXCEPT) -# define CATCH_NOEXCEPT noexcept -# define CATCH_NOEXCEPT_IS(x) noexcept(x) -#else -# define CATCH_NOEXCEPT throw() -# define CATCH_NOEXCEPT_IS(x) -#endif - -// nullptr support -#ifdef CATCH_CONFIG_CPP11_NULLPTR -# define CATCH_NULL nullptr -#else -# define CATCH_NULL NULL -#endif - -// override support -#ifdef CATCH_CONFIG_CPP11_OVERRIDE -# define CATCH_OVERRIDE override -#else -# define CATCH_OVERRIDE -#endif - -// unique_ptr support -#ifdef CATCH_CONFIG_CPP11_UNIQUE_PTR -# define CATCH_AUTO_PTR( T ) std::unique_ptr -#else -# define CATCH_AUTO_PTR( T ) std::auto_ptr -#endif - -#define INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) name##line -#define INTERNAL_CATCH_UNIQUE_NAME_LINE( name, line ) INTERNAL_CATCH_UNIQUE_NAME_LINE2( name, line ) -#ifdef CATCH_CONFIG_COUNTER -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __COUNTER__ ) -#else -# define INTERNAL_CATCH_UNIQUE_NAME( name ) INTERNAL_CATCH_UNIQUE_NAME_LINE( name, __LINE__ ) -#endif - -#define INTERNAL_CATCH_STRINGIFY2( expr ) #expr -#define INTERNAL_CATCH_STRINGIFY( expr ) INTERNAL_CATCH_STRINGIFY2( expr ) - -#include -#include - -namespace Catch { - - struct IConfig; - - struct CaseSensitive { enum Choice { - Yes, - No - }; }; - - class NonCopyable { -#ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS - NonCopyable( NonCopyable const& ) = delete; - NonCopyable( NonCopyable && ) = delete; - NonCopyable& operator = ( NonCopyable const& ) = delete; - NonCopyable& operator = ( NonCopyable && ) = delete; -#else - NonCopyable( NonCopyable const& info ); - NonCopyable& operator = ( NonCopyable const& ); -#endif - - protected: - NonCopyable() {} - virtual ~NonCopyable(); - }; - - class SafeBool { - public: - typedef void (SafeBool::*type)() const; - - static type makeSafe( bool value ) { - return value ? &SafeBool::trueValue : 0; - } - private: - void trueValue() const {} - }; - - template - inline void deleteAll( ContainerT& container ) { - typename ContainerT::const_iterator it = container.begin(); - typename ContainerT::const_iterator itEnd = container.end(); - for(; it != itEnd; ++it ) - delete *it; - } - template - inline void deleteAllValues( AssociativeContainerT& container ) { - typename AssociativeContainerT::const_iterator it = container.begin(); - typename AssociativeContainerT::const_iterator itEnd = container.end(); - for(; it != itEnd; ++it ) - delete it->second; - } - - bool startsWith( std::string const& s, std::string const& prefix ); - bool startsWith( std::string const& s, char prefix ); - bool endsWith( std::string const& s, std::string const& suffix ); - bool endsWith( std::string const& s, char suffix ); - bool contains( std::string const& s, std::string const& infix ); - void toLowerInPlace( std::string& s ); - std::string toLower( std::string const& s ); - std::string trim( std::string const& str ); - bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ); - - struct pluralise { - pluralise( std::size_t count, std::string const& label ); - - friend std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ); - - std::size_t m_count; - std::string m_label; - }; - - struct SourceLineInfo { - - SourceLineInfo(); - SourceLineInfo( char const* _file, std::size_t _line ); -# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS - SourceLineInfo(SourceLineInfo const& other) = default; - SourceLineInfo( SourceLineInfo && ) = default; - SourceLineInfo& operator = ( SourceLineInfo const& ) = default; - SourceLineInfo& operator = ( SourceLineInfo && ) = default; -# endif - bool empty() const; - bool operator == ( SourceLineInfo const& other ) const; - bool operator < ( SourceLineInfo const& other ) const; - - char const* file; - std::size_t line; - }; - - std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ); - - // This is just here to avoid compiler warnings with macro constants and boolean literals - inline bool isTrue( bool value ){ return value; } - inline bool alwaysTrue() { return true; } - inline bool alwaysFalse() { return false; } - - void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo ); - - void seedRng( IConfig const& config ); - unsigned int rngSeed(); - - // Use this in variadic streaming macros to allow - // >> +StreamEndStop - // as well as - // >> stuff +StreamEndStop - struct StreamEndStop { - std::string operator+() { - return std::string(); - } - }; - template - T const& operator + ( T const& value, StreamEndStop ) { - return value; - } -} - -#define CATCH_INTERNAL_LINEINFO ::Catch::SourceLineInfo( __FILE__, static_cast( __LINE__ ) ) -#define CATCH_INTERNAL_ERROR( msg ) ::Catch::throwLogicError( msg, CATCH_INTERNAL_LINEINFO ); - -namespace Catch { - - class NotImplementedException : public std::exception - { - public: - NotImplementedException( SourceLineInfo const& lineInfo ); - NotImplementedException( NotImplementedException const& ) {} - - virtual ~NotImplementedException() CATCH_NOEXCEPT {} - - virtual const char* what() const CATCH_NOEXCEPT; - - private: - std::string m_what; - SourceLineInfo m_lineInfo; - }; - -} // end namespace Catch - -/////////////////////////////////////////////////////////////////////////////// -#define CATCH_NOT_IMPLEMENTED throw Catch::NotImplementedException( CATCH_INTERNAL_LINEINFO ) - -// #included from: internal/catch_context.h -#define TWOBLUECUBES_CATCH_CONTEXT_H_INCLUDED - -// #included from: catch_interfaces_generators.h -#define TWOBLUECUBES_CATCH_INTERFACES_GENERATORS_H_INCLUDED - -#include - -namespace Catch { - - struct IGeneratorInfo { - virtual ~IGeneratorInfo(); - virtual bool moveNext() = 0; - virtual std::size_t getCurrentIndex() const = 0; - }; - - struct IGeneratorsForTest { - virtual ~IGeneratorsForTest(); - - virtual IGeneratorInfo& getGeneratorInfo( std::string const& fileInfo, std::size_t size ) = 0; - virtual bool moveNext() = 0; - }; - - IGeneratorsForTest* createGeneratorsForTest(); - -} // end namespace Catch - -// #included from: catch_ptr.hpp -#define TWOBLUECUBES_CATCH_PTR_HPP_INCLUDED - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpadded" -#endif - -namespace Catch { - - // An intrusive reference counting smart pointer. - // T must implement addRef() and release() methods - // typically implementing the IShared interface - template - class Ptr { - public: - Ptr() : m_p( CATCH_NULL ){} - Ptr( T* p ) : m_p( p ){ - if( m_p ) - m_p->addRef(); - } - Ptr( Ptr const& other ) : m_p( other.m_p ){ - if( m_p ) - m_p->addRef(); - } - ~Ptr(){ - if( m_p ) - m_p->release(); - } - void reset() { - if( m_p ) - m_p->release(); - m_p = CATCH_NULL; - } - Ptr& operator = ( T* p ){ - Ptr temp( p ); - swap( temp ); - return *this; - } - Ptr& operator = ( Ptr const& other ){ - Ptr temp( other ); - swap( temp ); - return *this; - } - void swap( Ptr& other ) { std::swap( m_p, other.m_p ); } - T* get() const{ return m_p; } - T& operator*() const { return *m_p; } - T* operator->() const { return m_p; } - bool operator !() const { return m_p == CATCH_NULL; } - operator SafeBool::type() const { return SafeBool::makeSafe( m_p != CATCH_NULL ); } - - private: - T* m_p; - }; - - struct IShared : NonCopyable { - virtual ~IShared(); - virtual void addRef() const = 0; - virtual void release() const = 0; - }; - - template - struct SharedImpl : T { - - SharedImpl() : m_rc( 0 ){} - - virtual void addRef() const { - ++m_rc; - } - virtual void release() const { - if( --m_rc == 0 ) - delete this; - } - - mutable unsigned int m_rc; - }; - -} // end namespace Catch - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -namespace Catch { - - class TestCase; - class Stream; - struct IResultCapture; - struct IRunner; - struct IGeneratorsForTest; - struct IConfig; - - struct IContext - { - virtual ~IContext(); - - virtual IResultCapture* getResultCapture() = 0; - virtual IRunner* getRunner() = 0; - virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) = 0; - virtual bool advanceGeneratorsForCurrentTest() = 0; - virtual Ptr getConfig() const = 0; - }; - - struct IMutableContext : IContext - { - virtual ~IMutableContext(); - virtual void setResultCapture( IResultCapture* resultCapture ) = 0; - virtual void setRunner( IRunner* runner ) = 0; - virtual void setConfig( Ptr const& config ) = 0; - }; - - IContext& getCurrentContext(); - IMutableContext& getCurrentMutableContext(); - void cleanUpContext(); - Stream createStream( std::string const& streamName ); - -} - -// #included from: internal/catch_test_registry.hpp -#define TWOBLUECUBES_CATCH_TEST_REGISTRY_HPP_INCLUDED - -// #included from: catch_interfaces_testcase.h -#define TWOBLUECUBES_CATCH_INTERFACES_TESTCASE_H_INCLUDED - -#include - -namespace Catch { - - class TestSpec; - - struct ITestCase : IShared { - virtual void invoke () const = 0; - protected: - virtual ~ITestCase(); - }; - - class TestCase; - struct IConfig; - - struct ITestCaseRegistry { - virtual ~ITestCaseRegistry(); - virtual std::vector const& getAllTests() const = 0; - virtual std::vector const& getAllTestsSorted( IConfig const& config ) const = 0; - }; - - bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ); - std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ); - std::vector const& getAllTestCasesSorted( IConfig const& config ); - -} - -namespace Catch { - -template -class MethodTestCase : public SharedImpl { - -public: - MethodTestCase( void (C::*method)() ) : m_method( method ) {} - - virtual void invoke() const { - C obj; - (obj.*m_method)(); - } - -private: - virtual ~MethodTestCase() {} - - void (C::*m_method)(); -}; - -typedef void(*TestFunction)(); - -struct NameAndDesc { - NameAndDesc( const char* _name = "", const char* _description= "" ) - : name( _name ), description( _description ) - {} - - const char* name; - const char* description; -}; - -void registerTestCase - ( ITestCase* testCase, - char const* className, - NameAndDesc const& nameAndDesc, - SourceLineInfo const& lineInfo ); - -struct AutoReg { - - AutoReg - ( TestFunction function, - SourceLineInfo const& lineInfo, - NameAndDesc const& nameAndDesc ); - - template - AutoReg - ( void (C::*method)(), - char const* className, - NameAndDesc const& nameAndDesc, - SourceLineInfo const& lineInfo ) { - - registerTestCase - ( new MethodTestCase( method ), - className, - nameAndDesc, - lineInfo ); - } - - ~AutoReg(); - -private: - AutoReg( AutoReg const& ); - void operator= ( AutoReg const& ); -}; - -void registerTestCaseFunction - ( TestFunction function, - SourceLineInfo const& lineInfo, - NameAndDesc const& nameAndDesc ); - -} // end namespace Catch - -#ifdef CATCH_CONFIG_VARIADIC_MACROS - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \ - static void TestName(); \ - CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \ - namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); } \ - CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \ - static void TestName() - #define INTERNAL_CATCH_TESTCASE( ... ) \ - INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), __VA_ARGS__ ) - - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \ - CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \ - namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); } \ - CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS - - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_TEST_CASE_METHOD2( TestName, ClassName, ... )\ - CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \ - namespace{ \ - struct TestName : ClassName{ \ - void test(); \ - }; \ - Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestName::test, #ClassName, Catch::NameAndDesc( __VA_ARGS__ ), CATCH_INTERNAL_LINEINFO ); \ - } \ - CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \ - void TestName::test() - #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, ... ) \ - INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, __VA_ARGS__ ) - - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \ - CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \ - Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( __VA_ARGS__ ) ); \ - CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS - -#else - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_TESTCASE2( TestName, Name, Desc ) \ - static void TestName(); \ - CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \ - namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &TestName, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); }\ - CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \ - static void TestName() - #define INTERNAL_CATCH_TESTCASE( Name, Desc ) \ - INTERNAL_CATCH_TESTCASE2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), Name, Desc ) - - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, Name, Desc ) \ - CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \ - namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( &QualifiedMethod, "&" #QualifiedMethod, Catch::NameAndDesc( Name, Desc ), CATCH_INTERNAL_LINEINFO ); } \ - CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS - - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_TEST_CASE_METHOD2( TestCaseName, ClassName, TestName, Desc )\ - CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \ - namespace{ \ - struct TestCaseName : ClassName{ \ - void test(); \ - }; \ - Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( &TestCaseName::test, #ClassName, Catch::NameAndDesc( TestName, Desc ), CATCH_INTERNAL_LINEINFO ); \ - } \ - CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \ - void TestCaseName::test() - #define INTERNAL_CATCH_TEST_CASE_METHOD( ClassName, TestName, Desc )\ - INTERNAL_CATCH_TEST_CASE_METHOD2( INTERNAL_CATCH_UNIQUE_NAME( ____C_A_T_C_H____T_E_S_T____ ), ClassName, TestName, Desc ) - - /////////////////////////////////////////////////////////////////////////////// - #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, Name, Desc ) \ - CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \ - Catch::AutoReg( Function, CATCH_INTERNAL_LINEINFO, Catch::NameAndDesc( Name, Desc ) ); \ - CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS - -#endif - -// #included from: internal/catch_capture.hpp -#define TWOBLUECUBES_CATCH_CAPTURE_HPP_INCLUDED - -// #included from: catch_result_builder.h -#define TWOBLUECUBES_CATCH_RESULT_BUILDER_H_INCLUDED - -// #included from: catch_result_type.h -#define TWOBLUECUBES_CATCH_RESULT_TYPE_H_INCLUDED - -namespace Catch { - - // ResultWas::OfType enum - struct ResultWas { enum OfType { - Unknown = -1, - Ok = 0, - Info = 1, - Warning = 2, - - FailureBit = 0x10, - - ExpressionFailed = FailureBit | 1, - ExplicitFailure = FailureBit | 2, - - Exception = 0x100 | FailureBit, - - ThrewException = Exception | 1, - DidntThrowException = Exception | 2, - - FatalErrorCondition = 0x200 | FailureBit - - }; }; - - inline bool isOk( ResultWas::OfType resultType ) { - return ( resultType & ResultWas::FailureBit ) == 0; - } - inline bool isJustInfo( int flags ) { - return flags == ResultWas::Info; - } - - // ResultDisposition::Flags enum - struct ResultDisposition { enum Flags { - Normal = 0x01, - - ContinueOnFailure = 0x02, // Failures fail test, but execution continues - FalseTest = 0x04, // Prefix expression with ! - SuppressFail = 0x08 // Failures are reported but do not fail the test - }; }; - - inline ResultDisposition::Flags operator | ( ResultDisposition::Flags lhs, ResultDisposition::Flags rhs ) { - return static_cast( static_cast( lhs ) | static_cast( rhs ) ); - } - - inline bool shouldContinueOnFailure( int flags ) { return ( flags & ResultDisposition::ContinueOnFailure ) != 0; } - inline bool isFalseTest( int flags ) { return ( flags & ResultDisposition::FalseTest ) != 0; } - inline bool shouldSuppressFailure( int flags ) { return ( flags & ResultDisposition::SuppressFail ) != 0; } - -} // end namespace Catch - -// #included from: catch_assertionresult.h -#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_H_INCLUDED - -#include - -namespace Catch { - - struct STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison; - - struct DecomposedExpression - { - virtual ~DecomposedExpression() {} - virtual bool isBinaryExpression() const { - return false; - } - virtual void reconstructExpression( std::string& dest ) const = 0; - - // Only simple binary comparisons can be decomposed. - // If more complex check is required then wrap sub-expressions in parentheses. - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator + ( T const& ); - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator - ( T const& ); - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator * ( T const& ); - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator / ( T const& ); - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator % ( T const& ); - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator && ( T const& ); - template STATIC_ASSERT_Expression_Too_Complex_Please_Rewrite_As_Binary_Comparison& operator || ( T const& ); - - private: - DecomposedExpression& operator = (DecomposedExpression const&); - }; - - struct AssertionInfo - { - AssertionInfo() {} - AssertionInfo( char const * _macroName, - SourceLineInfo const& _lineInfo, - char const * _capturedExpression, - ResultDisposition::Flags _resultDisposition, - char const * _secondArg = ""); - - char const * macroName; - SourceLineInfo lineInfo; - char const * capturedExpression; - ResultDisposition::Flags resultDisposition; - char const * secondArg; - }; - - struct AssertionResultData - { - AssertionResultData() : decomposedExpression( CATCH_NULL ) - , resultType( ResultWas::Unknown ) - , negated( false ) - , parenthesized( false ) {} - - void negate( bool parenthesize ) { - negated = !negated; - parenthesized = parenthesize; - if( resultType == ResultWas::Ok ) - resultType = ResultWas::ExpressionFailed; - else if( resultType == ResultWas::ExpressionFailed ) - resultType = ResultWas::Ok; - } - - std::string const& reconstructExpression() const { - if( decomposedExpression != CATCH_NULL ) { - decomposedExpression->reconstructExpression( reconstructedExpression ); - if( parenthesized ) { - reconstructedExpression.insert( 0, 1, '(' ); - reconstructedExpression.append( 1, ')' ); - } - if( negated ) { - reconstructedExpression.insert( 0, 1, '!' ); - } - decomposedExpression = CATCH_NULL; - } - return reconstructedExpression; - } - - mutable DecomposedExpression const* decomposedExpression; - mutable std::string reconstructedExpression; - std::string message; - ResultWas::OfType resultType; - bool negated; - bool parenthesized; - }; - - class AssertionResult { - public: - AssertionResult(); - AssertionResult( AssertionInfo const& info, AssertionResultData const& data ); - ~AssertionResult(); -# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS - AssertionResult( AssertionResult const& ) = default; - AssertionResult( AssertionResult && ) = default; - AssertionResult& operator = ( AssertionResult const& ) = default; - AssertionResult& operator = ( AssertionResult && ) = default; -# endif - - bool isOk() const; - bool succeeded() const; - ResultWas::OfType getResultType() const; - bool hasExpression() const; - bool hasMessage() const; - std::string getExpression() const; - std::string getExpressionInMacro() const; - bool hasExpandedExpression() const; - std::string getExpandedExpression() const; - std::string getMessage() const; - SourceLineInfo getSourceInfo() const; - std::string getTestMacroName() const; - void discardDecomposedExpression() const; - void expandDecomposedExpression() const; - - protected: - AssertionInfo m_info; - AssertionResultData m_resultData; - }; - -} // end namespace Catch - -// #included from: catch_matchers.hpp -#define TWOBLUECUBES_CATCH_MATCHERS_HPP_INCLUDED - -namespace Catch { -namespace Matchers { - namespace Impl { - - template struct MatchAllOf; - template struct MatchAnyOf; - template struct MatchNotOf; - - class MatcherUntypedBase { - public: - std::string toString() const { - if( m_cachedToString.empty() ) - m_cachedToString = describe(); - return m_cachedToString; - } - - protected: - virtual ~MatcherUntypedBase(); - virtual std::string describe() const = 0; - mutable std::string m_cachedToString; - private: - MatcherUntypedBase& operator = ( MatcherUntypedBase const& ); - }; - - template - struct MatcherMethod { - virtual bool match( ObjectT const& arg ) const = 0; - }; - template - struct MatcherMethod { - virtual bool match( PtrT* arg ) const = 0; - }; - - template - struct MatcherBase : MatcherUntypedBase, MatcherMethod { - - MatchAllOf operator && ( MatcherBase const& other ) const; - MatchAnyOf operator || ( MatcherBase const& other ) const; - MatchNotOf operator ! () const; - }; - - template - struct MatchAllOf : MatcherBase { - virtual bool match( ArgT const& arg ) const CATCH_OVERRIDE { - for( std::size_t i = 0; i < m_matchers.size(); ++i ) { - if (!m_matchers[i]->match(arg)) - return false; - } - return true; - } - virtual std::string describe() const CATCH_OVERRIDE { - std::string description; - description.reserve( 4 + m_matchers.size()*32 ); - description += "( "; - for( std::size_t i = 0; i < m_matchers.size(); ++i ) { - if( i != 0 ) - description += " and "; - description += m_matchers[i]->toString(); - } - description += " )"; - return description; - } - - MatchAllOf& operator && ( MatcherBase const& other ) { - m_matchers.push_back( &other ); - return *this; - } - - std::vector const*> m_matchers; - }; - template - struct MatchAnyOf : MatcherBase { - - virtual bool match( ArgT const& arg ) const CATCH_OVERRIDE { - for( std::size_t i = 0; i < m_matchers.size(); ++i ) { - if (m_matchers[i]->match(arg)) - return true; - } - return false; - } - virtual std::string describe() const CATCH_OVERRIDE { - std::string description; - description.reserve( 4 + m_matchers.size()*32 ); - description += "( "; - for( std::size_t i = 0; i < m_matchers.size(); ++i ) { - if( i != 0 ) - description += " or "; - description += m_matchers[i]->toString(); - } - description += " )"; - return description; - } - - MatchAnyOf& operator || ( MatcherBase const& other ) { - m_matchers.push_back( &other ); - return *this; - } - - std::vector const*> m_matchers; - }; - - template - struct MatchNotOf : MatcherBase { - - MatchNotOf( MatcherBase const& underlyingMatcher ) : m_underlyingMatcher( underlyingMatcher ) {} - - virtual bool match( ArgT const& arg ) const CATCH_OVERRIDE { - return !m_underlyingMatcher.match( arg ); - } - - virtual std::string describe() const CATCH_OVERRIDE { - return "not " + m_underlyingMatcher.toString(); - } - MatcherBase const& m_underlyingMatcher; - }; - - template - MatchAllOf MatcherBase::operator && ( MatcherBase const& other ) const { - return MatchAllOf() && *this && other; - } - template - MatchAnyOf MatcherBase::operator || ( MatcherBase const& other ) const { - return MatchAnyOf() || *this || other; - } - template - MatchNotOf MatcherBase::operator ! () const { - return MatchNotOf( *this ); - } - - } // namespace Impl - - // The following functions create the actual matcher objects. - // This allows the types to be inferred - // - deprecated: prefer ||, && and ! - template - inline Impl::MatchNotOf Not( Impl::MatcherBase const& underlyingMatcher ) { - return Impl::MatchNotOf( underlyingMatcher ); - } - template - inline Impl::MatchAllOf AllOf( Impl::MatcherBase const& m1, Impl::MatcherBase const& m2 ) { - return Impl::MatchAllOf() && m1 && m2; - } - template - inline Impl::MatchAllOf AllOf( Impl::MatcherBase const& m1, Impl::MatcherBase const& m2, Impl::MatcherBase const& m3 ) { - return Impl::MatchAllOf() && m1 && m2 && m3; - } - template - inline Impl::MatchAnyOf AnyOf( Impl::MatcherBase const& m1, Impl::MatcherBase const& m2 ) { - return Impl::MatchAnyOf() || m1 || m2; - } - template - inline Impl::MatchAnyOf AnyOf( Impl::MatcherBase const& m1, Impl::MatcherBase const& m2, Impl::MatcherBase const& m3 ) { - return Impl::MatchAnyOf() || m1 || m2 || m3; - } - -} // namespace Matchers - -using namespace Matchers; -using Matchers::Impl::MatcherBase; - -} // namespace Catch - -namespace Catch { - - struct TestFailureException{}; - - template class ExpressionLhs; - - struct CopyableStream { - CopyableStream() {} - CopyableStream( CopyableStream const& other ) { - oss << other.oss.str(); - } - CopyableStream& operator=( CopyableStream const& other ) { - oss.str(std::string()); - oss << other.oss.str(); - return *this; - } - std::ostringstream oss; - }; - - class ResultBuilder : public DecomposedExpression { - public: - ResultBuilder( char const* macroName, - SourceLineInfo const& lineInfo, - char const* capturedExpression, - ResultDisposition::Flags resultDisposition, - char const* secondArg = "" ); - ~ResultBuilder(); - - template - ExpressionLhs operator <= ( T const& operand ); - ExpressionLhs operator <= ( bool value ); - - template - ResultBuilder& operator << ( T const& value ) { - m_stream().oss << value; - return *this; - } - - ResultBuilder& setResultType( ResultWas::OfType result ); - ResultBuilder& setResultType( bool result ); - - void endExpression( DecomposedExpression const& expr ); - - virtual void reconstructExpression( std::string& dest ) const CATCH_OVERRIDE; - - AssertionResult build() const; - AssertionResult build( DecomposedExpression const& expr ) const; - - void useActiveException( ResultDisposition::Flags resultDisposition = ResultDisposition::Normal ); - void captureResult( ResultWas::OfType resultType ); - void captureExpression(); - void captureExpectedException( std::string const& expectedMessage ); - void captureExpectedException( Matchers::Impl::MatcherBase const& matcher ); - void handleResult( AssertionResult const& result ); - void react(); - bool shouldDebugBreak() const; - bool allowThrows() const; - - template - void captureMatch( ArgT const& arg, MatcherT const& matcher, char const* matcherString ); - - void setExceptionGuard(); - void unsetExceptionGuard(); - - private: - AssertionInfo m_assertionInfo; - AssertionResultData m_data; - - static CopyableStream &m_stream() - { - static CopyableStream s; - return s; - } - - bool m_shouldDebugBreak; - bool m_shouldThrow; - bool m_guardException; - }; - -} // namespace Catch - -// Include after due to circular dependency: -// #included from: catch_expression_lhs.hpp -#define TWOBLUECUBES_CATCH_EXPRESSION_LHS_HPP_INCLUDED - -// #included from: catch_evaluate.hpp -#define TWOBLUECUBES_CATCH_EVALUATE_HPP_INCLUDED - -#ifdef _MSC_VER -#pragma warning(push) -#pragma warning(disable:4389) // '==' : signed/unsigned mismatch -#pragma warning(disable:4312) // Converting int to T* using reinterpret_cast (issue on x64 platform) -#endif - -#include - -namespace Catch { -namespace Internal { - - enum Operator { - IsEqualTo, - IsNotEqualTo, - IsLessThan, - IsGreaterThan, - IsLessThanOrEqualTo, - IsGreaterThanOrEqualTo - }; - - template struct OperatorTraits { static const char* getName(){ return "*error*"; } }; - template<> struct OperatorTraits { static const char* getName(){ return "=="; } }; - template<> struct OperatorTraits { static const char* getName(){ return "!="; } }; - template<> struct OperatorTraits { static const char* getName(){ return "<"; } }; - template<> struct OperatorTraits { static const char* getName(){ return ">"; } }; - template<> struct OperatorTraits { static const char* getName(){ return "<="; } }; - template<> struct OperatorTraits{ static const char* getName(){ return ">="; } }; - - template - inline T& opCast(T const& t) { return const_cast(t); } - -// nullptr_t support based on pull request #154 from Konstantin Baumann -#ifdef CATCH_CONFIG_CPP11_NULLPTR - inline std::nullptr_t opCast(std::nullptr_t) { return nullptr; } -#endif // CATCH_CONFIG_CPP11_NULLPTR - - // So the compare overloads can be operator agnostic we convey the operator as a template - // enum, which is used to specialise an Evaluator for doing the comparison. - template - class Evaluator{}; - - template - struct Evaluator { - static bool evaluate( T1 const& lhs, T2 const& rhs) { - return bool( opCast( lhs ) == opCast( rhs ) ); - } - }; - template - struct Evaluator { - static bool evaluate( T1 const& lhs, T2 const& rhs ) { - return bool( opCast( lhs ) != opCast( rhs ) ); - } - }; - template - struct Evaluator { - static bool evaluate( T1 const& lhs, T2 const& rhs ) { - return bool( opCast( lhs ) < opCast( rhs ) ); - } - }; - template - struct Evaluator { - static bool evaluate( T1 const& lhs, T2 const& rhs ) { - return bool( opCast( lhs ) > opCast( rhs ) ); - } - }; - template - struct Evaluator { - static bool evaluate( T1 const& lhs, T2 const& rhs ) { - return bool( opCast( lhs ) >= opCast( rhs ) ); - } - }; - template - struct Evaluator { - static bool evaluate( T1 const& lhs, T2 const& rhs ) { - return bool( opCast( lhs ) <= opCast( rhs ) ); - } - }; - - template - bool applyEvaluator( T1 const& lhs, T2 const& rhs ) { - return Evaluator::evaluate( lhs, rhs ); - } - - // This level of indirection allows us to specialise for integer types - // to avoid signed/ unsigned warnings - - // "base" overload - template - bool compare( T1 const& lhs, T2 const& rhs ) { - return Evaluator::evaluate( lhs, rhs ); - } - - // unsigned X to int - template bool compare( unsigned int lhs, int rhs ) { - return applyEvaluator( lhs, static_cast( rhs ) ); - } - template bool compare( unsigned long lhs, int rhs ) { - return applyEvaluator( lhs, static_cast( rhs ) ); - } - template bool compare( unsigned char lhs, int rhs ) { - return applyEvaluator( lhs, static_cast( rhs ) ); - } - - // unsigned X to long - template bool compare( unsigned int lhs, long rhs ) { - return applyEvaluator( lhs, static_cast( rhs ) ); - } - template bool compare( unsigned long lhs, long rhs ) { - return applyEvaluator( lhs, static_cast( rhs ) ); - } - template bool compare( unsigned char lhs, long rhs ) { - return applyEvaluator( lhs, static_cast( rhs ) ); - } - - // int to unsigned X - template bool compare( int lhs, unsigned int rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( int lhs, unsigned long rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( int lhs, unsigned char rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - - // long to unsigned X - template bool compare( long lhs, unsigned int rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( long lhs, unsigned long rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( long lhs, unsigned char rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - - // pointer to long (when comparing against NULL) - template bool compare( long lhs, T* rhs ) { - return Evaluator::evaluate( reinterpret_cast( lhs ), rhs ); - } - template bool compare( T* lhs, long rhs ) { - return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) ); - } - - // pointer to int (when comparing against NULL) - template bool compare( int lhs, T* rhs ) { - return Evaluator::evaluate( reinterpret_cast( lhs ), rhs ); - } - template bool compare( T* lhs, int rhs ) { - return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) ); - } - -#ifdef CATCH_CONFIG_CPP11_LONG_LONG - // long long to unsigned X - template bool compare( long long lhs, unsigned int rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( long long lhs, unsigned long rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( long long lhs, unsigned long long rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( long long lhs, unsigned char rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - - // unsigned long long to X - template bool compare( unsigned long long lhs, int rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( unsigned long long lhs, long rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( unsigned long long lhs, long long rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - template bool compare( unsigned long long lhs, char rhs ) { - return applyEvaluator( static_cast( lhs ), rhs ); - } - - // pointer to long long (when comparing against NULL) - template bool compare( long long lhs, T* rhs ) { - return Evaluator::evaluate( reinterpret_cast( lhs ), rhs ); - } - template bool compare( T* lhs, long long rhs ) { - return Evaluator::evaluate( lhs, reinterpret_cast( rhs ) ); - } -#endif // CATCH_CONFIG_CPP11_LONG_LONG - -#ifdef CATCH_CONFIG_CPP11_NULLPTR - // pointer to nullptr_t (when comparing against nullptr) - template bool compare( std::nullptr_t, T* rhs ) { - return Evaluator::evaluate( nullptr, rhs ); - } - template bool compare( T* lhs, std::nullptr_t ) { - return Evaluator::evaluate( lhs, nullptr ); - } -#endif // CATCH_CONFIG_CPP11_NULLPTR - -} // end of namespace Internal -} // end of namespace Catch - -#ifdef _MSC_VER -#pragma warning(pop) -#endif - -// #included from: catch_tostring.h -#define TWOBLUECUBES_CATCH_TOSTRING_H_INCLUDED - -#include -#include -#include -#include -#include - -#ifdef __OBJC__ -// #included from: catch_objc_arc.hpp -#define TWOBLUECUBES_CATCH_OBJC_ARC_HPP_INCLUDED - -#import - -#ifdef __has_feature -#define CATCH_ARC_ENABLED __has_feature(objc_arc) -#else -#define CATCH_ARC_ENABLED 0 -#endif - -void arcSafeRelease( NSObject* obj ); -id performOptionalSelector( id obj, SEL sel ); - -#if !CATCH_ARC_ENABLED -inline void arcSafeRelease( NSObject* obj ) { - [obj release]; -} -inline id performOptionalSelector( id obj, SEL sel ) { - if( [obj respondsToSelector: sel] ) - return [obj performSelector: sel]; - return nil; -} -#define CATCH_UNSAFE_UNRETAINED -#define CATCH_ARC_STRONG -#else -inline void arcSafeRelease( NSObject* ){} -inline id performOptionalSelector( id obj, SEL sel ) { -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Warc-performSelector-leaks" -#endif - if( [obj respondsToSelector: sel] ) - return [obj performSelector: sel]; -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - return nil; -} -#define CATCH_UNSAFE_UNRETAINED __unsafe_unretained -#define CATCH_ARC_STRONG __strong -#endif - -#endif - -#ifdef CATCH_CONFIG_CPP11_TUPLE -#include -#endif - -#ifdef CATCH_CONFIG_CPP11_IS_ENUM -#include -#endif - -namespace Catch { - -// Why we're here. -template -std::string toString( T const& value ); - -// Built in overloads - -std::string toString( std::string const& value ); -std::string toString( std::wstring const& value ); -std::string toString( const char* const value ); -std::string toString( char* const value ); -std::string toString( const wchar_t* const value ); -std::string toString( wchar_t* const value ); -std::string toString( int value ); -std::string toString( unsigned long value ); -std::string toString( unsigned int value ); -std::string toString( const double value ); -std::string toString( const float value ); -std::string toString( bool value ); -std::string toString( char value ); -std::string toString( signed char value ); -std::string toString( unsigned char value ); - -#ifdef CATCH_CONFIG_CPP11_LONG_LONG -std::string toString( long long value ); -std::string toString( unsigned long long value ); -#endif - -#ifdef CATCH_CONFIG_CPP11_NULLPTR -std::string toString( std::nullptr_t ); -#endif - -#ifdef __OBJC__ - std::string toString( NSString const * const& nsstring ); - std::string toString( NSString * CATCH_ARC_STRONG & nsstring ); - std::string toString( NSObject* const& nsObject ); -#endif - -namespace Detail { - - extern const std::string unprintableString; - - #if !defined(CATCH_CONFIG_CPP11_STREAM_INSERTABLE_CHECK) - struct BorgType { - template BorgType( T const& ); - }; - - struct TrueType { char sizer[1]; }; - struct FalseType { char sizer[2]; }; - - TrueType& testStreamable( std::ostream& ); - FalseType testStreamable( FalseType ); - - FalseType operator<<( std::ostream const&, BorgType const& ); - - template - struct IsStreamInsertable { - static std::ostream &s; - static T const&t; - enum { value = sizeof( testStreamable(s << t) ) == sizeof( TrueType ) }; - }; -#else - template - class IsStreamInsertable { - template - static auto test(int) - -> decltype( std::declval() << std::declval(), std::true_type() ); - - template - static auto test(...) -> std::false_type; - - public: - static const bool value = decltype(test(0))::value; - }; -#endif - -#if defined(CATCH_CONFIG_CPP11_IS_ENUM) - template::value - > - struct EnumStringMaker - { - static std::string convert( T const& ) { return unprintableString; } - }; - - template - struct EnumStringMaker - { - static std::string convert( T const& v ) - { - return ::Catch::toString( - static_cast::type>(v) - ); - } - }; -#endif - template - struct StringMakerBase { -#if defined(CATCH_CONFIG_CPP11_IS_ENUM) - template - static std::string convert( T const& v ) - { - return EnumStringMaker::convert( v ); - } -#else - template - static std::string convert( T const& ) { return unprintableString; } -#endif - }; - - template<> - struct StringMakerBase { - template - static std::string convert( T const& _value ) { - std::ostringstream oss; - oss << _value; - return oss.str(); - } - }; - - std::string rawMemoryToString( const void *object, std::size_t size ); - - template - inline std::string rawMemoryToString( const T& object ) { - return rawMemoryToString( &object, sizeof(object) ); - } - -} // end namespace Detail - -template -struct StringMaker : - Detail::StringMakerBase::value> {}; - -template -struct StringMaker { - template - static std::string convert( U* p ) { - if( !p ) - return "NULL"; - else - return Detail::rawMemoryToString( p ); - } -}; - -template -struct StringMaker { - static std::string convert( R C::* p ) { - if( !p ) - return "NULL"; - else - return Detail::rawMemoryToString( p ); - } -}; - -namespace Detail { - template - std::string rangeToString( InputIterator first, InputIterator last ); -} - -//template -//struct StringMaker > { -// static std::string convert( std::vector const& v ) { -// return Detail::rangeToString( v.begin(), v.end() ); -// } -//}; - -template -std::string toString( std::vector const& v ) { - return Detail::rangeToString( v.begin(), v.end() ); -} - -#ifdef CATCH_CONFIG_CPP11_TUPLE - -// toString for tuples -namespace TupleDetail { - template< - typename Tuple, - std::size_t N = 0, - bool = (N < std::tuple_size::value) - > - struct ElementPrinter { - static void print( const Tuple& tuple, std::ostream& os ) - { - os << ( N ? ", " : " " ) - << Catch::toString(std::get(tuple)); - ElementPrinter::print(tuple,os); - } - }; - - template< - typename Tuple, - std::size_t N - > - struct ElementPrinter { - static void print( const Tuple&, std::ostream& ) {} - }; - -} - -template -struct StringMaker> { - - static std::string convert( const std::tuple& tuple ) - { - std::ostringstream os; - os << '{'; - TupleDetail::ElementPrinter>::print( tuple, os ); - os << " }"; - return os.str(); - } -}; -#endif // CATCH_CONFIG_CPP11_TUPLE - -namespace Detail { - template - std::string makeString( T const& value ) { - return StringMaker::convert( value ); - } -} // end namespace Detail - -/// \brief converts any type to a string -/// -/// The default template forwards on to ostringstream - except when an -/// ostringstream overload does not exist - in which case it attempts to detect -/// that and writes {?}. -/// Overload (not specialise) this template for custom typs that you don't want -/// to provide an ostream overload for. -template -std::string toString( T const& value ) { - return StringMaker::convert( value ); -} - - namespace Detail { - template - std::string rangeToString( InputIterator first, InputIterator last ) { - std::ostringstream oss; - oss << "{ "; - if( first != last ) { - oss << Catch::toString( *first ); - for( ++first ; first != last ; ++first ) - oss << ", " << Catch::toString( *first ); - } - oss << " }"; - return oss.str(); - } -} - -} // end namespace Catch - -namespace Catch { - -template -class BinaryExpression; - -template -class MatchExpression; - -// Wraps the LHS of an expression and overloads comparison operators -// for also capturing those and RHS (if any) -template -class ExpressionLhs : public DecomposedExpression { -public: - ExpressionLhs( ResultBuilder& rb, T lhs ) : m_rb( rb ), m_lhs( lhs ), m_truthy(false) {} - - ExpressionLhs& operator = ( const ExpressionLhs& ); - - template - BinaryExpression - operator == ( RhsT const& rhs ) { - return captureExpression( rhs ); - } - - template - BinaryExpression - operator != ( RhsT const& rhs ) { - return captureExpression( rhs ); - } - - template - BinaryExpression - operator < ( RhsT const& rhs ) { - return captureExpression( rhs ); - } - - template - BinaryExpression - operator > ( RhsT const& rhs ) { - return captureExpression( rhs ); - } - - template - BinaryExpression - operator <= ( RhsT const& rhs ) { - return captureExpression( rhs ); - } - - template - BinaryExpression - operator >= ( RhsT const& rhs ) { - return captureExpression( rhs ); - } - - BinaryExpression operator == ( bool rhs ) { - return captureExpression( rhs ); - } - - BinaryExpression operator != ( bool rhs ) { - return captureExpression( rhs ); - } - - void endExpression() { - m_truthy = m_lhs ? true : false; - m_rb - .setResultType( m_truthy ) - .endExpression( *this ); - } - - virtual void reconstructExpression( std::string& dest ) const CATCH_OVERRIDE { - dest = Catch::toString( m_lhs ); - } - -private: - template - BinaryExpression captureExpression( RhsT& rhs ) const { - return BinaryExpression( m_rb, m_lhs, rhs ); - } - - template - BinaryExpression captureExpression( bool rhs ) const { - return BinaryExpression( m_rb, m_lhs, rhs ); - } - -private: - ResultBuilder& m_rb; - T m_lhs; - bool m_truthy; -}; - -template -class BinaryExpression : public DecomposedExpression { -public: - BinaryExpression( ResultBuilder& rb, LhsT lhs, RhsT rhs ) - : m_rb( rb ), m_lhs( lhs ), m_rhs( rhs ) {} - - BinaryExpression& operator = ( BinaryExpression& ); - - void endExpression() const { - m_rb - .setResultType( Internal::compare( m_lhs, m_rhs ) ) - .endExpression( *this ); - } - - virtual bool isBinaryExpression() const CATCH_OVERRIDE { - return true; - } - - virtual void reconstructExpression( std::string& dest ) const CATCH_OVERRIDE { - std::string lhs = Catch::toString( m_lhs ); - std::string rhs = Catch::toString( m_rhs ); - char delim = lhs.size() + rhs.size() < 40 && - lhs.find('\n') == std::string::npos && - rhs.find('\n') == std::string::npos ? ' ' : '\n'; - dest.reserve( 7 + lhs.size() + rhs.size() ); - // 2 for spaces around operator - // 2 for operator - // 2 for parentheses (conditionally added later) - // 1 for negation (conditionally added later) - dest = lhs; - dest += delim; - dest += Internal::OperatorTraits::getName(); - dest += delim; - dest += rhs; - } - -private: - ResultBuilder& m_rb; - LhsT m_lhs; - RhsT m_rhs; -}; - -template -class MatchExpression : public DecomposedExpression { -public: - MatchExpression( ArgT arg, MatcherT matcher, char const* matcherString ) - : m_arg( arg ), m_matcher( matcher ), m_matcherString( matcherString ) {} - - virtual bool isBinaryExpression() const CATCH_OVERRIDE { - return true; - } - - virtual void reconstructExpression( std::string& dest ) const CATCH_OVERRIDE { - std::string matcherAsString = m_matcher.toString(); - dest = Catch::toString( m_arg ); - dest += ' '; - if( matcherAsString == Detail::unprintableString ) - dest += m_matcherString; - else - dest += matcherAsString; - } - -private: - ArgT m_arg; - MatcherT m_matcher; - char const* m_matcherString; -}; - -} // end namespace Catch - - -namespace Catch { - - template - inline ExpressionLhs ResultBuilder::operator <= ( T const& operand ) { - return ExpressionLhs( *this, operand ); - } - - inline ExpressionLhs ResultBuilder::operator <= ( bool value ) { - return ExpressionLhs( *this, value ); - } - - template - inline void ResultBuilder::captureMatch( ArgT const& arg, MatcherT const& matcher, - char const* matcherString ) { - MatchExpression expr( arg, matcher, matcherString ); - setResultType( matcher.match( arg ) ); - endExpression( expr ); - } - -} // namespace Catch - -// #included from: catch_message.h -#define TWOBLUECUBES_CATCH_MESSAGE_H_INCLUDED - -#include - -namespace Catch { - - struct MessageInfo { - MessageInfo( std::string const& _macroName, - SourceLineInfo const& _lineInfo, - ResultWas::OfType _type ); - - std::string macroName; - SourceLineInfo lineInfo; - ResultWas::OfType type; - std::string message; - unsigned int sequence; - - bool operator == ( MessageInfo const& other ) const { - return sequence == other.sequence; - } - bool operator < ( MessageInfo const& other ) const { - return sequence < other.sequence; - } - private: - static unsigned int globalCount; - }; - - struct MessageBuilder { - MessageBuilder( std::string const& macroName, - SourceLineInfo const& lineInfo, - ResultWas::OfType type ) - : m_info( macroName, lineInfo, type ) - {} - - template - MessageBuilder& operator << ( T const& value ) { - m_stream << value; - return *this; - } - - MessageInfo m_info; - std::ostringstream m_stream; - }; - - class ScopedMessage { - public: - ScopedMessage( MessageBuilder const& builder ); - ScopedMessage( ScopedMessage const& other ); - ~ScopedMessage(); - - MessageInfo m_info; - }; - -} // end namespace Catch - -// #included from: catch_interfaces_capture.h -#define TWOBLUECUBES_CATCH_INTERFACES_CAPTURE_H_INCLUDED - -#include - -namespace Catch { - - class TestCase; - class AssertionResult; - struct AssertionInfo; - struct SectionInfo; - struct SectionEndInfo; - struct MessageInfo; - class ScopedMessageBuilder; - struct Counts; - - struct IResultCapture { - - virtual ~IResultCapture(); - - virtual void assertionEnded( AssertionResult const& result ) = 0; - virtual bool sectionStarted( SectionInfo const& sectionInfo, - Counts& assertions ) = 0; - virtual void sectionEnded( SectionEndInfo const& endInfo ) = 0; - virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) = 0; - virtual void pushScopedMessage( MessageInfo const& message ) = 0; - virtual void popScopedMessage( MessageInfo const& message ) = 0; - - virtual std::string getCurrentTestName() const = 0; - virtual const AssertionResult* getLastResult() const = 0; - - virtual void exceptionEarlyReported() = 0; - - virtual void handleFatalErrorCondition( std::string const& message ) = 0; - }; - - IResultCapture& getResultCapture(); -} - -// #included from: catch_debugger.h -#define TWOBLUECUBES_CATCH_DEBUGGER_H_INCLUDED - -// #included from: catch_platform.h -#define TWOBLUECUBES_CATCH_PLATFORM_H_INCLUDED - -#if defined(__MAC_OS_X_VERSION_MIN_REQUIRED) -# define CATCH_PLATFORM_MAC -#elif defined(__IPHONE_OS_VERSION_MIN_REQUIRED) -# define CATCH_PLATFORM_IPHONE -#elif defined(linux) || defined(__linux) || defined(__linux__) -# define CATCH_PLATFORM_LINUX -#elif defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) -# define CATCH_PLATFORM_WINDOWS -# if !defined(NOMINMAX) && !defined(CATCH_CONFIG_NO_NOMINMAX) -# define CATCH_DEFINES_NOMINMAX -# endif -# if !defined(WIN32_LEAN_AND_MEAN) && !defined(CATCH_CONFIG_NO_WIN32_LEAN_AND_MEAN) -# define CATCH_DEFINES_WIN32_LEAN_AND_MEAN -# endif -#endif - -#include - -namespace Catch{ - - bool isDebuggerActive(); - void writeToDebugConsole( std::string const& text ); -} - -#ifdef CATCH_PLATFORM_MAC - - // The following code snippet based on: - // http://cocoawithlove.com/2008/03/break-into-debugger.html - #if defined(__ppc64__) || defined(__ppc__) - #define CATCH_TRAP() \ - __asm__("li r0, 20\nsc\nnop\nli r0, 37\nli r4, 2\nsc\nnop\n" \ - : : : "memory","r0","r3","r4" ) - #else - #define CATCH_TRAP() __asm__("int $3\n" : : ) - #endif - -#elif defined(CATCH_PLATFORM_LINUX) - // If we can use inline assembler, do it because this allows us to break - // directly at the location of the failing check instead of breaking inside - // raise() called from it, i.e. one stack frame below. - #if defined(__GNUC__) && (defined(__i386) || defined(__x86_64)) - #define CATCH_TRAP() asm volatile ("int $3") - #else // Fall back to the generic way. - #include - - #define CATCH_TRAP() raise(SIGTRAP) - #endif -#elif defined(_MSC_VER) - #define CATCH_TRAP() __debugbreak() -#elif defined(__MINGW32__) - extern "C" __declspec(dllimport) void __stdcall DebugBreak(); - #define CATCH_TRAP() DebugBreak() -#endif - -#ifdef CATCH_TRAP - #define CATCH_BREAK_INTO_DEBUGGER() if( Catch::isDebuggerActive() ) { CATCH_TRAP(); } -#else - #define CATCH_BREAK_INTO_DEBUGGER() Catch::alwaysTrue(); -#endif - -// #included from: catch_interfaces_runner.h -#define TWOBLUECUBES_CATCH_INTERFACES_RUNNER_H_INCLUDED - -namespace Catch { - class TestCase; - - struct IRunner { - virtual ~IRunner(); - virtual bool aborting() const = 0; - }; -} - -#if defined(CATCH_CONFIG_FAST_COMPILE) -/////////////////////////////////////////////////////////////////////////////// -// We can speedup compilation significantly by breaking into debugger lower in -// the callstack, because then we don't have to expand CATCH_BREAK_INTO_DEBUGGER -// macro in each assertion -#define INTERNAL_CATCH_REACT( resultBuilder ) \ - resultBuilder.react(); - -/////////////////////////////////////////////////////////////////////////////// -// Another way to speed-up compilation is to omit local try-catch for REQUIRE* -// macros. -// This can potentially cause false negative, if the test code catches -// the exception before it propagates back up to the runner. -#define INTERNAL_CATCH_TEST_NO_TRY( macroName, resultDisposition, expr ) \ - do { \ - Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \ - __catchResult.setExceptionGuard(); \ - CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ - ( __catchResult <= expr ).endExpression(); \ - CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \ - __catchResult.unsetExceptionGuard(); \ - INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::isTrue( false && static_cast( !!(expr) ) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look -// The double negation silences MSVC's C4800 warning, the static_cast forces short-circuit evaluation if the type has overloaded &&. - -#define INTERNAL_CHECK_THAT_NO_TRY( macroName, matcher, resultDisposition, arg ) \ - do { \ - Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #arg ", " #matcher, resultDisposition ); \ - __catchResult.setExceptionGuard(); \ - __catchResult.captureMatch( arg, matcher, #matcher ); \ - __catchResult.unsetExceptionGuard(); \ - INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::alwaysFalse() ) - -#else -/////////////////////////////////////////////////////////////////////////////// -// In the event of a failure works out if the debugger needs to be invoked -// and/or an exception thrown and takes appropriate action. -// This needs to be done as a macro so the debugger will stop in the user -// source code rather than in Catch library code -#define INTERNAL_CATCH_REACT( resultBuilder ) \ - if( resultBuilder.shouldDebugBreak() ) CATCH_BREAK_INTO_DEBUGGER(); \ - resultBuilder.react(); -#endif - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ) \ - do { \ - Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \ - try { \ - CATCH_INTERNAL_SUPPRESS_PARENTHESES_WARNINGS \ - ( __catchResult <= expr ).endExpression(); \ - CATCH_INTERNAL_UNSUPPRESS_PARENTHESES_WARNINGS \ - } \ - catch( ... ) { \ - __catchResult.useActiveException( resultDisposition ); \ - } \ - INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::isTrue( false && static_cast( !!(expr) ) ) ) // expr here is never evaluated at runtime but it forces the compiler to give it a look - // The double negation silences MSVC's C4800 warning, the static_cast forces short-circuit evaluation if the type has overloaded &&. - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_IF( macroName, resultDisposition, expr ) \ - INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ); \ - if( Catch::getResultCapture().getLastResult()->succeeded() ) - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_ELSE( macroName, resultDisposition, expr ) \ - INTERNAL_CATCH_TEST( macroName, resultDisposition, expr ); \ - if( !Catch::getResultCapture().getLastResult()->succeeded() ) - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_NO_THROW( macroName, resultDisposition, expr ) \ - do { \ - Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition ); \ - try { \ - static_cast(expr); \ - __catchResult.captureResult( Catch::ResultWas::Ok ); \ - } \ - catch( ... ) { \ - __catchResult.useActiveException( resultDisposition ); \ - } \ - INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::alwaysFalse() ) - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_THROWS( macroName, resultDisposition, matcher, expr ) \ - do { \ - Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr, resultDisposition, #matcher ); \ - if( __catchResult.allowThrows() ) \ - try { \ - static_cast(expr); \ - __catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \ - } \ - catch( ... ) { \ - __catchResult.captureExpectedException( matcher ); \ - } \ - else \ - __catchResult.captureResult( Catch::ResultWas::Ok ); \ - INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::alwaysFalse() ) - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_THROWS_AS( macroName, exceptionType, resultDisposition, expr ) \ - do { \ - Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #expr ", " #exceptionType, resultDisposition ); \ - if( __catchResult.allowThrows() ) \ - try { \ - static_cast(expr); \ - __catchResult.captureResult( Catch::ResultWas::DidntThrowException ); \ - } \ - catch( exceptionType ) { \ - __catchResult.captureResult( Catch::ResultWas::Ok ); \ - } \ - catch( ... ) { \ - __catchResult.useActiveException( resultDisposition ); \ - } \ - else \ - __catchResult.captureResult( Catch::ResultWas::Ok ); \ - INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::alwaysFalse() ) - -/////////////////////////////////////////////////////////////////////////////// -#ifdef CATCH_CONFIG_VARIADIC_MACROS - #define INTERNAL_CATCH_MSG( macroName, messageType, resultDisposition, ... ) \ - do { \ - Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, "", resultDisposition ); \ - __catchResult << __VA_ARGS__ + ::Catch::StreamEndStop(); \ - __catchResult.captureResult( messageType ); \ - INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::alwaysFalse() ) -#else - #define INTERNAL_CATCH_MSG( macroName, messageType, resultDisposition, log ) \ - do { \ - Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, "", resultDisposition ); \ - __catchResult << log + ::Catch::StreamEndStop(); \ - __catchResult.captureResult( messageType ); \ - INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::alwaysFalse() ) -#endif - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_INFO( macroName, log ) \ - Catch::ScopedMessage INTERNAL_CATCH_UNIQUE_NAME( scopedMessage ) = Catch::MessageBuilder( macroName, CATCH_INTERNAL_LINEINFO, Catch::ResultWas::Info ) << log; - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CHECK_THAT( macroName, matcher, resultDisposition, arg ) \ - do { \ - Catch::ResultBuilder __catchResult( macroName, CATCH_INTERNAL_LINEINFO, #arg ", " #matcher, resultDisposition ); \ - try { \ - __catchResult.captureMatch( arg, matcher, #matcher ); \ - } catch( ... ) { \ - __catchResult.useActiveException( resultDisposition | Catch::ResultDisposition::ContinueOnFailure ); \ - } \ - INTERNAL_CATCH_REACT( __catchResult ) \ - } while( Catch::alwaysFalse() ) - -// #included from: internal/catch_section.h -#define TWOBLUECUBES_CATCH_SECTION_H_INCLUDED - -// #included from: catch_section_info.h -#define TWOBLUECUBES_CATCH_SECTION_INFO_H_INCLUDED - -// #included from: catch_totals.hpp -#define TWOBLUECUBES_CATCH_TOTALS_HPP_INCLUDED - -#include - -namespace Catch { - - struct Counts { - Counts() : passed( 0 ), failed( 0 ), failedButOk( 0 ) {} - - Counts operator - ( Counts const& other ) const { - Counts diff; - diff.passed = passed - other.passed; - diff.failed = failed - other.failed; - diff.failedButOk = failedButOk - other.failedButOk; - return diff; - } - Counts& operator += ( Counts const& other ) { - passed += other.passed; - failed += other.failed; - failedButOk += other.failedButOk; - return *this; - } - - std::size_t total() const { - return passed + failed + failedButOk; - } - bool allPassed() const { - return failed == 0 && failedButOk == 0; - } - bool allOk() const { - return failed == 0; - } - - std::size_t passed; - std::size_t failed; - std::size_t failedButOk; - }; - - struct Totals { - - Totals operator - ( Totals const& other ) const { - Totals diff; - diff.assertions = assertions - other.assertions; - diff.testCases = testCases - other.testCases; - return diff; - } - - Totals delta( Totals const& prevTotals ) const { - Totals diff = *this - prevTotals; - if( diff.assertions.failed > 0 ) - ++diff.testCases.failed; - else if( diff.assertions.failedButOk > 0 ) - ++diff.testCases.failedButOk; - else - ++diff.testCases.passed; - return diff; - } - - Totals& operator += ( Totals const& other ) { - assertions += other.assertions; - testCases += other.testCases; - return *this; - } - - Counts assertions; - Counts testCases; - }; -} - -#include - -namespace Catch { - - struct SectionInfo { - SectionInfo - ( SourceLineInfo const& _lineInfo, - std::string const& _name, - std::string const& _description = std::string() ); - - std::string name; - std::string description; - SourceLineInfo lineInfo; - }; - - struct SectionEndInfo { - SectionEndInfo( SectionInfo const& _sectionInfo, Counts const& _prevAssertions, double _durationInSeconds ) - : sectionInfo( _sectionInfo ), prevAssertions( _prevAssertions ), durationInSeconds( _durationInSeconds ) - {} - - SectionInfo sectionInfo; - Counts prevAssertions; - double durationInSeconds; - }; - -} // end namespace Catch - -// #included from: catch_timer.h -#define TWOBLUECUBES_CATCH_TIMER_H_INCLUDED - -#ifdef _MSC_VER - -namespace Catch { - typedef unsigned long long UInt64; -} -#else -#include -namespace Catch { - typedef uint64_t UInt64; -} -#endif - -namespace Catch { - class Timer { - public: - Timer() : m_ticks( 0 ) {} - void start(); - unsigned int getElapsedMicroseconds() const; - unsigned int getElapsedMilliseconds() const; - double getElapsedSeconds() const; - - private: - UInt64 m_ticks; - }; - -} // namespace Catch - -#include - -namespace Catch { - - class Section : NonCopyable { - public: - Section( SectionInfo const& info ); - ~Section(); - - // This indicates whether the section should be executed or not - operator bool() const; - - private: - SectionInfo m_info; - - std::string m_name; - Counts m_assertions; - bool m_sectionIncluded; - Timer m_timer; - }; - -} // end namespace Catch - -#ifdef CATCH_CONFIG_VARIADIC_MACROS - #define INTERNAL_CATCH_SECTION( ... ) \ - if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, __VA_ARGS__ ) ) -#else - #define INTERNAL_CATCH_SECTION( name, desc ) \ - if( Catch::Section const& INTERNAL_CATCH_UNIQUE_NAME( catch_internal_Section ) = Catch::SectionInfo( CATCH_INTERNAL_LINEINFO, name, desc ) ) -#endif - -// #included from: internal/catch_generators.hpp -#define TWOBLUECUBES_CATCH_GENERATORS_HPP_INCLUDED - -#include -#include -#include - -namespace Catch { - -template -struct IGenerator { - virtual ~IGenerator() {} - virtual T getValue( std::size_t index ) const = 0; - virtual std::size_t size () const = 0; -}; - -template -class BetweenGenerator : public IGenerator { -public: - BetweenGenerator( T from, T to ) : m_from( from ), m_to( to ){} - - virtual T getValue( std::size_t index ) const { - return m_from+static_cast( index ); - } - - virtual std::size_t size() const { - return static_cast( 1+m_to-m_from ); - } - -private: - - T m_from; - T m_to; -}; - -template -class ValuesGenerator : public IGenerator { -public: - ValuesGenerator(){} - - void add( T value ) { - m_values.push_back( value ); - } - - virtual T getValue( std::size_t index ) const { - return m_values[index]; - } - - virtual std::size_t size() const { - return m_values.size(); - } - -private: - std::vector m_values; -}; - -template -class CompositeGenerator { -public: - CompositeGenerator() : m_totalSize( 0 ) {} - - // *** Move semantics, similar to auto_ptr *** - CompositeGenerator( CompositeGenerator& other ) - : m_fileInfo( other.m_fileInfo ), - m_totalSize( 0 ) - { - move( other ); - } - - CompositeGenerator& setFileInfo( const char* fileInfo ) { - m_fileInfo = fileInfo; - return *this; - } - - ~CompositeGenerator() { - deleteAll( m_composed ); - } - - operator T () const { - size_t overallIndex = getCurrentContext().getGeneratorIndex( m_fileInfo, m_totalSize ); - - typename std::vector*>::const_iterator it = m_composed.begin(); - typename std::vector*>::const_iterator itEnd = m_composed.end(); - for( size_t index = 0; it != itEnd; ++it ) - { - const IGenerator* generator = *it; - if( overallIndex >= index && overallIndex < index + generator->size() ) - { - return generator->getValue( overallIndex-index ); - } - index += generator->size(); - } - CATCH_INTERNAL_ERROR( "Indexed past end of generated range" ); - return T(); // Suppress spurious "not all control paths return a value" warning in Visual Studio - if you know how to fix this please do so - } - - void add( const IGenerator* generator ) { - m_totalSize += generator->size(); - m_composed.push_back( generator ); - } - - CompositeGenerator& then( CompositeGenerator& other ) { - move( other ); - return *this; - } - - CompositeGenerator& then( T value ) { - ValuesGenerator* valuesGen = new ValuesGenerator(); - valuesGen->add( value ); - add( valuesGen ); - return *this; - } - -private: - - void move( CompositeGenerator& other ) { - m_composed.insert( m_composed.end(), other.m_composed.begin(), other.m_composed.end() ); - m_totalSize += other.m_totalSize; - other.m_composed.clear(); - } - - std::vector*> m_composed; - std::string m_fileInfo; - size_t m_totalSize; -}; - -namespace Generators -{ - template - CompositeGenerator between( T from, T to ) { - CompositeGenerator generators; - generators.add( new BetweenGenerator( from, to ) ); - return generators; - } - - template - CompositeGenerator values( T val1, T val2 ) { - CompositeGenerator generators; - ValuesGenerator* valuesGen = new ValuesGenerator(); - valuesGen->add( val1 ); - valuesGen->add( val2 ); - generators.add( valuesGen ); - return generators; - } - - template - CompositeGenerator values( T val1, T val2, T val3 ){ - CompositeGenerator generators; - ValuesGenerator* valuesGen = new ValuesGenerator(); - valuesGen->add( val1 ); - valuesGen->add( val2 ); - valuesGen->add( val3 ); - generators.add( valuesGen ); - return generators; - } - - template - CompositeGenerator values( T val1, T val2, T val3, T val4 ) { - CompositeGenerator generators; - ValuesGenerator* valuesGen = new ValuesGenerator(); - valuesGen->add( val1 ); - valuesGen->add( val2 ); - valuesGen->add( val3 ); - valuesGen->add( val4 ); - generators.add( valuesGen ); - return generators; - } - -} // end namespace Generators - -using namespace Generators; - -} // end namespace Catch - -#define INTERNAL_CATCH_LINESTR2( line ) #line -#define INTERNAL_CATCH_LINESTR( line ) INTERNAL_CATCH_LINESTR2( line ) - -#define INTERNAL_CATCH_GENERATE( expr ) expr.setFileInfo( __FILE__ "(" INTERNAL_CATCH_LINESTR( __LINE__ ) ")" ) - -// #included from: internal/catch_interfaces_exception.h -#define TWOBLUECUBES_CATCH_INTERFACES_EXCEPTION_H_INCLUDED - -#include -#include - -// #included from: catch_interfaces_registry_hub.h -#define TWOBLUECUBES_CATCH_INTERFACES_REGISTRY_HUB_H_INCLUDED - -#include - -namespace Catch { - - class TestCase; - struct ITestCaseRegistry; - struct IExceptionTranslatorRegistry; - struct IExceptionTranslator; - struct IReporterRegistry; - struct IReporterFactory; - struct ITagAliasRegistry; - - struct IRegistryHub { - virtual ~IRegistryHub(); - - virtual IReporterRegistry const& getReporterRegistry() const = 0; - virtual ITestCaseRegistry const& getTestCaseRegistry() const = 0; - virtual ITagAliasRegistry const& getTagAliasRegistry() const = 0; - - virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() = 0; - }; - - struct IMutableRegistryHub { - virtual ~IMutableRegistryHub(); - virtual void registerReporter( std::string const& name, Ptr const& factory ) = 0; - virtual void registerListener( Ptr const& factory ) = 0; - virtual void registerTest( TestCase const& testInfo ) = 0; - virtual void registerTranslator( const IExceptionTranslator* translator ) = 0; - virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) = 0; - }; - - IRegistryHub& getRegistryHub(); - IMutableRegistryHub& getMutableRegistryHub(); - void cleanUp(); - std::string translateActiveException(); - -} - -namespace Catch { - - typedef std::string(*exceptionTranslateFunction)(); - - struct IExceptionTranslator; - typedef std::vector ExceptionTranslators; - - struct IExceptionTranslator { - virtual ~IExceptionTranslator(); - virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const = 0; - }; - - struct IExceptionTranslatorRegistry { - virtual ~IExceptionTranslatorRegistry(); - - virtual std::string translateActiveException() const = 0; - }; - - class ExceptionTranslatorRegistrar { - template - class ExceptionTranslator : public IExceptionTranslator { - public: - - ExceptionTranslator( std::string(*translateFunction)( T& ) ) - : m_translateFunction( translateFunction ) - {} - - virtual std::string translate( ExceptionTranslators::const_iterator it, ExceptionTranslators::const_iterator itEnd ) const CATCH_OVERRIDE { - try { - if( it == itEnd ) - throw; - else - return (*it)->translate( it+1, itEnd ); - } - catch( T& ex ) { - return m_translateFunction( ex ); - } - } - - protected: - std::string(*m_translateFunction)( T& ); - }; - - public: - template - ExceptionTranslatorRegistrar( std::string(*translateFunction)( T& ) ) { - getMutableRegistryHub().registerTranslator - ( new ExceptionTranslator( translateFunction ) ); - } - }; -} - -/////////////////////////////////////////////////////////////////////////////// -#define INTERNAL_CATCH_TRANSLATE_EXCEPTION2( translatorName, signature ) \ - static std::string translatorName( signature ); \ - namespace{ Catch::ExceptionTranslatorRegistrar INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionRegistrar )( &translatorName ); }\ - static std::string translatorName( signature ) - -#define INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION2( INTERNAL_CATCH_UNIQUE_NAME( catch_internal_ExceptionTranslator ), signature ) - -// #included from: internal/catch_approx.hpp -#define TWOBLUECUBES_CATCH_APPROX_HPP_INCLUDED - -#include -#include - -#if defined(CATCH_CONFIG_CPP11_TYPE_TRAITS) -#include -#endif - -namespace Catch { -namespace Detail { - - class Approx { - public: - explicit Approx ( double value ) - : m_epsilon( std::numeric_limits::epsilon()*100 ), - m_margin( 0.0 ), - m_scale( 1.0 ), - m_value( value ) - {} - - Approx( Approx const& other ) - : m_epsilon( other.m_epsilon ), - m_margin( other.m_margin ), - m_scale( other.m_scale ), - m_value( other.m_value ) - {} - - static Approx custom() { - return Approx( 0 ); - } - -#if defined(CATCH_CONFIG_CPP11_TYPE_TRAITS) - - template ::value>::type> - Approx operator()( T value ) { - Approx approx( static_cast(value) ); - approx.epsilon( m_epsilon ); - approx.margin( m_margin ); - approx.scale( m_scale ); - return approx; - } - - template ::value>::type> - explicit Approx( T value ): Approx(static_cast(value)) - {} - - template ::value>::type> - friend bool operator == ( const T& lhs, Approx const& rhs ) { - // Thanks to Richard Harris for his help refining this formula - auto lhs_v = double(lhs); - bool relativeOK = std::fabs(lhs_v - rhs.m_value) < rhs.m_epsilon * (rhs.m_scale + (std::max)(std::fabs(lhs_v), std::fabs(rhs.m_value))); - if (relativeOK) { - return true; - } - return std::fabs(lhs_v - rhs.m_value) < rhs.m_margin; - } - - template ::value>::type> - friend bool operator == ( Approx const& lhs, const T& rhs ) { - return operator==( rhs, lhs ); - } - - template ::value>::type> - friend bool operator != ( T lhs, Approx const& rhs ) { - return !operator==( lhs, rhs ); - } - - template ::value>::type> - friend bool operator != ( Approx const& lhs, T rhs ) { - return !operator==( rhs, lhs ); - } - - template ::value>::type> - friend bool operator <= ( T lhs, Approx const& rhs ) { - return double(lhs) < rhs.m_value || lhs == rhs; - } - - template ::value>::type> - friend bool operator <= ( Approx const& lhs, T rhs ) { - return lhs.m_value < double(rhs) || lhs == rhs; - } - - template ::value>::type> - friend bool operator >= ( T lhs, Approx const& rhs ) { - return double(lhs) > rhs.m_value || lhs == rhs; - } - - template ::value>::type> - friend bool operator >= ( Approx const& lhs, T rhs ) { - return lhs.m_value > double(rhs) || lhs == rhs; - } - - template ::value>::type> - Approx& epsilon( T newEpsilon ) { - m_epsilon = double(newEpsilon); - return *this; - } - - template ::value>::type> - Approx& margin( T newMargin ) { - m_margin = double(newMargin); - return *this; - } - - template ::value>::type> - Approx& scale( T newScale ) { - m_scale = double(newScale); - return *this; - } - -#else - - Approx operator()( double value ) { - Approx approx( value ); - approx.epsilon( m_epsilon ); - approx.margin( m_margin ); - approx.scale( m_scale ); - return approx; - } - - friend bool operator == ( double lhs, Approx const& rhs ) { - // Thanks to Richard Harris for his help refining this formula - bool relativeOK = std::fabs( lhs - rhs.m_value ) < rhs.m_epsilon * (rhs.m_scale + (std::max)( std::fabs(lhs), std::fabs(rhs.m_value) ) ); - if (relativeOK) { - return true; - } - return std::fabs(lhs - rhs.m_value) < rhs.m_margin; - } - - friend bool operator == ( Approx const& lhs, double rhs ) { - return operator==( rhs, lhs ); - } - - friend bool operator != ( double lhs, Approx const& rhs ) { - return !operator==( lhs, rhs ); - } - - friend bool operator != ( Approx const& lhs, double rhs ) { - return !operator==( rhs, lhs ); - } - - friend bool operator <= ( double lhs, Approx const& rhs ) { - return lhs < rhs.m_value || lhs == rhs; - } - - friend bool operator <= ( Approx const& lhs, double rhs ) { - return lhs.m_value < rhs || lhs == rhs; - } - - friend bool operator >= ( double lhs, Approx const& rhs ) { - return lhs > rhs.m_value || lhs == rhs; - } - - friend bool operator >= ( Approx const& lhs, double rhs ) { - return lhs.m_value > rhs || lhs == rhs; - } - - Approx& epsilon( double newEpsilon ) { - m_epsilon = newEpsilon; - return *this; - } - - Approx& margin( double newMargin ) { - m_margin = newMargin; - return *this; - } - - Approx& scale( double newScale ) { - m_scale = newScale; - return *this; - } -#endif - - std::string toString() const { - std::ostringstream oss; - oss << "Approx( " << Catch::toString( m_value ) << " )"; - return oss.str(); - } - - private: - double m_epsilon; - double m_margin; - double m_scale; - double m_value; - }; -} - -template<> -inline std::string toString( Detail::Approx const& value ) { - return value.toString(); -} - -} // end namespace Catch - -// #included from: internal/catch_matchers_string.h -#define TWOBLUECUBES_CATCH_MATCHERS_STRING_H_INCLUDED - -namespace Catch { -namespace Matchers { - - namespace StdString { - - struct CasedString - { - CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity ); - std::string adjustString( std::string const& str ) const; - std::string caseSensitivitySuffix() const; - - CaseSensitive::Choice m_caseSensitivity; - std::string m_str; - }; - - struct StringMatcherBase : MatcherBase { - StringMatcherBase( std::string const& operation, CasedString const& comparator ); - virtual std::string describe() const CATCH_OVERRIDE; - - CasedString m_comparator; - std::string m_operation; - }; - - struct EqualsMatcher : StringMatcherBase { - EqualsMatcher( CasedString const& comparator ); - virtual bool match( std::string const& source ) const CATCH_OVERRIDE; - }; - struct ContainsMatcher : StringMatcherBase { - ContainsMatcher( CasedString const& comparator ); - virtual bool match( std::string const& source ) const CATCH_OVERRIDE; - }; - struct StartsWithMatcher : StringMatcherBase { - StartsWithMatcher( CasedString const& comparator ); - virtual bool match( std::string const& source ) const CATCH_OVERRIDE; - }; - struct EndsWithMatcher : StringMatcherBase { - EndsWithMatcher( CasedString const& comparator ); - virtual bool match( std::string const& source ) const CATCH_OVERRIDE; - }; - - } // namespace StdString - - // The following functions create the actual matcher objects. - // This allows the types to be inferred - - StdString::EqualsMatcher Equals( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); - StdString::ContainsMatcher Contains( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); - StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); - StdString::StartsWithMatcher StartsWith( std::string const& str, CaseSensitive::Choice caseSensitivity = CaseSensitive::Yes ); - -} // namespace Matchers -} // namespace Catch - -// #included from: internal/catch_matchers_vector.h -#define TWOBLUECUBES_CATCH_MATCHERS_VECTOR_H_INCLUDED - -namespace Catch { -namespace Matchers { - - namespace Vector { - - template - struct ContainsElementMatcher : MatcherBase, T> { - - ContainsElementMatcher(T const &comparator) : m_comparator( comparator) {} - - bool match(std::vector const &v) const CATCH_OVERRIDE { - return std::find(v.begin(), v.end(), m_comparator) != v.end(); - } - - virtual std::string describe() const CATCH_OVERRIDE { - return "Contains: " + Catch::toString( m_comparator ); - } - - T const& m_comparator; - }; - - template - struct ContainsMatcher : MatcherBase, std::vector > { - - ContainsMatcher(std::vector const &comparator) : m_comparator( comparator ) {} - - bool match(std::vector const &v) const CATCH_OVERRIDE { - // !TBD: see note in EqualsMatcher - if (m_comparator.size() > v.size()) - return false; - for (size_t i = 0; i < m_comparator.size(); ++i) - if (std::find(v.begin(), v.end(), m_comparator[i]) == v.end()) - return false; - return true; - } - virtual std::string describe() const CATCH_OVERRIDE { - return "Contains: " + Catch::toString( m_comparator ); - } - - std::vector const& m_comparator; - }; - - template - struct EqualsMatcher : MatcherBase, std::vector > { - - EqualsMatcher(std::vector const &comparator) : m_comparator( comparator ) {} - - bool match(std::vector const &v) const CATCH_OVERRIDE { - // !TBD: This currently works if all elements can be compared using != - // - a more general approach would be via a compare template that defaults - // to using !=. but could be specialised for, e.g. std::vector etc - // - then just call that directly - if (m_comparator.size() != v.size()) - return false; - for (size_t i = 0; i < v.size(); ++i) - if (m_comparator[i] != v[i]) - return false; - return true; - } - virtual std::string describe() const CATCH_OVERRIDE { - return "Equals: " + Catch::toString( m_comparator ); - } - std::vector const& m_comparator; - }; - - } // namespace Vector - - // The following functions create the actual matcher objects. - // This allows the types to be inferred - - template - Vector::ContainsMatcher Contains( std::vector const& comparator ) { - return Vector::ContainsMatcher( comparator ); - } - - template - Vector::ContainsElementMatcher VectorContains( T const& comparator ) { - return Vector::ContainsElementMatcher( comparator ); - } - - template - Vector::EqualsMatcher Equals( std::vector const& comparator ) { - return Vector::EqualsMatcher( comparator ); - } - -} // namespace Matchers -} // namespace Catch - -// #included from: internal/catch_interfaces_tag_alias_registry.h -#define TWOBLUECUBES_CATCH_INTERFACES_TAG_ALIAS_REGISTRY_H_INCLUDED - -// #included from: catch_tag_alias.h -#define TWOBLUECUBES_CATCH_TAG_ALIAS_H_INCLUDED - -#include - -namespace Catch { - - struct TagAlias { - TagAlias( std::string const& _tag, SourceLineInfo _lineInfo ) : tag( _tag ), lineInfo( _lineInfo ) {} - - std::string tag; - SourceLineInfo lineInfo; - }; - - struct RegistrarForTagAliases { - RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ); - }; - -} // end namespace Catch - -#define CATCH_REGISTER_TAG_ALIAS( alias, spec ) namespace{ Catch::RegistrarForTagAliases INTERNAL_CATCH_UNIQUE_NAME( AutoRegisterTagAlias )( alias, spec, CATCH_INTERNAL_LINEINFO ); } -// #included from: catch_option.hpp -#define TWOBLUECUBES_CATCH_OPTION_HPP_INCLUDED - -namespace Catch { - - // An optional type - template - class Option { - public: - Option() : nullableValue( CATCH_NULL ) {} - Option( T const& _value ) - : nullableValue( new( storage ) T( _value ) ) - {} - Option( Option const& _other ) - : nullableValue( _other ? new( storage ) T( *_other ) : CATCH_NULL ) - {} - - ~Option() { - reset(); - } - - Option& operator= ( Option const& _other ) { - if( &_other != this ) { - reset(); - if( _other ) - nullableValue = new( storage ) T( *_other ); - } - return *this; - } - Option& operator = ( T const& _value ) { - reset(); - nullableValue = new( storage ) T( _value ); - return *this; - } - - void reset() { - if( nullableValue ) - nullableValue->~T(); - nullableValue = CATCH_NULL; - } - - T& operator*() { return *nullableValue; } - T const& operator*() const { return *nullableValue; } - T* operator->() { return nullableValue; } - const T* operator->() const { return nullableValue; } - - T valueOr( T const& defaultValue ) const { - return nullableValue ? *nullableValue : defaultValue; - } - - bool some() const { return nullableValue != CATCH_NULL; } - bool none() const { return nullableValue == CATCH_NULL; } - - bool operator !() const { return nullableValue == CATCH_NULL; } - operator SafeBool::type() const { - return SafeBool::makeSafe( some() ); - } - - private: - T *nullableValue; - union { - char storage[sizeof(T)]; - - // These are here to force alignment for the storage - long double dummy1; - void (*dummy2)(); - long double dummy3; -#ifdef CATCH_CONFIG_CPP11_LONG_LONG - long long dummy4; -#endif - }; - }; - -} // end namespace Catch - -namespace Catch { - - struct ITagAliasRegistry { - virtual ~ITagAliasRegistry(); - virtual Option find( std::string const& alias ) const = 0; - virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const = 0; - - static ITagAliasRegistry const& get(); - }; - -} // end namespace Catch - -// These files are included here so the single_include script doesn't put them -// in the conditionally compiled sections -// #included from: internal/catch_test_case_info.h -#define TWOBLUECUBES_CATCH_TEST_CASE_INFO_H_INCLUDED - -#include -#include - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpadded" -#endif - -namespace Catch { - - struct ITestCase; - - struct TestCaseInfo { - enum SpecialProperties{ - None = 0, - IsHidden = 1 << 1, - ShouldFail = 1 << 2, - MayFail = 1 << 3, - Throws = 1 << 4, - NonPortable = 1 << 5 - }; - - TestCaseInfo( std::string const& _name, - std::string const& _className, - std::string const& _description, - std::set const& _tags, - SourceLineInfo const& _lineInfo ); - - TestCaseInfo( TestCaseInfo const& other ); - - friend void setTags( TestCaseInfo& testCaseInfo, std::set const& tags ); - - bool isHidden() const; - bool throws() const; - bool okToFail() const; - bool expectedToFail() const; - - std::string name; - std::string className; - std::string description; - std::set tags; - std::set lcaseTags; - std::string tagsAsString; - SourceLineInfo lineInfo; - SpecialProperties properties; - }; - - class TestCase : public TestCaseInfo { - public: - - TestCase( ITestCase* testCase, TestCaseInfo const& info ); - TestCase( TestCase const& other ); - - TestCase withName( std::string const& _newName ) const; - - void invoke() const; - - TestCaseInfo const& getTestCaseInfo() const; - - void swap( TestCase& other ); - bool operator == ( TestCase const& other ) const; - bool operator < ( TestCase const& other ) const; - TestCase& operator = ( TestCase const& other ); - - private: - Ptr test; - }; - - TestCase makeTestCase( ITestCase* testCase, - std::string const& className, - std::string const& name, - std::string const& description, - SourceLineInfo const& lineInfo ); -} - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - - -#ifdef __OBJC__ -// #included from: internal/catch_objc.hpp -#define TWOBLUECUBES_CATCH_OBJC_HPP_INCLUDED - -#import - -#include - -// NB. Any general catch headers included here must be included -// in catch.hpp first to make sure they are included by the single -// header for non obj-usage - -/////////////////////////////////////////////////////////////////////////////// -// This protocol is really only here for (self) documenting purposes, since -// all its methods are optional. -@protocol OcFixture - -@optional - --(void) setUp; --(void) tearDown; - -@end - -namespace Catch { - - class OcMethod : public SharedImpl { - - public: - OcMethod( Class cls, SEL sel ) : m_cls( cls ), m_sel( sel ) {} - - virtual void invoke() const { - id obj = [[m_cls alloc] init]; - - performOptionalSelector( obj, @selector(setUp) ); - performOptionalSelector( obj, m_sel ); - performOptionalSelector( obj, @selector(tearDown) ); - - arcSafeRelease( obj ); - } - private: - virtual ~OcMethod() {} - - Class m_cls; - SEL m_sel; - }; - - namespace Detail{ - - inline std::string getAnnotation( Class cls, - std::string const& annotationName, - std::string const& testCaseName ) { - NSString* selStr = [[NSString alloc] initWithFormat:@"Catch_%s_%s", annotationName.c_str(), testCaseName.c_str()]; - SEL sel = NSSelectorFromString( selStr ); - arcSafeRelease( selStr ); - id value = performOptionalSelector( cls, sel ); - if( value ) - return [(NSString*)value UTF8String]; - return ""; - } - } - - inline size_t registerTestMethods() { - size_t noTestMethods = 0; - int noClasses = objc_getClassList( CATCH_NULL, 0 ); - - Class* classes = (CATCH_UNSAFE_UNRETAINED Class *)malloc( sizeof(Class) * noClasses); - objc_getClassList( classes, noClasses ); - - for( int c = 0; c < noClasses; c++ ) { - Class cls = classes[c]; - { - u_int count; - Method* methods = class_copyMethodList( cls, &count ); - for( u_int m = 0; m < count ; m++ ) { - SEL selector = method_getName(methods[m]); - std::string methodName = sel_getName(selector); - if( startsWith( methodName, "Catch_TestCase_" ) ) { - std::string testCaseName = methodName.substr( 15 ); - std::string name = Detail::getAnnotation( cls, "Name", testCaseName ); - std::string desc = Detail::getAnnotation( cls, "Description", testCaseName ); - const char* className = class_getName( cls ); - - getMutableRegistryHub().registerTest( makeTestCase( new OcMethod( cls, selector ), className, name.c_str(), desc.c_str(), SourceLineInfo() ) ); - noTestMethods++; - } - } - free(methods); - } - } - return noTestMethods; - } - - namespace Matchers { - namespace Impl { - namespace NSStringMatchers { - - struct StringHolder : MatcherBase{ - StringHolder( NSString* substr ) : m_substr( [substr copy] ){} - StringHolder( StringHolder const& other ) : m_substr( [other.m_substr copy] ){} - StringHolder() { - arcSafeRelease( m_substr ); - } - - virtual bool match( NSString* arg ) const CATCH_OVERRIDE { - return false; - } - - NSString* m_substr; - }; - - struct Equals : StringHolder { - Equals( NSString* substr ) : StringHolder( substr ){} - - virtual bool match( NSString* str ) const CATCH_OVERRIDE { - return (str != nil || m_substr == nil ) && - [str isEqualToString:m_substr]; - } - - virtual std::string describe() const CATCH_OVERRIDE { - return "equals string: " + Catch::toString( m_substr ); - } - }; - - struct Contains : StringHolder { - Contains( NSString* substr ) : StringHolder( substr ){} - - virtual bool match( NSString* str ) const { - return (str != nil || m_substr == nil ) && - [str rangeOfString:m_substr].location != NSNotFound; - } - - virtual std::string describe() const CATCH_OVERRIDE { - return "contains string: " + Catch::toString( m_substr ); - } - }; - - struct StartsWith : StringHolder { - StartsWith( NSString* substr ) : StringHolder( substr ){} - - virtual bool match( NSString* str ) const { - return (str != nil || m_substr == nil ) && - [str rangeOfString:m_substr].location == 0; - } - - virtual std::string describe() const CATCH_OVERRIDE { - return "starts with: " + Catch::toString( m_substr ); - } - }; - struct EndsWith : StringHolder { - EndsWith( NSString* substr ) : StringHolder( substr ){} - - virtual bool match( NSString* str ) const { - return (str != nil || m_substr == nil ) && - [str rangeOfString:m_substr].location == [str length] - [m_substr length]; - } - - virtual std::string describe() const CATCH_OVERRIDE { - return "ends with: " + Catch::toString( m_substr ); - } - }; - - } // namespace NSStringMatchers - } // namespace Impl - - inline Impl::NSStringMatchers::Equals - Equals( NSString* substr ){ return Impl::NSStringMatchers::Equals( substr ); } - - inline Impl::NSStringMatchers::Contains - Contains( NSString* substr ){ return Impl::NSStringMatchers::Contains( substr ); } - - inline Impl::NSStringMatchers::StartsWith - StartsWith( NSString* substr ){ return Impl::NSStringMatchers::StartsWith( substr ); } - - inline Impl::NSStringMatchers::EndsWith - EndsWith( NSString* substr ){ return Impl::NSStringMatchers::EndsWith( substr ); } - - } // namespace Matchers - - using namespace Matchers; - -} // namespace Catch - -/////////////////////////////////////////////////////////////////////////////// -#define OC_TEST_CASE( name, desc )\ -+(NSString*) INTERNAL_CATCH_UNIQUE_NAME( Catch_Name_test ) \ -{\ -return @ name; \ -}\ -+(NSString*) INTERNAL_CATCH_UNIQUE_NAME( Catch_Description_test ) \ -{ \ -return @ desc; \ -} \ --(void) INTERNAL_CATCH_UNIQUE_NAME( Catch_TestCase_test ) - -#endif - -#ifdef CATCH_IMPL - -// !TBD: Move the leak detector code into a separate header -#ifdef CATCH_CONFIG_WINDOWS_CRTDBG -#include -class LeakDetector { -public: - LeakDetector() { - int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); - flag |= _CRTDBG_LEAK_CHECK_DF; - flag |= _CRTDBG_ALLOC_MEM_DF; - _CrtSetDbgFlag(flag); - _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); - _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); - // Change this to leaking allocation's number to break there - _CrtSetBreakAlloc(-1); - } -}; -#else -class LeakDetector {}; -#endif - -LeakDetector leakDetector; - -// #included from: internal/catch_impl.hpp -#define TWOBLUECUBES_CATCH_IMPL_HPP_INCLUDED - -// Collect all the implementation files together here -// These are the equivalent of what would usually be cpp files - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wweak-vtables" -#endif - -// #included from: ../catch_session.hpp -#define TWOBLUECUBES_CATCH_RUNNER_HPP_INCLUDED - -// #included from: internal/catch_commandline.hpp -#define TWOBLUECUBES_CATCH_COMMANDLINE_HPP_INCLUDED - -// #included from: catch_config.hpp -#define TWOBLUECUBES_CATCH_CONFIG_HPP_INCLUDED - -// #included from: catch_test_spec_parser.hpp -#define TWOBLUECUBES_CATCH_TEST_SPEC_PARSER_HPP_INCLUDED - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpadded" -#endif - -// #included from: catch_test_spec.hpp -#define TWOBLUECUBES_CATCH_TEST_SPEC_HPP_INCLUDED - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wpadded" -#endif - -// #included from: catch_wildcard_pattern.hpp -#define TWOBLUECUBES_CATCH_WILDCARD_PATTERN_HPP_INCLUDED - -#include - -namespace Catch -{ - class WildcardPattern { - enum WildcardPosition { - NoWildcard = 0, - WildcardAtStart = 1, - WildcardAtEnd = 2, - WildcardAtBothEnds = WildcardAtStart | WildcardAtEnd - }; - - public: - - WildcardPattern( std::string const& pattern, CaseSensitive::Choice caseSensitivity ) - : m_caseSensitivity( caseSensitivity ), - m_wildcard( NoWildcard ), - m_pattern( adjustCase( pattern ) ) - { - if( startsWith( m_pattern, '*' ) ) { - m_pattern = m_pattern.substr( 1 ); - m_wildcard = WildcardAtStart; - } - if( endsWith( m_pattern, '*' ) ) { - m_pattern = m_pattern.substr( 0, m_pattern.size()-1 ); - m_wildcard = static_cast( m_wildcard | WildcardAtEnd ); - } - } - virtual ~WildcardPattern(); - virtual bool matches( std::string const& str ) const { - switch( m_wildcard ) { - case NoWildcard: - return m_pattern == adjustCase( str ); - case WildcardAtStart: - return endsWith( adjustCase( str ), m_pattern ); - case WildcardAtEnd: - return startsWith( adjustCase( str ), m_pattern ); - case WildcardAtBothEnds: - return contains( adjustCase( str ), m_pattern ); - } - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wunreachable-code" -#endif - throw std::logic_error( "Unknown enum" ); -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - } - private: - std::string adjustCase( std::string const& str ) const { - return m_caseSensitivity == CaseSensitive::No ? toLower( str ) : str; - } - CaseSensitive::Choice m_caseSensitivity; - WildcardPosition m_wildcard; - std::string m_pattern; - }; -} - -#include -#include - -namespace Catch { - - class TestSpec { - struct Pattern : SharedImpl<> { - virtual ~Pattern(); - virtual bool matches( TestCaseInfo const& testCase ) const = 0; - }; - class NamePattern : public Pattern { - public: - NamePattern( std::string const& name ) - : m_wildcardPattern( toLower( name ), CaseSensitive::No ) - {} - virtual ~NamePattern(); - virtual bool matches( TestCaseInfo const& testCase ) const { - return m_wildcardPattern.matches( toLower( testCase.name ) ); - } - private: - WildcardPattern m_wildcardPattern; - }; - - class TagPattern : public Pattern { - public: - TagPattern( std::string const& tag ) : m_tag( toLower( tag ) ) {} - virtual ~TagPattern(); - virtual bool matches( TestCaseInfo const& testCase ) const { - return testCase.lcaseTags.find( m_tag ) != testCase.lcaseTags.end(); - } - private: - std::string m_tag; - }; - - class ExcludedPattern : public Pattern { - public: - ExcludedPattern( Ptr const& underlyingPattern ) : m_underlyingPattern( underlyingPattern ) {} - virtual ~ExcludedPattern(); - virtual bool matches( TestCaseInfo const& testCase ) const { return !m_underlyingPattern->matches( testCase ); } - private: - Ptr m_underlyingPattern; - }; - - struct Filter { - std::vector > m_patterns; - - bool matches( TestCaseInfo const& testCase ) const { - // All patterns in a filter must match for the filter to be a match - for( std::vector >::const_iterator it = m_patterns.begin(), itEnd = m_patterns.end(); it != itEnd; ++it ) { - if( !(*it)->matches( testCase ) ) - return false; - } - return true; - } - }; - - public: - bool hasFilters() const { - return !m_filters.empty(); - } - bool matches( TestCaseInfo const& testCase ) const { - // A TestSpec matches if any filter matches - for( std::vector::const_iterator it = m_filters.begin(), itEnd = m_filters.end(); it != itEnd; ++it ) - if( it->matches( testCase ) ) - return true; - return false; - } - - private: - std::vector m_filters; - - friend class TestSpecParser; - }; -} - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -namespace Catch { - - class TestSpecParser { - enum Mode{ None, Name, QuotedName, Tag, EscapedName }; - Mode m_mode; - bool m_exclusion; - std::size_t m_start, m_pos; - std::string m_arg; - std::vector m_escapeChars; - TestSpec::Filter m_currentFilter; - TestSpec m_testSpec; - ITagAliasRegistry const* m_tagAliases; - - public: - TestSpecParser( ITagAliasRegistry const& tagAliases ) : m_tagAliases( &tagAliases ) {} - - TestSpecParser& parse( std::string const& arg ) { - m_mode = None; - m_exclusion = false; - m_start = std::string::npos; - m_arg = m_tagAliases->expandAliases( arg ); - m_escapeChars.clear(); - for( m_pos = 0; m_pos < m_arg.size(); ++m_pos ) - visitChar( m_arg[m_pos] ); - if( m_mode == Name ) - addPattern(); - return *this; - } - TestSpec testSpec() { - addFilter(); - return m_testSpec; - } - private: - void visitChar( char c ) { - if( m_mode == None ) { - switch( c ) { - case ' ': return; - case '~': m_exclusion = true; return; - case '[': return startNewMode( Tag, ++m_pos ); - case '"': return startNewMode( QuotedName, ++m_pos ); - case '\\': return escape(); - default: startNewMode( Name, m_pos ); break; - } - } - if( m_mode == Name ) { - if( c == ',' ) { - addPattern(); - addFilter(); - } - else if( c == '[' ) { - if( subString() == "exclude:" ) - m_exclusion = true; - else - addPattern(); - startNewMode( Tag, ++m_pos ); - } - else if( c == '\\' ) - escape(); - } - else if( m_mode == EscapedName ) - m_mode = Name; - else if( m_mode == QuotedName && c == '"' ) - addPattern(); - else if( m_mode == Tag && c == ']' ) - addPattern(); - } - void startNewMode( Mode mode, std::size_t start ) { - m_mode = mode; - m_start = start; - } - void escape() { - if( m_mode == None ) - m_start = m_pos; - m_mode = EscapedName; - m_escapeChars.push_back( m_pos ); - } - std::string subString() const { return m_arg.substr( m_start, m_pos - m_start ); } - template - void addPattern() { - std::string token = subString(); - for( size_t i = 0; i < m_escapeChars.size(); ++i ) - token = token.substr( 0, m_escapeChars[i]-m_start-i ) + token.substr( m_escapeChars[i]-m_start-i+1 ); - m_escapeChars.clear(); - if( startsWith( token, "exclude:" ) ) { - m_exclusion = true; - token = token.substr( 8 ); - } - if( !token.empty() ) { - Ptr pattern = new T( token ); - if( m_exclusion ) - pattern = new TestSpec::ExcludedPattern( pattern ); - m_currentFilter.m_patterns.push_back( pattern ); - } - m_exclusion = false; - m_mode = None; - } - void addFilter() { - if( !m_currentFilter.m_patterns.empty() ) { - m_testSpec.m_filters.push_back( m_currentFilter ); - m_currentFilter = TestSpec::Filter(); - } - } - }; - inline TestSpec parseTestSpec( std::string const& arg ) { - return TestSpecParser( ITagAliasRegistry::get() ).parse( arg ).testSpec(); - } - -} // namespace Catch - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -// #included from: catch_interfaces_config.h -#define TWOBLUECUBES_CATCH_INTERFACES_CONFIG_H_INCLUDED - -#include -#include -#include - -namespace Catch { - - struct Verbosity { enum Level { - NoOutput = 0, - Quiet, - Normal - }; }; - - struct WarnAbout { enum What { - Nothing = 0x00, - NoAssertions = 0x01 - }; }; - - struct ShowDurations { enum OrNot { - DefaultForReporter, - Always, - Never - }; }; - struct RunTests { enum InWhatOrder { - InDeclarationOrder, - InLexicographicalOrder, - InRandomOrder - }; }; - struct UseColour { enum YesOrNo { - Auto, - Yes, - No - }; }; - - class TestSpec; - - struct IConfig : IShared { - - virtual ~IConfig(); - - virtual bool allowThrows() const = 0; - virtual std::ostream& stream() const = 0; - virtual std::string name() const = 0; - virtual bool includeSuccessfulResults() const = 0; - virtual bool shouldDebugBreak() const = 0; - virtual bool warnAboutMissingAssertions() const = 0; - virtual int abortAfter() const = 0; - virtual bool showInvisibles() const = 0; - virtual ShowDurations::OrNot showDurations() const = 0; - virtual TestSpec const& testSpec() const = 0; - virtual RunTests::InWhatOrder runOrder() const = 0; - virtual unsigned int rngSeed() const = 0; - virtual UseColour::YesOrNo useColour() const = 0; - virtual std::vector const& getSectionsToRun() const = 0; - - }; -} - -// #included from: catch_stream.h -#define TWOBLUECUBES_CATCH_STREAM_H_INCLUDED - -// #included from: catch_streambuf.h -#define TWOBLUECUBES_CATCH_STREAMBUF_H_INCLUDED - -#include - -namespace Catch { - - class StreamBufBase : public std::streambuf { - public: - virtual ~StreamBufBase() CATCH_NOEXCEPT; - }; -} - -#include -#include -#include -#include - -namespace Catch { - - std::ostream& cout(); - std::ostream& cerr(); - - struct IStream { - virtual ~IStream() CATCH_NOEXCEPT; - virtual std::ostream& stream() const = 0; - }; - - class FileStream : public IStream { - mutable std::ofstream m_ofs; - public: - FileStream( std::string const& filename ); - virtual ~FileStream() CATCH_NOEXCEPT; - public: // IStream - virtual std::ostream& stream() const CATCH_OVERRIDE; - }; - - class CoutStream : public IStream { - mutable std::ostream m_os; - public: - CoutStream(); - virtual ~CoutStream() CATCH_NOEXCEPT; - - public: // IStream - virtual std::ostream& stream() const CATCH_OVERRIDE; - }; - - class DebugOutStream : public IStream { - CATCH_AUTO_PTR( StreamBufBase ) m_streamBuf; - mutable std::ostream m_os; - public: - DebugOutStream(); - virtual ~DebugOutStream() CATCH_NOEXCEPT; - - public: // IStream - virtual std::ostream& stream() const CATCH_OVERRIDE; - }; -} - -#include -#include -#include -#include - -#ifndef CATCH_CONFIG_CONSOLE_WIDTH -#define CATCH_CONFIG_CONSOLE_WIDTH 80 -#endif - -namespace Catch { - - struct ConfigData { - - ConfigData() - : listTests( false ), - listTags( false ), - listReporters( false ), - listTestNamesOnly( false ), - listExtraInfo( false ), - showSuccessfulTests( false ), - shouldDebugBreak( false ), - noThrow( false ), - showHelp( false ), - showInvisibles( false ), - filenamesAsTags( false ), - abortAfter( -1 ), - rngSeed( 0 ), - verbosity( Verbosity::Normal ), - warnings( WarnAbout::Nothing ), - showDurations( ShowDurations::DefaultForReporter ), - runOrder( RunTests::InDeclarationOrder ), - useColour( UseColour::Auto ) - {} - - bool listTests; - bool listTags; - bool listReporters; - bool listTestNamesOnly; - bool listExtraInfo; - - bool showSuccessfulTests; - bool shouldDebugBreak; - bool noThrow; - bool showHelp; - bool showInvisibles; - bool filenamesAsTags; - - int abortAfter; - unsigned int rngSeed; - - Verbosity::Level verbosity; - WarnAbout::What warnings; - ShowDurations::OrNot showDurations; - RunTests::InWhatOrder runOrder; - UseColour::YesOrNo useColour; - - std::string outputFilename; - std::string name; - std::string processName; - - std::vector reporterNames; - std::vector testsOrTags; - std::vector sectionsToRun; - }; - - class Config : public SharedImpl { - private: - Config( Config const& other ); - Config& operator = ( Config const& other ); - virtual void dummy(); - public: - - Config() - {} - - Config( ConfigData const& data ) - : m_data( data ), - m_stream( openStream() ) - { - if( !data.testsOrTags.empty() ) { - TestSpecParser parser( ITagAliasRegistry::get() ); - for( std::size_t i = 0; i < data.testsOrTags.size(); ++i ) - parser.parse( data.testsOrTags[i] ); - m_testSpec = parser.testSpec(); - } - } - - virtual ~Config() {} - - std::string const& getFilename() const { - return m_data.outputFilename ; - } - - bool listTests() const { return m_data.listTests; } - bool listTestNamesOnly() const { return m_data.listTestNamesOnly; } - bool listTags() const { return m_data.listTags; } - bool listReporters() const { return m_data.listReporters; } - bool listExtraInfo() const { return m_data.listExtraInfo; } - - std::string getProcessName() const { return m_data.processName; } - - std::vector const& getReporterNames() const { return m_data.reporterNames; } - std::vector const& getSectionsToRun() const CATCH_OVERRIDE { return m_data.sectionsToRun; } - - virtual TestSpec const& testSpec() const CATCH_OVERRIDE { return m_testSpec; } - - bool showHelp() const { return m_data.showHelp; } - - // IConfig interface - virtual bool allowThrows() const CATCH_OVERRIDE { return !m_data.noThrow; } - virtual std::ostream& stream() const CATCH_OVERRIDE { return m_stream->stream(); } - virtual std::string name() const CATCH_OVERRIDE { return m_data.name.empty() ? m_data.processName : m_data.name; } - virtual bool includeSuccessfulResults() const CATCH_OVERRIDE { return m_data.showSuccessfulTests; } - virtual bool warnAboutMissingAssertions() const CATCH_OVERRIDE { return m_data.warnings & WarnAbout::NoAssertions; } - virtual ShowDurations::OrNot showDurations() const CATCH_OVERRIDE { return m_data.showDurations; } - virtual RunTests::InWhatOrder runOrder() const CATCH_OVERRIDE { return m_data.runOrder; } - virtual unsigned int rngSeed() const CATCH_OVERRIDE { return m_data.rngSeed; } - virtual UseColour::YesOrNo useColour() const CATCH_OVERRIDE { return m_data.useColour; } - virtual bool shouldDebugBreak() const CATCH_OVERRIDE { return m_data.shouldDebugBreak; } - virtual int abortAfter() const CATCH_OVERRIDE { return m_data.abortAfter; } - virtual bool showInvisibles() const CATCH_OVERRIDE { return m_data.showInvisibles; } - - private: - - IStream const* openStream() { - if( m_data.outputFilename.empty() ) - return new CoutStream(); - else if( m_data.outputFilename[0] == '%' ) { - if( m_data.outputFilename == "%debug" ) - return new DebugOutStream(); - else - throw std::domain_error( "Unrecognised stream: " + m_data.outputFilename ); - } - else - return new FileStream( m_data.outputFilename ); - } - ConfigData m_data; - - CATCH_AUTO_PTR( IStream const ) m_stream; - TestSpec m_testSpec; - }; - -} // end namespace Catch - -// #included from: catch_clara.h -#define TWOBLUECUBES_CATCH_CLARA_H_INCLUDED - -// Use Catch's value for console width (store Clara's off to the side, if present) -#ifdef CLARA_CONFIG_CONSOLE_WIDTH -#define CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH CLARA_CONFIG_CONSOLE_WIDTH -#undef CLARA_CONFIG_CONSOLE_WIDTH -#endif -#define CLARA_CONFIG_CONSOLE_WIDTH CATCH_CONFIG_CONSOLE_WIDTH - -// Declare Clara inside the Catch namespace -#define STITCH_CLARA_OPEN_NAMESPACE namespace Catch { -// #included from: ../external/clara.h - -// Version 0.0.2.4 - -// Only use header guard if we are not using an outer namespace -#if !defined(TWOBLUECUBES_CLARA_H_INCLUDED) || defined(STITCH_CLARA_OPEN_NAMESPACE) - -#ifndef STITCH_CLARA_OPEN_NAMESPACE -#define TWOBLUECUBES_CLARA_H_INCLUDED -#define STITCH_CLARA_OPEN_NAMESPACE -#define STITCH_CLARA_CLOSE_NAMESPACE -#else -#define STITCH_CLARA_CLOSE_NAMESPACE } -#endif - -#define STITCH_TBC_TEXT_FORMAT_OPEN_NAMESPACE STITCH_CLARA_OPEN_NAMESPACE - -// ----------- #included from tbc_text_format.h ----------- - -// Only use header guard if we are not using an outer namespace -#if !defined(TBC_TEXT_FORMAT_H_INCLUDED) || defined(STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE) -#ifndef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE -#define TBC_TEXT_FORMAT_H_INCLUDED -#endif - -#include -#include -#include -#include -#include - -// Use optional outer namespace -#ifdef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE -namespace STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE { -#endif - -namespace Tbc { - -#ifdef TBC_TEXT_FORMAT_CONSOLE_WIDTH - const unsigned int consoleWidth = TBC_TEXT_FORMAT_CONSOLE_WIDTH; -#else - const unsigned int consoleWidth = 80; -#endif - - struct TextAttributes { - TextAttributes() - : initialIndent( std::string::npos ), - indent( 0 ), - width( consoleWidth-1 ), - tabChar( '\t' ) - {} - - TextAttributes& setInitialIndent( std::size_t _value ) { initialIndent = _value; return *this; } - TextAttributes& setIndent( std::size_t _value ) { indent = _value; return *this; } - TextAttributes& setWidth( std::size_t _value ) { width = _value; return *this; } - TextAttributes& setTabChar( char _value ) { tabChar = _value; return *this; } - - std::size_t initialIndent; // indent of first line, or npos - std::size_t indent; // indent of subsequent lines, or all if initialIndent is npos - std::size_t width; // maximum width of text, including indent. Longer text will wrap - char tabChar; // If this char is seen the indent is changed to current pos - }; - - class Text { - public: - Text( std::string const& _str, TextAttributes const& _attr = TextAttributes() ) - : attr( _attr ) - { - std::string wrappableChars = " [({.,/|\\-"; - std::size_t indent = _attr.initialIndent != std::string::npos - ? _attr.initialIndent - : _attr.indent; - std::string remainder = _str; - - while( !remainder.empty() ) { - if( lines.size() >= 1000 ) { - lines.push_back( "... message truncated due to excessive size" ); - return; - } - std::size_t tabPos = std::string::npos; - std::size_t width = (std::min)( remainder.size(), _attr.width - indent ); - std::size_t pos = remainder.find_first_of( '\n' ); - if( pos <= width ) { - width = pos; - } - pos = remainder.find_last_of( _attr.tabChar, width ); - if( pos != std::string::npos ) { - tabPos = pos; - if( remainder[width] == '\n' ) - width--; - remainder = remainder.substr( 0, tabPos ) + remainder.substr( tabPos+1 ); - } - - if( width == remainder.size() ) { - spliceLine( indent, remainder, width ); - } - else if( remainder[width] == '\n' ) { - spliceLine( indent, remainder, width ); - if( width <= 1 || remainder.size() != 1 ) - remainder = remainder.substr( 1 ); - indent = _attr.indent; - } - else { - pos = remainder.find_last_of( wrappableChars, width ); - if( pos != std::string::npos && pos > 0 ) { - spliceLine( indent, remainder, pos ); - if( remainder[0] == ' ' ) - remainder = remainder.substr( 1 ); - } - else { - spliceLine( indent, remainder, width-1 ); - lines.back() += "-"; - } - if( lines.size() == 1 ) - indent = _attr.indent; - if( tabPos != std::string::npos ) - indent += tabPos; - } - } - } - - void spliceLine( std::size_t _indent, std::string& _remainder, std::size_t _pos ) { - lines.push_back( std::string( _indent, ' ' ) + _remainder.substr( 0, _pos ) ); - _remainder = _remainder.substr( _pos ); - } - - typedef std::vector::const_iterator const_iterator; - - const_iterator begin() const { return lines.begin(); } - const_iterator end() const { return lines.end(); } - std::string const& last() const { return lines.back(); } - std::size_t size() const { return lines.size(); } - std::string const& operator[]( std::size_t _index ) const { return lines[_index]; } - std::string toString() const { - std::ostringstream oss; - oss << *this; - return oss.str(); - } - - inline friend std::ostream& operator << ( std::ostream& _stream, Text const& _text ) { - for( Text::const_iterator it = _text.begin(), itEnd = _text.end(); - it != itEnd; ++it ) { - if( it != _text.begin() ) - _stream << "\n"; - _stream << *it; - } - return _stream; - } - - private: - std::string str; - TextAttributes attr; - std::vector lines; - }; - -} // end namespace Tbc - -#ifdef STITCH_TBC_TEXT_FORMAT_OUTER_NAMESPACE -} // end outer namespace -#endif - -#endif // TBC_TEXT_FORMAT_H_INCLUDED - -// ----------- end of #include from tbc_text_format.h ----------- -// ........... back in clara.h - -#undef STITCH_TBC_TEXT_FORMAT_OPEN_NAMESPACE - -// ----------- #included from clara_compilers.h ----------- - -#ifndef TWOBLUECUBES_CLARA_COMPILERS_H_INCLUDED -#define TWOBLUECUBES_CLARA_COMPILERS_H_INCLUDED - -// Detect a number of compiler features - mostly C++11/14 conformance - by compiler -// The following features are defined: -// -// CLARA_CONFIG_CPP11_NULLPTR : is nullptr supported? -// CLARA_CONFIG_CPP11_NOEXCEPT : is noexcept supported? -// CLARA_CONFIG_CPP11_GENERATED_METHODS : The delete and default keywords for compiler generated methods -// CLARA_CONFIG_CPP11_OVERRIDE : is override supported? -// CLARA_CONFIG_CPP11_UNIQUE_PTR : is unique_ptr supported (otherwise use auto_ptr) - -// CLARA_CONFIG_CPP11_OR_GREATER : Is C++11 supported? - -// CLARA_CONFIG_VARIADIC_MACROS : are variadic macros supported? - -// In general each macro has a _NO_ form -// (e.g. CLARA_CONFIG_CPP11_NO_NULLPTR) which disables the feature. -// Many features, at point of detection, define an _INTERNAL_ macro, so they -// can be combined, en-mass, with the _NO_ forms later. - -// All the C++11 features can be disabled with CLARA_CONFIG_NO_CPP11 - -#ifdef __clang__ - -#if __has_feature(cxx_nullptr) -#define CLARA_INTERNAL_CONFIG_CPP11_NULLPTR -#endif - -#if __has_feature(cxx_noexcept) -#define CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT -#endif - -#endif // __clang__ - -//////////////////////////////////////////////////////////////////////////////// -// GCC -#ifdef __GNUC__ - -#if __GNUC__ == 4 && __GNUC_MINOR__ >= 6 && defined(__GXX_EXPERIMENTAL_CXX0X__) -#define CLARA_INTERNAL_CONFIG_CPP11_NULLPTR -#endif - -// - otherwise more recent versions define __cplusplus >= 201103L -// and will get picked up below - -#endif // __GNUC__ - -//////////////////////////////////////////////////////////////////////////////// -// Visual C++ -#ifdef _MSC_VER - -#if (_MSC_VER >= 1600) -#define CLARA_INTERNAL_CONFIG_CPP11_NULLPTR -#define CLARA_INTERNAL_CONFIG_CPP11_UNIQUE_PTR -#endif - -#if (_MSC_VER >= 1900 ) // (VC++ 13 (VS2015)) -#define CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT -#define CLARA_INTERNAL_CONFIG_CPP11_GENERATED_METHODS -#endif - -#endif // _MSC_VER - -//////////////////////////////////////////////////////////////////////////////// -// C++ language feature support - -// catch all support for C++11 -#if defined(__cplusplus) && __cplusplus >= 201103L - -#define CLARA_CPP11_OR_GREATER - -#if !defined(CLARA_INTERNAL_CONFIG_CPP11_NULLPTR) -#define CLARA_INTERNAL_CONFIG_CPP11_NULLPTR -#endif - -#ifndef CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT -#define CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT -#endif - -#ifndef CLARA_INTERNAL_CONFIG_CPP11_GENERATED_METHODS -#define CLARA_INTERNAL_CONFIG_CPP11_GENERATED_METHODS -#endif - -#if !defined(CLARA_INTERNAL_CONFIG_CPP11_OVERRIDE) -#define CLARA_INTERNAL_CONFIG_CPP11_OVERRIDE -#endif -#if !defined(CLARA_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) -#define CLARA_INTERNAL_CONFIG_CPP11_UNIQUE_PTR -#endif - -#endif // __cplusplus >= 201103L - -// Now set the actual defines based on the above + anything the user has configured -#if defined(CLARA_INTERNAL_CONFIG_CPP11_NULLPTR) && !defined(CLARA_CONFIG_CPP11_NO_NULLPTR) && !defined(CLARA_CONFIG_CPP11_NULLPTR) && !defined(CLARA_CONFIG_NO_CPP11) -#define CLARA_CONFIG_CPP11_NULLPTR -#endif -#if defined(CLARA_INTERNAL_CONFIG_CPP11_NOEXCEPT) && !defined(CLARA_CONFIG_CPP11_NO_NOEXCEPT) && !defined(CLARA_CONFIG_CPP11_NOEXCEPT) && !defined(CLARA_CONFIG_NO_CPP11) -#define CLARA_CONFIG_CPP11_NOEXCEPT -#endif -#if defined(CLARA_INTERNAL_CONFIG_CPP11_GENERATED_METHODS) && !defined(CLARA_CONFIG_CPP11_NO_GENERATED_METHODS) && !defined(CLARA_CONFIG_CPP11_GENERATED_METHODS) && !defined(CLARA_CONFIG_NO_CPP11) -#define CLARA_CONFIG_CPP11_GENERATED_METHODS -#endif -#if defined(CLARA_INTERNAL_CONFIG_CPP11_OVERRIDE) && !defined(CLARA_CONFIG_NO_OVERRIDE) && !defined(CLARA_CONFIG_CPP11_OVERRIDE) && !defined(CLARA_CONFIG_NO_CPP11) -#define CLARA_CONFIG_CPP11_OVERRIDE -#endif -#if defined(CLARA_INTERNAL_CONFIG_CPP11_UNIQUE_PTR) && !defined(CLARA_CONFIG_NO_UNIQUE_PTR) && !defined(CLARA_CONFIG_CPP11_UNIQUE_PTR) && !defined(CLARA_CONFIG_NO_CPP11) -#define CLARA_CONFIG_CPP11_UNIQUE_PTR -#endif - -// noexcept support: -#if defined(CLARA_CONFIG_CPP11_NOEXCEPT) && !defined(CLARA_NOEXCEPT) -#define CLARA_NOEXCEPT noexcept -# define CLARA_NOEXCEPT_IS(x) noexcept(x) -#else -#define CLARA_NOEXCEPT throw() -# define CLARA_NOEXCEPT_IS(x) -#endif - -// nullptr support -#ifdef CLARA_CONFIG_CPP11_NULLPTR -#define CLARA_NULL nullptr -#else -#define CLARA_NULL NULL -#endif - -// override support -#ifdef CLARA_CONFIG_CPP11_OVERRIDE -#define CLARA_OVERRIDE override -#else -#define CLARA_OVERRIDE -#endif - -// unique_ptr support -#ifdef CLARA_CONFIG_CPP11_UNIQUE_PTR -# define CLARA_AUTO_PTR( T ) std::unique_ptr -#else -# define CLARA_AUTO_PTR( T ) std::auto_ptr -#endif - -#endif // TWOBLUECUBES_CLARA_COMPILERS_H_INCLUDED - -// ----------- end of #include from clara_compilers.h ----------- -// ........... back in clara.h - -#include -#include -#include - -#if defined(WIN32) || defined(__WIN32__) || defined(_WIN32) || defined(_MSC_VER) -#define CLARA_PLATFORM_WINDOWS -#endif - -// Use optional outer namespace -#ifdef STITCH_CLARA_OPEN_NAMESPACE -STITCH_CLARA_OPEN_NAMESPACE -#endif - -namespace Clara { - - struct UnpositionalTag {}; - - extern UnpositionalTag _; - -#ifdef CLARA_CONFIG_MAIN - UnpositionalTag _; -#endif - - namespace Detail { - -#ifdef CLARA_CONSOLE_WIDTH - const unsigned int consoleWidth = CLARA_CONFIG_CONSOLE_WIDTH; -#else - const unsigned int consoleWidth = 80; -#endif - - using namespace Tbc; - - inline bool startsWith( std::string const& str, std::string const& prefix ) { - return str.size() >= prefix.size() && str.substr( 0, prefix.size() ) == prefix; - } - - template struct RemoveConstRef{ typedef T type; }; - template struct RemoveConstRef{ typedef T type; }; - template struct RemoveConstRef{ typedef T type; }; - template struct RemoveConstRef{ typedef T type; }; - - template struct IsBool { static const bool value = false; }; - template<> struct IsBool { static const bool value = true; }; - - template - void convertInto( std::string const& _source, T& _dest ) { - std::stringstream ss; - ss << _source; - ss >> _dest; - if( ss.fail() ) - throw std::runtime_error( "Unable to convert " + _source + " to destination type" ); - } - inline void convertInto( std::string const& _source, std::string& _dest ) { - _dest = _source; - } - char toLowerCh(char c) { - return static_cast( std::tolower( c ) ); - } - inline void convertInto( std::string const& _source, bool& _dest ) { - std::string sourceLC = _source; - std::transform( sourceLC.begin(), sourceLC.end(), sourceLC.begin(), toLowerCh ); - if( sourceLC == "y" || sourceLC == "1" || sourceLC == "true" || sourceLC == "yes" || sourceLC == "on" ) - _dest = true; - else if( sourceLC == "n" || sourceLC == "0" || sourceLC == "false" || sourceLC == "no" || sourceLC == "off" ) - _dest = false; - else - throw std::runtime_error( "Expected a boolean value but did not recognise:\n '" + _source + "'" ); - } - - template - struct IArgFunction { - virtual ~IArgFunction() {} -#ifdef CLARA_CONFIG_CPP11_GENERATED_METHODS - IArgFunction() = default; - IArgFunction( IArgFunction const& ) = default; -#endif - virtual void set( ConfigT& config, std::string const& value ) const = 0; - virtual bool takesArg() const = 0; - virtual IArgFunction* clone() const = 0; - }; - - template - class BoundArgFunction { - public: - BoundArgFunction() : functionObj( CLARA_NULL ) {} - BoundArgFunction( IArgFunction* _functionObj ) : functionObj( _functionObj ) {} - BoundArgFunction( BoundArgFunction const& other ) : functionObj( other.functionObj ? other.functionObj->clone() : CLARA_NULL ) {} - BoundArgFunction& operator = ( BoundArgFunction const& other ) { - IArgFunction* newFunctionObj = other.functionObj ? other.functionObj->clone() : CLARA_NULL; - delete functionObj; - functionObj = newFunctionObj; - return *this; - } - ~BoundArgFunction() { delete functionObj; } - - void set( ConfigT& config, std::string const& value ) const { - functionObj->set( config, value ); - } - bool takesArg() const { return functionObj->takesArg(); } - - bool isSet() const { - return functionObj != CLARA_NULL; - } - private: - IArgFunction* functionObj; - }; - - template - struct NullBinder : IArgFunction{ - virtual void set( C&, std::string const& ) const {} - virtual bool takesArg() const { return true; } - virtual IArgFunction* clone() const { return new NullBinder( *this ); } - }; - - template - struct BoundDataMember : IArgFunction{ - BoundDataMember( M C::* _member ) : member( _member ) {} - virtual void set( C& p, std::string const& stringValue ) const { - convertInto( stringValue, p.*member ); - } - virtual bool takesArg() const { return !IsBool::value; } - virtual IArgFunction* clone() const { return new BoundDataMember( *this ); } - M C::* member; - }; - template - struct BoundUnaryMethod : IArgFunction{ - BoundUnaryMethod( void (C::*_member)( M ) ) : member( _member ) {} - virtual void set( C& p, std::string const& stringValue ) const { - typename RemoveConstRef::type value; - convertInto( stringValue, value ); - (p.*member)( value ); - } - virtual bool takesArg() const { return !IsBool::value; } - virtual IArgFunction* clone() const { return new BoundUnaryMethod( *this ); } - void (C::*member)( M ); - }; - template - struct BoundNullaryMethod : IArgFunction{ - BoundNullaryMethod( void (C::*_member)() ) : member( _member ) {} - virtual void set( C& p, std::string const& stringValue ) const { - bool value; - convertInto( stringValue, value ); - if( value ) - (p.*member)(); - } - virtual bool takesArg() const { return false; } - virtual IArgFunction* clone() const { return new BoundNullaryMethod( *this ); } - void (C::*member)(); - }; - - template - struct BoundUnaryFunction : IArgFunction{ - BoundUnaryFunction( void (*_function)( C& ) ) : function( _function ) {} - virtual void set( C& obj, std::string const& stringValue ) const { - bool value; - convertInto( stringValue, value ); - if( value ) - function( obj ); - } - virtual bool takesArg() const { return false; } - virtual IArgFunction* clone() const { return new BoundUnaryFunction( *this ); } - void (*function)( C& ); - }; - - template - struct BoundBinaryFunction : IArgFunction{ - BoundBinaryFunction( void (*_function)( C&, T ) ) : function( _function ) {} - virtual void set( C& obj, std::string const& stringValue ) const { - typename RemoveConstRef::type value; - convertInto( stringValue, value ); - function( obj, value ); - } - virtual bool takesArg() const { return !IsBool::value; } - virtual IArgFunction* clone() const { return new BoundBinaryFunction( *this ); } - void (*function)( C&, T ); - }; - - } // namespace Detail - - inline std::vector argsToVector( int argc, char const* const* const argv ) { - std::vector args( static_cast( argc ) ); - for( std::size_t i = 0; i < static_cast( argc ); ++i ) - args[i] = argv[i]; - - return args; - } - - class Parser { - enum Mode { None, MaybeShortOpt, SlashOpt, ShortOpt, LongOpt, Positional }; - Mode mode; - std::size_t from; - bool inQuotes; - public: - - struct Token { - enum Type { Positional, ShortOpt, LongOpt }; - Token( Type _type, std::string const& _data ) : type( _type ), data( _data ) {} - Type type; - std::string data; - }; - - Parser() : mode( None ), from( 0 ), inQuotes( false ){} - - void parseIntoTokens( std::vector const& args, std::vector& tokens ) { - const std::string doubleDash = "--"; - for( std::size_t i = 1; i < args.size() && args[i] != doubleDash; ++i ) - parseIntoTokens( args[i], tokens); - } - - void parseIntoTokens( std::string const& arg, std::vector& tokens ) { - for( std::size_t i = 0; i < arg.size(); ++i ) { - char c = arg[i]; - if( c == '"' ) - inQuotes = !inQuotes; - mode = handleMode( i, c, arg, tokens ); - } - mode = handleMode( arg.size(), '\0', arg, tokens ); - } - Mode handleMode( std::size_t i, char c, std::string const& arg, std::vector& tokens ) { - switch( mode ) { - case None: return handleNone( i, c ); - case MaybeShortOpt: return handleMaybeShortOpt( i, c ); - case ShortOpt: - case LongOpt: - case SlashOpt: return handleOpt( i, c, arg, tokens ); - case Positional: return handlePositional( i, c, arg, tokens ); - default: throw std::logic_error( "Unknown mode" ); - } - } - - Mode handleNone( std::size_t i, char c ) { - if( inQuotes ) { - from = i; - return Positional; - } - switch( c ) { - case '-': return MaybeShortOpt; -#ifdef CLARA_PLATFORM_WINDOWS - case '/': from = i+1; return SlashOpt; -#endif - default: from = i; return Positional; - } - } - Mode handleMaybeShortOpt( std::size_t i, char c ) { - switch( c ) { - case '-': from = i+1; return LongOpt; - default: from = i; return ShortOpt; - } - } - - Mode handleOpt( std::size_t i, char c, std::string const& arg, std::vector& tokens ) { - if( std::string( ":=\0", 3 ).find( c ) == std::string::npos ) - return mode; - - std::string optName = arg.substr( from, i-from ); - if( mode == ShortOpt ) - for( std::size_t j = 0; j < optName.size(); ++j ) - tokens.push_back( Token( Token::ShortOpt, optName.substr( j, 1 ) ) ); - else if( mode == SlashOpt && optName.size() == 1 ) - tokens.push_back( Token( Token::ShortOpt, optName ) ); - else - tokens.push_back( Token( Token::LongOpt, optName ) ); - return None; - } - Mode handlePositional( std::size_t i, char c, std::string const& arg, std::vector& tokens ) { - if( inQuotes || std::string( "\0", 1 ).find( c ) == std::string::npos ) - return mode; - - std::string data = arg.substr( from, i-from ); - tokens.push_back( Token( Token::Positional, data ) ); - return None; - } - }; - - template - struct CommonArgProperties { - CommonArgProperties() {} - CommonArgProperties( Detail::BoundArgFunction const& _boundField ) : boundField( _boundField ) {} - - Detail::BoundArgFunction boundField; - std::string description; - std::string detail; - std::string placeholder; // Only value if boundField takes an arg - - bool takesArg() const { - return !placeholder.empty(); - } - void validate() const { - if( !boundField.isSet() ) - throw std::logic_error( "option not bound" ); - } - }; - struct OptionArgProperties { - std::vector shortNames; - std::string longName; - - bool hasShortName( std::string const& shortName ) const { - return std::find( shortNames.begin(), shortNames.end(), shortName ) != shortNames.end(); - } - bool hasLongName( std::string const& _longName ) const { - return _longName == longName; - } - }; - struct PositionalArgProperties { - PositionalArgProperties() : position( -1 ) {} - int position; // -1 means non-positional (floating) - - bool isFixedPositional() const { - return position != -1; - } - }; - - template - class CommandLine { - - struct Arg : CommonArgProperties, OptionArgProperties, PositionalArgProperties { - Arg() {} - Arg( Detail::BoundArgFunction const& _boundField ) : CommonArgProperties( _boundField ) {} - - using CommonArgProperties::placeholder; // !TBD - - std::string dbgName() const { - if( !longName.empty() ) - return "--" + longName; - if( !shortNames.empty() ) - return "-" + shortNames[0]; - return "positional args"; - } - std::string commands() const { - std::ostringstream oss; - bool first = true; - std::vector::const_iterator it = shortNames.begin(), itEnd = shortNames.end(); - for(; it != itEnd; ++it ) { - if( first ) - first = false; - else - oss << ", "; - oss << "-" << *it; - } - if( !longName.empty() ) { - if( !first ) - oss << ", "; - oss << "--" << longName; - } - if( !placeholder.empty() ) - oss << " <" << placeholder << ">"; - return oss.str(); - } - }; - - typedef CLARA_AUTO_PTR( Arg ) ArgAutoPtr; - - friend void addOptName( Arg& arg, std::string const& optName ) - { - if( optName.empty() ) - return; - if( Detail::startsWith( optName, "--" ) ) { - if( !arg.longName.empty() ) - throw std::logic_error( "Only one long opt may be specified. '" - + arg.longName - + "' already specified, now attempting to add '" - + optName + "'" ); - arg.longName = optName.substr( 2 ); - } - else if( Detail::startsWith( optName, "-" ) ) - arg.shortNames.push_back( optName.substr( 1 ) ); - else - throw std::logic_error( "option must begin with - or --. Option was: '" + optName + "'" ); - } - friend void setPositionalArg( Arg& arg, int position ) - { - arg.position = position; - } - - class ArgBuilder { - public: - ArgBuilder( Arg* arg ) : m_arg( arg ) {} - - // Bind a non-boolean data member (requires placeholder string) - template - void bind( M C::* field, std::string const& placeholder ) { - m_arg->boundField = new Detail::BoundDataMember( field ); - m_arg->placeholder = placeholder; - } - // Bind a boolean data member (no placeholder required) - template - void bind( bool C::* field ) { - m_arg->boundField = new Detail::BoundDataMember( field ); - } - - // Bind a method taking a single, non-boolean argument (requires a placeholder string) - template - void bind( void (C::* unaryMethod)( M ), std::string const& placeholder ) { - m_arg->boundField = new Detail::BoundUnaryMethod( unaryMethod ); - m_arg->placeholder = placeholder; - } - - // Bind a method taking a single, boolean argument (no placeholder string required) - template - void bind( void (C::* unaryMethod)( bool ) ) { - m_arg->boundField = new Detail::BoundUnaryMethod( unaryMethod ); - } - - // Bind a method that takes no arguments (will be called if opt is present) - template - void bind( void (C::* nullaryMethod)() ) { - m_arg->boundField = new Detail::BoundNullaryMethod( nullaryMethod ); - } - - // Bind a free function taking a single argument - the object to operate on (no placeholder string required) - template - void bind( void (* unaryFunction)( C& ) ) { - m_arg->boundField = new Detail::BoundUnaryFunction( unaryFunction ); - } - - // Bind a free function taking a single argument - the object to operate on (requires a placeholder string) - template - void bind( void (* binaryFunction)( C&, T ), std::string const& placeholder ) { - m_arg->boundField = new Detail::BoundBinaryFunction( binaryFunction ); - m_arg->placeholder = placeholder; - } - - ArgBuilder& describe( std::string const& description ) { - m_arg->description = description; - return *this; - } - ArgBuilder& detail( std::string const& detail ) { - m_arg->detail = detail; - return *this; - } - - protected: - Arg* m_arg; - }; - - class OptBuilder : public ArgBuilder { - public: - OptBuilder( Arg* arg ) : ArgBuilder( arg ) {} - OptBuilder( OptBuilder& other ) : ArgBuilder( other ) {} - - OptBuilder& operator[]( std::string const& optName ) { - addOptName( *ArgBuilder::m_arg, optName ); - return *this; - } - }; - - public: - - CommandLine() - : m_boundProcessName( new Detail::NullBinder() ), - m_highestSpecifiedArgPosition( 0 ), - m_throwOnUnrecognisedTokens( false ) - {} - CommandLine( CommandLine const& other ) - : m_boundProcessName( other.m_boundProcessName ), - m_options ( other.m_options ), - m_positionalArgs( other.m_positionalArgs ), - m_highestSpecifiedArgPosition( other.m_highestSpecifiedArgPosition ), - m_throwOnUnrecognisedTokens( other.m_throwOnUnrecognisedTokens ) - { - if( other.m_floatingArg.get() ) - m_floatingArg.reset( new Arg( *other.m_floatingArg ) ); - } - - CommandLine& setThrowOnUnrecognisedTokens( bool shouldThrow = true ) { - m_throwOnUnrecognisedTokens = shouldThrow; - return *this; - } - - OptBuilder operator[]( std::string const& optName ) { - m_options.push_back( Arg() ); - addOptName( m_options.back(), optName ); - OptBuilder builder( &m_options.back() ); - return builder; - } - - ArgBuilder operator[]( int position ) { - m_positionalArgs.insert( std::make_pair( position, Arg() ) ); - if( position > m_highestSpecifiedArgPosition ) - m_highestSpecifiedArgPosition = position; - setPositionalArg( m_positionalArgs[position], position ); - ArgBuilder builder( &m_positionalArgs[position] ); - return builder; - } - - // Invoke this with the _ instance - ArgBuilder operator[]( UnpositionalTag ) { - if( m_floatingArg.get() ) - throw std::logic_error( "Only one unpositional argument can be added" ); - m_floatingArg.reset( new Arg() ); - ArgBuilder builder( m_floatingArg.get() ); - return builder; - } - - template - void bindProcessName( M C::* field ) { - m_boundProcessName = new Detail::BoundDataMember( field ); - } - template - void bindProcessName( void (C::*_unaryMethod)( M ) ) { - m_boundProcessName = new Detail::BoundUnaryMethod( _unaryMethod ); - } - - void optUsage( std::ostream& os, std::size_t indent = 0, std::size_t width = Detail::consoleWidth ) const { - typename std::vector::const_iterator itBegin = m_options.begin(), itEnd = m_options.end(), it; - std::size_t maxWidth = 0; - for( it = itBegin; it != itEnd; ++it ) - maxWidth = (std::max)( maxWidth, it->commands().size() ); - - for( it = itBegin; it != itEnd; ++it ) { - Detail::Text usage( it->commands(), Detail::TextAttributes() - .setWidth( maxWidth+indent ) - .setIndent( indent ) ); - Detail::Text desc( it->description, Detail::TextAttributes() - .setWidth( width - maxWidth - 3 ) ); - - for( std::size_t i = 0; i < (std::max)( usage.size(), desc.size() ); ++i ) { - std::string usageCol = i < usage.size() ? usage[i] : ""; - os << usageCol; - - if( i < desc.size() && !desc[i].empty() ) - os << std::string( indent + 2 + maxWidth - usageCol.size(), ' ' ) - << desc[i]; - os << "\n"; - } - } - } - std::string optUsage() const { - std::ostringstream oss; - optUsage( oss ); - return oss.str(); - } - - void argSynopsis( std::ostream& os ) const { - for( int i = 1; i <= m_highestSpecifiedArgPosition; ++i ) { - if( i > 1 ) - os << " "; - typename std::map::const_iterator it = m_positionalArgs.find( i ); - if( it != m_positionalArgs.end() ) - os << "<" << it->second.placeholder << ">"; - else if( m_floatingArg.get() ) - os << "<" << m_floatingArg->placeholder << ">"; - else - throw std::logic_error( "non consecutive positional arguments with no floating args" ); - } - // !TBD No indication of mandatory args - if( m_floatingArg.get() ) { - if( m_highestSpecifiedArgPosition > 1 ) - os << " "; - os << "[<" << m_floatingArg->placeholder << "> ...]"; - } - } - std::string argSynopsis() const { - std::ostringstream oss; - argSynopsis( oss ); - return oss.str(); - } - - void usage( std::ostream& os, std::string const& procName ) const { - validate(); - os << "usage:\n " << procName << " "; - argSynopsis( os ); - if( !m_options.empty() ) { - os << " [options]\n\nwhere options are: \n"; - optUsage( os, 2 ); - } - os << "\n"; - } - std::string usage( std::string const& procName ) const { - std::ostringstream oss; - usage( oss, procName ); - return oss.str(); - } - - ConfigT parse( std::vector const& args ) const { - ConfigT config; - parseInto( args, config ); - return config; - } - - std::vector parseInto( std::vector const& args, ConfigT& config ) const { - std::string processName = args.empty() ? std::string() : args[0]; - std::size_t lastSlash = processName.find_last_of( "/\\" ); - if( lastSlash != std::string::npos ) - processName = processName.substr( lastSlash+1 ); - m_boundProcessName.set( config, processName ); - std::vector tokens; - Parser parser; - parser.parseIntoTokens( args, tokens ); - return populate( tokens, config ); - } - - std::vector populate( std::vector const& tokens, ConfigT& config ) const { - validate(); - std::vector unusedTokens = populateOptions( tokens, config ); - unusedTokens = populateFixedArgs( unusedTokens, config ); - unusedTokens = populateFloatingArgs( unusedTokens, config ); - return unusedTokens; - } - - std::vector populateOptions( std::vector const& tokens, ConfigT& config ) const { - std::vector unusedTokens; - std::vector errors; - for( std::size_t i = 0; i < tokens.size(); ++i ) { - Parser::Token const& token = tokens[i]; - typename std::vector::const_iterator it = m_options.begin(), itEnd = m_options.end(); - for(; it != itEnd; ++it ) { - Arg const& arg = *it; - - try { - if( ( token.type == Parser::Token::ShortOpt && arg.hasShortName( token.data ) ) || - ( token.type == Parser::Token::LongOpt && arg.hasLongName( token.data ) ) ) { - if( arg.takesArg() ) { - if( i == tokens.size()-1 || tokens[i+1].type != Parser::Token::Positional ) - errors.push_back( "Expected argument to option: " + token.data ); - else - arg.boundField.set( config, tokens[++i].data ); - } - else { - arg.boundField.set( config, "true" ); - } - break; - } - } - catch( std::exception& ex ) { - errors.push_back( std::string( ex.what() ) + "\n- while parsing: (" + arg.commands() + ")" ); - } - } - if( it == itEnd ) { - if( token.type == Parser::Token::Positional || !m_throwOnUnrecognisedTokens ) - unusedTokens.push_back( token ); - else if( errors.empty() && m_throwOnUnrecognisedTokens ) - errors.push_back( "unrecognised option: " + token.data ); - } - } - if( !errors.empty() ) { - std::ostringstream oss; - for( std::vector::const_iterator it = errors.begin(), itEnd = errors.end(); - it != itEnd; - ++it ) { - if( it != errors.begin() ) - oss << "\n"; - oss << *it; - } - throw std::runtime_error( oss.str() ); - } - return unusedTokens; - } - std::vector populateFixedArgs( std::vector const& tokens, ConfigT& config ) const { - std::vector unusedTokens; - int position = 1; - for( std::size_t i = 0; i < tokens.size(); ++i ) { - Parser::Token const& token = tokens[i]; - typename std::map::const_iterator it = m_positionalArgs.find( position ); - if( it != m_positionalArgs.end() ) - it->second.boundField.set( config, token.data ); - else - unusedTokens.push_back( token ); - if( token.type == Parser::Token::Positional ) - position++; - } - return unusedTokens; - } - std::vector populateFloatingArgs( std::vector const& tokens, ConfigT& config ) const { - if( !m_floatingArg.get() ) - return tokens; - std::vector unusedTokens; - for( std::size_t i = 0; i < tokens.size(); ++i ) { - Parser::Token const& token = tokens[i]; - if( token.type == Parser::Token::Positional ) - m_floatingArg->boundField.set( config, token.data ); - else - unusedTokens.push_back( token ); - } - return unusedTokens; - } - - void validate() const - { - if( m_options.empty() && m_positionalArgs.empty() && !m_floatingArg.get() ) - throw std::logic_error( "No options or arguments specified" ); - - for( typename std::vector::const_iterator it = m_options.begin(), - itEnd = m_options.end(); - it != itEnd; ++it ) - it->validate(); - } - - private: - Detail::BoundArgFunction m_boundProcessName; - std::vector m_options; - std::map m_positionalArgs; - ArgAutoPtr m_floatingArg; - int m_highestSpecifiedArgPosition; - bool m_throwOnUnrecognisedTokens; - }; - -} // end namespace Clara - -STITCH_CLARA_CLOSE_NAMESPACE -#undef STITCH_CLARA_OPEN_NAMESPACE -#undef STITCH_CLARA_CLOSE_NAMESPACE - -#endif // TWOBLUECUBES_CLARA_H_INCLUDED -#undef STITCH_CLARA_OPEN_NAMESPACE - -// Restore Clara's value for console width, if present -#ifdef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH -#define CLARA_CONFIG_CONSOLE_WIDTH CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH -#undef CATCH_TEMP_CLARA_CONFIG_CONSOLE_WIDTH -#endif - -#include -#include - -namespace Catch { - - inline void abortAfterFirst( ConfigData& config ) { config.abortAfter = 1; } - inline void abortAfterX( ConfigData& config, int x ) { - if( x < 1 ) - throw std::runtime_error( "Value after -x or --abortAfter must be greater than zero" ); - config.abortAfter = x; - } - inline void addTestOrTags( ConfigData& config, std::string const& _testSpec ) { config.testsOrTags.push_back( _testSpec ); } - inline void addSectionToRun( ConfigData& config, std::string const& sectionName ) { config.sectionsToRun.push_back( sectionName ); } - inline void addReporterName( ConfigData& config, std::string const& _reporterName ) { config.reporterNames.push_back( _reporterName ); } - - inline void addWarning( ConfigData& config, std::string const& _warning ) { - if( _warning == "NoAssertions" ) - config.warnings = static_cast( config.warnings | WarnAbout::NoAssertions ); - else - throw std::runtime_error( "Unrecognised warning: '" + _warning + '\'' ); - } - inline void setOrder( ConfigData& config, std::string const& order ) { - if( startsWith( "declared", order ) ) - config.runOrder = RunTests::InDeclarationOrder; - else if( startsWith( "lexical", order ) ) - config.runOrder = RunTests::InLexicographicalOrder; - else if( startsWith( "random", order ) ) - config.runOrder = RunTests::InRandomOrder; - else - throw std::runtime_error( "Unrecognised ordering: '" + order + '\'' ); - } - inline void setRngSeed( ConfigData& config, std::string const& seed ) { - if( seed == "time" ) { - config.rngSeed = static_cast( std::time(0) ); - } - else { - std::stringstream ss; - ss << seed; - ss >> config.rngSeed; - if( ss.fail() ) - throw std::runtime_error( "Argument to --rng-seed should be the word 'time' or a number" ); - } - } - inline void setVerbosity( ConfigData& config, int level ) { - // !TBD: accept strings? - config.verbosity = static_cast( level ); - } - inline void setShowDurations( ConfigData& config, bool _showDurations ) { - config.showDurations = _showDurations - ? ShowDurations::Always - : ShowDurations::Never; - } - inline void setUseColour( ConfigData& config, std::string const& value ) { - std::string mode = toLower( value ); - - if( mode == "yes" ) - config.useColour = UseColour::Yes; - else if( mode == "no" ) - config.useColour = UseColour::No; - else if( mode == "auto" ) - config.useColour = UseColour::Auto; - else - throw std::runtime_error( "colour mode must be one of: auto, yes or no" ); - } - inline void forceColour( ConfigData& config ) { - config.useColour = UseColour::Yes; - } - inline void loadTestNamesFromFile( ConfigData& config, std::string const& _filename ) { - std::ifstream f( _filename.c_str() ); - if( !f.is_open() ) - throw std::domain_error( "Unable to load input file: " + _filename ); - - std::string line; - while( std::getline( f, line ) ) { - line = trim(line); - if( !line.empty() && !startsWith( line, '#' ) ) { - if( !startsWith( line, '"' ) ) - line = '"' + line + '"'; - addTestOrTags( config, line + ',' ); - } - } - } - - inline Clara::CommandLine makeCommandLineParser() { - - using namespace Clara; - CommandLine cli; - - cli.bindProcessName( &ConfigData::processName ); - - cli["-?"]["-h"]["--help"] - .describe( "display usage information" ) - .bind( &ConfigData::showHelp ); - - cli["-l"]["--list-tests"] - .describe( "list all/matching test cases" ) - .bind( &ConfigData::listTests ); - - cli["-t"]["--list-tags"] - .describe( "list all/matching tags" ) - .bind( &ConfigData::listTags ); - - cli["-s"]["--success"] - .describe( "include successful tests in output" ) - .bind( &ConfigData::showSuccessfulTests ); - - cli["-b"]["--break"] - .describe( "break into debugger on failure" ) - .bind( &ConfigData::shouldDebugBreak ); - - cli["-e"]["--nothrow"] - .describe( "skip exception tests" ) - .bind( &ConfigData::noThrow ); - - cli["-i"]["--invisibles"] - .describe( "show invisibles (tabs, newlines)" ) - .bind( &ConfigData::showInvisibles ); - - cli["-o"]["--out"] - .describe( "output filename" ) - .bind( &ConfigData::outputFilename, "filename" ); - - cli["-r"]["--reporter"] -// .placeholder( "name[:filename]" ) - .describe( "reporter to use (defaults to console)" ) - .bind( &addReporterName, "name" ); - - cli["-n"]["--name"] - .describe( "suite name" ) - .bind( &ConfigData::name, "name" ); - - cli["-a"]["--abort"] - .describe( "abort at first failure" ) - .bind( &abortAfterFirst ); - - cli["-x"]["--abortx"] - .describe( "abort after x failures" ) - .bind( &abortAfterX, "no. failures" ); - - cli["-w"]["--warn"] - .describe( "enable warnings" ) - .bind( &addWarning, "warning name" ); - -// - needs updating if reinstated -// cli.into( &setVerbosity ) -// .describe( "level of verbosity (0=no output)" ) -// .shortOpt( "v") -// .longOpt( "verbosity" ) -// .placeholder( "level" ); - - cli[_] - .describe( "which test or tests to use" ) - .bind( &addTestOrTags, "test name, pattern or tags" ); - - cli["-d"]["--durations"] - .describe( "show test durations" ) - .bind( &setShowDurations, "yes|no" ); - - cli["-f"]["--input-file"] - .describe( "load test names to run from a file" ) - .bind( &loadTestNamesFromFile, "filename" ); - - cli["-#"]["--filenames-as-tags"] - .describe( "adds a tag for the filename" ) - .bind( &ConfigData::filenamesAsTags ); - - cli["-c"]["--section"] - .describe( "specify section to run" ) - .bind( &addSectionToRun, "section name" ); - - // Less common commands which don't have a short form - cli["--list-test-names-only"] - .describe( "list all/matching test cases names only" ) - .bind( &ConfigData::listTestNamesOnly ); - - cli["--list-extra-info"] - .describe( "list all/matching test cases with more info" ) - .bind( &ConfigData::listExtraInfo ); - - cli["--list-reporters"] - .describe( "list all reporters" ) - .bind( &ConfigData::listReporters ); - - cli["--order"] - .describe( "test case order (defaults to decl)" ) - .bind( &setOrder, "decl|lex|rand" ); - - cli["--rng-seed"] - .describe( "set a specific seed for random numbers" ) - .bind( &setRngSeed, "'time'|number" ); - - cli["--force-colour"] - .describe( "force colourised output (deprecated)" ) - .bind( &forceColour ); - - cli["--use-colour"] - .describe( "should output be colourised" ) - .bind( &setUseColour, "yes|no" ); - - return cli; - } - -} // end namespace Catch - -// #included from: internal/catch_list.hpp -#define TWOBLUECUBES_CATCH_LIST_HPP_INCLUDED - -// #included from: catch_text.h -#define TWOBLUECUBES_CATCH_TEXT_H_INCLUDED - -#define TBC_TEXT_FORMAT_CONSOLE_WIDTH CATCH_CONFIG_CONSOLE_WIDTH - -#define CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE Catch -// #included from: ../external/tbc_text_format.h -// Only use header guard if we are not using an outer namespace -#ifndef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE -# ifdef TWOBLUECUBES_TEXT_FORMAT_H_INCLUDED -# ifndef TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED -# define TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED -# endif -# else -# define TWOBLUECUBES_TEXT_FORMAT_H_INCLUDED -# endif -#endif -#ifndef TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED -#include -#include -#include - -// Use optional outer namespace -#ifdef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE -namespace CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE { -#endif - -namespace Tbc { - -#ifdef TBC_TEXT_FORMAT_CONSOLE_WIDTH - const unsigned int consoleWidth = TBC_TEXT_FORMAT_CONSOLE_WIDTH; -#else - const unsigned int consoleWidth = 80; -#endif - - struct TextAttributes { - TextAttributes() - : initialIndent( std::string::npos ), - indent( 0 ), - width( consoleWidth-1 ) - {} - - TextAttributes& setInitialIndent( std::size_t _value ) { initialIndent = _value; return *this; } - TextAttributes& setIndent( std::size_t _value ) { indent = _value; return *this; } - TextAttributes& setWidth( std::size_t _value ) { width = _value; return *this; } - - std::size_t initialIndent; // indent of first line, or npos - std::size_t indent; // indent of subsequent lines, or all if initialIndent is npos - std::size_t width; // maximum width of text, including indent. Longer text will wrap - }; - - class Text { - public: - Text( std::string const& _str, TextAttributes const& _attr = TextAttributes() ) - : attr( _attr ) - { - const std::string wrappableBeforeChars = "[({<\t"; - const std::string wrappableAfterChars = "])}>-,./|\\"; - const std::string wrappableInsteadOfChars = " \n\r"; - std::string indent = _attr.initialIndent != std::string::npos - ? std::string( _attr.initialIndent, ' ' ) - : std::string( _attr.indent, ' ' ); - - typedef std::string::const_iterator iterator; - iterator it = _str.begin(); - const iterator strEnd = _str.end(); - - while( it != strEnd ) { - - if( lines.size() >= 1000 ) { - lines.push_back( "... message truncated due to excessive size" ); - return; - } - - std::string suffix; - std::size_t width = (std::min)( static_cast( strEnd-it ), _attr.width-static_cast( indent.size() ) ); - iterator itEnd = it+width; - iterator itNext = _str.end(); - - iterator itNewLine = std::find( it, itEnd, '\n' ); - if( itNewLine != itEnd ) - itEnd = itNewLine; - - if( itEnd != strEnd ) { - bool foundWrapPoint = false; - iterator findIt = itEnd; - do { - if( wrappableAfterChars.find( *findIt ) != std::string::npos && findIt != itEnd ) { - itEnd = findIt+1; - itNext = findIt+1; - foundWrapPoint = true; - } - else if( findIt > it && wrappableBeforeChars.find( *findIt ) != std::string::npos ) { - itEnd = findIt; - itNext = findIt; - foundWrapPoint = true; - } - else if( wrappableInsteadOfChars.find( *findIt ) != std::string::npos ) { - itNext = findIt+1; - itEnd = findIt; - foundWrapPoint = true; - } - if( findIt == it ) - break; - else - --findIt; - } - while( !foundWrapPoint ); - - if( !foundWrapPoint ) { - // No good wrap char, so we'll break mid word and add a hyphen - --itEnd; - itNext = itEnd; - suffix = "-"; - } - else { - while( itEnd > it && wrappableInsteadOfChars.find( *(itEnd-1) ) != std::string::npos ) - --itEnd; - } - } - lines.push_back( indent + std::string( it, itEnd ) + suffix ); - - if( indent.size() != _attr.indent ) - indent = std::string( _attr.indent, ' ' ); - it = itNext; - } - } - - typedef std::vector::const_iterator const_iterator; - - const_iterator begin() const { return lines.begin(); } - const_iterator end() const { return lines.end(); } - std::string const& last() const { return lines.back(); } - std::size_t size() const { return lines.size(); } - std::string const& operator[]( std::size_t _index ) const { return lines[_index]; } - std::string toString() const { - std::ostringstream oss; - oss << *this; - return oss.str(); - } - - inline friend std::ostream& operator << ( std::ostream& _stream, Text const& _text ) { - for( Text::const_iterator it = _text.begin(), itEnd = _text.end(); - it != itEnd; ++it ) { - if( it != _text.begin() ) - _stream << "\n"; - _stream << *it; - } - return _stream; - } - - private: - std::string str; - TextAttributes attr; - std::vector lines; - }; - -} // end namespace Tbc - -#ifdef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE -} // end outer namespace -#endif - -#endif // TWOBLUECUBES_TEXT_FORMAT_H_ALREADY_INCLUDED -#undef CLICHE_TBC_TEXT_FORMAT_OUTER_NAMESPACE - -namespace Catch { - using Tbc::Text; - using Tbc::TextAttributes; -} - -// #included from: catch_console_colour.hpp -#define TWOBLUECUBES_CATCH_CONSOLE_COLOUR_HPP_INCLUDED - -namespace Catch { - - struct Colour { - enum Code { - None = 0, - - White, - Red, - Green, - Blue, - Cyan, - Yellow, - Grey, - - Bright = 0x10, - - BrightRed = Bright | Red, - BrightGreen = Bright | Green, - LightGrey = Bright | Grey, - BrightWhite = Bright | White, - - // By intention - FileName = LightGrey, - Warning = Yellow, - ResultError = BrightRed, - ResultSuccess = BrightGreen, - ResultExpectedFailure = Warning, - - Error = BrightRed, - Success = Green, - - OriginalExpression = Cyan, - ReconstructedExpression = Yellow, - - SecondaryText = LightGrey, - Headers = White - }; - - // Use constructed object for RAII guard - Colour( Code _colourCode ); - Colour( Colour const& other ); - ~Colour(); - - // Use static method for one-shot changes - static void use( Code _colourCode ); - - private: - bool m_moved; - }; - - inline std::ostream& operator << ( std::ostream& os, Colour const& ) { return os; } - -} // end namespace Catch - -// #included from: catch_interfaces_reporter.h -#define TWOBLUECUBES_CATCH_INTERFACES_REPORTER_H_INCLUDED - -#include -#include -#include - -namespace Catch -{ - struct ReporterConfig { - explicit ReporterConfig( Ptr const& _fullConfig ) - : m_stream( &_fullConfig->stream() ), m_fullConfig( _fullConfig ) {} - - ReporterConfig( Ptr const& _fullConfig, std::ostream& _stream ) - : m_stream( &_stream ), m_fullConfig( _fullConfig ) {} - - std::ostream& stream() const { return *m_stream; } - Ptr fullConfig() const { return m_fullConfig; } - - private: - std::ostream* m_stream; - Ptr m_fullConfig; - }; - - struct ReporterPreferences { - ReporterPreferences() - : shouldRedirectStdOut( false ) - {} - - bool shouldRedirectStdOut; - }; - - template - struct LazyStat : Option { - LazyStat() : used( false ) {} - LazyStat& operator=( T const& _value ) { - Option::operator=( _value ); - used = false; - return *this; - } - void reset() { - Option::reset(); - used = false; - } - bool used; - }; - - struct TestRunInfo { - TestRunInfo( std::string const& _name ) : name( _name ) {} - std::string name; - }; - struct GroupInfo { - GroupInfo( std::string const& _name, - std::size_t _groupIndex, - std::size_t _groupsCount ) - : name( _name ), - groupIndex( _groupIndex ), - groupsCounts( _groupsCount ) - {} - - std::string name; - std::size_t groupIndex; - std::size_t groupsCounts; - }; - - struct AssertionStats { - AssertionStats( AssertionResult const& _assertionResult, - std::vector const& _infoMessages, - Totals const& _totals ) - : assertionResult( _assertionResult ), - infoMessages( _infoMessages ), - totals( _totals ) - { - if( assertionResult.hasMessage() ) { - // Copy message into messages list. - // !TBD This should have been done earlier, somewhere - MessageBuilder builder( assertionResult.getTestMacroName(), assertionResult.getSourceInfo(), assertionResult.getResultType() ); - builder << assertionResult.getMessage(); - builder.m_info.message = builder.m_stream.str(); - - infoMessages.push_back( builder.m_info ); - } - } - virtual ~AssertionStats(); - -# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS - AssertionStats( AssertionStats const& ) = default; - AssertionStats( AssertionStats && ) = default; - AssertionStats& operator = ( AssertionStats const& ) = default; - AssertionStats& operator = ( AssertionStats && ) = default; -# endif - - AssertionResult assertionResult; - std::vector infoMessages; - Totals totals; - }; - - struct SectionStats { - SectionStats( SectionInfo const& _sectionInfo, - Counts const& _assertions, - double _durationInSeconds, - bool _missingAssertions ) - : sectionInfo( _sectionInfo ), - assertions( _assertions ), - durationInSeconds( _durationInSeconds ), - missingAssertions( _missingAssertions ) - {} - virtual ~SectionStats(); -# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS - SectionStats( SectionStats const& ) = default; - SectionStats( SectionStats && ) = default; - SectionStats& operator = ( SectionStats const& ) = default; - SectionStats& operator = ( SectionStats && ) = default; -# endif - - SectionInfo sectionInfo; - Counts assertions; - double durationInSeconds; - bool missingAssertions; - }; - - struct TestCaseStats { - TestCaseStats( TestCaseInfo const& _testInfo, - Totals const& _totals, - std::string const& _stdOut, - std::string const& _stdErr, - bool _aborting ) - : testInfo( _testInfo ), - totals( _totals ), - stdOut( _stdOut ), - stdErr( _stdErr ), - aborting( _aborting ) - {} - virtual ~TestCaseStats(); - -# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS - TestCaseStats( TestCaseStats const& ) = default; - TestCaseStats( TestCaseStats && ) = default; - TestCaseStats& operator = ( TestCaseStats const& ) = default; - TestCaseStats& operator = ( TestCaseStats && ) = default; -# endif - - TestCaseInfo testInfo; - Totals totals; - std::string stdOut; - std::string stdErr; - bool aborting; - }; - - struct TestGroupStats { - TestGroupStats( GroupInfo const& _groupInfo, - Totals const& _totals, - bool _aborting ) - : groupInfo( _groupInfo ), - totals( _totals ), - aborting( _aborting ) - {} - TestGroupStats( GroupInfo const& _groupInfo ) - : groupInfo( _groupInfo ), - aborting( false ) - {} - virtual ~TestGroupStats(); - -# ifdef CATCH_CONFIG_CPP11_GENERATED_METHODS - TestGroupStats( TestGroupStats const& ) = default; - TestGroupStats( TestGroupStats && ) = default; - TestGroupStats& operator = ( TestGroupStats const& ) = default; - TestGroupStats& operator = ( TestGroupStats && ) = default; -# endif - - GroupInfo groupInfo; - Totals totals; - bool aborting; - }; - - struct TestRunStats { - TestRunStats( TestRunInfo const& _runInfo, - Totals const& _totals, - bool _aborting ) - : runInfo( _runInfo ), - totals( _totals ), - aborting( _aborting ) - {} - virtual ~TestRunStats(); - -# ifndef CATCH_CONFIG_CPP11_GENERATED_METHODS - TestRunStats( TestRunStats const& _other ) - : runInfo( _other.runInfo ), - totals( _other.totals ), - aborting( _other.aborting ) - {} -# else - TestRunStats( TestRunStats const& ) = default; - TestRunStats( TestRunStats && ) = default; - TestRunStats& operator = ( TestRunStats const& ) = default; - TestRunStats& operator = ( TestRunStats && ) = default; -# endif - - TestRunInfo runInfo; - Totals totals; - bool aborting; - }; - - class MultipleReporters; - - struct IStreamingReporter : IShared { - virtual ~IStreamingReporter(); - - // Implementing class must also provide the following static method: - // static std::string getDescription(); - - virtual ReporterPreferences getPreferences() const = 0; - - virtual void noMatchingTestCases( std::string const& spec ) = 0; - - virtual void testRunStarting( TestRunInfo const& testRunInfo ) = 0; - virtual void testGroupStarting( GroupInfo const& groupInfo ) = 0; - - virtual void testCaseStarting( TestCaseInfo const& testInfo ) = 0; - virtual void sectionStarting( SectionInfo const& sectionInfo ) = 0; - - virtual void assertionStarting( AssertionInfo const& assertionInfo ) = 0; - - // The return value indicates if the messages buffer should be cleared: - virtual bool assertionEnded( AssertionStats const& assertionStats ) = 0; - - virtual void sectionEnded( SectionStats const& sectionStats ) = 0; - virtual void testCaseEnded( TestCaseStats const& testCaseStats ) = 0; - virtual void testGroupEnded( TestGroupStats const& testGroupStats ) = 0; - virtual void testRunEnded( TestRunStats const& testRunStats ) = 0; - - virtual void skipTest( TestCaseInfo const& testInfo ) = 0; - - virtual MultipleReporters* tryAsMulti() { return CATCH_NULL; } - }; - - struct IReporterFactory : IShared { - virtual ~IReporterFactory(); - virtual IStreamingReporter* create( ReporterConfig const& config ) const = 0; - virtual std::string getDescription() const = 0; - }; - - struct IReporterRegistry { - typedef std::map > FactoryMap; - typedef std::vector > Listeners; - - virtual ~IReporterRegistry(); - virtual IStreamingReporter* create( std::string const& name, Ptr const& config ) const = 0; - virtual FactoryMap const& getFactories() const = 0; - virtual Listeners const& getListeners() const = 0; - }; - - Ptr addReporter( Ptr const& existingReporter, Ptr const& additionalReporter ); - -} - -#include -#include - -namespace Catch { - - inline std::size_t listTests( Config const& config ) { - - TestSpec testSpec = config.testSpec(); - if( config.testSpec().hasFilters() ) - Catch::cout() << "Matching test cases:\n"; - else { - Catch::cout() << "All available test cases:\n"; - testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec(); - } - - std::size_t matchedTests = 0; - TextAttributes nameAttr, descAttr, tagsAttr; - nameAttr.setInitialIndent( 2 ).setIndent( 4 ); - descAttr.setIndent( 4 ); - tagsAttr.setIndent( 6 ); - - std::vector matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); - for( std::vector::const_iterator it = matchedTestCases.begin(), itEnd = matchedTestCases.end(); - it != itEnd; - ++it ) { - matchedTests++; - TestCaseInfo const& testCaseInfo = it->getTestCaseInfo(); - Colour::Code colour = testCaseInfo.isHidden() - ? Colour::SecondaryText - : Colour::None; - Colour colourGuard( colour ); - - Catch::cout() << Text( testCaseInfo.name, nameAttr ) << std::endl; - if( config.listExtraInfo() ) { - Catch::cout() << " " << testCaseInfo.lineInfo << std::endl; - std::string description = testCaseInfo.description; - if( description.empty() ) - description = "(NO DESCRIPTION)"; - Catch::cout() << Text( description, descAttr ) << std::endl; - } - if( !testCaseInfo.tags.empty() ) - Catch::cout() << Text( testCaseInfo.tagsAsString, tagsAttr ) << std::endl; - } - - if( !config.testSpec().hasFilters() ) - Catch::cout() << pluralise( matchedTests, "test case" ) << '\n' << std::endl; - else - Catch::cout() << pluralise( matchedTests, "matching test case" ) << '\n' << std::endl; - return matchedTests; - } - - inline std::size_t listTestsNamesOnly( Config const& config ) { - TestSpec testSpec = config.testSpec(); - if( !config.testSpec().hasFilters() ) - testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec(); - std::size_t matchedTests = 0; - std::vector matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); - for( std::vector::const_iterator it = matchedTestCases.begin(), itEnd = matchedTestCases.end(); - it != itEnd; - ++it ) { - matchedTests++; - TestCaseInfo const& testCaseInfo = it->getTestCaseInfo(); - if( startsWith( testCaseInfo.name, '#' ) ) - Catch::cout() << '"' << testCaseInfo.name << '"'; - else - Catch::cout() << testCaseInfo.name; - if ( config.listExtraInfo() ) - Catch::cout() << "\t@" << testCaseInfo.lineInfo; - Catch::cout() << std::endl; - } - return matchedTests; - } - - struct TagInfo { - TagInfo() : count ( 0 ) {} - void add( std::string const& spelling ) { - ++count; - spellings.insert( spelling ); - } - std::string all() const { - std::string out; - for( std::set::const_iterator it = spellings.begin(), itEnd = spellings.end(); - it != itEnd; - ++it ) - out += "[" + *it + "]"; - return out; - } - std::set spellings; - std::size_t count; - }; - - inline std::size_t listTags( Config const& config ) { - TestSpec testSpec = config.testSpec(); - if( config.testSpec().hasFilters() ) - Catch::cout() << "Tags for matching test cases:\n"; - else { - Catch::cout() << "All available tags:\n"; - testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "*" ).testSpec(); - } - - std::map tagCounts; - - std::vector matchedTestCases = filterTests( getAllTestCasesSorted( config ), testSpec, config ); - for( std::vector::const_iterator it = matchedTestCases.begin(), itEnd = matchedTestCases.end(); - it != itEnd; - ++it ) { - for( std::set::const_iterator tagIt = it->getTestCaseInfo().tags.begin(), - tagItEnd = it->getTestCaseInfo().tags.end(); - tagIt != tagItEnd; - ++tagIt ) { - std::string tagName = *tagIt; - std::string lcaseTagName = toLower( tagName ); - std::map::iterator countIt = tagCounts.find( lcaseTagName ); - if( countIt == tagCounts.end() ) - countIt = tagCounts.insert( std::make_pair( lcaseTagName, TagInfo() ) ).first; - countIt->second.add( tagName ); - } - } - - for( std::map::const_iterator countIt = tagCounts.begin(), - countItEnd = tagCounts.end(); - countIt != countItEnd; - ++countIt ) { - std::ostringstream oss; - oss << " " << std::setw(2) << countIt->second.count << " "; - Text wrapper( countIt->second.all(), TextAttributes() - .setInitialIndent( 0 ) - .setIndent( oss.str().size() ) - .setWidth( CATCH_CONFIG_CONSOLE_WIDTH-10 ) ); - Catch::cout() << oss.str() << wrapper << '\n'; - } - Catch::cout() << pluralise( tagCounts.size(), "tag" ) << '\n' << std::endl; - return tagCounts.size(); - } - - inline std::size_t listReporters( Config const& /*config*/ ) { - Catch::cout() << "Available reporters:\n"; - IReporterRegistry::FactoryMap const& factories = getRegistryHub().getReporterRegistry().getFactories(); - IReporterRegistry::FactoryMap::const_iterator itBegin = factories.begin(), itEnd = factories.end(), it; - std::size_t maxNameLen = 0; - for(it = itBegin; it != itEnd; ++it ) - maxNameLen = (std::max)( maxNameLen, it->first.size() ); - - for(it = itBegin; it != itEnd; ++it ) { - Text wrapper( it->second->getDescription(), TextAttributes() - .setInitialIndent( 0 ) - .setIndent( 7+maxNameLen ) - .setWidth( CATCH_CONFIG_CONSOLE_WIDTH - maxNameLen-8 ) ); - Catch::cout() << " " - << it->first - << ':' - << std::string( maxNameLen - it->first.size() + 2, ' ' ) - << wrapper << '\n'; - } - Catch::cout() << std::endl; - return factories.size(); - } - - inline Option list( Config const& config ) { - Option listedCount; - if( config.listTests() || ( config.listExtraInfo() && !config.listTestNamesOnly() ) ) - listedCount = listedCount.valueOr(0) + listTests( config ); - if( config.listTestNamesOnly() ) - listedCount = listedCount.valueOr(0) + listTestsNamesOnly( config ); - if( config.listTags() ) - listedCount = listedCount.valueOr(0) + listTags( config ); - if( config.listReporters() ) - listedCount = listedCount.valueOr(0) + listReporters( config ); - return listedCount; - } - -} // end namespace Catch - -// #included from: internal/catch_run_context.hpp -#define TWOBLUECUBES_CATCH_RUNNER_IMPL_HPP_INCLUDED - -// #included from: catch_test_case_tracker.hpp -#define TWOBLUECUBES_CATCH_TEST_CASE_TRACKER_HPP_INCLUDED - -#include -#include -#include -#include -#include - -CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS - -namespace Catch { -namespace TestCaseTracking { - - struct NameAndLocation { - std::string name; - SourceLineInfo location; - - NameAndLocation( std::string const& _name, SourceLineInfo const& _location ) - : name( _name ), - location( _location ) - {} - }; - - struct ITracker : SharedImpl<> { - virtual ~ITracker(); - - // static queries - virtual NameAndLocation const& nameAndLocation() const = 0; - - // dynamic queries - virtual bool isComplete() const = 0; // Successfully completed or failed - virtual bool isSuccessfullyCompleted() const = 0; - virtual bool isOpen() const = 0; // Started but not complete - virtual bool hasChildren() const = 0; - - virtual ITracker& parent() = 0; - - // actions - virtual void close() = 0; // Successfully complete - virtual void fail() = 0; - virtual void markAsNeedingAnotherRun() = 0; - - virtual void addChild( Ptr const& child ) = 0; - virtual ITracker* findChild( NameAndLocation const& nameAndLocation ) = 0; - virtual void openChild() = 0; - - // Debug/ checking - virtual bool isSectionTracker() const = 0; - virtual bool isIndexTracker() const = 0; - }; - - class TrackerContext { - - enum RunState { - NotStarted, - Executing, - CompletedCycle - }; - - Ptr m_rootTracker; - ITracker* m_currentTracker; - RunState m_runState; - - public: - - static TrackerContext& instance() { - static TrackerContext s_instance; - return s_instance; - } - - TrackerContext() - : m_currentTracker( CATCH_NULL ), - m_runState( NotStarted ) - {} - - ITracker& startRun(); - - void endRun() { - m_rootTracker.reset(); - m_currentTracker = CATCH_NULL; - m_runState = NotStarted; - } - - void startCycle() { - m_currentTracker = m_rootTracker.get(); - m_runState = Executing; - } - void completeCycle() { - m_runState = CompletedCycle; - } - - bool completedCycle() const { - return m_runState == CompletedCycle; - } - ITracker& currentTracker() { - return *m_currentTracker; - } - void setCurrentTracker( ITracker* tracker ) { - m_currentTracker = tracker; - } - }; - - class TrackerBase : public ITracker { - protected: - enum CycleState { - NotStarted, - Executing, - ExecutingChildren, - NeedsAnotherRun, - CompletedSuccessfully, - Failed - }; - class TrackerHasName { - NameAndLocation m_nameAndLocation; - public: - TrackerHasName( NameAndLocation const& nameAndLocation ) : m_nameAndLocation( nameAndLocation ) {} - bool operator ()( Ptr const& tracker ) { - return - tracker->nameAndLocation().name == m_nameAndLocation.name && - tracker->nameAndLocation().location == m_nameAndLocation.location; - } - }; - typedef std::vector > Children; - NameAndLocation m_nameAndLocation; - TrackerContext& m_ctx; - ITracker* m_parent; - Children m_children; - CycleState m_runState; - public: - TrackerBase( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ) - : m_nameAndLocation( nameAndLocation ), - m_ctx( ctx ), - m_parent( parent ), - m_runState( NotStarted ) - {} - virtual ~TrackerBase(); - - virtual NameAndLocation const& nameAndLocation() const CATCH_OVERRIDE { - return m_nameAndLocation; - } - virtual bool isComplete() const CATCH_OVERRIDE { - return m_runState == CompletedSuccessfully || m_runState == Failed; - } - virtual bool isSuccessfullyCompleted() const CATCH_OVERRIDE { - return m_runState == CompletedSuccessfully; - } - virtual bool isOpen() const CATCH_OVERRIDE { - return m_runState != NotStarted && !isComplete(); - } - virtual bool hasChildren() const CATCH_OVERRIDE { - return !m_children.empty(); - } - - virtual void addChild( Ptr const& child ) CATCH_OVERRIDE { - m_children.push_back( child ); - } - - virtual ITracker* findChild( NameAndLocation const& nameAndLocation ) CATCH_OVERRIDE { - Children::const_iterator it = std::find_if( m_children.begin(), m_children.end(), TrackerHasName( nameAndLocation ) ); - return( it != m_children.end() ) - ? it->get() - : CATCH_NULL; - } - virtual ITracker& parent() CATCH_OVERRIDE { - assert( m_parent ); // Should always be non-null except for root - return *m_parent; - } - - virtual void openChild() CATCH_OVERRIDE { - if( m_runState != ExecutingChildren ) { - m_runState = ExecutingChildren; - if( m_parent ) - m_parent->openChild(); - } - } - - virtual bool isSectionTracker() const CATCH_OVERRIDE { return false; } - virtual bool isIndexTracker() const CATCH_OVERRIDE { return false; } - - void open() { - m_runState = Executing; - moveToThis(); - if( m_parent ) - m_parent->openChild(); - } - - virtual void close() CATCH_OVERRIDE { - - // Close any still open children (e.g. generators) - while( &m_ctx.currentTracker() != this ) - m_ctx.currentTracker().close(); - - switch( m_runState ) { - case NotStarted: - case CompletedSuccessfully: - case Failed: - throw std::logic_error( "Illogical state" ); - - case NeedsAnotherRun: - break;; - - case Executing: - m_runState = CompletedSuccessfully; - break; - case ExecutingChildren: - if( m_children.empty() || m_children.back()->isComplete() ) - m_runState = CompletedSuccessfully; - break; - - default: - throw std::logic_error( "Unexpected state" ); - } - moveToParent(); - m_ctx.completeCycle(); - } - virtual void fail() CATCH_OVERRIDE { - m_runState = Failed; - if( m_parent ) - m_parent->markAsNeedingAnotherRun(); - moveToParent(); - m_ctx.completeCycle(); - } - virtual void markAsNeedingAnotherRun() CATCH_OVERRIDE { - m_runState = NeedsAnotherRun; - } - private: - void moveToParent() { - assert( m_parent ); - m_ctx.setCurrentTracker( m_parent ); - } - void moveToThis() { - m_ctx.setCurrentTracker( this ); - } - }; - - class SectionTracker : public TrackerBase { - std::vector m_filters; - public: - SectionTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent ) - : TrackerBase( nameAndLocation, ctx, parent ) - { - if( parent ) { - while( !parent->isSectionTracker() ) - parent = &parent->parent(); - - SectionTracker& parentSection = static_cast( *parent ); - addNextFilters( parentSection.m_filters ); - } - } - virtual ~SectionTracker(); - - virtual bool isSectionTracker() const CATCH_OVERRIDE { return true; } - - static SectionTracker& acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation ) { - SectionTracker* section = CATCH_NULL; - - ITracker& currentTracker = ctx.currentTracker(); - if( ITracker* childTracker = currentTracker.findChild( nameAndLocation ) ) { - assert( childTracker ); - assert( childTracker->isSectionTracker() ); - section = static_cast( childTracker ); - } - else { - section = new SectionTracker( nameAndLocation, ctx, ¤tTracker ); - currentTracker.addChild( section ); - } - if( !ctx.completedCycle() ) - section->tryOpen(); - return *section; - } - - void tryOpen() { - if( !isComplete() && (m_filters.empty() || m_filters[0].empty() || m_filters[0] == m_nameAndLocation.name ) ) - open(); - } - - void addInitialFilters( std::vector const& filters ) { - if( !filters.empty() ) { - m_filters.push_back(""); // Root - should never be consulted - m_filters.push_back(""); // Test Case - not a section filter - m_filters.insert( m_filters.end(), filters.begin(), filters.end() ); - } - } - void addNextFilters( std::vector const& filters ) { - if( filters.size() > 1 ) - m_filters.insert( m_filters.end(), ++filters.begin(), filters.end() ); - } - }; - - class IndexTracker : public TrackerBase { - int m_size; - int m_index; - public: - IndexTracker( NameAndLocation const& nameAndLocation, TrackerContext& ctx, ITracker* parent, int size ) - : TrackerBase( nameAndLocation, ctx, parent ), - m_size( size ), - m_index( -1 ) - {} - virtual ~IndexTracker(); - - virtual bool isIndexTracker() const CATCH_OVERRIDE { return true; } - - static IndexTracker& acquire( TrackerContext& ctx, NameAndLocation const& nameAndLocation, int size ) { - IndexTracker* tracker = CATCH_NULL; - - ITracker& currentTracker = ctx.currentTracker(); - if( ITracker* childTracker = currentTracker.findChild( nameAndLocation ) ) { - assert( childTracker ); - assert( childTracker->isIndexTracker() ); - tracker = static_cast( childTracker ); - } - else { - tracker = new IndexTracker( nameAndLocation, ctx, ¤tTracker, size ); - currentTracker.addChild( tracker ); - } - - if( !ctx.completedCycle() && !tracker->isComplete() ) { - if( tracker->m_runState != ExecutingChildren && tracker->m_runState != NeedsAnotherRun ) - tracker->moveNext(); - tracker->open(); - } - - return *tracker; - } - - int index() const { return m_index; } - - void moveNext() { - m_index++; - m_children.clear(); - } - - virtual void close() CATCH_OVERRIDE { - TrackerBase::close(); - if( m_runState == CompletedSuccessfully && m_index < m_size-1 ) - m_runState = Executing; - } - }; - - inline ITracker& TrackerContext::startRun() { - m_rootTracker = new SectionTracker( NameAndLocation( "{root}", CATCH_INTERNAL_LINEINFO ), *this, CATCH_NULL ); - m_currentTracker = CATCH_NULL; - m_runState = Executing; - return *m_rootTracker; - } - -} // namespace TestCaseTracking - -using TestCaseTracking::ITracker; -using TestCaseTracking::TrackerContext; -using TestCaseTracking::SectionTracker; -using TestCaseTracking::IndexTracker; - -} // namespace Catch - -CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS - -// #included from: catch_fatal_condition.hpp -#define TWOBLUECUBES_CATCH_FATAL_CONDITION_H_INCLUDED - -namespace Catch { - - // Report the error condition - inline void reportFatal( std::string const& message ) { - IContext& context = Catch::getCurrentContext(); - IResultCapture* resultCapture = context.getResultCapture(); - resultCapture->handleFatalErrorCondition( message ); - } - -} // namespace Catch - -#if defined ( CATCH_PLATFORM_WINDOWS ) ///////////////////////////////////////// -// #included from: catch_windows_h_proxy.h - -#define TWOBLUECUBES_CATCH_WINDOWS_H_PROXY_H_INCLUDED - -#ifdef CATCH_DEFINES_NOMINMAX -# define NOMINMAX -#endif -#ifdef CATCH_DEFINES_WIN32_LEAN_AND_MEAN -# define WIN32_LEAN_AND_MEAN -#endif - -#ifdef __AFXDLL -#include -#else -#include -#endif - -#ifdef CATCH_DEFINES_NOMINMAX -# undef NOMINMAX -#endif -#ifdef CATCH_DEFINES_WIN32_LEAN_AND_MEAN -# undef WIN32_LEAN_AND_MEAN -#endif - - -# if !defined ( CATCH_CONFIG_WINDOWS_SEH ) - -namespace Catch { - struct FatalConditionHandler { - void reset() {} - }; -} - -# else // CATCH_CONFIG_WINDOWS_SEH is defined - -namespace Catch { - - struct SignalDefs { DWORD id; const char* name; }; - extern SignalDefs signalDefs[]; - // There is no 1-1 mapping between signals and windows exceptions. - // Windows can easily distinguish between SO and SigSegV, - // but SigInt, SigTerm, etc are handled differently. - SignalDefs signalDefs[] = { - { EXCEPTION_ILLEGAL_INSTRUCTION, "SIGILL - Illegal instruction signal" }, - { EXCEPTION_STACK_OVERFLOW, "SIGSEGV - Stack overflow" }, - { EXCEPTION_ACCESS_VIOLATION, "SIGSEGV - Segmentation violation signal" }, - { EXCEPTION_INT_DIVIDE_BY_ZERO, "Divide by zero error" }, - }; - - struct FatalConditionHandler { - - static LONG CALLBACK handleVectoredException(PEXCEPTION_POINTERS ExceptionInfo) { - for (int i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { - if (ExceptionInfo->ExceptionRecord->ExceptionCode == signalDefs[i].id) { - reportFatal(signalDefs[i].name); - } - } - // If its not an exception we care about, pass it along. - // This stops us from eating debugger breaks etc. - return EXCEPTION_CONTINUE_SEARCH; - } - - FatalConditionHandler() { - isSet = true; - // 32k seems enough for Catch to handle stack overflow, - // but the value was found experimentally, so there is no strong guarantee - guaranteeSize = 32 * 1024; - exceptionHandlerHandle = CATCH_NULL; - // Register as first handler in current chain - exceptionHandlerHandle = AddVectoredExceptionHandler(1, handleVectoredException); - // Pass in guarantee size to be filled - SetThreadStackGuarantee(&guaranteeSize); - } - - static void reset() { - if (isSet) { - // Unregister handler and restore the old guarantee - RemoveVectoredExceptionHandler(exceptionHandlerHandle); - SetThreadStackGuarantee(&guaranteeSize); - exceptionHandlerHandle = CATCH_NULL; - isSet = false; - } - } - - ~FatalConditionHandler() { - reset(); - } - private: - static bool isSet; - static ULONG guaranteeSize; - static PVOID exceptionHandlerHandle; - }; - - bool FatalConditionHandler::isSet = false; - ULONG FatalConditionHandler::guaranteeSize = 0; - PVOID FatalConditionHandler::exceptionHandlerHandle = CATCH_NULL; - -} // namespace Catch - -# endif // CATCH_CONFIG_WINDOWS_SEH - -#else // Not Windows - assumed to be POSIX compatible ////////////////////////// - -# if !defined(CATCH_CONFIG_POSIX_SIGNALS) - -namespace Catch { - struct FatalConditionHandler { - void reset() {} - }; -} - -# else // CATCH_CONFIG_POSIX_SIGNALS is defined - -#include - -namespace Catch { - - struct SignalDefs { - int id; - const char* name; - }; - extern SignalDefs signalDefs[]; - SignalDefs signalDefs[] = { - { SIGINT, "SIGINT - Terminal interrupt signal" }, - { SIGILL, "SIGILL - Illegal instruction signal" }, - { SIGFPE, "SIGFPE - Floating point error signal" }, - { SIGSEGV, "SIGSEGV - Segmentation violation signal" }, - { SIGTERM, "SIGTERM - Termination request signal" }, - { SIGABRT, "SIGABRT - Abort (abnormal termination) signal" } - }; - - struct FatalConditionHandler { - - static bool isSet; - static struct sigaction oldSigActions [sizeof(signalDefs)/sizeof(SignalDefs)]; - static stack_t oldSigStack; - static char altStackMem[SIGSTKSZ]; - - static void handleSignal( int sig ) { - std::string name = ""; - for (std::size_t i = 0; i < sizeof(signalDefs) / sizeof(SignalDefs); ++i) { - SignalDefs &def = signalDefs[i]; - if (sig == def.id) { - name = def.name; - break; - } - } - reset(); - reportFatal(name); - raise( sig ); - } - - FatalConditionHandler() { - isSet = true; - stack_t sigStack; - sigStack.ss_sp = altStackMem; - sigStack.ss_size = SIGSTKSZ; - sigStack.ss_flags = 0; - sigaltstack(&sigStack, &oldSigStack); - struct sigaction sa = { 0 }; - - sa.sa_handler = handleSignal; - sa.sa_flags = SA_ONSTACK; - for (std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i) { - sigaction(signalDefs[i].id, &sa, &oldSigActions[i]); - } - } - - ~FatalConditionHandler() { - reset(); - } - static void reset() { - if( isSet ) { - // Set signals back to previous values -- hopefully nobody overwrote them in the meantime - for( std::size_t i = 0; i < sizeof(signalDefs)/sizeof(SignalDefs); ++i ) { - sigaction(signalDefs[i].id, &oldSigActions[i], CATCH_NULL); - } - // Return the old stack - sigaltstack(&oldSigStack, CATCH_NULL); - isSet = false; - } - } - }; - - bool FatalConditionHandler::isSet = false; - struct sigaction FatalConditionHandler::oldSigActions[sizeof(signalDefs)/sizeof(SignalDefs)] = {}; - stack_t FatalConditionHandler::oldSigStack = {}; - char FatalConditionHandler::altStackMem[SIGSTKSZ] = {}; - -} // namespace Catch - -# endif // CATCH_CONFIG_POSIX_SIGNALS - -#endif // not Windows - -#include -#include - -namespace Catch { - - class StreamRedirect { - - public: - StreamRedirect( std::ostream& stream, std::string& targetString ) - : m_stream( stream ), - m_prevBuf( stream.rdbuf() ), - m_targetString( targetString ) - { - stream.rdbuf( m_oss.rdbuf() ); - } - - ~StreamRedirect() { - m_targetString += m_oss.str(); - m_stream.rdbuf( m_prevBuf ); - } - - private: - std::ostream& m_stream; - std::streambuf* m_prevBuf; - std::ostringstream m_oss; - std::string& m_targetString; - }; - - /////////////////////////////////////////////////////////////////////////// - - class RunContext : public IResultCapture, public IRunner { - - RunContext( RunContext const& ); - void operator =( RunContext const& ); - - public: - - explicit RunContext( Ptr const& _config, Ptr const& reporter ) - : m_runInfo( _config->name() ), - m_context( getCurrentMutableContext() ), - m_activeTestCase( CATCH_NULL ), - m_config( _config ), - m_reporter( reporter ), - m_shouldReportUnexpected ( true ) - { - m_context.setRunner( this ); - m_context.setConfig( m_config ); - m_context.setResultCapture( this ); - m_reporter->testRunStarting( m_runInfo ); - } - - virtual ~RunContext() { - m_reporter->testRunEnded( TestRunStats( m_runInfo, m_totals, aborting() ) ); - } - - void testGroupStarting( std::string const& testSpec, std::size_t groupIndex, std::size_t groupsCount ) { - m_reporter->testGroupStarting( GroupInfo( testSpec, groupIndex, groupsCount ) ); - } - void testGroupEnded( std::string const& testSpec, Totals const& totals, std::size_t groupIndex, std::size_t groupsCount ) { - m_reporter->testGroupEnded( TestGroupStats( GroupInfo( testSpec, groupIndex, groupsCount ), totals, aborting() ) ); - } - - Totals runTest( TestCase const& testCase ) { - Totals prevTotals = m_totals; - - std::string redirectedCout; - std::string redirectedCerr; - - TestCaseInfo testInfo = testCase.getTestCaseInfo(); - - m_reporter->testCaseStarting( testInfo ); - - m_activeTestCase = &testCase; - - do { - ITracker& rootTracker = m_trackerContext.startRun(); - assert( rootTracker.isSectionTracker() ); - static_cast( rootTracker ).addInitialFilters( m_config->getSectionsToRun() ); - do { - m_trackerContext.startCycle(); - m_testCaseTracker = &SectionTracker::acquire( m_trackerContext, TestCaseTracking::NameAndLocation( testInfo.name, testInfo.lineInfo ) ); - runCurrentTest( redirectedCout, redirectedCerr ); - } - while( !m_testCaseTracker->isSuccessfullyCompleted() && !aborting() ); - } - // !TBD: deprecated - this will be replaced by indexed trackers - while( getCurrentContext().advanceGeneratorsForCurrentTest() && !aborting() ); - - Totals deltaTotals = m_totals.delta( prevTotals ); - if( testInfo.expectedToFail() && deltaTotals.testCases.passed > 0 ) { - deltaTotals.assertions.failed++; - deltaTotals.testCases.passed--; - deltaTotals.testCases.failed++; - } - m_totals.testCases += deltaTotals.testCases; - m_reporter->testCaseEnded( TestCaseStats( testInfo, - deltaTotals, - redirectedCout, - redirectedCerr, - aborting() ) ); - - m_activeTestCase = CATCH_NULL; - m_testCaseTracker = CATCH_NULL; - - return deltaTotals; - } - - Ptr config() const { - return m_config; - } - - private: // IResultCapture - - virtual void assertionEnded( AssertionResult const& result ) { - if( result.getResultType() == ResultWas::Ok ) { - m_totals.assertions.passed++; - } - else if( !result.isOk() ) { - m_totals.assertions.failed++; - } - - // We have no use for the return value (whether messages should be cleared), because messages were made scoped - // and should be let to clear themselves out. - static_cast(m_reporter->assertionEnded(AssertionStats(result, m_messages, m_totals))); - - // Reset working state - m_lastAssertionInfo = AssertionInfo( "", m_lastAssertionInfo.lineInfo, "{Unknown expression after the reported line}" , m_lastAssertionInfo.resultDisposition ); - m_lastResult = result; - } - - virtual bool sectionStarted ( - SectionInfo const& sectionInfo, - Counts& assertions - ) - { - ITracker& sectionTracker = SectionTracker::acquire( m_trackerContext, TestCaseTracking::NameAndLocation( sectionInfo.name, sectionInfo.lineInfo ) ); - if( !sectionTracker.isOpen() ) - return false; - m_activeSections.push_back( §ionTracker ); - - m_lastAssertionInfo.lineInfo = sectionInfo.lineInfo; - - m_reporter->sectionStarting( sectionInfo ); - - assertions = m_totals.assertions; - - return true; - } - bool testForMissingAssertions( Counts& assertions ) { - if( assertions.total() != 0 ) - return false; - if( !m_config->warnAboutMissingAssertions() ) - return false; - if( m_trackerContext.currentTracker().hasChildren() ) - return false; - m_totals.assertions.failed++; - assertions.failed++; - return true; - } - - virtual void sectionEnded( SectionEndInfo const& endInfo ) { - Counts assertions = m_totals.assertions - endInfo.prevAssertions; - bool missingAssertions = testForMissingAssertions( assertions ); - - if( !m_activeSections.empty() ) { - m_activeSections.back()->close(); - m_activeSections.pop_back(); - } - - m_reporter->sectionEnded( SectionStats( endInfo.sectionInfo, assertions, endInfo.durationInSeconds, missingAssertions ) ); - m_messages.clear(); - } - - virtual void sectionEndedEarly( SectionEndInfo const& endInfo ) { - if( m_unfinishedSections.empty() ) - m_activeSections.back()->fail(); - else - m_activeSections.back()->close(); - m_activeSections.pop_back(); - - m_unfinishedSections.push_back( endInfo ); - } - - virtual void pushScopedMessage( MessageInfo const& message ) { - m_messages.push_back( message ); - } - - virtual void popScopedMessage( MessageInfo const& message ) { - m_messages.erase( std::remove( m_messages.begin(), m_messages.end(), message ), m_messages.end() ); - } - - virtual std::string getCurrentTestName() const { - return m_activeTestCase - ? m_activeTestCase->getTestCaseInfo().name - : std::string(); - } - - virtual const AssertionResult* getLastResult() const { - return &m_lastResult; - } - - virtual void exceptionEarlyReported() { - m_shouldReportUnexpected = false; - } - - virtual void handleFatalErrorCondition( std::string const& message ) { - // Don't rebuild the result -- the stringification itself can cause more fatal errors - // Instead, fake a result data. - AssertionResultData tempResult; - tempResult.resultType = ResultWas::FatalErrorCondition; - tempResult.message = message; - AssertionResult result(m_lastAssertionInfo, tempResult); - - getResultCapture().assertionEnded(result); - - handleUnfinishedSections(); - - // Recreate section for test case (as we will lose the one that was in scope) - TestCaseInfo const& testCaseInfo = m_activeTestCase->getTestCaseInfo(); - SectionInfo testCaseSection( testCaseInfo.lineInfo, testCaseInfo.name, testCaseInfo.description ); - - Counts assertions; - assertions.failed = 1; - SectionStats testCaseSectionStats( testCaseSection, assertions, 0, false ); - m_reporter->sectionEnded( testCaseSectionStats ); - - TestCaseInfo testInfo = m_activeTestCase->getTestCaseInfo(); - - Totals deltaTotals; - deltaTotals.testCases.failed = 1; - m_reporter->testCaseEnded( TestCaseStats( testInfo, - deltaTotals, - std::string(), - std::string(), - false ) ); - m_totals.testCases.failed++; - testGroupEnded( std::string(), m_totals, 1, 1 ); - m_reporter->testRunEnded( TestRunStats( m_runInfo, m_totals, false ) ); - } - - public: - // !TBD We need to do this another way! - bool aborting() const { - return m_totals.assertions.failed == static_cast( m_config->abortAfter() ); - } - - private: - - void runCurrentTest( std::string& redirectedCout, std::string& redirectedCerr ) { - TestCaseInfo const& testCaseInfo = m_activeTestCase->getTestCaseInfo(); - SectionInfo testCaseSection( testCaseInfo.lineInfo, testCaseInfo.name, testCaseInfo.description ); - m_reporter->sectionStarting( testCaseSection ); - Counts prevAssertions = m_totals.assertions; - double duration = 0; - m_shouldReportUnexpected = true; - try { - m_lastAssertionInfo = AssertionInfo( "TEST_CASE", testCaseInfo.lineInfo, "", ResultDisposition::Normal ); - - seedRng( *m_config ); - - Timer timer; - timer.start(); - if( m_reporter->getPreferences().shouldRedirectStdOut ) { - StreamRedirect coutRedir( Catch::cout(), redirectedCout ); - StreamRedirect cerrRedir( Catch::cerr(), redirectedCerr ); - invokeActiveTestCase(); - } - else { - invokeActiveTestCase(); - } - duration = timer.getElapsedSeconds(); - } - catch( TestFailureException& ) { - // This just means the test was aborted due to failure - } - catch(...) { - // Under CATCH_CONFIG_FAST_COMPILE, unexpected exceptions under REQUIRE assertions - // are reported without translation at the point of origin. - if (m_shouldReportUnexpected) { - makeUnexpectedResultBuilder().useActiveException(); - } - } - m_testCaseTracker->close(); - handleUnfinishedSections(); - m_messages.clear(); - - Counts assertions = m_totals.assertions - prevAssertions; - bool missingAssertions = testForMissingAssertions( assertions ); - - if( testCaseInfo.okToFail() ) { - std::swap( assertions.failedButOk, assertions.failed ); - m_totals.assertions.failed -= assertions.failedButOk; - m_totals.assertions.failedButOk += assertions.failedButOk; - } - - SectionStats testCaseSectionStats( testCaseSection, assertions, duration, missingAssertions ); - m_reporter->sectionEnded( testCaseSectionStats ); - } - - void invokeActiveTestCase() { - FatalConditionHandler fatalConditionHandler; // Handle signals - m_activeTestCase->invoke(); - fatalConditionHandler.reset(); - } - - private: - - ResultBuilder makeUnexpectedResultBuilder() const { - return ResultBuilder( m_lastAssertionInfo.macroName, - m_lastAssertionInfo.lineInfo, - m_lastAssertionInfo.capturedExpression, - m_lastAssertionInfo.resultDisposition ); - } - - void handleUnfinishedSections() { - // If sections ended prematurely due to an exception we stored their - // infos here so we can tear them down outside the unwind process. - for( std::vector::const_reverse_iterator it = m_unfinishedSections.rbegin(), - itEnd = m_unfinishedSections.rend(); - it != itEnd; - ++it ) - sectionEnded( *it ); - m_unfinishedSections.clear(); - } - - TestRunInfo m_runInfo; - IMutableContext& m_context; - TestCase const* m_activeTestCase; - ITracker* m_testCaseTracker; - ITracker* m_currentSectionTracker; - AssertionResult m_lastResult; - - Ptr m_config; - Totals m_totals; - Ptr m_reporter; - std::vector m_messages; - AssertionInfo m_lastAssertionInfo; - std::vector m_unfinishedSections; - std::vector m_activeSections; - TrackerContext m_trackerContext; - bool m_shouldReportUnexpected; - }; - - IResultCapture& getResultCapture() { - if( IResultCapture* capture = getCurrentContext().getResultCapture() ) - return *capture; - else - throw std::logic_error( "No result capture instance" ); - } - -} // end namespace Catch - -// #included from: internal/catch_version.h -#define TWOBLUECUBES_CATCH_VERSION_H_INCLUDED - -namespace Catch { - - // Versioning information - struct Version { - Version( unsigned int _majorVersion, - unsigned int _minorVersion, - unsigned int _patchNumber, - char const * const _branchName, - unsigned int _buildNumber ); - - unsigned int const majorVersion; - unsigned int const minorVersion; - unsigned int const patchNumber; - - // buildNumber is only used if branchName is not null - char const * const branchName; - unsigned int const buildNumber; - - friend std::ostream& operator << ( std::ostream& os, Version const& version ); - - private: - void operator=( Version const& ); - }; - - inline Version libraryVersion(); -} - -#include -#include -#include - -namespace Catch { - - Ptr createReporter( std::string const& reporterName, Ptr const& config ) { - Ptr reporter = getRegistryHub().getReporterRegistry().create( reporterName, config.get() ); - if( !reporter ) { - std::ostringstream oss; - oss << "No reporter registered with name: '" << reporterName << "'"; - throw std::domain_error( oss.str() ); - } - return reporter; - } - - Ptr makeReporter( Ptr const& config ) { - std::vector reporters = config->getReporterNames(); - if( reporters.empty() ) - reporters.push_back( "console" ); - - Ptr reporter; - for( std::vector::const_iterator it = reporters.begin(), itEnd = reporters.end(); - it != itEnd; - ++it ) - reporter = addReporter( reporter, createReporter( *it, config ) ); - return reporter; - } - Ptr addListeners( Ptr const& config, Ptr reporters ) { - IReporterRegistry::Listeners listeners = getRegistryHub().getReporterRegistry().getListeners(); - for( IReporterRegistry::Listeners::const_iterator it = listeners.begin(), itEnd = listeners.end(); - it != itEnd; - ++it ) - reporters = addReporter(reporters, (*it)->create( ReporterConfig( config ) ) ); - return reporters; - } - - Totals runTests( Ptr const& config ) { - - Ptr iconfig = config.get(); - - Ptr reporter = makeReporter( config ); - reporter = addListeners( iconfig, reporter ); - - RunContext context( iconfig, reporter ); - - Totals totals; - - context.testGroupStarting( config->name(), 1, 1 ); - - TestSpec testSpec = config->testSpec(); - if( !testSpec.hasFilters() ) - testSpec = TestSpecParser( ITagAliasRegistry::get() ).parse( "~[.]" ).testSpec(); // All not hidden tests - - std::vector const& allTestCases = getAllTestCasesSorted( *iconfig ); - for( std::vector::const_iterator it = allTestCases.begin(), itEnd = allTestCases.end(); - it != itEnd; - ++it ) { - if( !context.aborting() && matchTest( *it, testSpec, *iconfig ) ) - totals += context.runTest( *it ); - else - reporter->skipTest( *it ); - } - - context.testGroupEnded( iconfig->name(), totals, 1, 1 ); - return totals; - } - - void applyFilenamesAsTags( IConfig const& config ) { - std::vector const& tests = getAllTestCasesSorted( config ); - for(std::size_t i = 0; i < tests.size(); ++i ) { - TestCase& test = const_cast( tests[i] ); - std::set tags = test.tags; - - std::string filename = test.lineInfo.file; - std::string::size_type lastSlash = filename.find_last_of( "\\/" ); - if( lastSlash != std::string::npos ) - filename = filename.substr( lastSlash+1 ); - - std::string::size_type lastDot = filename.find_last_of( "." ); - if( lastDot != std::string::npos ) - filename = filename.substr( 0, lastDot ); - - tags.insert( "#" + filename ); - setTags( test, tags ); - } - } - - class Session : NonCopyable { - static bool alreadyInstantiated; - - public: - - struct OnUnusedOptions { enum DoWhat { Ignore, Fail }; }; - - Session() - : m_cli( makeCommandLineParser() ) { - if( alreadyInstantiated ) { - std::string msg = "Only one instance of Catch::Session can ever be used"; - Catch::cerr() << msg << std::endl; - throw std::logic_error( msg ); - } - alreadyInstantiated = true; - } - ~Session() { - Catch::cleanUp(); - } - - void showHelp( std::string const& processName ) { - Catch::cout() << "\nCatch v" << libraryVersion() << "\n"; - - m_cli.usage( Catch::cout(), processName ); - Catch::cout() << "For more detail usage please see the project docs\n" << std::endl; - } - - int applyCommandLine( int argc, char const* const* const argv, OnUnusedOptions::DoWhat unusedOptionBehaviour = OnUnusedOptions::Fail ) { - try { - m_cli.setThrowOnUnrecognisedTokens( unusedOptionBehaviour == OnUnusedOptions::Fail ); - m_unusedTokens = m_cli.parseInto( Clara::argsToVector( argc, argv ), m_configData ); - if( m_configData.showHelp ) - showHelp( m_configData.processName ); - m_config.reset(); - } - catch( std::exception& ex ) { - { - Colour colourGuard( Colour::Red ); - Catch::cerr() - << "\nError(s) in input:\n" - << Text( ex.what(), TextAttributes().setIndent(2) ) - << "\n\n"; - } - m_cli.usage( Catch::cout(), m_configData.processName ); - return (std::numeric_limits::max)(); - } - return 0; - } - - void useConfigData( ConfigData const& _configData ) { - m_configData = _configData; - m_config.reset(); - } - - int run( int argc, char const* const* const argv ) { - - int returnCode = applyCommandLine( argc, argv ); - if( returnCode == 0 ) - returnCode = run(); - return returnCode; - } - - #if defined(WIN32) && defined(UNICODE) - int run( int argc, wchar_t const* const* const argv ) { - - char **utf8Argv = new char *[ argc ]; - - for ( int i = 0; i < argc; ++i ) { - int bufSize = WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, NULL, 0, NULL, NULL ); - - utf8Argv[ i ] = new char[ bufSize ]; - - WideCharToMultiByte( CP_UTF8, 0, argv[i], -1, utf8Argv[i], bufSize, NULL, NULL ); - } - - int returnCode = applyCommandLine( argc, utf8Argv ); - if( returnCode == 0 ) - returnCode = run(); - - for ( int i = 0; i < argc; ++i ) - delete [] utf8Argv[ i ]; - - delete [] utf8Argv; - - return returnCode; - } - #endif - - int run() { - if( m_configData.showHelp ) - return 0; - - try - { - config(); // Force config to be constructed - - seedRng( *m_config ); - - if( m_configData.filenamesAsTags ) - applyFilenamesAsTags( *m_config ); - - // Handle list request - if( Option listed = list( config() ) ) - return static_cast( *listed ); - - return static_cast( runTests( m_config ).assertions.failed ); - } - catch( std::exception& ex ) { - Catch::cerr() << ex.what() << std::endl; - return (std::numeric_limits::max)(); - } - } - - Clara::CommandLine const& cli() const { - return m_cli; - } - std::vector const& unusedTokens() const { - return m_unusedTokens; - } - ConfigData& configData() { - return m_configData; - } - Config& config() { - if( !m_config ) - m_config = new Config( m_configData ); - return *m_config; - } - private: - Clara::CommandLine m_cli; - std::vector m_unusedTokens; - ConfigData m_configData; - Ptr m_config; - }; - - bool Session::alreadyInstantiated = false; - -} // end namespace Catch - -// #included from: catch_registry_hub.hpp -#define TWOBLUECUBES_CATCH_REGISTRY_HUB_HPP_INCLUDED - -// #included from: catch_test_case_registry_impl.hpp -#define TWOBLUECUBES_CATCH_TEST_CASE_REGISTRY_IMPL_HPP_INCLUDED - -#include -#include -#include -#include - -namespace Catch { - - struct RandomNumberGenerator { - typedef std::ptrdiff_t result_type; - - result_type operator()( result_type n ) const { return std::rand() % n; } - -#ifdef CATCH_CONFIG_CPP11_SHUFFLE - static constexpr result_type min() { return 0; } - static constexpr result_type max() { return 1000000; } - result_type operator()() const { return std::rand() % max(); } -#endif - template - static void shuffle( V& vector ) { - RandomNumberGenerator rng; -#ifdef CATCH_CONFIG_CPP11_SHUFFLE - std::shuffle( vector.begin(), vector.end(), rng ); -#else - std::random_shuffle( vector.begin(), vector.end(), rng ); -#endif - } - }; - - inline std::vector sortTests( IConfig const& config, std::vector const& unsortedTestCases ) { - - std::vector sorted = unsortedTestCases; - - switch( config.runOrder() ) { - case RunTests::InLexicographicalOrder: - std::sort( sorted.begin(), sorted.end() ); - break; - case RunTests::InRandomOrder: - { - seedRng( config ); - RandomNumberGenerator::shuffle( sorted ); - } - break; - case RunTests::InDeclarationOrder: - // already in declaration order - break; - } - return sorted; - } - bool matchTest( TestCase const& testCase, TestSpec const& testSpec, IConfig const& config ) { - return testSpec.matches( testCase ) && ( config.allowThrows() || !testCase.throws() ); - } - - void enforceNoDuplicateTestCases( std::vector const& functions ) { - std::set seenFunctions; - for( std::vector::const_iterator it = functions.begin(), itEnd = functions.end(); - it != itEnd; - ++it ) { - std::pair::const_iterator, bool> prev = seenFunctions.insert( *it ); - if( !prev.second ) { - std::ostringstream ss; - - ss << Colour( Colour::Red ) - << "error: TEST_CASE( \"" << it->name << "\" ) already defined.\n" - << "\tFirst seen at " << prev.first->getTestCaseInfo().lineInfo << '\n' - << "\tRedefined at " << it->getTestCaseInfo().lineInfo << std::endl; - - throw std::runtime_error(ss.str()); - } - } - } - - std::vector filterTests( std::vector const& testCases, TestSpec const& testSpec, IConfig const& config ) { - std::vector filtered; - filtered.reserve( testCases.size() ); - for( std::vector::const_iterator it = testCases.begin(), itEnd = testCases.end(); - it != itEnd; - ++it ) - if( matchTest( *it, testSpec, config ) ) - filtered.push_back( *it ); - return filtered; - } - std::vector const& getAllTestCasesSorted( IConfig const& config ) { - return getRegistryHub().getTestCaseRegistry().getAllTestsSorted( config ); - } - - class TestRegistry : public ITestCaseRegistry { - public: - TestRegistry() - : m_currentSortOrder( RunTests::InDeclarationOrder ), - m_unnamedCount( 0 ) - {} - virtual ~TestRegistry(); - - virtual void registerTest( TestCase const& testCase ) { - std::string name = testCase.getTestCaseInfo().name; - if( name.empty() ) { - std::ostringstream oss; - oss << "Anonymous test case " << ++m_unnamedCount; - return registerTest( testCase.withName( oss.str() ) ); - } - m_functions.push_back( testCase ); - } - - virtual std::vector const& getAllTests() const { - return m_functions; - } - virtual std::vector const& getAllTestsSorted( IConfig const& config ) const { - if( m_sortedFunctions.empty() ) - enforceNoDuplicateTestCases( m_functions ); - - if( m_currentSortOrder != config.runOrder() || m_sortedFunctions.empty() ) { - m_sortedFunctions = sortTests( config, m_functions ); - m_currentSortOrder = config.runOrder(); - } - return m_sortedFunctions; - } - - private: - std::vector m_functions; - mutable RunTests::InWhatOrder m_currentSortOrder; - mutable std::vector m_sortedFunctions; - size_t m_unnamedCount; - std::ios_base::Init m_ostreamInit; // Forces cout/ cerr to be initialised - }; - - /////////////////////////////////////////////////////////////////////////// - - class FreeFunctionTestCase : public SharedImpl { - public: - - FreeFunctionTestCase( TestFunction fun ) : m_fun( fun ) {} - - virtual void invoke() const { - m_fun(); - } - - private: - virtual ~FreeFunctionTestCase(); - - TestFunction m_fun; - }; - - inline std::string extractClassName( std::string const& classOrQualifiedMethodName ) { - std::string className = classOrQualifiedMethodName; - if( startsWith( className, '&' ) ) - { - std::size_t lastColons = className.rfind( "::" ); - std::size_t penultimateColons = className.rfind( "::", lastColons-1 ); - if( penultimateColons == std::string::npos ) - penultimateColons = 1; - className = className.substr( penultimateColons, lastColons-penultimateColons ); - } - return className; - } - - void registerTestCase - ( ITestCase* testCase, - char const* classOrQualifiedMethodName, - NameAndDesc const& nameAndDesc, - SourceLineInfo const& lineInfo ) { - - getMutableRegistryHub().registerTest - ( makeTestCase - ( testCase, - extractClassName( classOrQualifiedMethodName ), - nameAndDesc.name, - nameAndDesc.description, - lineInfo ) ); - } - void registerTestCaseFunction - ( TestFunction function, - SourceLineInfo const& lineInfo, - NameAndDesc const& nameAndDesc ) { - registerTestCase( new FreeFunctionTestCase( function ), "", nameAndDesc, lineInfo ); - } - - /////////////////////////////////////////////////////////////////////////// - - AutoReg::AutoReg - ( TestFunction function, - SourceLineInfo const& lineInfo, - NameAndDesc const& nameAndDesc ) { - registerTestCaseFunction( function, lineInfo, nameAndDesc ); - } - - AutoReg::~AutoReg() {} - -} // end namespace Catch - -// #included from: catch_reporter_registry.hpp -#define TWOBLUECUBES_CATCH_REPORTER_REGISTRY_HPP_INCLUDED - -#include - -namespace Catch { - - class ReporterRegistry : public IReporterRegistry { - - public: - - virtual ~ReporterRegistry() CATCH_OVERRIDE {} - - virtual IStreamingReporter* create( std::string const& name, Ptr const& config ) const CATCH_OVERRIDE { - FactoryMap::const_iterator it = m_factories.find( name ); - if( it == m_factories.end() ) - return CATCH_NULL; - return it->second->create( ReporterConfig( config ) ); - } - - void registerReporter( std::string const& name, Ptr const& factory ) { - m_factories.insert( std::make_pair( name, factory ) ); - } - void registerListener( Ptr const& factory ) { - m_listeners.push_back( factory ); - } - - virtual FactoryMap const& getFactories() const CATCH_OVERRIDE { - return m_factories; - } - virtual Listeners const& getListeners() const CATCH_OVERRIDE { - return m_listeners; - } - - private: - FactoryMap m_factories; - Listeners m_listeners; - }; -} - -// #included from: catch_exception_translator_registry.hpp -#define TWOBLUECUBES_CATCH_EXCEPTION_TRANSLATOR_REGISTRY_HPP_INCLUDED - -#ifdef __OBJC__ -#import "Foundation/Foundation.h" -#endif - -namespace Catch { - - class ExceptionTranslatorRegistry : public IExceptionTranslatorRegistry { - public: - ~ExceptionTranslatorRegistry() { - deleteAll( m_translators ); - } - - virtual void registerTranslator( const IExceptionTranslator* translator ) { - m_translators.push_back( translator ); - } - - virtual std::string translateActiveException() const { - try { -#ifdef __OBJC__ - // In Objective-C try objective-c exceptions first - @try { - return tryTranslators(); - } - @catch (NSException *exception) { - return Catch::toString( [exception description] ); - } -#else - return tryTranslators(); -#endif - } - catch( TestFailureException& ) { - throw; - } - catch( std::exception& ex ) { - return ex.what(); - } - catch( std::string& msg ) { - return msg; - } - catch( const char* msg ) { - return msg; - } - catch(...) { - return "Unknown exception"; - } - } - - std::string tryTranslators() const { - if( m_translators.empty() ) - throw; - else - return m_translators[0]->translate( m_translators.begin()+1, m_translators.end() ); - } - - private: - std::vector m_translators; - }; -} - -// #included from: catch_tag_alias_registry.h -#define TWOBLUECUBES_CATCH_TAG_ALIAS_REGISTRY_H_INCLUDED - -#include - -namespace Catch { - - class TagAliasRegistry : public ITagAliasRegistry { - public: - virtual ~TagAliasRegistry(); - virtual Option find( std::string const& alias ) const; - virtual std::string expandAliases( std::string const& unexpandedTestSpec ) const; - void add( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ); - - private: - std::map m_registry; - }; - -} // end namespace Catch - -namespace Catch { - - namespace { - - class RegistryHub : public IRegistryHub, public IMutableRegistryHub { - - RegistryHub( RegistryHub const& ); - void operator=( RegistryHub const& ); - - public: // IRegistryHub - RegistryHub() { - } - virtual IReporterRegistry const& getReporterRegistry() const CATCH_OVERRIDE { - return m_reporterRegistry; - } - virtual ITestCaseRegistry const& getTestCaseRegistry() const CATCH_OVERRIDE { - return m_testCaseRegistry; - } - virtual IExceptionTranslatorRegistry& getExceptionTranslatorRegistry() CATCH_OVERRIDE { - return m_exceptionTranslatorRegistry; - } - virtual ITagAliasRegistry const& getTagAliasRegistry() const CATCH_OVERRIDE { - return m_tagAliasRegistry; - } - - public: // IMutableRegistryHub - virtual void registerReporter( std::string const& name, Ptr const& factory ) CATCH_OVERRIDE { - m_reporterRegistry.registerReporter( name, factory ); - } - virtual void registerListener( Ptr const& factory ) CATCH_OVERRIDE { - m_reporterRegistry.registerListener( factory ); - } - virtual void registerTest( TestCase const& testInfo ) CATCH_OVERRIDE { - m_testCaseRegistry.registerTest( testInfo ); - } - virtual void registerTranslator( const IExceptionTranslator* translator ) CATCH_OVERRIDE { - m_exceptionTranslatorRegistry.registerTranslator( translator ); - } - virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) CATCH_OVERRIDE { - m_tagAliasRegistry.add( alias, tag, lineInfo ); - } - - private: - TestRegistry m_testCaseRegistry; - ReporterRegistry m_reporterRegistry; - ExceptionTranslatorRegistry m_exceptionTranslatorRegistry; - TagAliasRegistry m_tagAliasRegistry; - }; - - // Single, global, instance - inline RegistryHub*& getTheRegistryHub() { - static RegistryHub* theRegistryHub = CATCH_NULL; - if( !theRegistryHub ) - theRegistryHub = new RegistryHub(); - return theRegistryHub; - } - } - - IRegistryHub& getRegistryHub() { - return *getTheRegistryHub(); - } - IMutableRegistryHub& getMutableRegistryHub() { - return *getTheRegistryHub(); - } - void cleanUp() { - delete getTheRegistryHub(); - getTheRegistryHub() = CATCH_NULL; - cleanUpContext(); - } - std::string translateActiveException() { - return getRegistryHub().getExceptionTranslatorRegistry().translateActiveException(); - } - -} // end namespace Catch - -// #included from: catch_notimplemented_exception.hpp -#define TWOBLUECUBES_CATCH_NOTIMPLEMENTED_EXCEPTION_HPP_INCLUDED - -#include - -namespace Catch { - - NotImplementedException::NotImplementedException( SourceLineInfo const& lineInfo ) - : m_lineInfo( lineInfo ) { - std::ostringstream oss; - oss << lineInfo << ": function "; - oss << "not implemented"; - m_what = oss.str(); - } - - const char* NotImplementedException::what() const CATCH_NOEXCEPT { - return m_what.c_str(); - } - -} // end namespace Catch - -// #included from: catch_context_impl.hpp -#define TWOBLUECUBES_CATCH_CONTEXT_IMPL_HPP_INCLUDED - -// #included from: catch_stream.hpp -#define TWOBLUECUBES_CATCH_STREAM_HPP_INCLUDED - -#include -#include -#include - -namespace Catch { - - template - class StreamBufImpl : public StreamBufBase { - char data[bufferSize]; - WriterF m_writer; - - public: - StreamBufImpl() { - setp( data, data + sizeof(data) ); - } - - ~StreamBufImpl() CATCH_NOEXCEPT { - sync(); - } - - private: - int overflow( int c ) { - sync(); - - if( c != EOF ) { - if( pbase() == epptr() ) - m_writer( std::string( 1, static_cast( c ) ) ); - else - sputc( static_cast( c ) ); - } - return 0; - } - - int sync() { - if( pbase() != pptr() ) { - m_writer( std::string( pbase(), static_cast( pptr() - pbase() ) ) ); - setp( pbase(), epptr() ); - } - return 0; - } - }; - - /////////////////////////////////////////////////////////////////////////// - - FileStream::FileStream( std::string const& filename ) { - m_ofs.open( filename.c_str() ); - if( m_ofs.fail() ) { - std::ostringstream oss; - oss << "Unable to open file: '" << filename << '\''; - throw std::domain_error( oss.str() ); - } - } - - std::ostream& FileStream::stream() const { - return m_ofs; - } - - struct OutputDebugWriter { - - void operator()( std::string const&str ) { - writeToDebugConsole( str ); - } - }; - - DebugOutStream::DebugOutStream() - : m_streamBuf( new StreamBufImpl() ), - m_os( m_streamBuf.get() ) - {} - - std::ostream& DebugOutStream::stream() const { - return m_os; - } - - // Store the streambuf from cout up-front because - // cout may get redirected when running tests - CoutStream::CoutStream() - : m_os( Catch::cout().rdbuf() ) - {} - - std::ostream& CoutStream::stream() const { - return m_os; - } - -#ifndef CATCH_CONFIG_NOSTDOUT // If you #define this you must implement these functions - std::ostream& cout() { - return std::cout; - } - std::ostream& cerr() { - return std::cerr; - } -#endif -} - -namespace Catch { - - class Context : public IMutableContext { - - Context() : m_config( CATCH_NULL ), m_runner( CATCH_NULL ), m_resultCapture( CATCH_NULL ) {} - Context( Context const& ); - void operator=( Context const& ); - - public: - virtual ~Context() { - deleteAllValues( m_generatorsByTestName ); - } - - public: // IContext - virtual IResultCapture* getResultCapture() { - return m_resultCapture; - } - virtual IRunner* getRunner() { - return m_runner; - } - virtual size_t getGeneratorIndex( std::string const& fileInfo, size_t totalSize ) { - return getGeneratorsForCurrentTest() - .getGeneratorInfo( fileInfo, totalSize ) - .getCurrentIndex(); - } - virtual bool advanceGeneratorsForCurrentTest() { - IGeneratorsForTest* generators = findGeneratorsForCurrentTest(); - return generators && generators->moveNext(); - } - - virtual Ptr getConfig() const { - return m_config; - } - - public: // IMutableContext - virtual void setResultCapture( IResultCapture* resultCapture ) { - m_resultCapture = resultCapture; - } - virtual void setRunner( IRunner* runner ) { - m_runner = runner; - } - virtual void setConfig( Ptr const& config ) { - m_config = config; - } - - friend IMutableContext& getCurrentMutableContext(); - - private: - IGeneratorsForTest* findGeneratorsForCurrentTest() { - std::string testName = getResultCapture()->getCurrentTestName(); - - std::map::const_iterator it = - m_generatorsByTestName.find( testName ); - return it != m_generatorsByTestName.end() - ? it->second - : CATCH_NULL; - } - - IGeneratorsForTest& getGeneratorsForCurrentTest() { - IGeneratorsForTest* generators = findGeneratorsForCurrentTest(); - if( !generators ) { - std::string testName = getResultCapture()->getCurrentTestName(); - generators = createGeneratorsForTest(); - m_generatorsByTestName.insert( std::make_pair( testName, generators ) ); - } - return *generators; - } - - private: - Ptr m_config; - IRunner* m_runner; - IResultCapture* m_resultCapture; - std::map m_generatorsByTestName; - }; - - namespace { - Context* currentContext = CATCH_NULL; - } - IMutableContext& getCurrentMutableContext() { - if( !currentContext ) - currentContext = new Context(); - return *currentContext; - } - IContext& getCurrentContext() { - return getCurrentMutableContext(); - } - - void cleanUpContext() { - delete currentContext; - currentContext = CATCH_NULL; - } -} - -// #included from: catch_console_colour_impl.hpp -#define TWOBLUECUBES_CATCH_CONSOLE_COLOUR_IMPL_HPP_INCLUDED - -// #included from: catch_errno_guard.hpp -#define TWOBLUECUBES_CATCH_ERRNO_GUARD_HPP_INCLUDED - -#include - -namespace Catch { - - class ErrnoGuard { - public: - ErrnoGuard():m_oldErrno(errno){} - ~ErrnoGuard() { errno = m_oldErrno; } - private: - int m_oldErrno; - }; - -} - -namespace Catch { - namespace { - - struct IColourImpl { - virtual ~IColourImpl() {} - virtual void use( Colour::Code _colourCode ) = 0; - }; - - struct NoColourImpl : IColourImpl { - void use( Colour::Code ) {} - - static IColourImpl* instance() { - static NoColourImpl s_instance; - return &s_instance; - } - }; - - } // anon namespace -} // namespace Catch - -#if !defined( CATCH_CONFIG_COLOUR_NONE ) && !defined( CATCH_CONFIG_COLOUR_WINDOWS ) && !defined( CATCH_CONFIG_COLOUR_ANSI ) -# ifdef CATCH_PLATFORM_WINDOWS -# define CATCH_CONFIG_COLOUR_WINDOWS -# else -# define CATCH_CONFIG_COLOUR_ANSI -# endif -#endif - -#if defined ( CATCH_CONFIG_COLOUR_WINDOWS ) ///////////////////////////////////////// - -namespace Catch { -namespace { - - class Win32ColourImpl : public IColourImpl { - public: - Win32ColourImpl() : stdoutHandle( GetStdHandle(STD_OUTPUT_HANDLE) ) - { - CONSOLE_SCREEN_BUFFER_INFO csbiInfo; - GetConsoleScreenBufferInfo( stdoutHandle, &csbiInfo ); - originalForegroundAttributes = csbiInfo.wAttributes & ~( BACKGROUND_GREEN | BACKGROUND_RED | BACKGROUND_BLUE | BACKGROUND_INTENSITY ); - originalBackgroundAttributes = csbiInfo.wAttributes & ~( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY ); - } - - virtual void use( Colour::Code _colourCode ) { - switch( _colourCode ) { - case Colour::None: return setTextAttribute( originalForegroundAttributes ); - case Colour::White: return setTextAttribute( FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE ); - case Colour::Red: return setTextAttribute( FOREGROUND_RED ); - case Colour::Green: return setTextAttribute( FOREGROUND_GREEN ); - case Colour::Blue: return setTextAttribute( FOREGROUND_BLUE ); - case Colour::Cyan: return setTextAttribute( FOREGROUND_BLUE | FOREGROUND_GREEN ); - case Colour::Yellow: return setTextAttribute( FOREGROUND_RED | FOREGROUND_GREEN ); - case Colour::Grey: return setTextAttribute( 0 ); - - case Colour::LightGrey: return setTextAttribute( FOREGROUND_INTENSITY ); - case Colour::BrightRed: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_RED ); - case Colour::BrightGreen: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN ); - case Colour::BrightWhite: return setTextAttribute( FOREGROUND_INTENSITY | FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE ); - - case Colour::Bright: throw std::logic_error( "not a colour" ); - } - } - - private: - void setTextAttribute( WORD _textAttribute ) { - SetConsoleTextAttribute( stdoutHandle, _textAttribute | originalBackgroundAttributes ); - } - HANDLE stdoutHandle; - WORD originalForegroundAttributes; - WORD originalBackgroundAttributes; - }; - - IColourImpl* platformColourInstance() { - static Win32ColourImpl s_instance; - - Ptr config = getCurrentContext().getConfig(); - UseColour::YesOrNo colourMode = config - ? config->useColour() - : UseColour::Auto; - if( colourMode == UseColour::Auto ) - colourMode = !isDebuggerActive() - ? UseColour::Yes - : UseColour::No; - return colourMode == UseColour::Yes - ? &s_instance - : NoColourImpl::instance(); - } - -} // end anon namespace -} // end namespace Catch - -#elif defined( CATCH_CONFIG_COLOUR_ANSI ) ////////////////////////////////////// - -#include - -namespace Catch { -namespace { - - // use POSIX/ ANSI console terminal codes - // Thanks to Adam Strzelecki for original contribution - // (http://github.com/nanoant) - // https://github.com/philsquared/Catch/pull/131 - class PosixColourImpl : public IColourImpl { - public: - virtual void use( Colour::Code _colourCode ) { - switch( _colourCode ) { - case Colour::None: - case Colour::White: return setColour( "[0m" ); - case Colour::Red: return setColour( "[0;31m" ); - case Colour::Green: return setColour( "[0;32m" ); - case Colour::Blue: return setColour( "[0;34m" ); - case Colour::Cyan: return setColour( "[0;36m" ); - case Colour::Yellow: return setColour( "[0;33m" ); - case Colour::Grey: return setColour( "[1;30m" ); - - case Colour::LightGrey: return setColour( "[0;37m" ); - case Colour::BrightRed: return setColour( "[1;31m" ); - case Colour::BrightGreen: return setColour( "[1;32m" ); - case Colour::BrightWhite: return setColour( "[1;37m" ); - - case Colour::Bright: throw std::logic_error( "not a colour" ); - } - } - static IColourImpl* instance() { - static PosixColourImpl s_instance; - return &s_instance; - } - - private: - void setColour( const char* _escapeCode ) { - Catch::cout() << '\033' << _escapeCode; - } - }; - - IColourImpl* platformColourInstance() { - ErrnoGuard guard; - Ptr config = getCurrentContext().getConfig(); - UseColour::YesOrNo colourMode = config - ? config->useColour() - : UseColour::Auto; - if( colourMode == UseColour::Auto ) - colourMode = (!isDebuggerActive() && isatty(STDOUT_FILENO) ) - ? UseColour::Yes - : UseColour::No; - return colourMode == UseColour::Yes - ? PosixColourImpl::instance() - : NoColourImpl::instance(); - } - -} // end anon namespace -} // end namespace Catch - -#else // not Windows or ANSI /////////////////////////////////////////////// - -namespace Catch { - - static IColourImpl* platformColourInstance() { return NoColourImpl::instance(); } - -} // end namespace Catch - -#endif // Windows/ ANSI/ None - -namespace Catch { - - Colour::Colour( Code _colourCode ) : m_moved( false ) { use( _colourCode ); } - Colour::Colour( Colour const& _other ) : m_moved( false ) { const_cast( _other ).m_moved = true; } - Colour::~Colour(){ if( !m_moved ) use( None ); } - - void Colour::use( Code _colourCode ) { - static IColourImpl* impl = platformColourInstance(); - impl->use( _colourCode ); - } - -} // end namespace Catch - -// #included from: catch_generators_impl.hpp -#define TWOBLUECUBES_CATCH_GENERATORS_IMPL_HPP_INCLUDED - -#include -#include -#include - -namespace Catch { - - struct GeneratorInfo : IGeneratorInfo { - - GeneratorInfo( std::size_t size ) - : m_size( size ), - m_currentIndex( 0 ) - {} - - bool moveNext() { - if( ++m_currentIndex == m_size ) { - m_currentIndex = 0; - return false; - } - return true; - } - - std::size_t getCurrentIndex() const { - return m_currentIndex; - } - - std::size_t m_size; - std::size_t m_currentIndex; - }; - - /////////////////////////////////////////////////////////////////////////// - - class GeneratorsForTest : public IGeneratorsForTest { - - public: - ~GeneratorsForTest() { - deleteAll( m_generatorsInOrder ); - } - - IGeneratorInfo& getGeneratorInfo( std::string const& fileInfo, std::size_t size ) { - std::map::const_iterator it = m_generatorsByName.find( fileInfo ); - if( it == m_generatorsByName.end() ) { - IGeneratorInfo* info = new GeneratorInfo( size ); - m_generatorsByName.insert( std::make_pair( fileInfo, info ) ); - m_generatorsInOrder.push_back( info ); - return *info; - } - return *it->second; - } - - bool moveNext() { - std::vector::const_iterator it = m_generatorsInOrder.begin(); - std::vector::const_iterator itEnd = m_generatorsInOrder.end(); - for(; it != itEnd; ++it ) { - if( (*it)->moveNext() ) - return true; - } - return false; - } - - private: - std::map m_generatorsByName; - std::vector m_generatorsInOrder; - }; - - IGeneratorsForTest* createGeneratorsForTest() - { - return new GeneratorsForTest(); - } - -} // end namespace Catch - -// #included from: catch_assertionresult.hpp -#define TWOBLUECUBES_CATCH_ASSERTIONRESULT_HPP_INCLUDED - -namespace Catch { - - AssertionInfo::AssertionInfo( char const * _macroName, - SourceLineInfo const& _lineInfo, - char const * _capturedExpression, - ResultDisposition::Flags _resultDisposition, - char const * _secondArg) - : macroName( _macroName ), - lineInfo( _lineInfo ), - capturedExpression( _capturedExpression ), - resultDisposition( _resultDisposition ), - secondArg( _secondArg ) - {} - - AssertionResult::AssertionResult() {} - - AssertionResult::AssertionResult( AssertionInfo const& info, AssertionResultData const& data ) - : m_info( info ), - m_resultData( data ) - {} - - AssertionResult::~AssertionResult() {} - - // Result was a success - bool AssertionResult::succeeded() const { - return Catch::isOk( m_resultData.resultType ); - } - - // Result was a success, or failure is suppressed - bool AssertionResult::isOk() const { - return Catch::isOk( m_resultData.resultType ) || shouldSuppressFailure( m_info.resultDisposition ); - } - - ResultWas::OfType AssertionResult::getResultType() const { - return m_resultData.resultType; - } - - bool AssertionResult::hasExpression() const { - return m_info.capturedExpression[0] != 0; - } - - bool AssertionResult::hasMessage() const { - return !m_resultData.message.empty(); - } - - std::string capturedExpressionWithSecondArgument( char const * capturedExpression, char const * secondArg ) { - return (secondArg[0] == 0 || secondArg[0] == '"' && secondArg[1] == '"') - ? capturedExpression - : std::string(capturedExpression) + ", " + secondArg; - } - - std::string AssertionResult::getExpression() const { - if( isFalseTest( m_info.resultDisposition ) ) - return '!' + capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg); - else - return capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg); - } - std::string AssertionResult::getExpressionInMacro() const { - if( m_info.macroName[0] == 0 ) - return capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg); - else - return std::string(m_info.macroName) + "( " + capturedExpressionWithSecondArgument(m_info.capturedExpression, m_info.secondArg) + " )"; - } - - bool AssertionResult::hasExpandedExpression() const { - return hasExpression() && getExpandedExpression() != getExpression(); - } - - std::string AssertionResult::getExpandedExpression() const { - return m_resultData.reconstructExpression(); - } - - std::string AssertionResult::getMessage() const { - return m_resultData.message; - } - SourceLineInfo AssertionResult::getSourceInfo() const { - return m_info.lineInfo; - } - - std::string AssertionResult::getTestMacroName() const { - return m_info.macroName; - } - - void AssertionResult::discardDecomposedExpression() const { - m_resultData.decomposedExpression = CATCH_NULL; - } - - void AssertionResult::expandDecomposedExpression() const { - m_resultData.reconstructExpression(); - } - -} // end namespace Catch - -// #included from: catch_test_case_info.hpp -#define TWOBLUECUBES_CATCH_TEST_CASE_INFO_HPP_INCLUDED - -#include - -namespace Catch { - - inline TestCaseInfo::SpecialProperties parseSpecialTag( std::string const& tag ) { - if( startsWith( tag, '.' ) || - tag == "hide" || - tag == "!hide" ) - return TestCaseInfo::IsHidden; - else if( tag == "!throws" ) - return TestCaseInfo::Throws; - else if( tag == "!shouldfail" ) - return TestCaseInfo::ShouldFail; - else if( tag == "!mayfail" ) - return TestCaseInfo::MayFail; - else if( tag == "!nonportable" ) - return TestCaseInfo::NonPortable; - else - return TestCaseInfo::None; - } - inline bool isReservedTag( std::string const& tag ) { - return parseSpecialTag( tag ) == TestCaseInfo::None && tag.size() > 0 && !std::isalnum( tag[0] ); - } - inline void enforceNotReservedTag( std::string const& tag, SourceLineInfo const& _lineInfo ) { - if( isReservedTag( tag ) ) { - std::ostringstream ss; - ss << Colour(Colour::Red) - << "Tag name [" << tag << "] not allowed.\n" - << "Tag names starting with non alpha-numeric characters are reserved\n" - << Colour(Colour::FileName) - << _lineInfo << '\n'; - throw std::runtime_error(ss.str()); - } - } - - TestCase makeTestCase( ITestCase* _testCase, - std::string const& _className, - std::string const& _name, - std::string const& _descOrTags, - SourceLineInfo const& _lineInfo ) - { - bool isHidden( startsWith( _name, "./" ) ); // Legacy support - - // Parse out tags - std::set tags; - std::string desc, tag; - bool inTag = false; - for( std::size_t i = 0; i < _descOrTags.size(); ++i ) { - char c = _descOrTags[i]; - if( !inTag ) { - if( c == '[' ) - inTag = true; - else - desc += c; - } - else { - if( c == ']' ) { - TestCaseInfo::SpecialProperties prop = parseSpecialTag( tag ); - if( prop == TestCaseInfo::IsHidden ) - isHidden = true; - else if( prop == TestCaseInfo::None ) - enforceNotReservedTag( tag, _lineInfo ); - - tags.insert( tag ); - tag.clear(); - inTag = false; - } - else - tag += c; - } - } - if( isHidden ) { - tags.insert( "hide" ); - tags.insert( "." ); - } - - TestCaseInfo info( _name, _className, desc, tags, _lineInfo ); - return TestCase( _testCase, info ); - } - - void setTags( TestCaseInfo& testCaseInfo, std::set const& tags ) - { - testCaseInfo.tags = tags; - testCaseInfo.lcaseTags.clear(); - - std::ostringstream oss; - for( std::set::const_iterator it = tags.begin(), itEnd = tags.end(); it != itEnd; ++it ) { - oss << '[' << *it << ']'; - std::string lcaseTag = toLower( *it ); - testCaseInfo.properties = static_cast( testCaseInfo.properties | parseSpecialTag( lcaseTag ) ); - testCaseInfo.lcaseTags.insert( lcaseTag ); - } - testCaseInfo.tagsAsString = oss.str(); - } - - TestCaseInfo::TestCaseInfo( std::string const& _name, - std::string const& _className, - std::string const& _description, - std::set const& _tags, - SourceLineInfo const& _lineInfo ) - : name( _name ), - className( _className ), - description( _description ), - lineInfo( _lineInfo ), - properties( None ) - { - setTags( *this, _tags ); - } - - TestCaseInfo::TestCaseInfo( TestCaseInfo const& other ) - : name( other.name ), - className( other.className ), - description( other.description ), - tags( other.tags ), - lcaseTags( other.lcaseTags ), - tagsAsString( other.tagsAsString ), - lineInfo( other.lineInfo ), - properties( other.properties ) - {} - - bool TestCaseInfo::isHidden() const { - return ( properties & IsHidden ) != 0; - } - bool TestCaseInfo::throws() const { - return ( properties & Throws ) != 0; - } - bool TestCaseInfo::okToFail() const { - return ( properties & (ShouldFail | MayFail ) ) != 0; - } - bool TestCaseInfo::expectedToFail() const { - return ( properties & (ShouldFail ) ) != 0; - } - - TestCase::TestCase( ITestCase* testCase, TestCaseInfo const& info ) : TestCaseInfo( info ), test( testCase ) {} - - TestCase::TestCase( TestCase const& other ) - : TestCaseInfo( other ), - test( other.test ) - {} - - TestCase TestCase::withName( std::string const& _newName ) const { - TestCase other( *this ); - other.name = _newName; - return other; - } - - void TestCase::swap( TestCase& other ) { - test.swap( other.test ); - name.swap( other.name ); - className.swap( other.className ); - description.swap( other.description ); - tags.swap( other.tags ); - lcaseTags.swap( other.lcaseTags ); - tagsAsString.swap( other.tagsAsString ); - std::swap( TestCaseInfo::properties, static_cast( other ).properties ); - std::swap( lineInfo, other.lineInfo ); - } - - void TestCase::invoke() const { - test->invoke(); - } - - bool TestCase::operator == ( TestCase const& other ) const { - return test.get() == other.test.get() && - name == other.name && - className == other.className; - } - - bool TestCase::operator < ( TestCase const& other ) const { - return name < other.name; - } - TestCase& TestCase::operator = ( TestCase const& other ) { - TestCase temp( other ); - swap( temp ); - return *this; - } - - TestCaseInfo const& TestCase::getTestCaseInfo() const - { - return *this; - } - -} // end namespace Catch - -// #included from: catch_version.hpp -#define TWOBLUECUBES_CATCH_VERSION_HPP_INCLUDED - -namespace Catch { - - Version::Version - ( unsigned int _majorVersion, - unsigned int _minorVersion, - unsigned int _patchNumber, - char const * const _branchName, - unsigned int _buildNumber ) - : majorVersion( _majorVersion ), - minorVersion( _minorVersion ), - patchNumber( _patchNumber ), - branchName( _branchName ), - buildNumber( _buildNumber ) - {} - - std::ostream& operator << ( std::ostream& os, Version const& version ) { - os << version.majorVersion << '.' - << version.minorVersion << '.' - << version.patchNumber; - // branchName is never null -> 0th char is \0 if it is empty - if (version.branchName[0]) { - os << '-' << version.branchName - << '.' << version.buildNumber; - } - return os; - } - - inline Version libraryVersion() { - static Version version( 1, 9, 6, "", 0 ); - return version; - } - -} - -// #included from: catch_message.hpp -#define TWOBLUECUBES_CATCH_MESSAGE_HPP_INCLUDED - -namespace Catch { - - MessageInfo::MessageInfo( std::string const& _macroName, - SourceLineInfo const& _lineInfo, - ResultWas::OfType _type ) - : macroName( _macroName ), - lineInfo( _lineInfo ), - type( _type ), - sequence( ++globalCount ) - {} - - // This may need protecting if threading support is added - unsigned int MessageInfo::globalCount = 0; - - //////////////////////////////////////////////////////////////////////////// - - ScopedMessage::ScopedMessage( MessageBuilder const& builder ) - : m_info( builder.m_info ) - { - m_info.message = builder.m_stream.str(); - getResultCapture().pushScopedMessage( m_info ); - } - ScopedMessage::ScopedMessage( ScopedMessage const& other ) - : m_info( other.m_info ) - {} - - ScopedMessage::~ScopedMessage() { - if ( !std::uncaught_exception() ){ - getResultCapture().popScopedMessage(m_info); - } - } - -} // end namespace Catch - -// #included from: catch_legacy_reporter_adapter.hpp -#define TWOBLUECUBES_CATCH_LEGACY_REPORTER_ADAPTER_HPP_INCLUDED - -// #included from: catch_legacy_reporter_adapter.h -#define TWOBLUECUBES_CATCH_LEGACY_REPORTER_ADAPTER_H_INCLUDED - -namespace Catch -{ - // Deprecated - struct IReporter : IShared { - virtual ~IReporter(); - - virtual bool shouldRedirectStdout() const = 0; - - virtual void StartTesting() = 0; - virtual void EndTesting( Totals const& totals ) = 0; - virtual void StartGroup( std::string const& groupName ) = 0; - virtual void EndGroup( std::string const& groupName, Totals const& totals ) = 0; - virtual void StartTestCase( TestCaseInfo const& testInfo ) = 0; - virtual void EndTestCase( TestCaseInfo const& testInfo, Totals const& totals, std::string const& stdOut, std::string const& stdErr ) = 0; - virtual void StartSection( std::string const& sectionName, std::string const& description ) = 0; - virtual void EndSection( std::string const& sectionName, Counts const& assertions ) = 0; - virtual void NoAssertionsInSection( std::string const& sectionName ) = 0; - virtual void NoAssertionsInTestCase( std::string const& testName ) = 0; - virtual void Aborted() = 0; - virtual void Result( AssertionResult const& result ) = 0; - }; - - class LegacyReporterAdapter : public SharedImpl - { - public: - LegacyReporterAdapter( Ptr const& legacyReporter ); - virtual ~LegacyReporterAdapter(); - - virtual ReporterPreferences getPreferences() const; - virtual void noMatchingTestCases( std::string const& ); - virtual void testRunStarting( TestRunInfo const& ); - virtual void testGroupStarting( GroupInfo const& groupInfo ); - virtual void testCaseStarting( TestCaseInfo const& testInfo ); - virtual void sectionStarting( SectionInfo const& sectionInfo ); - virtual void assertionStarting( AssertionInfo const& ); - virtual bool assertionEnded( AssertionStats const& assertionStats ); - virtual void sectionEnded( SectionStats const& sectionStats ); - virtual void testCaseEnded( TestCaseStats const& testCaseStats ); - virtual void testGroupEnded( TestGroupStats const& testGroupStats ); - virtual void testRunEnded( TestRunStats const& testRunStats ); - virtual void skipTest( TestCaseInfo const& ); - - private: - Ptr m_legacyReporter; - }; -} - -namespace Catch -{ - LegacyReporterAdapter::LegacyReporterAdapter( Ptr const& legacyReporter ) - : m_legacyReporter( legacyReporter ) - {} - LegacyReporterAdapter::~LegacyReporterAdapter() {} - - ReporterPreferences LegacyReporterAdapter::getPreferences() const { - ReporterPreferences prefs; - prefs.shouldRedirectStdOut = m_legacyReporter->shouldRedirectStdout(); - return prefs; - } - - void LegacyReporterAdapter::noMatchingTestCases( std::string const& ) {} - void LegacyReporterAdapter::testRunStarting( TestRunInfo const& ) { - m_legacyReporter->StartTesting(); - } - void LegacyReporterAdapter::testGroupStarting( GroupInfo const& groupInfo ) { - m_legacyReporter->StartGroup( groupInfo.name ); - } - void LegacyReporterAdapter::testCaseStarting( TestCaseInfo const& testInfo ) { - m_legacyReporter->StartTestCase( testInfo ); - } - void LegacyReporterAdapter::sectionStarting( SectionInfo const& sectionInfo ) { - m_legacyReporter->StartSection( sectionInfo.name, sectionInfo.description ); - } - void LegacyReporterAdapter::assertionStarting( AssertionInfo const& ) { - // Not on legacy interface - } - - bool LegacyReporterAdapter::assertionEnded( AssertionStats const& assertionStats ) { - if( assertionStats.assertionResult.getResultType() != ResultWas::Ok ) { - for( std::vector::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end(); - it != itEnd; - ++it ) { - if( it->type == ResultWas::Info ) { - ResultBuilder rb( it->macroName.c_str(), it->lineInfo, "", ResultDisposition::Normal ); - rb << it->message; - rb.setResultType( ResultWas::Info ); - AssertionResult result = rb.build(); - m_legacyReporter->Result( result ); - } - } - } - m_legacyReporter->Result( assertionStats.assertionResult ); - return true; - } - void LegacyReporterAdapter::sectionEnded( SectionStats const& sectionStats ) { - if( sectionStats.missingAssertions ) - m_legacyReporter->NoAssertionsInSection( sectionStats.sectionInfo.name ); - m_legacyReporter->EndSection( sectionStats.sectionInfo.name, sectionStats.assertions ); - } - void LegacyReporterAdapter::testCaseEnded( TestCaseStats const& testCaseStats ) { - m_legacyReporter->EndTestCase - ( testCaseStats.testInfo, - testCaseStats.totals, - testCaseStats.stdOut, - testCaseStats.stdErr ); - } - void LegacyReporterAdapter::testGroupEnded( TestGroupStats const& testGroupStats ) { - if( testGroupStats.aborting ) - m_legacyReporter->Aborted(); - m_legacyReporter->EndGroup( testGroupStats.groupInfo.name, testGroupStats.totals ); - } - void LegacyReporterAdapter::testRunEnded( TestRunStats const& testRunStats ) { - m_legacyReporter->EndTesting( testRunStats.totals ); - } - void LegacyReporterAdapter::skipTest( TestCaseInfo const& ) { - } -} - -// #included from: catch_timer.hpp - -#ifdef __clang__ -#pragma clang diagnostic push -#pragma clang diagnostic ignored "-Wc++11-long-long" -#endif - -#ifdef CATCH_PLATFORM_WINDOWS - -#else - -#include - -#endif - -namespace Catch { - - namespace { -#ifdef CATCH_PLATFORM_WINDOWS - UInt64 getCurrentTicks() { - static UInt64 hz=0, hzo=0; - if (!hz) { - QueryPerformanceFrequency( reinterpret_cast( &hz ) ); - QueryPerformanceCounter( reinterpret_cast( &hzo ) ); - } - UInt64 t; - QueryPerformanceCounter( reinterpret_cast( &t ) ); - return ((t-hzo)*1000000)/hz; - } -#else - UInt64 getCurrentTicks() { - timeval t; - gettimeofday(&t,CATCH_NULL); - return static_cast( t.tv_sec ) * 1000000ull + static_cast( t.tv_usec ); - } -#endif - } - - void Timer::start() { - m_ticks = getCurrentTicks(); - } - unsigned int Timer::getElapsedMicroseconds() const { - return static_cast(getCurrentTicks() - m_ticks); - } - unsigned int Timer::getElapsedMilliseconds() const { - return static_cast(getElapsedMicroseconds()/1000); - } - double Timer::getElapsedSeconds() const { - return getElapsedMicroseconds()/1000000.0; - } - -} // namespace Catch - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif -// #included from: catch_common.hpp -#define TWOBLUECUBES_CATCH_COMMON_HPP_INCLUDED - -#include -#include - -namespace Catch { - - bool startsWith( std::string const& s, std::string const& prefix ) { - return s.size() >= prefix.size() && std::equal(prefix.begin(), prefix.end(), s.begin()); - } - bool startsWith( std::string const& s, char prefix ) { - return !s.empty() && s[0] == prefix; - } - bool endsWith( std::string const& s, std::string const& suffix ) { - return s.size() >= suffix.size() && std::equal(suffix.rbegin(), suffix.rend(), s.rbegin()); - } - bool endsWith( std::string const& s, char suffix ) { - return !s.empty() && s[s.size()-1] == suffix; - } - bool contains( std::string const& s, std::string const& infix ) { - return s.find( infix ) != std::string::npos; - } - char toLowerCh(char c) { - return static_cast( std::tolower( c ) ); - } - void toLowerInPlace( std::string& s ) { - std::transform( s.begin(), s.end(), s.begin(), toLowerCh ); - } - std::string toLower( std::string const& s ) { - std::string lc = s; - toLowerInPlace( lc ); - return lc; - } - std::string trim( std::string const& str ) { - static char const* whitespaceChars = "\n\r\t "; - std::string::size_type start = str.find_first_not_of( whitespaceChars ); - std::string::size_type end = str.find_last_not_of( whitespaceChars ); - - return start != std::string::npos ? str.substr( start, 1+end-start ) : std::string(); - } - - bool replaceInPlace( std::string& str, std::string const& replaceThis, std::string const& withThis ) { - bool replaced = false; - std::size_t i = str.find( replaceThis ); - while( i != std::string::npos ) { - replaced = true; - str = str.substr( 0, i ) + withThis + str.substr( i+replaceThis.size() ); - if( i < str.size()-withThis.size() ) - i = str.find( replaceThis, i+withThis.size() ); - else - i = std::string::npos; - } - return replaced; - } - - pluralise::pluralise( std::size_t count, std::string const& label ) - : m_count( count ), - m_label( label ) - {} - - std::ostream& operator << ( std::ostream& os, pluralise const& pluraliser ) { - os << pluraliser.m_count << ' ' << pluraliser.m_label; - if( pluraliser.m_count != 1 ) - os << 's'; - return os; - } - - SourceLineInfo::SourceLineInfo() : file(""), line( 0 ){} - SourceLineInfo::SourceLineInfo( char const* _file, std::size_t _line ) - : file( _file ), - line( _line ) - {} - bool SourceLineInfo::empty() const { - return file[0] == '\0'; - } - bool SourceLineInfo::operator == ( SourceLineInfo const& other ) const { - return line == other.line && (file == other.file || std::strcmp(file, other.file) == 0); - } - bool SourceLineInfo::operator < ( SourceLineInfo const& other ) const { - return line < other.line || ( line == other.line && (std::strcmp(file, other.file) < 0)); - } - - void seedRng( IConfig const& config ) { - if( config.rngSeed() != 0 ) - std::srand( config.rngSeed() ); - } - unsigned int rngSeed() { - return getCurrentContext().getConfig()->rngSeed(); - } - - std::ostream& operator << ( std::ostream& os, SourceLineInfo const& info ) { -#ifndef __GNUG__ - os << info.file << '(' << info.line << ')'; -#else - os << info.file << ':' << info.line; -#endif - return os; - } - - void throwLogicError( std::string const& message, SourceLineInfo const& locationInfo ) { - std::ostringstream oss; - oss << locationInfo << ": Internal Catch error: '" << message << '\''; - if( alwaysTrue() ) - throw std::logic_error( oss.str() ); - } -} - -// #included from: catch_section.hpp -#define TWOBLUECUBES_CATCH_SECTION_HPP_INCLUDED - -namespace Catch { - - SectionInfo::SectionInfo - ( SourceLineInfo const& _lineInfo, - std::string const& _name, - std::string const& _description ) - : name( _name ), - description( _description ), - lineInfo( _lineInfo ) - {} - - Section::Section( SectionInfo const& info ) - : m_info( info ), - m_sectionIncluded( getResultCapture().sectionStarted( m_info, m_assertions ) ) - { - m_timer.start(); - } - -#if defined(_MSC_VER) -#pragma warning(push) -#pragma warning(disable:4996) // std::uncaught_exception is deprecated in C++17 -#endif - Section::~Section() { - if( m_sectionIncluded ) { - SectionEndInfo endInfo( m_info, m_assertions, m_timer.getElapsedSeconds() ); - if( std::uncaught_exception() ) - getResultCapture().sectionEndedEarly( endInfo ); - else - getResultCapture().sectionEnded( endInfo ); - } - } -#if defined(_MSC_VER) -#pragma warning(pop) -#endif - - // This indicates whether the section should be executed or not - Section::operator bool() const { - return m_sectionIncluded; - } - -} // end namespace Catch - -// #included from: catch_debugger.hpp -#define TWOBLUECUBES_CATCH_DEBUGGER_HPP_INCLUDED - -#ifdef CATCH_PLATFORM_MAC - - #include - #include - #include - #include - #include - - namespace Catch{ - - // The following function is taken directly from the following technical note: - // http://developer.apple.com/library/mac/#qa/qa2004/qa1361.html - - // Returns true if the current process is being debugged (either - // running under the debugger or has a debugger attached post facto). - bool isDebuggerActive(){ - - int mib[4]; - struct kinfo_proc info; - size_t size; - - // Initialize the flags so that, if sysctl fails for some bizarre - // reason, we get a predictable result. - - info.kp_proc.p_flag = 0; - - // Initialize mib, which tells sysctl the info we want, in this case - // we're looking for information about a specific process ID. - - mib[0] = CTL_KERN; - mib[1] = KERN_PROC; - mib[2] = KERN_PROC_PID; - mib[3] = getpid(); - - // Call sysctl. - - size = sizeof(info); - if( sysctl(mib, sizeof(mib) / sizeof(*mib), &info, &size, CATCH_NULL, 0) != 0 ) { - Catch::cerr() << "\n** Call to sysctl failed - unable to determine if debugger is active **\n" << std::endl; - return false; - } - - // We're being debugged if the P_TRACED flag is set. - - return ( (info.kp_proc.p_flag & P_TRACED) != 0 ); - } - } // namespace Catch - -#elif defined(CATCH_PLATFORM_LINUX) - #include - #include - - namespace Catch{ - // The standard POSIX way of detecting a debugger is to attempt to - // ptrace() the process, but this needs to be done from a child and not - // this process itself to still allow attaching to this process later - // if wanted, so is rather heavy. Under Linux we have the PID of the - // "debugger" (which doesn't need to be gdb, of course, it could also - // be strace, for example) in /proc/$PID/status, so just get it from - // there instead. - bool isDebuggerActive(){ - // Libstdc++ has a bug, where std::ifstream sets errno to 0 - // This way our users can properly assert over errno values - ErrnoGuard guard; - std::ifstream in("/proc/self/status"); - for( std::string line; std::getline(in, line); ) { - static const int PREFIX_LEN = 11; - if( line.compare(0, PREFIX_LEN, "TracerPid:\t") == 0 ) { - // We're traced if the PID is not 0 and no other PID starts - // with 0 digit, so it's enough to check for just a single - // character. - return line.length() > PREFIX_LEN && line[PREFIX_LEN] != '0'; - } - } - - return false; - } - } // namespace Catch -#elif defined(_MSC_VER) - extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); - namespace Catch { - bool isDebuggerActive() { - return IsDebuggerPresent() != 0; - } - } -#elif defined(__MINGW32__) - extern "C" __declspec(dllimport) int __stdcall IsDebuggerPresent(); - namespace Catch { - bool isDebuggerActive() { - return IsDebuggerPresent() != 0; - } - } -#else - namespace Catch { - inline bool isDebuggerActive() { return false; } - } -#endif // Platform - -#ifdef CATCH_PLATFORM_WINDOWS - - namespace Catch { - void writeToDebugConsole( std::string const& text ) { - ::OutputDebugStringA( text.c_str() ); - } - } -#else - namespace Catch { - void writeToDebugConsole( std::string const& text ) { - // !TBD: Need a version for Mac/ XCode and other IDEs - Catch::cout() << text; - } - } -#endif // Platform - -// #included from: catch_tostring.hpp -#define TWOBLUECUBES_CATCH_TOSTRING_HPP_INCLUDED - -namespace Catch { - -namespace Detail { - - const std::string unprintableString = "{?}"; - - namespace { - const int hexThreshold = 255; - - struct Endianness { - enum Arch { Big, Little }; - - static Arch which() { - union _{ - int asInt; - char asChar[sizeof (int)]; - } u; - - u.asInt = 1; - return ( u.asChar[sizeof(int)-1] == 1 ) ? Big : Little; - } - }; - } - - std::string rawMemoryToString( const void *object, std::size_t size ) - { - // Reverse order for little endian architectures - int i = 0, end = static_cast( size ), inc = 1; - if( Endianness::which() == Endianness::Little ) { - i = end-1; - end = inc = -1; - } - - unsigned char const *bytes = static_cast(object); - std::ostringstream os; - os << "0x" << std::setfill('0') << std::hex; - for( ; i != end; i += inc ) - os << std::setw(2) << static_cast(bytes[i]); - return os.str(); - } -} - -std::string toString( std::string const& value ) { - std::string s = value; - if( getCurrentContext().getConfig()->showInvisibles() ) { - for(size_t i = 0; i < s.size(); ++i ) { - std::string subs; - switch( s[i] ) { - case '\n': subs = "\\n"; break; - case '\t': subs = "\\t"; break; - default: break; - } - if( !subs.empty() ) { - s = s.substr( 0, i ) + subs + s.substr( i+1 ); - ++i; - } - } - } - return '"' + s + '"'; -} -std::string toString( std::wstring const& value ) { - - std::string s; - s.reserve( value.size() ); - for(size_t i = 0; i < value.size(); ++i ) - s += value[i] <= 0xff ? static_cast( value[i] ) : '?'; - return Catch::toString( s ); -} - -std::string toString( const char* const value ) { - return value ? Catch::toString( std::string( value ) ) : std::string( "{null string}" ); -} - -std::string toString( char* const value ) { - return Catch::toString( static_cast( value ) ); -} - -std::string toString( const wchar_t* const value ) -{ - return value ? Catch::toString( std::wstring(value) ) : std::string( "{null string}" ); -} - -std::string toString( wchar_t* const value ) -{ - return Catch::toString( static_cast( value ) ); -} - -std::string toString( int value ) { - std::ostringstream oss; - oss << value; - if( value > Detail::hexThreshold ) - oss << " (0x" << std::hex << value << ')'; - return oss.str(); -} - -std::string toString( unsigned long value ) { - std::ostringstream oss; - oss << value; - if( value > Detail::hexThreshold ) - oss << " (0x" << std::hex << value << ')'; - return oss.str(); -} - -std::string toString( unsigned int value ) { - return Catch::toString( static_cast( value ) ); -} - -template -std::string fpToString( T value, int precision ) { - std::ostringstream oss; - oss << std::setprecision( precision ) - << std::fixed - << value; - std::string d = oss.str(); - std::size_t i = d.find_last_not_of( '0' ); - if( i != std::string::npos && i != d.size()-1 ) { - if( d[i] == '.' ) - i++; - d = d.substr( 0, i+1 ); - } - return d; -} - -std::string toString( const double value ) { - return fpToString( value, 10 ); -} -std::string toString( const float value ) { - return fpToString( value, 5 ) + 'f'; -} - -std::string toString( bool value ) { - return value ? "true" : "false"; -} - -std::string toString( char value ) { - if ( value == '\r' ) - return "'\\r'"; - if ( value == '\f' ) - return "'\\f'"; - if ( value == '\n' ) - return "'\\n'"; - if ( value == '\t' ) - return "'\\t'"; - if ( '\0' <= value && value < ' ' ) - return toString( static_cast( value ) ); - char chstr[] = "' '"; - chstr[1] = value; - return chstr; -} - -std::string toString( signed char value ) { - return toString( static_cast( value ) ); -} - -std::string toString( unsigned char value ) { - return toString( static_cast( value ) ); -} - -#ifdef CATCH_CONFIG_CPP11_LONG_LONG -std::string toString( long long value ) { - std::ostringstream oss; - oss << value; - if( value > Detail::hexThreshold ) - oss << " (0x" << std::hex << value << ')'; - return oss.str(); -} -std::string toString( unsigned long long value ) { - std::ostringstream oss; - oss << value; - if( value > Detail::hexThreshold ) - oss << " (0x" << std::hex << value << ')'; - return oss.str(); -} -#endif - -#ifdef CATCH_CONFIG_CPP11_NULLPTR -std::string toString( std::nullptr_t ) { - return "nullptr"; -} -#endif - -#ifdef __OBJC__ - std::string toString( NSString const * const& nsstring ) { - if( !nsstring ) - return "nil"; - return "@" + toString([nsstring UTF8String]); - } - std::string toString( NSString * CATCH_ARC_STRONG & nsstring ) { - if( !nsstring ) - return "nil"; - return "@" + toString([nsstring UTF8String]); - } - std::string toString( NSObject* const& nsObject ) { - return toString( [nsObject description] ); - } -#endif - -} // end namespace Catch - -// #included from: catch_result_builder.hpp -#define TWOBLUECUBES_CATCH_RESULT_BUILDER_HPP_INCLUDED - -namespace Catch { - - ResultBuilder::ResultBuilder( char const* macroName, - SourceLineInfo const& lineInfo, - char const* capturedExpression, - ResultDisposition::Flags resultDisposition, - char const* secondArg ) - : m_assertionInfo( macroName, lineInfo, capturedExpression, resultDisposition, secondArg ), - m_shouldDebugBreak( false ), - m_shouldThrow( false ), - m_guardException( false ) - { - m_stream().oss.str(""); - } - - ResultBuilder::~ResultBuilder() { -#if defined(CATCH_CONFIG_FAST_COMPILE) - if ( m_guardException ) { - m_stream().oss << "Exception translation was disabled by CATCH_CONFIG_FAST_COMPILE"; - captureResult( ResultWas::ThrewException ); - getCurrentContext().getResultCapture()->exceptionEarlyReported(); - } -#endif - } - - ResultBuilder& ResultBuilder::setResultType( ResultWas::OfType result ) { - m_data.resultType = result; - return *this; - } - ResultBuilder& ResultBuilder::setResultType( bool result ) { - m_data.resultType = result ? ResultWas::Ok : ResultWas::ExpressionFailed; - return *this; - } - - void ResultBuilder::endExpression( DecomposedExpression const& expr ) { - AssertionResult result = build( expr ); - handleResult( result ); - } - - void ResultBuilder::useActiveException( ResultDisposition::Flags resultDisposition ) { - m_assertionInfo.resultDisposition = resultDisposition; - m_stream().oss << Catch::translateActiveException(); - captureResult( ResultWas::ThrewException ); - } - - void ResultBuilder::captureResult( ResultWas::OfType resultType ) { - setResultType( resultType ); - captureExpression(); - } - - void ResultBuilder::captureExpectedException( std::string const& expectedMessage ) { - if( expectedMessage.empty() ) - captureExpectedException( Matchers::Impl::MatchAllOf() ); - else - captureExpectedException( Matchers::Equals( expectedMessage ) ); - } - - void ResultBuilder::captureExpectedException( Matchers::Impl::MatcherBase const& matcher ) { - - assert( !isFalseTest( m_assertionInfo.resultDisposition ) ); - AssertionResultData data = m_data; - data.resultType = ResultWas::Ok; - data.reconstructedExpression = capturedExpressionWithSecondArgument(m_assertionInfo.capturedExpression, m_assertionInfo.secondArg); - - std::string actualMessage = Catch::translateActiveException(); - if( !matcher.match( actualMessage ) ) { - data.resultType = ResultWas::ExpressionFailed; - data.reconstructedExpression = actualMessage; - } - AssertionResult result( m_assertionInfo, data ); - handleResult( result ); - } - - void ResultBuilder::captureExpression() { - AssertionResult result = build(); - handleResult( result ); - } - - void ResultBuilder::handleResult( AssertionResult const& result ) - { - getResultCapture().assertionEnded( result ); - - if( !result.isOk() ) { - if( getCurrentContext().getConfig()->shouldDebugBreak() ) - m_shouldDebugBreak = true; - if( getCurrentContext().getRunner()->aborting() || (m_assertionInfo.resultDisposition & ResultDisposition::Normal) ) - m_shouldThrow = true; - } - } - - void ResultBuilder::react() { -#if defined(CATCH_CONFIG_FAST_COMPILE) - if (m_shouldDebugBreak) { - /////////////////////////////////////////////////////////////////// - // To inspect the state during test, you need to go one level up the callstack - // To go back to the test and change execution, jump over the throw statement - /////////////////////////////////////////////////////////////////// - CATCH_BREAK_INTO_DEBUGGER(); - } -#endif - if( m_shouldThrow ) - throw Catch::TestFailureException(); - } - - bool ResultBuilder::shouldDebugBreak() const { return m_shouldDebugBreak; } - bool ResultBuilder::allowThrows() const { return getCurrentContext().getConfig()->allowThrows(); } - - AssertionResult ResultBuilder::build() const - { - return build( *this ); - } - - // CAVEAT: The returned AssertionResult stores a pointer to the argument expr, - // a temporary DecomposedExpression, which in turn holds references to - // operands, possibly temporary as well. - // It should immediately be passed to handleResult; if the expression - // needs to be reported, its string expansion must be composed before - // the temporaries are destroyed. - AssertionResult ResultBuilder::build( DecomposedExpression const& expr ) const - { - assert( m_data.resultType != ResultWas::Unknown ); - AssertionResultData data = m_data; - - // Flip bool results if FalseTest flag is set - if( isFalseTest( m_assertionInfo.resultDisposition ) ) { - data.negate( expr.isBinaryExpression() ); - } - - data.message = m_stream().oss.str(); - data.decomposedExpression = &expr; // for lazy reconstruction - return AssertionResult( m_assertionInfo, data ); - } - - void ResultBuilder::reconstructExpression( std::string& dest ) const { - dest = capturedExpressionWithSecondArgument(m_assertionInfo.capturedExpression, m_assertionInfo.secondArg); - } - - void ResultBuilder::setExceptionGuard() { - m_guardException = true; - } - void ResultBuilder::unsetExceptionGuard() { - m_guardException = false; - } - -} // end namespace Catch - -// #included from: catch_tag_alias_registry.hpp -#define TWOBLUECUBES_CATCH_TAG_ALIAS_REGISTRY_HPP_INCLUDED - -namespace Catch { - - TagAliasRegistry::~TagAliasRegistry() {} - - Option TagAliasRegistry::find( std::string const& alias ) const { - std::map::const_iterator it = m_registry.find( alias ); - if( it != m_registry.end() ) - return it->second; - else - return Option(); - } - - std::string TagAliasRegistry::expandAliases( std::string const& unexpandedTestSpec ) const { - std::string expandedTestSpec = unexpandedTestSpec; - for( std::map::const_iterator it = m_registry.begin(), itEnd = m_registry.end(); - it != itEnd; - ++it ) { - std::size_t pos = expandedTestSpec.find( it->first ); - if( pos != std::string::npos ) { - expandedTestSpec = expandedTestSpec.substr( 0, pos ) + - it->second.tag + - expandedTestSpec.substr( pos + it->first.size() ); - } - } - return expandedTestSpec; - } - - void TagAliasRegistry::add( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) { - - if( !startsWith( alias, "[@" ) || !endsWith( alias, ']' ) ) { - std::ostringstream oss; - oss << Colour( Colour::Red ) - << "error: tag alias, \"" << alias << "\" is not of the form [@alias name].\n" - << Colour( Colour::FileName ) - << lineInfo << '\n'; - throw std::domain_error( oss.str().c_str() ); - } - if( !m_registry.insert( std::make_pair( alias, TagAlias( tag, lineInfo ) ) ).second ) { - std::ostringstream oss; - oss << Colour( Colour::Red ) - << "error: tag alias, \"" << alias << "\" already registered.\n" - << "\tFirst seen at " - << Colour( Colour::Red ) << find(alias)->lineInfo << '\n' - << Colour( Colour::Red ) << "\tRedefined at " - << Colour( Colour::FileName) << lineInfo << '\n'; - throw std::domain_error( oss.str().c_str() ); - } - } - - ITagAliasRegistry::~ITagAliasRegistry() {} - - ITagAliasRegistry const& ITagAliasRegistry::get() { - return getRegistryHub().getTagAliasRegistry(); - } - - RegistrarForTagAliases::RegistrarForTagAliases( char const* alias, char const* tag, SourceLineInfo const& lineInfo ) { - getMutableRegistryHub().registerTagAlias( alias, tag, lineInfo ); - } - -} // end namespace Catch - -// #included from: catch_matchers_string.hpp - -namespace Catch { -namespace Matchers { - - namespace StdString { - - CasedString::CasedString( std::string const& str, CaseSensitive::Choice caseSensitivity ) - : m_caseSensitivity( caseSensitivity ), - m_str( adjustString( str ) ) - {} - std::string CasedString::adjustString( std::string const& str ) const { - return m_caseSensitivity == CaseSensitive::No - ? toLower( str ) - : str; - } - std::string CasedString::caseSensitivitySuffix() const { - return m_caseSensitivity == CaseSensitive::No - ? " (case insensitive)" - : std::string(); - } - - StringMatcherBase::StringMatcherBase( std::string const& operation, CasedString const& comparator ) - : m_comparator( comparator ), - m_operation( operation ) { - } - - std::string StringMatcherBase::describe() const { - std::string description; - description.reserve(5 + m_operation.size() + m_comparator.m_str.size() + - m_comparator.caseSensitivitySuffix().size()); - description += m_operation; - description += ": \""; - description += m_comparator.m_str; - description += "\""; - description += m_comparator.caseSensitivitySuffix(); - return description; - } - - EqualsMatcher::EqualsMatcher( CasedString const& comparator ) : StringMatcherBase( "equals", comparator ) {} - - bool EqualsMatcher::match( std::string const& source ) const { - return m_comparator.adjustString( source ) == m_comparator.m_str; - } - - ContainsMatcher::ContainsMatcher( CasedString const& comparator ) : StringMatcherBase( "contains", comparator ) {} - - bool ContainsMatcher::match( std::string const& source ) const { - return contains( m_comparator.adjustString( source ), m_comparator.m_str ); - } - - StartsWithMatcher::StartsWithMatcher( CasedString const& comparator ) : StringMatcherBase( "starts with", comparator ) {} - - bool StartsWithMatcher::match( std::string const& source ) const { - return startsWith( m_comparator.adjustString( source ), m_comparator.m_str ); - } - - EndsWithMatcher::EndsWithMatcher( CasedString const& comparator ) : StringMatcherBase( "ends with", comparator ) {} - - bool EndsWithMatcher::match( std::string const& source ) const { - return endsWith( m_comparator.adjustString( source ), m_comparator.m_str ); - } - - } // namespace StdString - - StdString::EqualsMatcher Equals( std::string const& str, CaseSensitive::Choice caseSensitivity ) { - return StdString::EqualsMatcher( StdString::CasedString( str, caseSensitivity) ); - } - StdString::ContainsMatcher Contains( std::string const& str, CaseSensitive::Choice caseSensitivity ) { - return StdString::ContainsMatcher( StdString::CasedString( str, caseSensitivity) ); - } - StdString::EndsWithMatcher EndsWith( std::string const& str, CaseSensitive::Choice caseSensitivity ) { - return StdString::EndsWithMatcher( StdString::CasedString( str, caseSensitivity) ); - } - StdString::StartsWithMatcher StartsWith( std::string const& str, CaseSensitive::Choice caseSensitivity ) { - return StdString::StartsWithMatcher( StdString::CasedString( str, caseSensitivity) ); - } - -} // namespace Matchers -} // namespace Catch -// #included from: ../reporters/catch_reporter_multi.hpp -#define TWOBLUECUBES_CATCH_REPORTER_MULTI_HPP_INCLUDED - -namespace Catch { - -class MultipleReporters : public SharedImpl { - typedef std::vector > Reporters; - Reporters m_reporters; - -public: - void add( Ptr const& reporter ) { - m_reporters.push_back( reporter ); - } - -public: // IStreamingReporter - - virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE { - return m_reporters[0]->getPreferences(); - } - - virtual void noMatchingTestCases( std::string const& spec ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->noMatchingTestCases( spec ); - } - - virtual void testRunStarting( TestRunInfo const& testRunInfo ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->testRunStarting( testRunInfo ); - } - - virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->testGroupStarting( groupInfo ); - } - - virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->testCaseStarting( testInfo ); - } - - virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->sectionStarting( sectionInfo ); - } - - virtual void assertionStarting( AssertionInfo const& assertionInfo ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->assertionStarting( assertionInfo ); - } - - // The return value indicates if the messages buffer should be cleared: - virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE { - bool clearBuffer = false; - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - clearBuffer |= (*it)->assertionEnded( assertionStats ); - return clearBuffer; - } - - virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->sectionEnded( sectionStats ); - } - - virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->testCaseEnded( testCaseStats ); - } - - virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->testGroupEnded( testGroupStats ); - } - - virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->testRunEnded( testRunStats ); - } - - virtual void skipTest( TestCaseInfo const& testInfo ) CATCH_OVERRIDE { - for( Reporters::const_iterator it = m_reporters.begin(), itEnd = m_reporters.end(); - it != itEnd; - ++it ) - (*it)->skipTest( testInfo ); - } - - virtual MultipleReporters* tryAsMulti() CATCH_OVERRIDE { - return this; - } - -}; - -Ptr addReporter( Ptr const& existingReporter, Ptr const& additionalReporter ) { - Ptr resultingReporter; - - if( existingReporter ) { - MultipleReporters* multi = existingReporter->tryAsMulti(); - if( !multi ) { - multi = new MultipleReporters; - resultingReporter = Ptr( multi ); - if( existingReporter ) - multi->add( existingReporter ); - } - else - resultingReporter = existingReporter; - multi->add( additionalReporter ); - } - else - resultingReporter = additionalReporter; - - return resultingReporter; -} - -} // end namespace Catch - -// #included from: ../reporters/catch_reporter_xml.hpp -#define TWOBLUECUBES_CATCH_REPORTER_XML_HPP_INCLUDED - -// #included from: catch_reporter_bases.hpp -#define TWOBLUECUBES_CATCH_REPORTER_BASES_HPP_INCLUDED - -#include -#include -#include -#include - -namespace Catch { - - namespace { - // Because formatting using c++ streams is stateful, drop down to C is required - // Alternatively we could use stringstream, but its performance is... not good. - std::string getFormattedDuration( double duration ) { - // Max exponent + 1 is required to represent the whole part - // + 1 for decimal point - // + 3 for the 3 decimal places - // + 1 for null terminator - const size_t maxDoubleSize = DBL_MAX_10_EXP + 1 + 1 + 3 + 1; - char buffer[maxDoubleSize]; - - // Save previous errno, to prevent sprintf from overwriting it - ErrnoGuard guard; -#ifdef _MSC_VER - sprintf_s(buffer, "%.3f", duration); -#else - sprintf(buffer, "%.3f", duration); -#endif - return std::string(buffer); - } - } - - struct StreamingReporterBase : SharedImpl { - - StreamingReporterBase( ReporterConfig const& _config ) - : m_config( _config.fullConfig() ), - stream( _config.stream() ) - { - m_reporterPrefs.shouldRedirectStdOut = false; - } - - virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE { - return m_reporterPrefs; - } - - virtual ~StreamingReporterBase() CATCH_OVERRIDE; - - virtual void noMatchingTestCases( std::string const& ) CATCH_OVERRIDE {} - - virtual void testRunStarting( TestRunInfo const& _testRunInfo ) CATCH_OVERRIDE { - currentTestRunInfo = _testRunInfo; - } - virtual void testGroupStarting( GroupInfo const& _groupInfo ) CATCH_OVERRIDE { - currentGroupInfo = _groupInfo; - } - - virtual void testCaseStarting( TestCaseInfo const& _testInfo ) CATCH_OVERRIDE { - currentTestCaseInfo = _testInfo; - } - virtual void sectionStarting( SectionInfo const& _sectionInfo ) CATCH_OVERRIDE { - m_sectionStack.push_back( _sectionInfo ); - } - - virtual void sectionEnded( SectionStats const& /* _sectionStats */ ) CATCH_OVERRIDE { - m_sectionStack.pop_back(); - } - virtual void testCaseEnded( TestCaseStats const& /* _testCaseStats */ ) CATCH_OVERRIDE { - currentTestCaseInfo.reset(); - } - virtual void testGroupEnded( TestGroupStats const& /* _testGroupStats */ ) CATCH_OVERRIDE { - currentGroupInfo.reset(); - } - virtual void testRunEnded( TestRunStats const& /* _testRunStats */ ) CATCH_OVERRIDE { - currentTestCaseInfo.reset(); - currentGroupInfo.reset(); - currentTestRunInfo.reset(); - } - - virtual void skipTest( TestCaseInfo const& ) CATCH_OVERRIDE { - // Don't do anything with this by default. - // It can optionally be overridden in the derived class. - } - - Ptr m_config; - std::ostream& stream; - - LazyStat currentTestRunInfo; - LazyStat currentGroupInfo; - LazyStat currentTestCaseInfo; - - std::vector m_sectionStack; - ReporterPreferences m_reporterPrefs; - }; - - struct CumulativeReporterBase : SharedImpl { - template - struct Node : SharedImpl<> { - explicit Node( T const& _value ) : value( _value ) {} - virtual ~Node() {} - - typedef std::vector > ChildNodes; - T value; - ChildNodes children; - }; - struct SectionNode : SharedImpl<> { - explicit SectionNode( SectionStats const& _stats ) : stats( _stats ) {} - virtual ~SectionNode(); - - bool operator == ( SectionNode const& other ) const { - return stats.sectionInfo.lineInfo == other.stats.sectionInfo.lineInfo; - } - bool operator == ( Ptr const& other ) const { - return operator==( *other ); - } - - SectionStats stats; - typedef std::vector > ChildSections; - typedef std::vector Assertions; - ChildSections childSections; - Assertions assertions; - std::string stdOut; - std::string stdErr; - }; - - struct BySectionInfo { - BySectionInfo( SectionInfo const& other ) : m_other( other ) {} - BySectionInfo( BySectionInfo const& other ) : m_other( other.m_other ) {} - bool operator() ( Ptr const& node ) const { - return node->stats.sectionInfo.lineInfo == m_other.lineInfo; - } - private: - void operator=( BySectionInfo const& ); - SectionInfo const& m_other; - }; - - typedef Node TestCaseNode; - typedef Node TestGroupNode; - typedef Node TestRunNode; - - CumulativeReporterBase( ReporterConfig const& _config ) - : m_config( _config.fullConfig() ), - stream( _config.stream() ) - { - m_reporterPrefs.shouldRedirectStdOut = false; - } - ~CumulativeReporterBase(); - - virtual ReporterPreferences getPreferences() const CATCH_OVERRIDE { - return m_reporterPrefs; - } - - virtual void testRunStarting( TestRunInfo const& ) CATCH_OVERRIDE {} - virtual void testGroupStarting( GroupInfo const& ) CATCH_OVERRIDE {} - - virtual void testCaseStarting( TestCaseInfo const& ) CATCH_OVERRIDE {} - - virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE { - SectionStats incompleteStats( sectionInfo, Counts(), 0, false ); - Ptr node; - if( m_sectionStack.empty() ) { - if( !m_rootSection ) - m_rootSection = new SectionNode( incompleteStats ); - node = m_rootSection; - } - else { - SectionNode& parentNode = *m_sectionStack.back(); - SectionNode::ChildSections::const_iterator it = - std::find_if( parentNode.childSections.begin(), - parentNode.childSections.end(), - BySectionInfo( sectionInfo ) ); - if( it == parentNode.childSections.end() ) { - node = new SectionNode( incompleteStats ); - parentNode.childSections.push_back( node ); - } - else - node = *it; - } - m_sectionStack.push_back( node ); - m_deepestSection = node; - } - - virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {} - - virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE { - assert( !m_sectionStack.empty() ); - SectionNode& sectionNode = *m_sectionStack.back(); - sectionNode.assertions.push_back( assertionStats ); - // AssertionResult holds a pointer to a temporary DecomposedExpression, - // which getExpandedExpression() calls to build the expression string. - // Our section stack copy of the assertionResult will likely outlive the - // temporary, so it must be expanded or discarded now to avoid calling - // a destroyed object later. - prepareExpandedExpression( sectionNode.assertions.back().assertionResult ); - return true; - } - virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_OVERRIDE { - assert( !m_sectionStack.empty() ); - SectionNode& node = *m_sectionStack.back(); - node.stats = sectionStats; - m_sectionStack.pop_back(); - } - virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE { - Ptr node = new TestCaseNode( testCaseStats ); - assert( m_sectionStack.size() == 0 ); - node->children.push_back( m_rootSection ); - m_testCases.push_back( node ); - m_rootSection.reset(); - - assert( m_deepestSection ); - m_deepestSection->stdOut = testCaseStats.stdOut; - m_deepestSection->stdErr = testCaseStats.stdErr; - } - virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE { - Ptr node = new TestGroupNode( testGroupStats ); - node->children.swap( m_testCases ); - m_testGroups.push_back( node ); - } - virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_OVERRIDE { - Ptr node = new TestRunNode( testRunStats ); - node->children.swap( m_testGroups ); - m_testRuns.push_back( node ); - testRunEndedCumulative(); - } - virtual void testRunEndedCumulative() = 0; - - virtual void skipTest( TestCaseInfo const& ) CATCH_OVERRIDE {} - - virtual void prepareExpandedExpression( AssertionResult& result ) const { - if( result.isOk() ) - result.discardDecomposedExpression(); - else - result.expandDecomposedExpression(); - } - - Ptr m_config; - std::ostream& stream; - std::vector m_assertions; - std::vector > > m_sections; - std::vector > m_testCases; - std::vector > m_testGroups; - - std::vector > m_testRuns; - - Ptr m_rootSection; - Ptr m_deepestSection; - std::vector > m_sectionStack; - ReporterPreferences m_reporterPrefs; - - }; - - template - char const* getLineOfChars() { - static char line[CATCH_CONFIG_CONSOLE_WIDTH] = {0}; - if( !*line ) { - std::memset( line, C, CATCH_CONFIG_CONSOLE_WIDTH-1 ); - line[CATCH_CONFIG_CONSOLE_WIDTH-1] = 0; - } - return line; - } - - struct TestEventListenerBase : StreamingReporterBase { - TestEventListenerBase( ReporterConfig const& _config ) - : StreamingReporterBase( _config ) - {} - - virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE {} - virtual bool assertionEnded( AssertionStats const& ) CATCH_OVERRIDE { - return false; - } - }; - -} // end namespace Catch - -// #included from: ../internal/catch_reporter_registrars.hpp -#define TWOBLUECUBES_CATCH_REPORTER_REGISTRARS_HPP_INCLUDED - -namespace Catch { - - template - class LegacyReporterRegistrar { - - class ReporterFactory : public IReporterFactory { - virtual IStreamingReporter* create( ReporterConfig const& config ) const { - return new LegacyReporterAdapter( new T( config ) ); - } - - virtual std::string getDescription() const { - return T::getDescription(); - } - }; - - public: - - LegacyReporterRegistrar( std::string const& name ) { - getMutableRegistryHub().registerReporter( name, new ReporterFactory() ); - } - }; - - template - class ReporterRegistrar { - - class ReporterFactory : public SharedImpl { - - // *** Please Note ***: - // - If you end up here looking at a compiler error because it's trying to register - // your custom reporter class be aware that the native reporter interface has changed - // to IStreamingReporter. The "legacy" interface, IReporter, is still supported via - // an adapter. Just use REGISTER_LEGACY_REPORTER to take advantage of the adapter. - // However please consider updating to the new interface as the old one is now - // deprecated and will probably be removed quite soon! - // Please contact me via github if you have any questions at all about this. - // In fact, ideally, please contact me anyway to let me know you've hit this - as I have - // no idea who is actually using custom reporters at all (possibly no-one!). - // The new interface is designed to minimise exposure to interface changes in the future. - virtual IStreamingReporter* create( ReporterConfig const& config ) const { - return new T( config ); - } - - virtual std::string getDescription() const { - return T::getDescription(); - } - }; - - public: - - ReporterRegistrar( std::string const& name ) { - getMutableRegistryHub().registerReporter( name, new ReporterFactory() ); - } - }; - - template - class ListenerRegistrar { - - class ListenerFactory : public SharedImpl { - - virtual IStreamingReporter* create( ReporterConfig const& config ) const { - return new T( config ); - } - virtual std::string getDescription() const { - return std::string(); - } - }; - - public: - - ListenerRegistrar() { - getMutableRegistryHub().registerListener( new ListenerFactory() ); - } - }; -} - -#define INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) \ - namespace{ Catch::LegacyReporterRegistrar catch_internal_RegistrarFor##reporterType( name ); } - -#define INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) \ - namespace{ Catch::ReporterRegistrar catch_internal_RegistrarFor##reporterType( name ); } - -// Deprecated - use the form without INTERNAL_ -#define INTERNAL_CATCH_REGISTER_LISTENER( listenerType ) \ - namespace{ Catch::ListenerRegistrar catch_internal_RegistrarFor##listenerType; } - -#define CATCH_REGISTER_LISTENER( listenerType ) \ - namespace{ Catch::ListenerRegistrar catch_internal_RegistrarFor##listenerType; } - -// #included from: ../internal/catch_xmlwriter.hpp -#define TWOBLUECUBES_CATCH_XMLWRITER_HPP_INCLUDED - -#include -#include -#include -#include - -namespace Catch { - - class XmlEncode { - public: - enum ForWhat { ForTextNodes, ForAttributes }; - - XmlEncode( std::string const& str, ForWhat forWhat = ForTextNodes ) - : m_str( str ), - m_forWhat( forWhat ) - {} - - void encodeTo( std::ostream& os ) const { - - // Apostrophe escaping not necessary if we always use " to write attributes - // (see: http://www.w3.org/TR/xml/#syntax) - - for( std::size_t i = 0; i < m_str.size(); ++ i ) { - char c = m_str[i]; - switch( c ) { - case '<': os << "<"; break; - case '&': os << "&"; break; - - case '>': - // See: http://www.w3.org/TR/xml/#syntax - if( i > 2 && m_str[i-1] == ']' && m_str[i-2] == ']' ) - os << ">"; - else - os << c; - break; - - case '\"': - if( m_forWhat == ForAttributes ) - os << """; - else - os << c; - break; - - default: - // Escape control chars - based on contribution by @espenalb in PR #465 and - // by @mrpi PR #588 - if ( ( c >= 0 && c < '\x09' ) || ( c > '\x0D' && c < '\x20') || c=='\x7F' ) { - // see http://stackoverflow.com/questions/404107/why-are-control-characters-illegal-in-xml-1-0 - os << "\\x" << std::uppercase << std::hex << std::setfill('0') << std::setw(2) - << static_cast( c ); - } - else - os << c; - } - } - } - - friend std::ostream& operator << ( std::ostream& os, XmlEncode const& xmlEncode ) { - xmlEncode.encodeTo( os ); - return os; - } - - private: - std::string m_str; - ForWhat m_forWhat; - }; - - class XmlWriter { - public: - - class ScopedElement { - public: - ScopedElement( XmlWriter* writer ) - : m_writer( writer ) - {} - - ScopedElement( ScopedElement const& other ) - : m_writer( other.m_writer ){ - other.m_writer = CATCH_NULL; - } - - ~ScopedElement() { - if( m_writer ) - m_writer->endElement(); - } - - ScopedElement& writeText( std::string const& text, bool indent = true ) { - m_writer->writeText( text, indent ); - return *this; - } - - template - ScopedElement& writeAttribute( std::string const& name, T const& attribute ) { - m_writer->writeAttribute( name, attribute ); - return *this; - } - - private: - mutable XmlWriter* m_writer; - }; - - XmlWriter() - : m_tagIsOpen( false ), - m_needsNewline( false ), - m_os( Catch::cout() ) - { - writeDeclaration(); - } - - XmlWriter( std::ostream& os ) - : m_tagIsOpen( false ), - m_needsNewline( false ), - m_os( os ) - { - writeDeclaration(); - } - - ~XmlWriter() { - while( !m_tags.empty() ) - endElement(); - } - - XmlWriter& startElement( std::string const& name ) { - ensureTagClosed(); - newlineIfNecessary(); - m_os << m_indent << '<' << name; - m_tags.push_back( name ); - m_indent += " "; - m_tagIsOpen = true; - return *this; - } - - ScopedElement scopedElement( std::string const& name ) { - ScopedElement scoped( this ); - startElement( name ); - return scoped; - } - - XmlWriter& endElement() { - newlineIfNecessary(); - m_indent = m_indent.substr( 0, m_indent.size()-2 ); - if( m_tagIsOpen ) { - m_os << "/>"; - m_tagIsOpen = false; - } - else { - m_os << m_indent << ""; - } - m_os << std::endl; - m_tags.pop_back(); - return *this; - } - - XmlWriter& writeAttribute( std::string const& name, std::string const& attribute ) { - if( !name.empty() && !attribute.empty() ) - m_os << ' ' << name << "=\"" << XmlEncode( attribute, XmlEncode::ForAttributes ) << '"'; - return *this; - } - - XmlWriter& writeAttribute( std::string const& name, bool attribute ) { - m_os << ' ' << name << "=\"" << ( attribute ? "true" : "false" ) << '"'; - return *this; - } - - template - XmlWriter& writeAttribute( std::string const& name, T const& attribute ) { - std::ostringstream oss; - oss << attribute; - return writeAttribute( name, oss.str() ); - } - - XmlWriter& writeText( std::string const& text, bool indent = true ) { - if( !text.empty() ){ - bool tagWasOpen = m_tagIsOpen; - ensureTagClosed(); - if( tagWasOpen && indent ) - m_os << m_indent; - m_os << XmlEncode( text ); - m_needsNewline = true; - } - return *this; - } - - XmlWriter& writeComment( std::string const& text ) { - ensureTagClosed(); - m_os << m_indent << ""; - m_needsNewline = true; - return *this; - } - - void writeStylesheetRef( std::string const& url ) { - m_os << "\n"; - } - - XmlWriter& writeBlankLine() { - ensureTagClosed(); - m_os << '\n'; - return *this; - } - - void ensureTagClosed() { - if( m_tagIsOpen ) { - m_os << ">" << std::endl; - m_tagIsOpen = false; - } - } - - private: - XmlWriter( XmlWriter const& ); - void operator=( XmlWriter const& ); - - void writeDeclaration() { - m_os << "\n"; - } - - void newlineIfNecessary() { - if( m_needsNewline ) { - m_os << std::endl; - m_needsNewline = false; - } - } - - bool m_tagIsOpen; - bool m_needsNewline; - std::vector m_tags; - std::string m_indent; - std::ostream& m_os; - }; - -} - -namespace Catch { - class XmlReporter : public StreamingReporterBase { - public: - XmlReporter( ReporterConfig const& _config ) - : StreamingReporterBase( _config ), - m_xml(_config.stream()), - m_sectionDepth( 0 ) - { - m_reporterPrefs.shouldRedirectStdOut = true; - } - - virtual ~XmlReporter() CATCH_OVERRIDE; - - static std::string getDescription() { - return "Reports test results as an XML document"; - } - - virtual std::string getStylesheetRef() const { - return std::string(); - } - - void writeSourceInfo( SourceLineInfo const& sourceInfo ) { - m_xml - .writeAttribute( "filename", sourceInfo.file ) - .writeAttribute( "line", sourceInfo.line ); - } - - public: // StreamingReporterBase - - virtual void noMatchingTestCases( std::string const& s ) CATCH_OVERRIDE { - StreamingReporterBase::noMatchingTestCases( s ); - } - - virtual void testRunStarting( TestRunInfo const& testInfo ) CATCH_OVERRIDE { - StreamingReporterBase::testRunStarting( testInfo ); - std::string stylesheetRef = getStylesheetRef(); - if( !stylesheetRef.empty() ) - m_xml.writeStylesheetRef( stylesheetRef ); - m_xml.startElement( "Catch" ); - if( !m_config->name().empty() ) - m_xml.writeAttribute( "name", m_config->name() ); - } - - virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE { - StreamingReporterBase::testGroupStarting( groupInfo ); - m_xml.startElement( "Group" ) - .writeAttribute( "name", groupInfo.name ); - } - - virtual void testCaseStarting( TestCaseInfo const& testInfo ) CATCH_OVERRIDE { - StreamingReporterBase::testCaseStarting(testInfo); - m_xml.startElement( "TestCase" ) - .writeAttribute( "name", trim( testInfo.name ) ) - .writeAttribute( "description", testInfo.description ) - .writeAttribute( "tags", testInfo.tagsAsString ); - - writeSourceInfo( testInfo.lineInfo ); - - if ( m_config->showDurations() == ShowDurations::Always ) - m_testCaseTimer.start(); - m_xml.ensureTagClosed(); - } - - virtual void sectionStarting( SectionInfo const& sectionInfo ) CATCH_OVERRIDE { - StreamingReporterBase::sectionStarting( sectionInfo ); - if( m_sectionDepth++ > 0 ) { - m_xml.startElement( "Section" ) - .writeAttribute( "name", trim( sectionInfo.name ) ) - .writeAttribute( "description", sectionInfo.description ); - writeSourceInfo( sectionInfo.lineInfo ); - m_xml.ensureTagClosed(); - } - } - - virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE { } - - virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE { - - AssertionResult const& result = assertionStats.assertionResult; - - bool includeResults = m_config->includeSuccessfulResults() || !result.isOk(); - - if( includeResults ) { - // Print any info messages in tags. - for( std::vector::const_iterator it = assertionStats.infoMessages.begin(), itEnd = assertionStats.infoMessages.end(); - it != itEnd; - ++it ) { - if( it->type == ResultWas::Info ) { - m_xml.scopedElement( "Info" ) - .writeText( it->message ); - } else if ( it->type == ResultWas::Warning ) { - m_xml.scopedElement( "Warning" ) - .writeText( it->message ); - } - } - } - - // Drop out if result was successful but we're not printing them. - if( !includeResults && result.getResultType() != ResultWas::Warning ) - return true; - - // Print the expression if there is one. - if( result.hasExpression() ) { - m_xml.startElement( "Expression" ) - .writeAttribute( "success", result.succeeded() ) - .writeAttribute( "type", result.getTestMacroName() ); - - writeSourceInfo( result.getSourceInfo() ); - - m_xml.scopedElement( "Original" ) - .writeText( result.getExpression() ); - m_xml.scopedElement( "Expanded" ) - .writeText( result.getExpandedExpression() ); - } - - // And... Print a result applicable to each result type. - switch( result.getResultType() ) { - case ResultWas::ThrewException: - m_xml.startElement( "Exception" ); - writeSourceInfo( result.getSourceInfo() ); - m_xml.writeText( result.getMessage() ); - m_xml.endElement(); - break; - case ResultWas::FatalErrorCondition: - m_xml.startElement( "FatalErrorCondition" ); - writeSourceInfo( result.getSourceInfo() ); - m_xml.writeText( result.getMessage() ); - m_xml.endElement(); - break; - case ResultWas::Info: - m_xml.scopedElement( "Info" ) - .writeText( result.getMessage() ); - break; - case ResultWas::Warning: - // Warning will already have been written - break; - case ResultWas::ExplicitFailure: - m_xml.startElement( "Failure" ); - writeSourceInfo( result.getSourceInfo() ); - m_xml.writeText( result.getMessage() ); - m_xml.endElement(); - break; - default: - break; - } - - if( result.hasExpression() ) - m_xml.endElement(); - - return true; - } - - virtual void sectionEnded( SectionStats const& sectionStats ) CATCH_OVERRIDE { - StreamingReporterBase::sectionEnded( sectionStats ); - if( --m_sectionDepth > 0 ) { - XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResults" ); - e.writeAttribute( "successes", sectionStats.assertions.passed ); - e.writeAttribute( "failures", sectionStats.assertions.failed ); - e.writeAttribute( "expectedFailures", sectionStats.assertions.failedButOk ); - - if ( m_config->showDurations() == ShowDurations::Always ) - e.writeAttribute( "durationInSeconds", sectionStats.durationInSeconds ); - - m_xml.endElement(); - } - } - - virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE { - StreamingReporterBase::testCaseEnded( testCaseStats ); - XmlWriter::ScopedElement e = m_xml.scopedElement( "OverallResult" ); - e.writeAttribute( "success", testCaseStats.totals.assertions.allOk() ); - - if ( m_config->showDurations() == ShowDurations::Always ) - e.writeAttribute( "durationInSeconds", m_testCaseTimer.getElapsedSeconds() ); - - if( !testCaseStats.stdOut.empty() ) - m_xml.scopedElement( "StdOut" ).writeText( trim( testCaseStats.stdOut ), false ); - if( !testCaseStats.stdErr.empty() ) - m_xml.scopedElement( "StdErr" ).writeText( trim( testCaseStats.stdErr ), false ); - - m_xml.endElement(); - } - - virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE { - StreamingReporterBase::testGroupEnded( testGroupStats ); - // TODO: Check testGroupStats.aborting and act accordingly. - m_xml.scopedElement( "OverallResults" ) - .writeAttribute( "successes", testGroupStats.totals.assertions.passed ) - .writeAttribute( "failures", testGroupStats.totals.assertions.failed ) - .writeAttribute( "expectedFailures", testGroupStats.totals.assertions.failedButOk ); - m_xml.endElement(); - } - - virtual void testRunEnded( TestRunStats const& testRunStats ) CATCH_OVERRIDE { - StreamingReporterBase::testRunEnded( testRunStats ); - m_xml.scopedElement( "OverallResults" ) - .writeAttribute( "successes", testRunStats.totals.assertions.passed ) - .writeAttribute( "failures", testRunStats.totals.assertions.failed ) - .writeAttribute( "expectedFailures", testRunStats.totals.assertions.failedButOk ); - m_xml.endElement(); - } - - private: - Timer m_testCaseTimer; - XmlWriter m_xml; - int m_sectionDepth; - }; - - INTERNAL_CATCH_REGISTER_REPORTER( "xml", XmlReporter ) - -} // end namespace Catch - -// #included from: ../reporters/catch_reporter_junit.hpp -#define TWOBLUECUBES_CATCH_REPORTER_JUNIT_HPP_INCLUDED - -#include - -namespace Catch { - - namespace { - std::string getCurrentTimestamp() { - // Beware, this is not reentrant because of backward compatibility issues - // Also, UTC only, again because of backward compatibility (%z is C++11) - time_t rawtime; - std::time(&rawtime); - const size_t timeStampSize = sizeof("2017-01-16T17:06:45Z"); - -#ifdef _MSC_VER - std::tm timeInfo = {}; - gmtime_s(&timeInfo, &rawtime); -#else - std::tm* timeInfo; - timeInfo = std::gmtime(&rawtime); -#endif - - char timeStamp[timeStampSize]; - const char * const fmt = "%Y-%m-%dT%H:%M:%SZ"; - -#ifdef _MSC_VER - std::strftime(timeStamp, timeStampSize, fmt, &timeInfo); -#else - std::strftime(timeStamp, timeStampSize, fmt, timeInfo); -#endif - return std::string(timeStamp); - } - - } - - class JunitReporter : public CumulativeReporterBase { - public: - JunitReporter( ReporterConfig const& _config ) - : CumulativeReporterBase( _config ), - xml( _config.stream() ), - m_okToFail( false ) - { - m_reporterPrefs.shouldRedirectStdOut = true; - } - - virtual ~JunitReporter() CATCH_OVERRIDE; - - static std::string getDescription() { - return "Reports test results in an XML format that looks like Ant's junitreport target"; - } - - virtual void noMatchingTestCases( std::string const& /*spec*/ ) CATCH_OVERRIDE {} - - virtual void testRunStarting( TestRunInfo const& runInfo ) CATCH_OVERRIDE { - CumulativeReporterBase::testRunStarting( runInfo ); - xml.startElement( "testsuites" ); - } - - virtual void testGroupStarting( GroupInfo const& groupInfo ) CATCH_OVERRIDE { - suiteTimer.start(); - stdOutForSuite.str(""); - stdErrForSuite.str(""); - unexpectedExceptions = 0; - CumulativeReporterBase::testGroupStarting( groupInfo ); - } - - virtual void testCaseStarting( TestCaseInfo const& testCaseInfo ) CATCH_OVERRIDE { - m_okToFail = testCaseInfo.okToFail(); - } - virtual bool assertionEnded( AssertionStats const& assertionStats ) CATCH_OVERRIDE { - if( assertionStats.assertionResult.getResultType() == ResultWas::ThrewException && !m_okToFail ) - unexpectedExceptions++; - return CumulativeReporterBase::assertionEnded( assertionStats ); - } - - virtual void testCaseEnded( TestCaseStats const& testCaseStats ) CATCH_OVERRIDE { - stdOutForSuite << testCaseStats.stdOut; - stdErrForSuite << testCaseStats.stdErr; - CumulativeReporterBase::testCaseEnded( testCaseStats ); - } - - virtual void testGroupEnded( TestGroupStats const& testGroupStats ) CATCH_OVERRIDE { - double suiteTime = suiteTimer.getElapsedSeconds(); - CumulativeReporterBase::testGroupEnded( testGroupStats ); - writeGroup( *m_testGroups.back(), suiteTime ); - } - - virtual void testRunEndedCumulative() CATCH_OVERRIDE { - xml.endElement(); - } - - void writeGroup( TestGroupNode const& groupNode, double suiteTime ) { - XmlWriter::ScopedElement e = xml.scopedElement( "testsuite" ); - TestGroupStats const& stats = groupNode.value; - xml.writeAttribute( "name", stats.groupInfo.name ); - xml.writeAttribute( "errors", unexpectedExceptions ); - xml.writeAttribute( "failures", stats.totals.assertions.failed-unexpectedExceptions ); - xml.writeAttribute( "tests", stats.totals.assertions.total() ); - xml.writeAttribute( "hostname", "tbd" ); // !TBD - if( m_config->showDurations() == ShowDurations::Never ) - xml.writeAttribute( "time", "" ); - else - xml.writeAttribute( "time", suiteTime ); - xml.writeAttribute( "timestamp", getCurrentTimestamp() ); - - // Write test cases - for( TestGroupNode::ChildNodes::const_iterator - it = groupNode.children.begin(), itEnd = groupNode.children.end(); - it != itEnd; - ++it ) - writeTestCase( **it ); - - xml.scopedElement( "system-out" ).writeText( trim( stdOutForSuite.str() ), false ); - xml.scopedElement( "system-err" ).writeText( trim( stdErrForSuite.str() ), false ); - } - - void writeTestCase( TestCaseNode const& testCaseNode ) { - TestCaseStats const& stats = testCaseNode.value; - - // All test cases have exactly one section - which represents the - // test case itself. That section may have 0-n nested sections - assert( testCaseNode.children.size() == 1 ); - SectionNode const& rootSection = *testCaseNode.children.front(); - - std::string className = stats.testInfo.className; - - if( className.empty() ) { - if( rootSection.childSections.empty() ) - className = "global"; - } - writeSection( className, "", rootSection ); - } - - void writeSection( std::string const& className, - std::string const& rootName, - SectionNode const& sectionNode ) { - std::string name = trim( sectionNode.stats.sectionInfo.name ); - if( !rootName.empty() ) - name = rootName + '/' + name; - - if( !sectionNode.assertions.empty() || - !sectionNode.stdOut.empty() || - !sectionNode.stdErr.empty() ) { - XmlWriter::ScopedElement e = xml.scopedElement( "testcase" ); - if( className.empty() ) { - xml.writeAttribute( "classname", name ); - xml.writeAttribute( "name", "root" ); - } - else { - xml.writeAttribute( "classname", className ); - xml.writeAttribute( "name", name ); - } - xml.writeAttribute( "time", Catch::toString( sectionNode.stats.durationInSeconds ) ); - - writeAssertions( sectionNode ); - - if( !sectionNode.stdOut.empty() ) - xml.scopedElement( "system-out" ).writeText( trim( sectionNode.stdOut ), false ); - if( !sectionNode.stdErr.empty() ) - xml.scopedElement( "system-err" ).writeText( trim( sectionNode.stdErr ), false ); - } - for( SectionNode::ChildSections::const_iterator - it = sectionNode.childSections.begin(), - itEnd = sectionNode.childSections.end(); - it != itEnd; - ++it ) - if( className.empty() ) - writeSection( name, "", **it ); - else - writeSection( className, name, **it ); - } - - void writeAssertions( SectionNode const& sectionNode ) { - for( SectionNode::Assertions::const_iterator - it = sectionNode.assertions.begin(), itEnd = sectionNode.assertions.end(); - it != itEnd; - ++it ) - writeAssertion( *it ); - } - void writeAssertion( AssertionStats const& stats ) { - AssertionResult const& result = stats.assertionResult; - if( !result.isOk() ) { - std::string elementName; - switch( result.getResultType() ) { - case ResultWas::ThrewException: - case ResultWas::FatalErrorCondition: - elementName = "error"; - break; - case ResultWas::ExplicitFailure: - elementName = "failure"; - break; - case ResultWas::ExpressionFailed: - elementName = "failure"; - break; - case ResultWas::DidntThrowException: - elementName = "failure"; - break; - - // We should never see these here: - case ResultWas::Info: - case ResultWas::Warning: - case ResultWas::Ok: - case ResultWas::Unknown: - case ResultWas::FailureBit: - case ResultWas::Exception: - elementName = "internalError"; - break; - } - - XmlWriter::ScopedElement e = xml.scopedElement( elementName ); - - xml.writeAttribute( "message", result.getExpandedExpression() ); - xml.writeAttribute( "type", result.getTestMacroName() ); - - std::ostringstream oss; - if( !result.getMessage().empty() ) - oss << result.getMessage() << '\n'; - for( std::vector::const_iterator - it = stats.infoMessages.begin(), - itEnd = stats.infoMessages.end(); - it != itEnd; - ++it ) - if( it->type == ResultWas::Info ) - oss << it->message << '\n'; - - oss << "at " << result.getSourceInfo(); - xml.writeText( oss.str(), false ); - } - } - - XmlWriter xml; - Timer suiteTimer; - std::ostringstream stdOutForSuite; - std::ostringstream stdErrForSuite; - unsigned int unexpectedExceptions; - bool m_okToFail; - }; - - INTERNAL_CATCH_REGISTER_REPORTER( "junit", JunitReporter ) - -} // end namespace Catch - -// #included from: ../reporters/catch_reporter_console.hpp -#define TWOBLUECUBES_CATCH_REPORTER_CONSOLE_HPP_INCLUDED - -#include -#include - -namespace Catch { - - struct ConsoleReporter : StreamingReporterBase { - ConsoleReporter( ReporterConfig const& _config ) - : StreamingReporterBase( _config ), - m_headerPrinted( false ) - {} - - virtual ~ConsoleReporter() CATCH_OVERRIDE; - static std::string getDescription() { - return "Reports test results as plain lines of text"; - } - - virtual void noMatchingTestCases( std::string const& spec ) CATCH_OVERRIDE { - stream << "No test cases matched '" << spec << '\'' << std::endl; - } - - virtual void assertionStarting( AssertionInfo const& ) CATCH_OVERRIDE { - } - - virtual bool assertionEnded( AssertionStats const& _assertionStats ) CATCH_OVERRIDE { - AssertionResult const& result = _assertionStats.assertionResult; - - bool includeResults = m_config->includeSuccessfulResults() || !result.isOk(); - - // Drop out if result was successful but we're not printing them. - if( !includeResults && result.getResultType() != ResultWas::Warning ) - return false; - - lazyPrint(); - - AssertionPrinter printer( stream, _assertionStats, includeResults ); - printer.print(); - stream << std::endl; - return true; - } - - virtual void sectionStarting( SectionInfo const& _sectionInfo ) CATCH_OVERRIDE { - m_headerPrinted = false; - StreamingReporterBase::sectionStarting( _sectionInfo ); - } - virtual void sectionEnded( SectionStats const& _sectionStats ) CATCH_OVERRIDE { - if( _sectionStats.missingAssertions ) { - lazyPrint(); - Colour colour( Colour::ResultError ); - if( m_sectionStack.size() > 1 ) - stream << "\nNo assertions in section"; - else - stream << "\nNo assertions in test case"; - stream << " '" << _sectionStats.sectionInfo.name << "'\n" << std::endl; - } - if( m_config->showDurations() == ShowDurations::Always ) { - stream << getFormattedDuration(_sectionStats.durationInSeconds) << " s: " << _sectionStats.sectionInfo.name << std::endl; - } - if( m_headerPrinted ) { - m_headerPrinted = false; - } - StreamingReporterBase::sectionEnded( _sectionStats ); - } - - virtual void testCaseEnded( TestCaseStats const& _testCaseStats ) CATCH_OVERRIDE { - StreamingReporterBase::testCaseEnded( _testCaseStats ); - m_headerPrinted = false; - } - virtual void testGroupEnded( TestGroupStats const& _testGroupStats ) CATCH_OVERRIDE { - if( currentGroupInfo.used ) { - printSummaryDivider(); - stream << "Summary for group '" << _testGroupStats.groupInfo.name << "':\n"; - printTotals( _testGroupStats.totals ); - stream << '\n' << std::endl; - } - StreamingReporterBase::testGroupEnded( _testGroupStats ); - } - virtual void testRunEnded( TestRunStats const& _testRunStats ) CATCH_OVERRIDE { - printTotalsDivider( _testRunStats.totals ); - printTotals( _testRunStats.totals ); - stream << std::endl; - StreamingReporterBase::testRunEnded( _testRunStats ); - } - - private: - - class AssertionPrinter { - void operator= ( AssertionPrinter const& ); - public: - AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages ) - : stream( _stream ), - stats( _stats ), - result( _stats.assertionResult ), - colour( Colour::None ), - message( result.getMessage() ), - messages( _stats.infoMessages ), - printInfoMessages( _printInfoMessages ) - { - switch( result.getResultType() ) { - case ResultWas::Ok: - colour = Colour::Success; - passOrFail = "PASSED"; - //if( result.hasMessage() ) - if( _stats.infoMessages.size() == 1 ) - messageLabel = "with message"; - if( _stats.infoMessages.size() > 1 ) - messageLabel = "with messages"; - break; - case ResultWas::ExpressionFailed: - if( result.isOk() ) { - colour = Colour::Success; - passOrFail = "FAILED - but was ok"; - } - else { - colour = Colour::Error; - passOrFail = "FAILED"; - } - if( _stats.infoMessages.size() == 1 ) - messageLabel = "with message"; - if( _stats.infoMessages.size() > 1 ) - messageLabel = "with messages"; - break; - case ResultWas::ThrewException: - colour = Colour::Error; - passOrFail = "FAILED"; - messageLabel = "due to unexpected exception with "; - if (_stats.infoMessages.size() == 1) - messageLabel += "message"; - if (_stats.infoMessages.size() > 1) - messageLabel += "messages"; - break; - case ResultWas::FatalErrorCondition: - colour = Colour::Error; - passOrFail = "FAILED"; - messageLabel = "due to a fatal error condition"; - break; - case ResultWas::DidntThrowException: - colour = Colour::Error; - passOrFail = "FAILED"; - messageLabel = "because no exception was thrown where one was expected"; - break; - case ResultWas::Info: - messageLabel = "info"; - break; - case ResultWas::Warning: - messageLabel = "warning"; - break; - case ResultWas::ExplicitFailure: - passOrFail = "FAILED"; - colour = Colour::Error; - if( _stats.infoMessages.size() == 1 ) - messageLabel = "explicitly with message"; - if( _stats.infoMessages.size() > 1 ) - messageLabel = "explicitly with messages"; - break; - // These cases are here to prevent compiler warnings - case ResultWas::Unknown: - case ResultWas::FailureBit: - case ResultWas::Exception: - passOrFail = "** internal error **"; - colour = Colour::Error; - break; - } - } - - void print() const { - printSourceInfo(); - if( stats.totals.assertions.total() > 0 ) { - if( result.isOk() ) - stream << '\n'; - printResultType(); - printOriginalExpression(); - printReconstructedExpression(); - } - else { - stream << '\n'; - } - printMessage(); - } - - private: - void printResultType() const { - if( !passOrFail.empty() ) { - Colour colourGuard( colour ); - stream << passOrFail << ":\n"; - } - } - void printOriginalExpression() const { - if( result.hasExpression() ) { - Colour colourGuard( Colour::OriginalExpression ); - stream << " "; - stream << result.getExpressionInMacro(); - stream << '\n'; - } - } - void printReconstructedExpression() const { - if( result.hasExpandedExpression() ) { - stream << "with expansion:\n"; - Colour colourGuard( Colour::ReconstructedExpression ); - stream << Text( result.getExpandedExpression(), TextAttributes().setIndent(2) ) << '\n'; - } - } - void printMessage() const { - if( !messageLabel.empty() ) - stream << messageLabel << ':' << '\n'; - for( std::vector::const_iterator it = messages.begin(), itEnd = messages.end(); - it != itEnd; - ++it ) { - // If this assertion is a warning ignore any INFO messages - if( printInfoMessages || it->type != ResultWas::Info ) - stream << Text( it->message, TextAttributes().setIndent(2) ) << '\n'; - } - } - void printSourceInfo() const { - Colour colourGuard( Colour::FileName ); - stream << result.getSourceInfo() << ": "; - } - - std::ostream& stream; - AssertionStats const& stats; - AssertionResult const& result; - Colour::Code colour; - std::string passOrFail; - std::string messageLabel; - std::string message; - std::vector messages; - bool printInfoMessages; - }; - - void lazyPrint() { - - if( !currentTestRunInfo.used ) - lazyPrintRunInfo(); - if( !currentGroupInfo.used ) - lazyPrintGroupInfo(); - - if( !m_headerPrinted ) { - printTestCaseAndSectionHeader(); - m_headerPrinted = true; - } - } - void lazyPrintRunInfo() { - stream << '\n' << getLineOfChars<'~'>() << '\n'; - Colour colour( Colour::SecondaryText ); - stream << currentTestRunInfo->name - << " is a Catch v" << libraryVersion() << " host application.\n" - << "Run with -? for options\n\n"; - - if( m_config->rngSeed() != 0 ) - stream << "Randomness seeded to: " << m_config->rngSeed() << "\n\n"; - - currentTestRunInfo.used = true; - } - void lazyPrintGroupInfo() { - if( !currentGroupInfo->name.empty() && currentGroupInfo->groupsCounts > 1 ) { - printClosedHeader( "Group: " + currentGroupInfo->name ); - currentGroupInfo.used = true; - } - } - void printTestCaseAndSectionHeader() { - assert( !m_sectionStack.empty() ); - printOpenHeader( currentTestCaseInfo->name ); - - if( m_sectionStack.size() > 1 ) { - Colour colourGuard( Colour::Headers ); - - std::vector::const_iterator - it = m_sectionStack.begin()+1, // Skip first section (test case) - itEnd = m_sectionStack.end(); - for( ; it != itEnd; ++it ) - printHeaderString( it->name, 2 ); - } - - SourceLineInfo lineInfo = m_sectionStack.back().lineInfo; - - if( !lineInfo.empty() ){ - stream << getLineOfChars<'-'>() << '\n'; - Colour colourGuard( Colour::FileName ); - stream << lineInfo << '\n'; - } - stream << getLineOfChars<'.'>() << '\n' << std::endl; - } - - void printClosedHeader( std::string const& _name ) { - printOpenHeader( _name ); - stream << getLineOfChars<'.'>() << '\n'; - } - void printOpenHeader( std::string const& _name ) { - stream << getLineOfChars<'-'>() << '\n'; - { - Colour colourGuard( Colour::Headers ); - printHeaderString( _name ); - } - } - - // if string has a : in first line will set indent to follow it on - // subsequent lines - void printHeaderString( std::string const& _string, std::size_t indent = 0 ) { - std::size_t i = _string.find( ": " ); - if( i != std::string::npos ) - i+=2; - else - i = 0; - stream << Text( _string, TextAttributes() - .setIndent( indent+i) - .setInitialIndent( indent ) ) << '\n'; - } - - struct SummaryColumn { - - SummaryColumn( std::string const& _label, Colour::Code _colour ) - : label( _label ), - colour( _colour ) - {} - SummaryColumn addRow( std::size_t count ) { - std::ostringstream oss; - oss << count; - std::string row = oss.str(); - for( std::vector::iterator it = rows.begin(); it != rows.end(); ++it ) { - while( it->size() < row.size() ) - *it = ' ' + *it; - while( it->size() > row.size() ) - row = ' ' + row; - } - rows.push_back( row ); - return *this; - } - - std::string label; - Colour::Code colour; - std::vector rows; - - }; - - void printTotals( Totals const& totals ) { - if( totals.testCases.total() == 0 ) { - stream << Colour( Colour::Warning ) << "No tests ran\n"; - } - else if( totals.assertions.total() > 0 && totals.testCases.allPassed() ) { - stream << Colour( Colour::ResultSuccess ) << "All tests passed"; - stream << " (" - << pluralise( totals.assertions.passed, "assertion" ) << " in " - << pluralise( totals.testCases.passed, "test case" ) << ')' - << '\n'; - } - else { - - std::vector columns; - columns.push_back( SummaryColumn( "", Colour::None ) - .addRow( totals.testCases.total() ) - .addRow( totals.assertions.total() ) ); - columns.push_back( SummaryColumn( "passed", Colour::Success ) - .addRow( totals.testCases.passed ) - .addRow( totals.assertions.passed ) ); - columns.push_back( SummaryColumn( "failed", Colour::ResultError ) - .addRow( totals.testCases.failed ) - .addRow( totals.assertions.failed ) ); - columns.push_back( SummaryColumn( "failed as expected", Colour::ResultExpectedFailure ) - .addRow( totals.testCases.failedButOk ) - .addRow( totals.assertions.failedButOk ) ); - - printSummaryRow( "test cases", columns, 0 ); - printSummaryRow( "assertions", columns, 1 ); - } - } - void printSummaryRow( std::string const& label, std::vector const& cols, std::size_t row ) { - for( std::vector::const_iterator it = cols.begin(); it != cols.end(); ++it ) { - std::string value = it->rows[row]; - if( it->label.empty() ) { - stream << label << ": "; - if( value != "0" ) - stream << value; - else - stream << Colour( Colour::Warning ) << "- none -"; - } - else if( value != "0" ) { - stream << Colour( Colour::LightGrey ) << " | "; - stream << Colour( it->colour ) - << value << ' ' << it->label; - } - } - stream << '\n'; - } - - static std::size_t makeRatio( std::size_t number, std::size_t total ) { - std::size_t ratio = total > 0 ? CATCH_CONFIG_CONSOLE_WIDTH * number/ total : 0; - return ( ratio == 0 && number > 0 ) ? 1 : ratio; - } - static std::size_t& findMax( std::size_t& i, std::size_t& j, std::size_t& k ) { - if( i > j && i > k ) - return i; - else if( j > k ) - return j; - else - return k; - } - - void printTotalsDivider( Totals const& totals ) { - if( totals.testCases.total() > 0 ) { - std::size_t failedRatio = makeRatio( totals.testCases.failed, totals.testCases.total() ); - std::size_t failedButOkRatio = makeRatio( totals.testCases.failedButOk, totals.testCases.total() ); - std::size_t passedRatio = makeRatio( totals.testCases.passed, totals.testCases.total() ); - while( failedRatio + failedButOkRatio + passedRatio < CATCH_CONFIG_CONSOLE_WIDTH-1 ) - findMax( failedRatio, failedButOkRatio, passedRatio )++; - while( failedRatio + failedButOkRatio + passedRatio > CATCH_CONFIG_CONSOLE_WIDTH-1 ) - findMax( failedRatio, failedButOkRatio, passedRatio )--; - - stream << Colour( Colour::Error ) << std::string( failedRatio, '=' ); - stream << Colour( Colour::ResultExpectedFailure ) << std::string( failedButOkRatio, '=' ); - if( totals.testCases.allPassed() ) - stream << Colour( Colour::ResultSuccess ) << std::string( passedRatio, '=' ); - else - stream << Colour( Colour::Success ) << std::string( passedRatio, '=' ); - } - else { - stream << Colour( Colour::Warning ) << std::string( CATCH_CONFIG_CONSOLE_WIDTH-1, '=' ); - } - stream << '\n'; - } - void printSummaryDivider() { - stream << getLineOfChars<'-'>() << '\n'; - } - - private: - bool m_headerPrinted; - }; - - INTERNAL_CATCH_REGISTER_REPORTER( "console", ConsoleReporter ) - -} // end namespace Catch - -// #included from: ../reporters/catch_reporter_compact.hpp -#define TWOBLUECUBES_CATCH_REPORTER_COMPACT_HPP_INCLUDED - -namespace Catch { - - struct CompactReporter : StreamingReporterBase { - - CompactReporter( ReporterConfig const& _config ) - : StreamingReporterBase( _config ) - {} - - virtual ~CompactReporter(); - - static std::string getDescription() { - return "Reports test results on a single line, suitable for IDEs"; - } - - virtual ReporterPreferences getPreferences() const { - ReporterPreferences prefs; - prefs.shouldRedirectStdOut = false; - return prefs; - } - - virtual void noMatchingTestCases( std::string const& spec ) { - stream << "No test cases matched '" << spec << '\'' << std::endl; - } - - virtual void assertionStarting( AssertionInfo const& ) {} - - virtual bool assertionEnded( AssertionStats const& _assertionStats ) { - AssertionResult const& result = _assertionStats.assertionResult; - - bool printInfoMessages = true; - - // Drop out if result was successful and we're not printing those - if( !m_config->includeSuccessfulResults() && result.isOk() ) { - if( result.getResultType() != ResultWas::Warning ) - return false; - printInfoMessages = false; - } - - AssertionPrinter printer( stream, _assertionStats, printInfoMessages ); - printer.print(); - - stream << std::endl; - return true; - } - - virtual void sectionEnded(SectionStats const& _sectionStats) CATCH_OVERRIDE { - if (m_config->showDurations() == ShowDurations::Always) { - stream << getFormattedDuration(_sectionStats.durationInSeconds) << " s: " << _sectionStats.sectionInfo.name << std::endl; - } - } - - virtual void testRunEnded( TestRunStats const& _testRunStats ) { - printTotals( _testRunStats.totals ); - stream << '\n' << std::endl; - StreamingReporterBase::testRunEnded( _testRunStats ); - } - - private: - class AssertionPrinter { - void operator= ( AssertionPrinter const& ); - public: - AssertionPrinter( std::ostream& _stream, AssertionStats const& _stats, bool _printInfoMessages ) - : stream( _stream ) - , stats( _stats ) - , result( _stats.assertionResult ) - , messages( _stats.infoMessages ) - , itMessage( _stats.infoMessages.begin() ) - , printInfoMessages( _printInfoMessages ) - {} - - void print() { - printSourceInfo(); - - itMessage = messages.begin(); - - switch( result.getResultType() ) { - case ResultWas::Ok: - printResultType( Colour::ResultSuccess, passedString() ); - printOriginalExpression(); - printReconstructedExpression(); - if ( ! result.hasExpression() ) - printRemainingMessages( Colour::None ); - else - printRemainingMessages(); - break; - case ResultWas::ExpressionFailed: - if( result.isOk() ) - printResultType( Colour::ResultSuccess, failedString() + std::string( " - but was ok" ) ); - else - printResultType( Colour::Error, failedString() ); - printOriginalExpression(); - printReconstructedExpression(); - printRemainingMessages(); - break; - case ResultWas::ThrewException: - printResultType( Colour::Error, failedString() ); - printIssue( "unexpected exception with message:" ); - printMessage(); - printExpressionWas(); - printRemainingMessages(); - break; - case ResultWas::FatalErrorCondition: - printResultType( Colour::Error, failedString() ); - printIssue( "fatal error condition with message:" ); - printMessage(); - printExpressionWas(); - printRemainingMessages(); - break; - case ResultWas::DidntThrowException: - printResultType( Colour::Error, failedString() ); - printIssue( "expected exception, got none" ); - printExpressionWas(); - printRemainingMessages(); - break; - case ResultWas::Info: - printResultType( Colour::None, "info" ); - printMessage(); - printRemainingMessages(); - break; - case ResultWas::Warning: - printResultType( Colour::None, "warning" ); - printMessage(); - printRemainingMessages(); - break; - case ResultWas::ExplicitFailure: - printResultType( Colour::Error, failedString() ); - printIssue( "explicitly" ); - printRemainingMessages( Colour::None ); - break; - // These cases are here to prevent compiler warnings - case ResultWas::Unknown: - case ResultWas::FailureBit: - case ResultWas::Exception: - printResultType( Colour::Error, "** internal error **" ); - break; - } - } - - private: - // Colour::LightGrey - - static Colour::Code dimColour() { return Colour::FileName; } - -#ifdef CATCH_PLATFORM_MAC - static const char* failedString() { return "FAILED"; } - static const char* passedString() { return "PASSED"; } -#else - static const char* failedString() { return "failed"; } - static const char* passedString() { return "passed"; } -#endif - - void printSourceInfo() const { - Colour colourGuard( Colour::FileName ); - stream << result.getSourceInfo() << ':'; - } - - void printResultType( Colour::Code colour, std::string const& passOrFail ) const { - if( !passOrFail.empty() ) { - { - Colour colourGuard( colour ); - stream << ' ' << passOrFail; - } - stream << ':'; - } - } - - void printIssue( std::string const& issue ) const { - stream << ' ' << issue; - } - - void printExpressionWas() { - if( result.hasExpression() ) { - stream << ';'; - { - Colour colour( dimColour() ); - stream << " expression was:"; - } - printOriginalExpression(); - } - } - - void printOriginalExpression() const { - if( result.hasExpression() ) { - stream << ' ' << result.getExpression(); - } - } - - void printReconstructedExpression() const { - if( result.hasExpandedExpression() ) { - { - Colour colour( dimColour() ); - stream << " for: "; - } - stream << result.getExpandedExpression(); - } - } - - void printMessage() { - if ( itMessage != messages.end() ) { - stream << " '" << itMessage->message << '\''; - ++itMessage; - } - } - - void printRemainingMessages( Colour::Code colour = dimColour() ) { - if ( itMessage == messages.end() ) - return; - - // using messages.end() directly yields compilation error: - std::vector::const_iterator itEnd = messages.end(); - const std::size_t N = static_cast( std::distance( itMessage, itEnd ) ); - - { - Colour colourGuard( colour ); - stream << " with " << pluralise( N, "message" ) << ':'; - } - - for(; itMessage != itEnd; ) { - // If this assertion is a warning ignore any INFO messages - if( printInfoMessages || itMessage->type != ResultWas::Info ) { - stream << " '" << itMessage->message << '\''; - if ( ++itMessage != itEnd ) { - Colour colourGuard( dimColour() ); - stream << " and"; - } - } - } - } - - private: - std::ostream& stream; - AssertionStats const& stats; - AssertionResult const& result; - std::vector messages; - std::vector::const_iterator itMessage; - bool printInfoMessages; - }; - - // Colour, message variants: - // - white: No tests ran. - // - red: Failed [both/all] N test cases, failed [both/all] M assertions. - // - white: Passed [both/all] N test cases (no assertions). - // - red: Failed N tests cases, failed M assertions. - // - green: Passed [both/all] N tests cases with M assertions. - - std::string bothOrAll( std::size_t count ) const { - return count == 1 ? std::string() : count == 2 ? "both " : "all " ; - } - - void printTotals( const Totals& totals ) const { - if( totals.testCases.total() == 0 ) { - stream << "No tests ran."; - } - else if( totals.testCases.failed == totals.testCases.total() ) { - Colour colour( Colour::ResultError ); - const std::string qualify_assertions_failed = - totals.assertions.failed == totals.assertions.total() ? - bothOrAll( totals.assertions.failed ) : std::string(); - stream << - "Failed " << bothOrAll( totals.testCases.failed ) - << pluralise( totals.testCases.failed, "test case" ) << ", " - "failed " << qualify_assertions_failed << - pluralise( totals.assertions.failed, "assertion" ) << '.'; - } - else if( totals.assertions.total() == 0 ) { - stream << - "Passed " << bothOrAll( totals.testCases.total() ) - << pluralise( totals.testCases.total(), "test case" ) - << " (no assertions)."; - } - else if( totals.assertions.failed ) { - Colour colour( Colour::ResultError ); - stream << - "Failed " << pluralise( totals.testCases.failed, "test case" ) << ", " - "failed " << pluralise( totals.assertions.failed, "assertion" ) << '.'; - } - else { - Colour colour( Colour::ResultSuccess ); - stream << - "Passed " << bothOrAll( totals.testCases.passed ) - << pluralise( totals.testCases.passed, "test case" ) << - " with " << pluralise( totals.assertions.passed, "assertion" ) << '.'; - } - } - }; - - INTERNAL_CATCH_REGISTER_REPORTER( "compact", CompactReporter ) - -} // end namespace Catch - -namespace Catch { - // These are all here to avoid warnings about not having any out of line - // virtual methods - NonCopyable::~NonCopyable() {} - IShared::~IShared() {} - IStream::~IStream() CATCH_NOEXCEPT {} - FileStream::~FileStream() CATCH_NOEXCEPT {} - CoutStream::~CoutStream() CATCH_NOEXCEPT {} - DebugOutStream::~DebugOutStream() CATCH_NOEXCEPT {} - StreamBufBase::~StreamBufBase() CATCH_NOEXCEPT {} - IContext::~IContext() {} - IResultCapture::~IResultCapture() {} - ITestCase::~ITestCase() {} - ITestCaseRegistry::~ITestCaseRegistry() {} - IRegistryHub::~IRegistryHub() {} - IMutableRegistryHub::~IMutableRegistryHub() {} - IExceptionTranslator::~IExceptionTranslator() {} - IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() {} - IReporter::~IReporter() {} - IReporterFactory::~IReporterFactory() {} - IReporterRegistry::~IReporterRegistry() {} - IStreamingReporter::~IStreamingReporter() {} - AssertionStats::~AssertionStats() {} - SectionStats::~SectionStats() {} - TestCaseStats::~TestCaseStats() {} - TestGroupStats::~TestGroupStats() {} - TestRunStats::~TestRunStats() {} - CumulativeReporterBase::SectionNode::~SectionNode() {} - CumulativeReporterBase::~CumulativeReporterBase() {} - - StreamingReporterBase::~StreamingReporterBase() {} - ConsoleReporter::~ConsoleReporter() {} - CompactReporter::~CompactReporter() {} - IRunner::~IRunner() {} - IMutableContext::~IMutableContext() {} - IConfig::~IConfig() {} - XmlReporter::~XmlReporter() {} - JunitReporter::~JunitReporter() {} - TestRegistry::~TestRegistry() {} - FreeFunctionTestCase::~FreeFunctionTestCase() {} - IGeneratorInfo::~IGeneratorInfo() {} - IGeneratorsForTest::~IGeneratorsForTest() {} - WildcardPattern::~WildcardPattern() {} - TestSpec::Pattern::~Pattern() {} - TestSpec::NamePattern::~NamePattern() {} - TestSpec::TagPattern::~TagPattern() {} - TestSpec::ExcludedPattern::~ExcludedPattern() {} - Matchers::Impl::MatcherUntypedBase::~MatcherUntypedBase() {} - - void Config::dummy() {} - - namespace TestCaseTracking { - ITracker::~ITracker() {} - TrackerBase::~TrackerBase() {} - SectionTracker::~SectionTracker() {} - IndexTracker::~IndexTracker() {} - } -} - -#ifdef __clang__ -#pragma clang diagnostic pop -#endif - -#endif - -#ifdef CATCH_CONFIG_MAIN -// #included from: internal/catch_default_main.hpp -#define TWOBLUECUBES_CATCH_DEFAULT_MAIN_HPP_INCLUDED - -#ifndef __OBJC__ - -#if defined(WIN32) && defined(_UNICODE) && !defined(DO_NOT_USE_WMAIN) -// Standard C/C++ Win32 Unicode wmain entry point -extern "C" int wmain (int argc, wchar_t * argv[], wchar_t * []) { -#else -// Standard C/C++ main entry point -int main (int argc, char * argv[]) { -#endif - - int result = Catch::Session().run( argc, argv ); - return ( result < 0xff ? result : 0xff ); -} - -#else // __OBJC__ - -// Objective-C entry point -int main (int argc, char * const argv[]) { -#if !CATCH_ARC_ENABLED - NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init]; -#endif - - Catch::registerTestMethods(); - int result = Catch::Session().run( argc, (char* const*)argv ); - -#if !CATCH_ARC_ENABLED - [pool drain]; -#endif - - return ( result < 0xff ? result : 0xff ); -} - -#endif // __OBJC__ - -#endif - -#ifdef CLARA_CONFIG_MAIN_NOT_DEFINED -# undef CLARA_CONFIG_MAIN -#endif - -////// - -// If this config identifier is defined then all CATCH macros are prefixed with CATCH_ -#ifdef CATCH_CONFIG_PREFIX_ALL - -#if defined(CATCH_CONFIG_FAST_COMPILE) -#define CATCH_REQUIRE( expr ) INTERNAL_CATCH_TEST_NO_TRY( "CATCH_REQUIRE", Catch::ResultDisposition::Normal, expr ) -#define CATCH_REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST_NO_TRY( "CATCH_REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, expr ) -#else -#define CATCH_REQUIRE( expr ) INTERNAL_CATCH_TEST( "CATCH_REQUIRE", Catch::ResultDisposition::Normal, expr ) -#define CATCH_REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( "CATCH_REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, expr ) -#endif - -#define CATCH_REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( "CATCH_REQUIRE_THROWS", Catch::ResultDisposition::Normal, "", expr ) -#define CATCH_REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr ) -#define CATCH_REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( "CATCH_REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr ) -#define CATCH_REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( "CATCH_REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, expr ) - -#define CATCH_CHECK( expr ) INTERNAL_CATCH_TEST( "CATCH_CHECK", Catch::ResultDisposition::ContinueOnFailure, expr ) -#define CATCH_CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( "CATCH_CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, expr ) -#define CATCH_CHECKED_IF( expr ) INTERNAL_CATCH_IF( "CATCH_CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, expr ) -#define CATCH_CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( "CATCH_CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure, expr ) -#define CATCH_CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( "CATCH_CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, expr ) - -#define CATCH_CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( "CATCH_CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, "", expr ) -#define CATCH_CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CATCH_CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr ) -#define CATCH_CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( "CATCH_CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) -#define CATCH_CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( "CATCH_CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, expr ) - -#define CATCH_CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg ) - -#if defined(CATCH_CONFIG_FAST_COMPILE) -#define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT_NO_TRY( "CATCH_REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg ) -#else -#define CATCH_REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CATCH_REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg ) -#endif - -#define CATCH_INFO( msg ) INTERNAL_CATCH_INFO( "CATCH_INFO", msg ) -#define CATCH_WARN( msg ) INTERNAL_CATCH_MSG( "CATCH_WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg ) -#define CATCH_SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( "CATCH_INFO", msg ) -#define CATCH_CAPTURE( msg ) INTERNAL_CATCH_INFO( "CATCH_CAPTURE", #msg " := " << Catch::toString(msg) ) -#define CATCH_SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( "CATCH_CAPTURE", #msg " := " << Catch::toString(msg) ) - -#ifdef CATCH_CONFIG_VARIADIC_MACROS - #define CATCH_TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) - #define CATCH_TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) - #define CATCH_METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) - #define CATCH_REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) - #define CATCH_SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) - #define CATCH_FAIL( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ ) - #define CATCH_FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "CATCH_FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) - #define CATCH_SUCCEED( ... ) INTERNAL_CATCH_MSG( "CATCH_SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) -#else - #define CATCH_TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description ) - #define CATCH_TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description ) - #define CATCH_METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description ) - #define CATCH_REGISTER_TEST_CASE( function, name, description ) INTERNAL_CATCH_REGISTER_TESTCASE( function, name, description ) - #define CATCH_SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description ) - #define CATCH_FAIL( msg ) INTERNAL_CATCH_MSG( "CATCH_FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, msg ) - #define CATCH_FAIL_CHECK( msg ) INTERNAL_CATCH_MSG( "CATCH_FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, msg ) - #define CATCH_SUCCEED( msg ) INTERNAL_CATCH_MSG( "CATCH_SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, msg ) -#endif -#define CATCH_ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" ) - -#define CATCH_REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) -#define CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) - -#define CATCH_GENERATE( expr) INTERNAL_CATCH_GENERATE( expr ) - -// "BDD-style" convenience wrappers -#ifdef CATCH_CONFIG_VARIADIC_MACROS -#define CATCH_SCENARIO( ... ) CATCH_TEST_CASE( "Scenario: " __VA_ARGS__ ) -#define CATCH_SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ ) -#else -#define CATCH_SCENARIO( name, tags ) CATCH_TEST_CASE( "Scenario: " name, tags ) -#define CATCH_SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags ) -#endif -#define CATCH_GIVEN( desc ) CATCH_SECTION( std::string( "Given: ") + desc, "" ) -#define CATCH_WHEN( desc ) CATCH_SECTION( std::string( " When: ") + desc, "" ) -#define CATCH_AND_WHEN( desc ) CATCH_SECTION( std::string( " And: ") + desc, "" ) -#define CATCH_THEN( desc ) CATCH_SECTION( std::string( " Then: ") + desc, "" ) -#define CATCH_AND_THEN( desc ) CATCH_SECTION( std::string( " And: ") + desc, "" ) - -// If CATCH_CONFIG_PREFIX_ALL is not defined then the CATCH_ prefix is not required -#else - -#if defined(CATCH_CONFIG_FAST_COMPILE) -#define REQUIRE( expr ) INTERNAL_CATCH_TEST_NO_TRY( "REQUIRE", Catch::ResultDisposition::Normal, expr ) -#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST_NO_TRY( "REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, expr ) - -#else -#define REQUIRE( expr ) INTERNAL_CATCH_TEST( "REQUIRE", Catch::ResultDisposition::Normal, expr ) -#define REQUIRE_FALSE( expr ) INTERNAL_CATCH_TEST( "REQUIRE_FALSE", Catch::ResultDisposition::Normal | Catch::ResultDisposition::FalseTest, expr ) -#endif - -#define REQUIRE_THROWS( expr ) INTERNAL_CATCH_THROWS( "REQUIRE_THROWS", Catch::ResultDisposition::Normal, "", expr ) -#define REQUIRE_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "REQUIRE_THROWS_AS", exceptionType, Catch::ResultDisposition::Normal, expr ) -#define REQUIRE_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( "REQUIRE_THROWS_WITH", Catch::ResultDisposition::Normal, matcher, expr ) -#define REQUIRE_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( "REQUIRE_NOTHROW", Catch::ResultDisposition::Normal, expr ) - -#define CHECK( expr ) INTERNAL_CATCH_TEST( "CHECK", Catch::ResultDisposition::ContinueOnFailure, expr ) -#define CHECK_FALSE( expr ) INTERNAL_CATCH_TEST( "CHECK_FALSE", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::FalseTest, expr ) -#define CHECKED_IF( expr ) INTERNAL_CATCH_IF( "CHECKED_IF", Catch::ResultDisposition::ContinueOnFailure, expr ) -#define CHECKED_ELSE( expr ) INTERNAL_CATCH_ELSE( "CHECKED_ELSE", Catch::ResultDisposition::ContinueOnFailure, expr ) -#define CHECK_NOFAIL( expr ) INTERNAL_CATCH_TEST( "CHECK_NOFAIL", Catch::ResultDisposition::ContinueOnFailure | Catch::ResultDisposition::SuppressFail, expr ) - -#define CHECK_THROWS( expr ) INTERNAL_CATCH_THROWS( "CHECK_THROWS", Catch::ResultDisposition::ContinueOnFailure, "", expr ) -#define CHECK_THROWS_AS( expr, exceptionType ) INTERNAL_CATCH_THROWS_AS( "CHECK_THROWS_AS", exceptionType, Catch::ResultDisposition::ContinueOnFailure, expr ) -#define CHECK_THROWS_WITH( expr, matcher ) INTERNAL_CATCH_THROWS( "CHECK_THROWS_WITH", Catch::ResultDisposition::ContinueOnFailure, matcher, expr ) -#define CHECK_NOTHROW( expr ) INTERNAL_CATCH_NO_THROW( "CHECK_NOTHROW", Catch::ResultDisposition::ContinueOnFailure, expr ) - -#define CHECK_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "CHECK_THAT", matcher, Catch::ResultDisposition::ContinueOnFailure, arg ) - -#if defined(CATCH_CONFIG_FAST_COMPILE) -#define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT_NO_TRY( "REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg ) -#else -#define REQUIRE_THAT( arg, matcher ) INTERNAL_CHECK_THAT( "REQUIRE_THAT", matcher, Catch::ResultDisposition::Normal, arg ) -#endif - -#define INFO( msg ) INTERNAL_CATCH_INFO( "INFO", msg ) -#define WARN( msg ) INTERNAL_CATCH_MSG( "WARN", Catch::ResultWas::Warning, Catch::ResultDisposition::ContinueOnFailure, msg ) -#define SCOPED_INFO( msg ) INTERNAL_CATCH_INFO( "INFO", msg ) -#define CAPTURE( msg ) INTERNAL_CATCH_INFO( "CAPTURE", #msg " := " << Catch::toString(msg) ) -#define SCOPED_CAPTURE( msg ) INTERNAL_CATCH_INFO( "CAPTURE", #msg " := " << Catch::toString(msg) ) - -#ifdef CATCH_CONFIG_VARIADIC_MACROS -#define TEST_CASE( ... ) INTERNAL_CATCH_TESTCASE( __VA_ARGS__ ) -#define TEST_CASE_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, __VA_ARGS__ ) -#define METHOD_AS_TEST_CASE( method, ... ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, __VA_ARGS__ ) -#define REGISTER_TEST_CASE( Function, ... ) INTERNAL_CATCH_REGISTER_TESTCASE( Function, __VA_ARGS__ ) -#define SECTION( ... ) INTERNAL_CATCH_SECTION( __VA_ARGS__ ) -#define FAIL( ... ) INTERNAL_CATCH_MSG( "FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, __VA_ARGS__ ) -#define FAIL_CHECK( ... ) INTERNAL_CATCH_MSG( "FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) -#define SUCCEED( ... ) INTERNAL_CATCH_MSG( "SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, __VA_ARGS__ ) -#else -#define TEST_CASE( name, description ) INTERNAL_CATCH_TESTCASE( name, description ) - #define TEST_CASE_METHOD( className, name, description ) INTERNAL_CATCH_TEST_CASE_METHOD( className, name, description ) - #define METHOD_AS_TEST_CASE( method, name, description ) INTERNAL_CATCH_METHOD_AS_TEST_CASE( method, name, description ) - #define REGISTER_TEST_CASE( method, name, description ) INTERNAL_CATCH_REGISTER_TESTCASE( method, name, description ) - #define SECTION( name, description ) INTERNAL_CATCH_SECTION( name, description ) - #define FAIL( msg ) INTERNAL_CATCH_MSG( "FAIL", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::Normal, msg ) - #define FAIL_CHECK( msg ) INTERNAL_CATCH_MSG( "FAIL_CHECK", Catch::ResultWas::ExplicitFailure, Catch::ResultDisposition::ContinueOnFailure, msg ) - #define SUCCEED( msg ) INTERNAL_CATCH_MSG( "SUCCEED", Catch::ResultWas::Ok, Catch::ResultDisposition::ContinueOnFailure, msg ) -#endif -#define ANON_TEST_CASE() INTERNAL_CATCH_TESTCASE( "", "" ) - -#define REGISTER_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_REPORTER( name, reporterType ) -#define REGISTER_LEGACY_REPORTER( name, reporterType ) INTERNAL_CATCH_REGISTER_LEGACY_REPORTER( name, reporterType ) - -#define GENERATE( expr) INTERNAL_CATCH_GENERATE( expr ) - -#endif - -#define CATCH_TRANSLATE_EXCEPTION( signature ) INTERNAL_CATCH_TRANSLATE_EXCEPTION( signature ) - -// "BDD-style" convenience wrappers -#ifdef CATCH_CONFIG_VARIADIC_MACROS -#define SCENARIO( ... ) TEST_CASE( "Scenario: " __VA_ARGS__ ) -#define SCENARIO_METHOD( className, ... ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " __VA_ARGS__ ) -#else -#define SCENARIO( name, tags ) TEST_CASE( "Scenario: " name, tags ) -#define SCENARIO_METHOD( className, name, tags ) INTERNAL_CATCH_TEST_CASE_METHOD( className, "Scenario: " name, tags ) -#endif -#define GIVEN( desc ) SECTION( std::string(" Given: ") + desc, "" ) -#define WHEN( desc ) SECTION( std::string(" When: ") + desc, "" ) -#define AND_WHEN( desc ) SECTION( std::string("And when: ") + desc, "" ) -#define THEN( desc ) SECTION( std::string(" Then: ") + desc, "" ) -#define AND_THEN( desc ) SECTION( std::string(" And: ") + desc, "" ) - -using Catch::Detail::Approx; - -// #included from: internal/catch_reenable_warnings.h - -#define TWOBLUECUBES_CATCH_REENABLE_WARNINGS_H_INCLUDED - -#ifdef __clang__ -# ifdef __ICC // icpc defines the __clang__ macro -# pragma warning(pop) -# else -# pragma clang diagnostic pop -# endif -#elif defined __GNUC__ -# pragma GCC diagnostic pop -#endif - -#endif // TWOBLUECUBES_SINGLE_INCLUDE_CATCH_HPP_INCLUDED - diff --git a/external/catch2 b/external/catch2 new file mode 160000 index 0000000..6ccd467 --- /dev/null +++ b/external/catch2 @@ -0,0 +1 @@ +Subproject commit 6ccd467094973824d89efb16cbc553e279f79823 diff --git a/make.py b/make.py index a22892a..28de7f5 100644 --- a/make.py +++ b/make.py @@ -1,3 +1,4 @@ +import argparse import os import platform import queue @@ -9,99 +10,43 @@ import zipfile def parse_argv(): - options = {} - options['build'] = False - options['clean'] = False - options['unit_test'] = False - options['compiler'] = None - options['config'] = 'Release' - options['cpu'] = 'x64' - options['num_threads'] = 4 + parser = argparse.ArgumentParser(add_help=False) - for i in range(1, len(sys.argv)): - value = sys.argv[i] - value_upper = value.upper() + actions = parser.add_argument_group(title='Actions', description='If no action is specified, on Windows, OS X, and Linux the solution/make files are generated. Multiple actions can be used simultaneously.') + actions.add_argument('-build', action='store_true') + actions.add_argument('-clean', action='store_true') + actions.add_argument('-unit_test', action='store_true') - if value == '-build': - options['build'] = True + target = parser.add_argument_group(title='Target') + target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'android', 'clang4', 'clang5', 'clang6', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'osx', 'ios'], help='Defaults to the host system\'s default compiler') + target.add_argument('-config', choices=['Debug', 'Release'], type=str.capitalize) + target.add_argument('-cpu', choices=['x86', 'x64'], help='Only supported for Windows, OS X, and Linux; defaults to the host system\'s architecture') - if value == '-clean': - options['clean'] = True + misc = parser.add_argument_group(title='Miscellaneous') + misc.add_argument('-num_threads', help='No. to use while compiling') + misc.add_argument('-tests_matching', help='Only run tests whose names match this regex') + misc.add_argument('-help', action='help', help='Display this usage information') - if value == '-unit_test': - options['unit_test'] = True + parser.set_defaults(build=False, clean=False, unit_test=False, compiler=None, config='Release', cpu='x64', num_threads=4, tests_matching='') - # TODO: Refactor to use the form: -compiler=vs2015 - if value == '-vs2015': - options['compiler'] = 'vs2015' - - if value == '-vs2017': - options['compiler'] = 'vs2017' - - if value == '-android': - if not platform.system() == 'Windows': - print('Android is only supported on Windows') - sys.exit(1) - - options['compiler'] = 'android' - - if value == '-clang4': - options['compiler'] = 'clang4' - - if value == '-clang5': - options['compiler'] = 'clang5' - - if value == '-clang6': - options['compiler'] = 'clang6' - - if value == '-gcc5': - options['compiler'] = 'gcc5' - - if value == '-gcc6': - options['compiler'] = 'gcc6' - - if value == '-gcc7': - options['compiler'] = 'gcc7' - - if value == '-gcc8': - options['compiler'] = 'gcc8' - - if value == '-osx': - options['compiler'] = 'osx' - - if value == '-ios': - options['compiler'] = 'ios' - - # TODO: Refactor to use the form: -config=Release - if value_upper == '-DEBUG': - options['config'] = 'Debug' - - if value_upper == '-RELEASE': - options['config'] = 'Release' - - # TODO: Refactor to use the form: -cpu=x86 - if value == '-x86': - options['cpu'] = 'x86' - - if value == '-x64': - options['cpu'] = 'x64' + args = parser.parse_args() # Sanitize and validate our options - if options['compiler'] == 'android': - options['cpu'] = 'armv7-a' + if args.compiler == 'android': + args.cpu = 'armv7-a' if not platform.system() == 'Windows': print('Android is only supported on Windows') sys.exit(1) - if options['compiler'] == 'ios': - options['cpu'] = 'arm64' + if args.compiler == 'ios': + args.cpu = 'arm64' if not platform.system() == 'Darwin': print('iOS is only supported on OS X') sys.exit(1) - return options + return args def get_cmake_exes(): if platform.system() == 'Windows': @@ -144,9 +89,9 @@ def get_toolchain(compiler): # No toolchain return None -def set_compiler_env(compiler, options): +def set_compiler_env(compiler, args): if platform.system() == 'Linux': - os.environ['MAKEFLAGS'] = '-j{}'.format(options['num_threads']) + os.environ['MAKEFLAGS'] = '-j{}'.format(args.num_threads) if compiler == 'clang4': os.environ['CC'] = 'clang-4.0' os.environ['CXX'] = 'clang++-4.0' @@ -172,13 +117,13 @@ def set_compiler_env(compiler, options): print('Unknown compiler: {}'.format(compiler)) sys.exit(1) -def do_generate_solution(cmake_exe, build_dir, cmake_script_dir, options): - compiler = options['compiler'] - cpu = options['cpu'] - config = options['config'] +def do_generate_solution(cmake_exe, build_dir, cmake_script_dir, args): + compiler = args.compiler + cpu = args.cpu + config = args.config if not compiler == None: - set_compiler_env(compiler, options) + set_compiler_env(compiler, args) extra_switches = ['--no-warn-unused-cli'] if not platform.system() == 'Windows': @@ -205,18 +150,18 @@ def do_generate_solution(cmake_exe, build_dir, cmake_script_dir, options): if result != 0: sys.exit(result) -def do_build(cmake_exe, options): - config = options['config'] +def do_build(cmake_exe, args): + config = args.config print('Building ...') cmake_cmd = '"{}" --build .'.format(cmake_exe) if platform.system() == 'Windows': - if options['compiler'] == 'android': + if args.compiler == 'android': cmake_cmd += ' --config {}'.format(config) else: cmake_cmd += ' --config {} --target INSTALL'.format(config) elif platform.system() == 'Darwin': - if options['compiler'] == 'ios': + if args.compiler == 'ios': cmake_cmd += ' --config {}'.format(config) else: cmake_cmd += ' --config {} --target install'.format(config) @@ -227,24 +172,22 @@ def do_build(cmake_exe, options): if result != 0: sys.exit(result) -def do_tests(ctest_exe, options): - config = options['config'] - +def do_tests(ctest_exe, args): print('Running unit tests ...') + ctest_cmd = '"{}" --output-on-failure'.format(ctest_exe) if platform.system() == 'Windows' or platform.system() == 'Darwin': - ctest_cmd += ' -C {}'.format(config) + ctest_cmd += ' -C {}'.format(args.config) + if args.tests_matching: + ctest_cmd += ' --tests-regex {}'.format(args.tests_matching) result = subprocess.call(ctest_cmd, shell=True) if result != 0: sys.exit(result) if __name__ == "__main__": - options = parse_argv() + args = parse_argv() cmake_exe, ctest_exe = get_cmake_exes() - compiler = options['compiler'] - cpu = options['cpu'] - config = options['config'] # Set the SJSON_CPP_CMAKE_HOME environment variable to point to CMake # otherwise we assume it is already in the user PATH @@ -256,7 +199,7 @@ def do_tests(ctest_exe, options): build_dir = os.path.join(os.getcwd(), 'build') cmake_script_dir = os.path.join(os.getcwd(), 'cmake') - if options['clean'] and os.path.exists(build_dir): + if args.clean and os.path.exists(build_dir): print('Cleaning previous build ...') shutil.rmtree(build_dir) @@ -265,15 +208,15 @@ def do_tests(ctest_exe, options): os.chdir(build_dir) - print('Using config: {}'.format(config)) - print('Using cpu: {}'.format(cpu)) - if not compiler == None: - print('Using compiler: {}'.format(compiler)) + print('Using config: {}'.format(args.config)) + print('Using cpu: {}'.format(args.cpu)) + if not args.compiler == None: + print('Using compiler: {}'.format(args.compiler)) - do_generate_solution(cmake_exe, build_dir, cmake_script_dir, options) + do_generate_solution(cmake_exe, build_dir, cmake_script_dir, args) - if options['build']: - do_build(cmake_exe, options) + if args.build: + do_build(cmake_exe, args) - if options['unit_test']: - do_tests(ctest_exe, options) + if args.unit_test: + do_tests(ctest_exe, args) diff --git a/tests/main_android/CMakeLists.txt b/tests/main_android/CMakeLists.txt index 76a86ba..efedc4c 100644 --- a/tests/main_android/CMakeLists.txt +++ b/tests/main_android/CMakeLists.txt @@ -15,7 +15,7 @@ set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") set(CMAKE_ANDROID_JAVA_SOURCE_DIR "${PROJECT_SOURCE_DIR}/java") include_directories("${PROJECT_SOURCE_DIR}/../../includes") -include_directories("${PROJECT_SOURCE_DIR}/../../external/catch-1.9.6") +include_directories("${PROJECT_SOURCE_DIR}/../../external/catch2/single_include/catch2") # Grab all of our test source files file(GLOB_RECURSE ALL_TEST_SOURCE_FILES LIST_DIRECTORIES false diff --git a/tests/main_generic/CMakeLists.txt b/tests/main_generic/CMakeLists.txt index 87fa5d7..1f73437 100644 --- a/tests/main_generic/CMakeLists.txt +++ b/tests/main_generic/CMakeLists.txt @@ -4,7 +4,7 @@ project(sjson-cpp_unit_tests CXX) set(CMAKE_CXX_STANDARD 11) include_directories("${PROJECT_SOURCE_DIR}/../../includes") -include_directories("${PROJECT_SOURCE_DIR}/../../external/catch-1.9.6") +include_directories("${PROJECT_SOURCE_DIR}/../../external/catch2/single_include/catch2") # Grab all of our test source files file(GLOB_RECURSE ALL_TEST_SOURCE_FILES LIST_DIRECTORIES false @@ -20,7 +20,11 @@ file(GLOB_RECURSE ALL_MAIN_SOURCE_FILES LIST_DIRECTORIES false create_source_groups("${ALL_MAIN_SOURCE_FILES}" ${PROJECT_SOURCE_DIR}) add_executable(${PROJECT_NAME} ${ALL_TEST_SOURCE_FILES} ${ALL_MAIN_SOURCE_FILES}) -add_test(NAME UNIT COMMAND ${PROJECT_NAME}) + +list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/../../external/catch2/contrib") +include(CTest) +include(ParseAndAddCatchTests) +ParseAndAddCatchTests(${PROJECT_NAME}) setup_default_compiler_flags(${PROJECT_NAME}) diff --git a/tests/main_ios/CMakeLists.txt b/tests/main_ios/CMakeLists.txt index b0fbde1..c0f841d 100644 --- a/tests/main_ios/CMakeLists.txt +++ b/tests/main_ios/CMakeLists.txt @@ -16,7 +16,7 @@ set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.sjson.cpp.unit-tests") set(MACOSX_BUNDLE_BUNDLE_NAME "sjson-cpp-unit-tests") include_directories("${PROJECT_SOURCE_DIR}/../../includes") -include_directories("${PROJECT_SOURCE_DIR}/../../external/catch-1.9.6") +include_directories("${PROJECT_SOURCE_DIR}/../../external/catch2/single_include/catch2") # Grab all of our test source files file(GLOB_RECURSE ALL_TEST_SOURCE_FILES LIST_DIRECTORIES false diff --git a/tools/release_scripts/test_everything.py b/tools/release_scripts/test_everything.py index d681f6e..59b8c80 100644 --- a/tools/release_scripts/test_everything.py +++ b/tools/release_scripts/test_everything.py @@ -5,11 +5,11 @@ def get_platform_compilers(): if platform.system() == 'Windows': - return [ '-vs2015', '-vs2017' ] + return [ 'vs2015', 'vs2017' ] elif platform.system() == 'Linux': - return [ '-gcc5', '-gcc6', '-gcc7', '-clang4', '-clang5' ] + return [ 'gcc5', 'gcc6', 'gcc7', 'clang4', 'clang5' ] elif platform.system() == 'Darwin': - return [ '-osx' ] + return [ 'osx' ] else: print('Unknown platform!') sys.exit(1) @@ -23,27 +23,27 @@ def get_python_exe_name(): if __name__ == "__main__": os.environ['PYTHONIOENCODING'] = 'utf_8' - configs = [ '-debug', '-release' ] - archs = [ '-x86', '-x64' ] + configs = [ 'debug', 'release' ] + archs = [ 'x86', 'x64' ] compilers = get_platform_compilers() python_exe = get_python_exe_name() - cmds = [] + cmd_args = [] for config in configs: for arch in archs: for compiler in compilers: - cmds.append('{} make.py {} {} {} -build -unit_test -clean'.format(python_exe, compiler, arch, config)) + args = [python_exe, 'make.py', '-compiler', compiler, '-cpu', arch, '-config', config, '-build', '-unit_test', '-clean'] + cmd_args.append([x for x in args if x]) root_dir = os.path.join(os.getcwd(), '../..') os.chdir(root_dir) - for cmd in cmds: - print('Running command: "{}" ...'.format(cmd)) + for args in cmd_args: + print('Running command: "{}" ...'.format(" ".join(args))) try: - args = cmd.split(' ') subprocess.check_output(args) except subprocess.CalledProcessError as e: - print('Failed command: {}'.format(cmd)) + print('Failed command: {}'.format(" ".join(args))) print(e.output.decode(sys.stdout.encoding)) sys.exit(1) From f18098302b7241a31c811212d39b5a2820b12ca8 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 11 Dec 2018 21:48:43 -0500 Subject: [PATCH 004/285] Adding the proper polyfill for older standard libs used by GCC and Clang. --- .../{platform.h => impl/compiler_utils.h} | 49 ++++++++----------- includes/sjson/parser.h | 8 +-- 2 files changed, 24 insertions(+), 33 deletions(-) rename includes/sjson/{platform.h => impl/compiler_utils.h} (55%) diff --git a/includes/sjson/platform.h b/includes/sjson/impl/compiler_utils.h similarity index 55% rename from includes/sjson/platform.h rename to includes/sjson/impl/compiler_utils.h index 73f5572..1293a8c 100644 --- a/includes/sjson/platform.h +++ b/includes/sjson/impl/compiler_utils.h @@ -24,42 +24,33 @@ // SOFTWARE. //////////////////////////////////////////////////////////////////////////////// -// NVIDIA CodeWorks used for Android has an old version of Clang that does not fully support C++11 -#if defined(__clang__) && __clang_major__ <= 3 && __clang_minor__ <= 8 - #include -#else +#if !defined(__GNUG__) || defined(_LIBCPP_VERSION) || defined(_GLIBCXX_USE_CXX11_ABI) #include +#else + #include #endif namespace sjson { - namespace impl + ////////////////////////////////////////////////////////////////////////// + // The version of the STL shipped with versions of GCC older than 5.1 are missing a number of type traits and functions, + // such as std::is_trivially_default_constructible. + // In this case, we polyfill the proper standard names using the deprecated std::has_trivial_default_constructor. + // This must also be done when the compiler is clang when it makes use of the GCC implementation of the STL, + // which is the default behavior on linux. Properly detecting the version of the GCC STL used by clang cannot + // be done with the __GNUC__ macro, which are overridden by clang. Instead, we check for the definition + // of the macro ``_GLIBCXX_USE_CXX11_ABI`` which is only defined with GCC versions greater than 5. + ////////////////////////////////////////////////////////////////////////// + namespace sjson_impl { - inline unsigned long long int strtoull(const char* str, char** endptr, int base) - { -#if defined(__clang__) && __clang_major__ <= 3 && __clang_minor__ <= 8 - return ::strtoull(str, endptr, base); -#else - return std::strtoull(str, endptr, base); -#endif - } - - inline long long int strtoll(const char* str, char** endptr, int base) - { -#if defined(__clang__) && __clang_major__ <= 3 && __clang_minor__ <= 8 - return ::strtoll(str, endptr, base); -#else - return std::strtoll(str, endptr, base); -#endif - } - - inline float strtof(const char* str, char** endptr) - { -#if defined(__clang__) && __clang_major__ <= 3 && __clang_minor__ <= 8 - return ::strtof(str, endptr); +#if !defined(__GNUG__) || defined(_LIBCPP_VERSION) || defined(_GLIBCXX_USE_CXX11_ABI) + using std::strtoull; + using std::strtoll; + using std::strtof; #else - return std::strtof(str, endptr); + using ::strtoull; + using ::strtoll; + using ::strtof; #endif - } } } diff --git a/includes/sjson/parser.h b/includes/sjson/parser.h index 20b7757..7a48850 100644 --- a/includes/sjson/parser.h +++ b/includes/sjson/parser.h @@ -31,7 +31,7 @@ #include "sjson/parser_error.h" #include "sjson/parser_state.h" -#include "sjson/platform.h" +#include "sjson/impl/compiler_utils.h" #include "sjson/string_view.h" #include @@ -723,7 +723,7 @@ namespace sjson if (dbl_value != nullptr) *dbl_value = std::strtod(slice, &last_used_symbol); else - *flt_value = impl::strtof(slice, &last_used_symbol); + *flt_value = sjson_impl::strtof(slice, &last_used_symbol); if (last_used_symbol != slice + length) { @@ -800,7 +800,7 @@ namespace sjson char* last_used_symbol = nullptr; if (std::is_unsigned::value) { - const uint64_t raw_value = impl::strtoull(slice, &last_used_symbol, base); + const uint64_t raw_value = sjson_impl::strtoull(slice, &last_used_symbol, base); value = static_cast(raw_value); if (static_cast(value) != raw_value) @@ -811,7 +811,7 @@ namespace sjson } else { - const int64_t raw_value = impl::strtoll(slice, &last_used_symbol, base); + const int64_t raw_value = sjson_impl::strtoll(slice, &last_used_symbol, base); value = static_cast(raw_value); if (static_cast(value) != raw_value) From d0fc0c38d0d3cf5d529ba5be7968086e1bbb3ea2 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 21 Dec 2018 22:42:36 -0500 Subject: [PATCH 005/285] Minor comment update. --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 36407eb..9eb7194 100644 --- a/README.md +++ b/README.md @@ -52,7 +52,7 @@ See [here](./external) for details. ### Windows, Linux, and OS X -1. Install CMake 3.2 or higher, Python 3, and the proper compiler for your platform +1. Install *CMake 3.2* or higher (*3.10* is required on OS X with *Xcode 10*), *Python 3*, and the proper compiler for your platform 2. Generate the IDE solution with: `python make.py` The solution is generated under `./build` Note that if you do not have CMake in your `PATH`, you should define the `SJSON_CPP_CMAKE_HOME` environment variable to something like `C:\Program Files\CMake`. @@ -61,11 +61,11 @@ See [here](./external) for details. ### Android -For Android, the steps are identical to Windows, Linux, and OS X but you also need to install NVIDIA CodeWorks 1R5 (or higher). +For *Android*, the steps are identical to *Windows, Linux, and OS X* but you also need to install *NVIDIA CodeWorks 1R5* (or higher). ### iOS -For iOS, the steps are identical to the other platforms but due to code signing, you will need to perform the builds from Xcode manually. Note that this is only an issue if you attempt to use the tools or run the unit tests locally. +For *iOS*, the steps are identical to the other platforms but due to code signing, you will need to perform the builds from *Xcode* manually. Note that this is only an issue if you attempt to use the tools or run the unit tests locally. ## Authors From 8c4e79847280d0bbcb210cc90979a8ccddf1c5f6 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Thu, 3 Jan 2019 20:56:14 -0500 Subject: [PATCH 006/285] Bumping travis Xcode 10 to 10.1. --- .travis.yml | 2 +- README.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 90e2e80..15866c1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,7 +48,7 @@ matrix: # OS X xcode10 - os: osx - osx_image: xcode10 + osx_image: xcode10.1 env: COMPILER=osx TOOLCHAIN=xcode before_install: diff --git a/README.md b/README.md index 9eb7194..e1d6811 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Unicode formats other than UTF-8 aren't supported. * Windows (VS2015, VS2017) x86 and x64 * Linux (gcc5, gcc6, gcc7, gcc8, clang4, clang5, clang6) x86 and x64 -* OS X (Xcode 8.3, Xcode 9.4, Xcode 10) x86 and x64 +* OS X (Xcode 8.3, Xcode 9.4, Xcode 10.1) x86 and x64 * Android (NVIDIA CodeWorks) ARMv7-A * iOS (Xcode 8.3, Xcode 9.4, Xcode 10) ARM64 From 7c7fd60cfe09774852f76db868a7a52ce39c25c3 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Thu, 3 Jan 2019 21:28:17 -0500 Subject: [PATCH 007/285] Minor comment update. --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e1d6811..e109b38 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Unicode formats other than UTF-8 aren't supported. * Linux (gcc5, gcc6, gcc7, gcc8, clang4, clang5, clang6) x86 and x64 * OS X (Xcode 8.3, Xcode 9.4, Xcode 10.1) x86 and x64 * Android (NVIDIA CodeWorks) ARMv7-A -* iOS (Xcode 8.3, Xcode 9.4, Xcode 10) ARM64 +* iOS (Xcode 8.3, Xcode 9.4, Xcode 10.1) ARM64 The above supported platform list is only what is tested every release but if it compiles, it should run just fine. From 2395931fa6a5f5aeb737569acb1d0c66fa9d2aed Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 11 Jan 2019 20:10:33 -0500 Subject: [PATCH 008/285] Adding brew update before python3 install on OSX travis. --- .travis.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 15866c1..62e093c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -61,7 +61,10 @@ before_install: sudo -E apt-get -yq update; sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install ${PACKAGES}; fi' - - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then brew upgrade python || true ; fi + - 'if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then + brew update || true; + brew upgrade python || true; + fi' script: - python3 make.py -clean -build -unit_test -compiler ${COMPILER} -config Debug -cpu x86 From 7647b6baf43011a464b3a7d3d3969060df3a7bb1 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 15 Jan 2019 21:34:27 -0500 Subject: [PATCH 009/285] Bumping android version to 21 so we can compile on ARM64. --- tests/main_android/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/main_android/CMakeLists.txt b/tests/main_android/CMakeLists.txt index efedc4c..154bd50 100644 --- a/tests/main_android/CMakeLists.txt +++ b/tests/main_android/CMakeLists.txt @@ -4,8 +4,8 @@ project(sjson-cpp_unit_tests) set(CMAKE_CXX_STANDARD 11) set(CMAKE_ANDROID_ARCH armv7-a) -set(CMAKE_ANDROID_API_MIN 9) -set(CMAKE_ANDROID_API 15) +set(CMAKE_ANDROID_API_MIN 21) +set(CMAKE_ANDROID_API 21) set(CMAKE_ANDROID_GUI 1) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") From adb48801cf47a98c91684909573fde9d9483dc60 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 22 Jan 2019 20:58:46 -0500 Subject: [PATCH 010/285] Add warnings when shadowing occurs. Add debug symbols even in release builds. --- cmake/CMakeCompiler.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/CMakeCompiler.cmake b/cmake/CMakeCompiler.cmake index 8ee4186..2868de1 100644 --- a/cmake/CMakeCompiler.cmake +++ b/cmake/CMakeCompiler.cmake @@ -27,6 +27,9 @@ macro(setup_default_compiler_flags _project_name) endif() target_compile_options(${_project_name} PRIVATE -Wall -Wextra) # Enable all warnings + target_compile_options(${_project_name} PRIVATE -Wshadow) # Enable shadowing warnings target_compile_options(${_project_name} PRIVATE -Werror) # Treat warnings as errors + + target_compile_options(${_project_name} PRIVATE -g) # Enable debug symbols endif() endmacro() From aad4ccc9292c32690ec0ca924f8f3375348f4b8c Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 22 Jan 2019 21:13:35 -0500 Subject: [PATCH 011/285] Fix shadowing warnings. --- tests/sources/test_writer.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tests/sources/test_writer.cpp b/tests/sources/test_writer.cpp index 9acd185..72f56bc 100644 --- a/tests/sources/test_writer.cpp +++ b/tests/sources/test_writer.cpp @@ -610,10 +610,10 @@ TEST_CASE("Writer Array Array Writing", "[writer]") Writer writer(str_writer); writer.insert("key", [](ArrayWriter& array_writer) { - array_writer.push([](ArrayWriter& array_writer) + array_writer.push([](ArrayWriter& array_writer1) { - array_writer.push(123.5); - array_writer.push(456.5); + array_writer1.push(123.5); + array_writer1.push(456.5); }); }); REQUIRE(str_writer.str() == "key = [ [ 123.5, 456.5 ] ]\r\n"); @@ -639,10 +639,10 @@ TEST_CASE("Writer Array Object Writing", "[writer]") Writer writer(str_writer); writer.insert("key", [](ArrayWriter& array_writer) { - array_writer.push([](ObjectWriter& object_writer) + array_writer.push([](ObjectWriter& object_writer1) { - object_writer["key0"] = 123.5; - object_writer["key1"] = 456.5; + object_writer1["key0"] = 123.5; + object_writer1["key1"] = 456.5; }); }); REQUIRE(str_writer.str() == "key = [ \r\n\t{\r\n\t\tkey0 = 123.5\r\n\t\tkey1 = 456.5\r\n\t}\r\n]\r\n"); From c57c519a7070a9c1c35acbc8701c4b549650809a Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 27 Feb 2019 20:59:03 -0500 Subject: [PATCH 012/285] Adding submodule usage mention. --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index e109b38..f4c2bd0 100644 --- a/README.md +++ b/README.md @@ -52,12 +52,13 @@ See [here](./external) for details. ### Windows, Linux, and OS X -1. Install *CMake 3.2* or higher (*3.10* is required on OS X with *Xcode 10*), *Python 3*, and the proper compiler for your platform -2. Generate the IDE solution with: `python make.py` +1. Install *CMake 3.2* or higher (*3.10* is required on OS X with *Xcode 10*), *Python 3*, and the proper compiler for your platform. +2. Execute `git submodule update --init` to get the files of thirdparty submodules (e.g. Catch2). +3. Generate the IDE solution with: `python make.py` The solution is generated under `./build` Note that if you do not have CMake in your `PATH`, you should define the `SJSON_CPP_CMAKE_HOME` environment variable to something like `C:\Program Files\CMake`. -3. Build the IDE solution with: `python make.py -build` -4. Run the unit tests with: `python make.py -unit_test` +4. Build the IDE solution with: `python make.py -build` +5. Run the unit tests with: `python make.py -unit_test` ### Android From 4ab88bd7d26a9b03c6c3fd36132935eb2ee8de16 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 30 Mar 2019 14:24:00 -0400 Subject: [PATCH 013/285] Adding support for UWP ARM64. --- README.md | 12 ++- appveyor.yml | 8 +- includes/sjson/writer.h | 134 +++++++++++++----------------- make.py | 40 +++++++-- tests/main_generic/CMakeLists.txt | 7 ++ 5 files changed, 115 insertions(+), 86 deletions(-) diff --git a/README.md b/README.md index f4c2bd0..30cb3d0 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Unicode formats other than UTF-8 aren't supported. ## Supported platforms -* Windows (VS2015, VS2017) x86 and x64 +* Windows VS2015 x86 and x64, VS2017 x86, x64, and ARM64* * Linux (gcc5, gcc6, gcc7, gcc8, clang4, clang5, clang6) x86 and x64 * OS X (Xcode 8.3, Xcode 9.4, Xcode 10.1) x86 and x64 * Android (NVIDIA CodeWorks) ARMv7-A @@ -43,6 +43,8 @@ Unicode formats other than UTF-8 aren't supported. The above supported platform list is only what is tested every release but if it compiles, it should run just fine. +Note: *VS2017* compiles with *ARM64* on *AppVeyor* but I have no device to test it with. + ## External dependencies There are none! You don't need anything else to get started: everything is self contained. @@ -50,7 +52,9 @@ See [here](./external) for details. ## Getting up and running -### Windows, Linux, and OS X +This library is **100%** headers as such you just need to include them in your own project to start using it. However, if you wish to run the unit tests you will need a few things, see below. + +### Windows, Linux, and OS X for x86 and x64 1. Install *CMake 3.2* or higher (*3.10* is required on OS X with *Xcode 10*), *Python 3*, and the proper compiler for your platform. 2. Execute `git submodule update --init` to get the files of thirdparty submodules (e.g. Catch2). @@ -60,6 +64,10 @@ See [here](./external) for details. 4. Build the IDE solution with: `python make.py -build` 5. Run the unit tests with: `python make.py -unit_test` +### Windows ARM64 + +For *Windows on ARM64*, the steps are identical to *x86 and x64* but you will need *CMake 3.13 or higher* and you must provide the architecture on the command line: `python make.py -compiler vs2017 -cpu arm64` + ### Android For *Android*, the steps are identical to *Windows, Linux, and OS X* but you also need to install *NVIDIA CodeWorks 1R5* (or higher). diff --git a/appveyor.yml b/appveyor.yml index f4acd56..5e65d6f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -13,7 +13,9 @@ install: build_script: - cmd: >- - IF "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" (SET COMPILER=vs2015) ELSE (SET COMPILER=vs2017) + IF "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" (SET COMPILER=vs2015) + + IF "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" (SET COMPILER=vs2017) %PYTHON%\\python.exe make.py -clean -build -unit_test -compiler %COMPILER% -config Debug -cpu x86 @@ -22,3 +24,7 @@ build_script: %PYTHON%\\python.exe make.py -clean -build -unit_test -compiler %COMPILER% -config Debug -cpu x64 %PYTHON%\\python.exe make.py -clean -build -unit_test -compiler %COMPILER% -config Release -cpu x64 + + IF "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" %PYTHON%\\python.exe make.py -clean -build -compiler %COMPILER% -config Debug -cpu arm64 + + IF "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" %PYTHON%\\python.exe make.py -clean -build -compiler %COMPILER% -config Release -cpu arm64 diff --git a/includes/sjson/writer.h b/includes/sjson/writer.h index a33f1b5..a9729bc 100644 --- a/includes/sjson/writer.h +++ b/includes/sjson/writer.h @@ -37,6 +37,8 @@ #include #include +#define IMPL_SJSON_CPP_VS2015_VER 1900 + namespace sjson { // TODO: Cleanup the locking stuff, wrap it in #ifdef to strip when asserts are disabled @@ -75,7 +77,26 @@ namespace sjson std::FILE* m_file; }; -#if !defined(_MSC_VER) +#if !defined(_MSC_VER) || _MSC_VER > IMPL_SJSON_CPP_VS2015_VER + // SFINAE HACK + // Note: This is funky because of C++ lambda coercion rules + // A lambda that does not capture anything is equivalent to a static function + // and calling a function with it as an argument is equivalent to passing a function pointer. + // Of course, a pointer can safely and automatically coerce to 'bool' and as such + // a clean signature like this does not work: void insert(const char*, std::function @@ -119,27 +140,16 @@ namespace sjson inline void push(int64_t value) { push_signed_integer(value); } inline void push(uint64_t value) { push_unsigned_integer(value); } - // Note: This is funky because of C++ lambda coercion rules - // A lambda that does not capture anything is equivalent to a static function - // and calling a function with it as an argument is equivalent to passing a function pointer. - // Of course, a pointer can safely and automatically coerces to 'bool' and as such - // a clean signature like this does not work: void insert(const char*, std::function writer_fun); inline void push(std::function writer_fun); #else - template - inline typename std::enable_if()>::type - push(F writer_fun); + template()>::type* dummy = nullptr> + inline void push(F writer_fun); - template - inline typename std::enable_if()>::type - push(F writer_fun); + template()>::type* dummy = nullptr> + inline void push(F writer_fun); #endif // TODO: Introduce a newline type @@ -180,27 +190,16 @@ namespace sjson inline void insert(const char* key, int64_t value) { insert_signed_integer(key, int64_t(value)); } inline void insert(const char* key, uint64_t value) { insert_unsigned_integer(key, uint64_t(value)); } - // Note: This is funky because of C++ lambda coercion rules - // A lambda that does not capture anything is equivalent to a static function - // and calling a function with it as an argument is equivalent to passing a function pointer. - // Of course, a pointer can safely and automatically coerces to 'bool' and as such - // a clean signature like this does not work: void insert(const char*, std::function writer_fun); inline void insert(const char* key, std::function writer_fun); #else - template - inline typename std::enable_if()>::type - insert(const char* key, F writer_fun); + template()>::type* dummy = nullptr> + inline void insert(const char* key, F writer_fun); - template - inline typename std::enable_if()>::type - insert(const char* key, F writer_fun); + template()>::type* dummy = nullptr> + inline void insert(const char* key, F writer_fun); #endif void insert_newline(); @@ -225,27 +224,16 @@ namespace sjson inline void operator=(int64_t value) { assign_signed_integer(int64_t(value)); } inline void operator=(uint64_t value) { assign_unsigned_integer(uint64_t(value)); } - // Note: This is funky because of C++ lambda coercion rules - // A lambda that does not capture anything is equivalent to a static function - // and calling a function with it as an argument is equivalent to passing a function pointer. - // Of course, a pointer can safely and automatically coerces to 'bool' and as such - // a clean signature like this does not work: void operator=(std::function writer_fun); inline void operator=(std::function writer_fun); #else - template - inline typename std::enable_if()>::type - operator=(F writer_fun); + template()>::type* dummy = nullptr> + inline void operator=(F writer_fun); - template - inline typename std::enable_if()>::type - operator=(F writer_fun); + template()>::type* dummy = nullptr> + inline void operator=(F writer_fun); #endif private: @@ -381,12 +369,11 @@ namespace sjson m_stream_writer.write(buffer, length); } -#if defined(_MSC_VER) +#if defined(_MSC_VER) && _MSC_VER <= IMPL_SJSON_CPP_VS2015_VER inline void ObjectWriter::insert(const char* key, std::function writer_fun) #else - template - inline typename std::enable_if()>::type - ObjectWriter::insert(const char* key, F writer_fun) + template()>::type* dummy> + inline void ObjectWriter::insert(const char* key, F writer_fun) #endif { SJSON_CPP_ASSERT(!m_is_locked, "Cannot insert SJSON object in locked object"); @@ -409,12 +396,11 @@ namespace sjson m_stream_writer.write(k_line_terminator); } -#if defined(_MSC_VER) +#if defined(_MSC_VER) && _MSC_VER <= IMPL_SJSON_CPP_VS2015_VER inline void ObjectWriter::insert(const char* key, std::function writer_fun) #else - template - inline typename std::enable_if()>::type - ObjectWriter::insert(const char* key, F writer_fun) + template()>::type* dummy> + inline void ObjectWriter::insert(const char* key, F writer_fun) #endif { SJSON_CPP_ASSERT(!m_is_locked, "Cannot insert SJSON array in locked object"); @@ -534,12 +520,11 @@ namespace sjson m_is_empty = false; } -#if defined(_MSC_VER) +#if defined(_MSC_VER) && _MSC_VER <= IMPL_SJSON_CPP_VS2015_VER inline void ObjectWriter::ValueRef::operator=(std::function writer_fun) #else - template - inline typename std::enable_if()>::type - ObjectWriter::ValueRef::operator=(F writer_fun) + template()>::type* dummy> + inline void ObjectWriter::ValueRef::operator=(F writer_fun) #endif { SJSON_CPP_ASSERT(m_is_empty, "Cannot write multiple values within a ValueRef"); @@ -560,12 +545,11 @@ namespace sjson m_is_empty = false; } -#if defined(_MSC_VER) +#if defined(_MSC_VER) && _MSC_VER <= IMPL_SJSON_CPP_VS2015_VER inline void ObjectWriter::ValueRef::operator=(std::function writer_fun) #else - template - inline typename std::enable_if()>::type - ObjectWriter::ValueRef::operator=(F writer_fun) + template()>::type* dummy> + inline void ObjectWriter::ValueRef::operator=(F writer_fun) #endif { SJSON_CPP_ASSERT(m_is_empty, "Cannot write multiple values within a ValueRef"); @@ -719,12 +703,11 @@ namespace sjson m_is_newline = false; } -#if defined(_MSC_VER) +#if defined(_MSC_VER) && _MSC_VER <= IMPL_SJSON_CPP_VS2015_VER inline void ArrayWriter::push(std::function writer_fun) #else - template - inline typename std::enable_if()>::type - ArrayWriter::push(F writer_fun) + template()>::type* dummy> + inline void ArrayWriter::push(F writer_fun) #endif { SJSON_CPP_ASSERT(!m_is_locked, "Cannot push SJSON object in locked array"); @@ -754,12 +737,11 @@ namespace sjson m_is_newline = true; } -#if defined(_MSC_VER) +#if defined(_MSC_VER) && _MSC_VER <= IMPL_SJSON_CPP_VS2015_VER inline void ArrayWriter::push(std::function writer_fun) #else - template - inline typename std::enable_if()>::type - ArrayWriter::push(F writer_fun) + template()>::type* dummy> + inline void ArrayWriter::push(F writer_fun) #endif { SJSON_CPP_ASSERT(!m_is_locked, "Cannot push SJSON array in locked array"); diff --git a/make.py b/make.py index 28de7f5..c075920 100644 --- a/make.py +++ b/make.py @@ -20,7 +20,7 @@ def parse_argv(): target = parser.add_argument_group(title='Target') target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'android', 'clang4', 'clang5', 'clang6', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'osx', 'ios'], help='Defaults to the host system\'s default compiler') target.add_argument('-config', choices=['Debug', 'Release'], type=str.capitalize) - target.add_argument('-cpu', choices=['x86', 'x64'], help='Only supported for Windows, OS X, and Linux; defaults to the host system\'s architecture') + target.add_argument('-cpu', choices=['x86', 'x64', 'arm64'], help='Only supported for Windows, OS X, and Linux; defaults to the host system\'s architecture') misc = parser.add_argument_group(title='Miscellaneous') misc.add_argument('-num_threads', help='No. to use while compiling') @@ -46,6 +46,11 @@ def parse_argv(): print('iOS is only supported on OS X') sys.exit(1) + if args.cpu == 'arm64': + if not args.compiler in ['vs2017', 'ios']: + print('ARM64 is only supported with VS2017 and iOS') + sys.exit(1) + return args def get_cmake_exes(): @@ -67,8 +72,12 @@ def get_generator(compiler, cpu): elif compiler == 'vs2017': if cpu == 'x86': return 'Visual Studio 15' - else: + elif cpu == 'x64': return 'Visual Studio 15 Win64' + elif cpu == 'arm64': + # VS2017 ARM/ARM64 support only works with cmake 3.13 and up and the architecture must be specified with + # the -A cmake switch + return 'Visual Studio 15 2017' elif compiler == 'android': return 'Visual Studio 14' elif platform.system() == 'Darwin': @@ -80,6 +89,19 @@ def get_generator(compiler, cpu): print('Unknown compiler: {}'.format(compiler)) sys.exit(1) +def get_architecture(compiler, cpu): + if compiler == None: + return None + + if platform.system() == 'Windows': + if compiler == 'vs2017': + if cpu == 'arm64': + return 'ARM64' + + # This compiler/cpu pair does not need the architecture switch + return None + + def get_toolchain(compiler): if platform.system() == 'Windows' and compiler == 'android': return 'Toolchain-Android.cmake' @@ -122,30 +144,34 @@ def do_generate_solution(cmake_exe, build_dir, cmake_script_dir, args): cpu = args.cpu config = args.config - if not compiler == None: + if compiler: set_compiler_env(compiler, args) extra_switches = ['--no-warn-unused-cli'] - if not platform.system() == 'Windows': - extra_switches.append('-DCPU_INSTRUCTION_SET:STRING={}'.format(cpu)) + extra_switches.append('-DCPU_INSTRUCTION_SET:STRING={}'.format(cpu)) if not platform.system() == 'Windows' and not platform.system() == 'Darwin': extra_switches.append('-DCMAKE_BUILD_TYPE={}'.format(config.upper())) toolchain = get_toolchain(compiler) - if not toolchain == None: + if toolchain: extra_switches.append('-DCMAKE_TOOLCHAIN_FILE={}'.format(os.path.join(cmake_script_dir, toolchain))) # Generate IDE solution print('Generating build files ...') cmake_cmd = '"{}" .. -DCMAKE_INSTALL_PREFIX="{}" {}'.format(cmake_exe, build_dir, ' '.join(extra_switches)) cmake_generator = get_generator(compiler, cpu) - if cmake_generator == None: + if not cmake_generator: print('Using default generator') else: print('Using generator: {}'.format(cmake_generator)) cmake_cmd += ' -G "{}"'.format(cmake_generator) + cmake_arch = get_architecture(compiler, cpu) + if cmake_arch: + print('Using architecture: {}'.format(cmake_arch)) + cmake_cmd += ' -A {}'.format(cmake_arch) + result = subprocess.call(cmake_cmd, shell=True) if result != 0: sys.exit(result) diff --git a/tests/main_generic/CMakeLists.txt b/tests/main_generic/CMakeLists.txt index 1f73437..943acca 100644 --- a/tests/main_generic/CMakeLists.txt +++ b/tests/main_generic/CMakeLists.txt @@ -28,6 +28,13 @@ ParseAndAddCatchTests(${PROJECT_NAME}) setup_default_compiler_flags(${PROJECT_NAME}) +if(MSVC) + if(CPU_INSTRUCTION_SET MATCHES "arm64") + # Exceptions are not enabled by default for ARM targets, enable them + target_compile_options(${PROJECT_NAME} PRIVATE /EHsc) + endif() +endif() + # Throw on failure to allow us to catch them and recover add_definitions(-DSJSON_CPP_ON_ASSERT_THROW) From 4c1f855967769b769a35dde1f229f510b9cb6fdf Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 30 Mar 2019 16:24:04 -0400 Subject: [PATCH 014/285] Adding minor tweaks. --- make.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/make.py b/make.py index c075920..6fa630e 100644 --- a/make.py +++ b/make.py @@ -67,7 +67,7 @@ def get_generator(compiler, cpu): if compiler == 'vs2015': if cpu == 'x86': return 'Visual Studio 14' - else: + elif cpu == 'x64': return 'Visual Studio 14 Win64' elif compiler == 'vs2017': if cpu == 'x86': @@ -87,6 +87,7 @@ def get_generator(compiler, cpu): return 'Unix Makefiles' print('Unknown compiler: {}'.format(compiler)) + print('See help with: python make.py -help') sys.exit(1) def get_architecture(compiler, cpu): From 3c609f23f9f27d78ba1648ca599af15b4e401c48 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 30 Mar 2019 16:47:33 -0400 Subject: [PATCH 015/285] Fix crash with catch2 on android. --- tests/main_android/jni/main.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/tests/main_android/jni/main.cpp b/tests/main_android/jni/main.cpp index d2f5df3..48062b8 100644 --- a/tests/main_android/jni/main.cpp +++ b/tests/main_android/jni/main.cpp @@ -34,8 +34,7 @@ extern "C" jint Java_com_sjson_cpp_MainActivity_getNumUnitTestCases(JNIEnv* env, extern "C" jint Java_com_sjson_cpp_MainActivity_runUnitTests(JNIEnv* env, jobject caller) { - char* argv[1] = { nullptr }; - int result = Catch::Session().run(0, argv); + int result = Catch::Session().run(); return (result < 0xff ? result : 0xff); } From 214dd7c27be61bfb61a63d67e43103790f745d46 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Thu, 4 Apr 2019 21:24:35 -0400 Subject: [PATCH 016/285] Adding windows arm64 and ios to test script. --- tools/release_scripts/test_everything.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/tools/release_scripts/test_everything.py b/tools/release_scripts/test_everything.py index 59b8c80..2f4dcdb 100644 --- a/tools/release_scripts/test_everything.py +++ b/tools/release_scripts/test_everything.py @@ -35,6 +35,15 @@ def get_python_exe_name(): args = [python_exe, 'make.py', '-compiler', compiler, '-cpu', arch, '-config', config, '-build', '-unit_test', '-clean'] cmd_args.append([x for x in args if x]) + if platform.system() == 'Windows': + for config in configs: + args = [python_exe, 'make.py', '-compiler', 'vs2017', '-cpu', 'arm64', '-config', config, '-build', '-clean'] + cmd_args.append([x for x in args if x]) + elif platform.system() == 'Darwin': + for config in configs: + args = [python_exe, 'make.py', '-compiler', 'ios', '-config', config, '-build', '-clean'] + cmd_args.append([x for x in args if x]) + root_dir = os.path.join(os.getcwd(), '../..') os.chdir(root_dir) From a4b6c52b1ecf84adeb27338a794ab3a26306308d Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Thu, 4 Apr 2019 21:26:46 -0400 Subject: [PATCH 017/285] Updating readme. --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 30cb3d0..60d6bb7 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ [![GitHub (pre-)release](https://img.shields.io/github/release/nfrechette/sjson-cpp/all.svg)](https://github.com/nfrechette/sjson-cpp/releases) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nfrechette/sjson-cpp/master/LICENSE) -# SJSON CPP +# sjson-cpp `sjson-cpp` is a C++ library to read and write [Simplified JSON](http://help.autodesk.com/view/Stingray/ENU/?guid=__stingray_help_managing_content_sjson_html) files. It aims to be minimal, fast, and get out of the way of the programmer. @@ -38,7 +38,7 @@ Unicode formats other than UTF-8 aren't supported. * Windows VS2015 x86 and x64, VS2017 x86, x64, and ARM64* * Linux (gcc5, gcc6, gcc7, gcc8, clang4, clang5, clang6) x86 and x64 * OS X (Xcode 8.3, Xcode 9.4, Xcode 10.1) x86 and x64 -* Android (NVIDIA CodeWorks) ARMv7-A +* Android (NVIDIA CodeWorks) ARMv7-A and ARM64 * iOS (Xcode 8.3, Xcode 9.4, Xcode 10.1) ARM64 The above supported platform list is only what is tested every release but if it compiles, it should run just fine. From 6d363c7af6dbfac2954694c8494b0b379209e493 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Thu, 4 Apr 2019 21:31:50 -0400 Subject: [PATCH 018/285] Updating changelog. --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5fe4008..cb5a78e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Significant changes per release +## 0.6.0 + +* Added support for Windows ARM64, GCC 8, clang 6, and Xcode 10 +* Integrated SonarCloud +* Cleanup and minor changes & fixes + ## 0.5.0 * Cleaned up error handling From d271f576101721b29ae9d558e3742eb8adf77653 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 5 Apr 2019 18:01:19 -0400 Subject: [PATCH 019/285] Updating version numbers. --- appveyor.yml | 2 +- sonar-project.properties | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 5e65d6f..6f710f8 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 0.5.0.{build} +version: 0.6.0.{build} environment: PYTHON: "C:\\Python33-x64" diff --git a/sonar-project.properties b/sonar-project.properties index 5137c7a..01ef609 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,6 +1,6 @@ sonar.projectKey=nfrechette_sjson-cpp -sonar.projectName=SJSON-cpp -sonar.projectVersion=0.5.0 +sonar.projectName=sjson-cpp +sonar.projectVersion=0.6.0 sonar.sources=includes From e41a2a363df1a2876d7fed16aa17efe230793eea Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Thu, 2 May 2019 10:32:00 -0400 Subject: [PATCH 020/285] docs(setup): add mention for the new commit message format --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 60d6bb7..6db936e 100644 --- a/README.md +++ b/README.md @@ -76,6 +76,10 @@ For *Android*, the steps are identical to *Windows, Linux, and OS X* but you als For *iOS*, the steps are identical to the other platforms but due to code signing, you will need to perform the builds from *Xcode* manually. Note that this is only an issue if you attempt to use the tools or run the unit tests locally. +## Commit message format + +This library uses the [angular.js message format](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commits) and it is enforced with commit linting through every pull request. + ## Authors * [Nicholas Frechette](https://github.com/nfrechette) From d6f841bb7f8979a092bea412868f9dbbaf1038b0 Mon Sep 17 00:00:00 2001 From: Cody Jones Date: Sun, 16 Jun 2019 07:16:46 -0700 Subject: [PATCH 021/285] chore: add Visual Studio 2019 support Also simplify the selective inclusion of methods using SFINAE. This is required because neither the existing SFINAE code nor the std::function overloads work when compiling for ARM64 with VS2019. CMake 3.14 or newer is required to build with VS2019. --- README.md | 6 +- appveyor.yml | 12 ++- includes/sjson/writer.h | 109 ++++------------------- make.py | 13 ++- tools/release_scripts/test_everything.py | 2 +- 5 files changed, 38 insertions(+), 104 deletions(-) diff --git a/README.md b/README.md index 6db936e..0b009ec 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,7 @@ Unicode formats other than UTF-8 aren't supported. ## Supported platforms -* Windows VS2015 x86 and x64, VS2017 x86, x64, and ARM64* +* Windows VS2015 x86 and x64, VS2017/2019 x86, x64, and ARM64* * Linux (gcc5, gcc6, gcc7, gcc8, clang4, clang5, clang6) x86 and x64 * OS X (Xcode 8.3, Xcode 9.4, Xcode 10.1) x86 and x64 * Android (NVIDIA CodeWorks) ARMv7-A and ARM64 @@ -43,7 +43,7 @@ Unicode formats other than UTF-8 aren't supported. The above supported platform list is only what is tested every release but if it compiles, it should run just fine. -Note: *VS2017* compiles with *ARM64* on *AppVeyor* but I have no device to test it with. +Note: *VS2017* and *VS2019* compile with *ARM64* on *AppVeyor* but I have no device to test them with. ## External dependencies @@ -56,7 +56,7 @@ This library is **100%** headers as such you just need to include them in your o ### Windows, Linux, and OS X for x86 and x64 -1. Install *CMake 3.2* or higher (*3.10* is required on OS X with *Xcode 10*), *Python 3*, and the proper compiler for your platform. +1. Install *CMake 3.2* or higher (*3.14* for Visual Studio 2019, or *3.10* on OS X with *Xcode 10*), *Python 3*, and the proper compiler for your platform. 2. Execute `git submodule update --init` to get the files of thirdparty submodules (e.g. Catch2). 3. Generate the IDE solution with: `python make.py` The solution is generated under `./build` diff --git a/appveyor.yml b/appveyor.yml index 6f710f8..14d8ea2 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -2,10 +2,12 @@ version: 0.6.0.{build} environment: PYTHON: "C:\\Python33-x64" + VISUAL_STUDIO: "C:\\Program Files (x86)\\Microsoft Visual Studio" image: - Visual Studio 2015 - Visual Studio 2017 +- Visual Studio 2019 install: - cmd: >- @@ -15,7 +17,11 @@ build_script: - cmd: >- IF "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" (SET COMPILER=vs2015) - IF "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" (SET COMPILER=vs2017) + IF "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" (SET COMPILER=vs2017 && SET ARM64_SUPPORTED=1) + + IF "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019" (SET COMPILER=vs2019 && SET ARM64_SUPPORTED=1) + + IF "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019" "%VISUAL_STUDIO%\\Installer\\vs_installershell.exe" modify --productId Microsoft.VisualStudio.Product.Community --channelId VisualStudio.16.Release --add Microsoft.VisualStudio.Component.VC.Tools.ARM64 --add Microsoft.VisualStudio.Component.VC.Runtimes.ARM64.Spectre --quiet %PYTHON%\\python.exe make.py -clean -build -unit_test -compiler %COMPILER% -config Debug -cpu x86 @@ -25,6 +31,6 @@ build_script: %PYTHON%\\python.exe make.py -clean -build -unit_test -compiler %COMPILER% -config Release -cpu x64 - IF "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" %PYTHON%\\python.exe make.py -clean -build -compiler %COMPILER% -config Debug -cpu arm64 + IF DEFINED ARM64_SUPPORTED %PYTHON%\\python.exe make.py -clean -build -compiler %COMPILER% -config Debug -cpu arm64 - IF "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" %PYTHON%\\python.exe make.py -clean -build -compiler %COMPILER% -config Release -cpu arm64 + IF DEFINED ARM64_SUPPORTED %PYTHON%\\python.exe make.py -clean -build -compiler %COMPILER% -config Release -cpu arm64 diff --git a/includes/sjson/writer.h b/includes/sjson/writer.h index a9729bc..008c9a6 100644 --- a/includes/sjson/writer.h +++ b/includes/sjson/writer.h @@ -36,8 +36,7 @@ #include #include #include - -#define IMPL_SJSON_CPP_VS2015_VER 1900 +#include namespace sjson { @@ -77,9 +76,6 @@ namespace sjson std::FILE* m_file; }; -#if !defined(_MSC_VER) || _MSC_VER > IMPL_SJSON_CPP_VS2015_VER - // SFINAE HACK - // Note: This is funky because of C++ lambda coercion rules // A lambda that does not capture anything is equivalent to a static function // and calling a function with it as an argument is equivalent to passing a function pointer. // Of course, a pointer can safely and automatically coerce to 'bool' and as such @@ -88,41 +84,8 @@ namespace sjson // // To resolve this, we use SFINAE template logic to deduce a real type if we pass a function // and if we pass bool, the type will not exist and the function is stripped. - // Different compilers behave differently here: - // VS2015 does not have any issues with the std::function overloads and there are no ambiguity with it but - // it does not support the SFINAE logic either with a return type or template argument. It complains the - // function is already declared. - // VS2017 works with the std::function overloads for x86 and x64 but not with ARM. It also does not work - // with a SFINAE return type but it works with a template argument. - // GCC and clang work with a SFINAE return type or template argument. - // As such, on VS2015, we use the std::function overloads and on VS2017, GCC, and clang we use SFINAE - // with a template argument. - namespace impl - { - template - struct invoke {}; - - template - struct invoke()(std::declval()...)))> - { - using type = decltype(std::declval()(std::declval()...)); - }; - - template - struct invoke_test : std::false_type {}; - - template - struct invoke_test::type()))> : std::true_type - {}; - - template - constexpr bool invokable() - { - return invoke_test::value; - } - } -#endif + template + struct HavingArgument : std::enable_if, F>::value> {}; class ArrayWriter { @@ -140,17 +103,11 @@ namespace sjson inline void push(int64_t value) { push_signed_integer(value); } inline void push(uint64_t value) { push_unsigned_integer(value); } - // See SFINAE HACK above -#if defined(_MSC_VER) && _MSC_VER <= IMPL_SJSON_CPP_VS2015_VER - inline void push(std::function writer_fun); - inline void push(std::function writer_fun); -#else - template()>::type* dummy = nullptr> + template::type* requirement = nullptr> inline void push(F writer_fun); - template()>::type* dummy = nullptr> + template::type* requirement = nullptr> inline void push(F writer_fun); -#endif // TODO: Introduce a newline type void push_newline(); @@ -190,17 +147,11 @@ namespace sjson inline void insert(const char* key, int64_t value) { insert_signed_integer(key, int64_t(value)); } inline void insert(const char* key, uint64_t value) { insert_unsigned_integer(key, uint64_t(value)); } - // See SFINAE HACK above -#if defined(_MSC_VER) && _MSC_VER <= IMPL_SJSON_CPP_VS2015_VER - inline void insert(const char* key, std::function writer_fun); - inline void insert(const char* key, std::function writer_fun); -#else - template()>::type* dummy = nullptr> + template::type* requirement = nullptr> inline void insert(const char* key, F writer_fun); - template()>::type* dummy = nullptr> + template::type* requirement = nullptr> inline void insert(const char* key, F writer_fun); -#endif void insert_newline(); @@ -224,17 +175,11 @@ namespace sjson inline void operator=(int64_t value) { assign_signed_integer(int64_t(value)); } inline void operator=(uint64_t value) { assign_unsigned_integer(uint64_t(value)); } - // See SFINAE HACK above -#if defined(_MSC_VER) && _MSC_VER <= IMPL_SJSON_CPP_VS2015_VER - inline void operator=(std::function writer_fun); - inline void operator=(std::function writer_fun); -#else - template()>::type* dummy = nullptr> + template::type* requirement = nullptr> inline void operator=(F writer_fun); - template()>::type* dummy = nullptr> + template::type* requirement = nullptr> inline void operator=(F writer_fun); -#endif private: inline ValueRef(ObjectWriter& object_writer, const char* key); @@ -369,12 +314,8 @@ namespace sjson m_stream_writer.write(buffer, length); } -#if defined(_MSC_VER) && _MSC_VER <= IMPL_SJSON_CPP_VS2015_VER - inline void ObjectWriter::insert(const char* key, std::function writer_fun) -#else - template()>::type* dummy> + template::type* requirement> inline void ObjectWriter::insert(const char* key, F writer_fun) -#endif { SJSON_CPP_ASSERT(!m_is_locked, "Cannot insert SJSON object in locked object"); SJSON_CPP_ASSERT(!m_has_live_value_ref, "Cannot insert SJSON object in object when it has a live ValueRef"); @@ -396,12 +337,8 @@ namespace sjson m_stream_writer.write(k_line_terminator); } -#if defined(_MSC_VER) && _MSC_VER <= IMPL_SJSON_CPP_VS2015_VER - inline void ObjectWriter::insert(const char* key, std::function writer_fun) -#else - template()>::type* dummy> + template::type* requirement > inline void ObjectWriter::insert(const char* key, F writer_fun) -#endif { SJSON_CPP_ASSERT(!m_is_locked, "Cannot insert SJSON array in locked object"); SJSON_CPP_ASSERT(!m_has_live_value_ref, "Cannot insert SJSON array in object when it has a live ValueRef"); @@ -520,12 +457,8 @@ namespace sjson m_is_empty = false; } -#if defined(_MSC_VER) && _MSC_VER <= IMPL_SJSON_CPP_VS2015_VER - inline void ObjectWriter::ValueRef::operator=(std::function writer_fun) -#else - template()>::type* dummy> + template::type* requirement> inline void ObjectWriter::ValueRef::operator=(F writer_fun) -#endif { SJSON_CPP_ASSERT(m_is_empty, "Cannot write multiple values within a ValueRef"); SJSON_CPP_ASSERT(m_object_writer != nullptr, "ValueRef not initialized"); @@ -545,12 +478,8 @@ namespace sjson m_is_empty = false; } -#if defined(_MSC_VER) && _MSC_VER <= IMPL_SJSON_CPP_VS2015_VER - inline void ObjectWriter::ValueRef::operator=(std::function writer_fun) -#else - template()>::type* dummy> + template::type* requirement> inline void ObjectWriter::ValueRef::operator=(F writer_fun) -#endif { SJSON_CPP_ASSERT(m_is_empty, "Cannot write multiple values within a ValueRef"); SJSON_CPP_ASSERT(m_object_writer != nullptr, "ValueRef not initialized"); @@ -703,12 +632,8 @@ namespace sjson m_is_newline = false; } -#if defined(_MSC_VER) && _MSC_VER <= IMPL_SJSON_CPP_VS2015_VER - inline void ArrayWriter::push(std::function writer_fun) -#else - template()>::type* dummy> + template::type* requirement> inline void ArrayWriter::push(F writer_fun) -#endif { SJSON_CPP_ASSERT(!m_is_locked, "Cannot push SJSON object in locked array"); @@ -737,12 +662,8 @@ namespace sjson m_is_newline = true; } -#if defined(_MSC_VER) && _MSC_VER <= IMPL_SJSON_CPP_VS2015_VER - inline void ArrayWriter::push(std::function writer_fun) -#else - template()>::type* dummy> + template::type* requirement> inline void ArrayWriter::push(F writer_fun) -#endif { SJSON_CPP_ASSERT(!m_is_locked, "Cannot push SJSON array in locked array"); diff --git a/make.py b/make.py index 6fa630e..b3cda20 100644 --- a/make.py +++ b/make.py @@ -18,7 +18,7 @@ def parse_argv(): actions.add_argument('-unit_test', action='store_true') target = parser.add_argument_group(title='Target') - target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'android', 'clang4', 'clang5', 'clang6', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'osx', 'ios'], help='Defaults to the host system\'s default compiler') + target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'android', 'clang4', 'clang5', 'clang6', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'osx', 'ios'], help='Defaults to the host system\'s default compiler') target.add_argument('-config', choices=['Debug', 'Release'], type=str.capitalize) target.add_argument('-cpu', choices=['x86', 'x64', 'arm64'], help='Only supported for Windows, OS X, and Linux; defaults to the host system\'s architecture') @@ -47,8 +47,8 @@ def parse_argv(): sys.exit(1) if args.cpu == 'arm64': - if not args.compiler in ['vs2017', 'ios']: - print('ARM64 is only supported with VS2017 and iOS') + if not args.compiler in ['vs2017', 'vs2019', 'ios']: + print('ARM64 is only supported with VS2017, VS2019, and iOS') sys.exit(1) return args @@ -78,6 +78,8 @@ def get_generator(compiler, cpu): # VS2017 ARM/ARM64 support only works with cmake 3.13 and up and the architecture must be specified with # the -A cmake switch return 'Visual Studio 15 2017' + elif compiler == 'vs2019': + return 'Visual Studio 16 2019' elif compiler == 'android': return 'Visual Studio 14' elif platform.system() == 'Darwin': @@ -98,6 +100,11 @@ def get_architecture(compiler, cpu): if compiler == 'vs2017': if cpu == 'arm64': return 'ARM64' + elif compiler == 'vs2019': + if cpu == 'x86': + return 'Win32' + else: + return cpu # This compiler/cpu pair does not need the architecture switch return None diff --git a/tools/release_scripts/test_everything.py b/tools/release_scripts/test_everything.py index 2f4dcdb..12661c2 100644 --- a/tools/release_scripts/test_everything.py +++ b/tools/release_scripts/test_everything.py @@ -5,7 +5,7 @@ def get_platform_compilers(): if platform.system() == 'Windows': - return [ 'vs2015', 'vs2017' ] + return [ 'vs2015', 'vs2017', 'vs2019' ] elif platform.system() == 'Linux': return [ 'gcc5', 'gcc6', 'gcc7', 'clang4', 'clang5' ] elif platform.system() == 'Darwin': From 407adde80a9afb1bf4d9e0500d254881dcff2f27 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 14 Aug 2019 20:05:11 -0400 Subject: [PATCH 022/285] chore: fix multicore support MSVC builds now use parallel compilation and python will detect the number of cores available properly. Bumping appveyor python version to 3.6. --- appveyor.yml | 2 +- cmake/CMakeCompiler.cmake | 1 + make.py | 10 +++++++++- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 14d8ea2..9507506 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,7 +1,7 @@ version: 0.6.0.{build} environment: - PYTHON: "C:\\Python33-x64" + PYTHON: "C:\\Python36-x64" VISUAL_STUDIO: "C:\\Program Files (x86)\\Microsoft Visual Studio" image: diff --git a/cmake/CMakeCompiler.cmake b/cmake/CMakeCompiler.cmake index 2868de1..fae4e93 100644 --- a/cmake/CMakeCompiler.cmake +++ b/cmake/CMakeCompiler.cmake @@ -8,6 +8,7 @@ macro(setup_default_compiler_flags _project_name) target_compile_options(${_project_name} PRIVATE /Zi) # Add debug info target_compile_options(${_project_name} PRIVATE /Oi) # Generate intrinsic functions target_compile_options(${_project_name} PRIVATE /WX) # Treat warnings as errors + target_compile_options(${_project_name} PRIVATE /MP) # Enable parallel compilation if(MSVC_VERSION GREATER 1900) # VS2017 and above diff --git a/make.py b/make.py index b3cda20..c5811f8 100644 --- a/make.py +++ b/make.py @@ -27,7 +27,14 @@ def parse_argv(): misc.add_argument('-tests_matching', help='Only run tests whose names match this regex') misc.add_argument('-help', action='help', help='Display this usage information') - parser.set_defaults(build=False, clean=False, unit_test=False, compiler=None, config='Release', cpu='x64', num_threads=4, tests_matching='') + + num_threads = os.cpu_count() + if platform.system() == 'Linux': + num_threads = len(os.sched_getaffinity(0)) + if not num_threads or num_threads == 0: + num_threads = 4 + + parser.set_defaults(build=False, clean=False, unit_test=False, compiler=None, config='Release', cpu='x64', num_threads=num_threads, tests_matching='') args = parser.parse_args() @@ -246,6 +253,7 @@ def do_tests(ctest_exe, args): print('Using cpu: {}'.format(args.cpu)) if not args.compiler == None: print('Using compiler: {}'.format(args.compiler)) + print('Using {} threads'.format(args.num_threads)) do_generate_solution(cmake_exe, build_dir, cmake_script_dir, args) From 1242ec74d7941958341a3434501f8b5c48d766f3 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 14 Aug 2019 20:06:07 -0400 Subject: [PATCH 023/285] fix(android): fix processor count detection to be cross-platform --- cmake/Toolchain-Android.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/Toolchain-Android.cmake b/cmake/Toolchain-Android.cmake index 97bda18..7910664 100644 --- a/cmake/Toolchain-Android.cmake +++ b/cmake/Toolchain-Android.cmake @@ -1,6 +1,10 @@ cmake_minimum_required (VERSION 3.2) +include(ProcessorCount) set(CMAKE_SYSTEM_NAME Android) # Use the clang tool set because it's support for C++11 is superior set(CMAKE_GENERATOR_TOOLSET DefaultClang) + +# Make sure we use all our processors when building +ProcessorCount(CMAKE_ANDROID_PROCESS_MAX) From d73257bb4082309914a6003f4b1b462395f47077 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 14 Aug 2019 20:47:24 -0400 Subject: [PATCH 024/285] fix(android): fix to properly newer NVIDIA CodeWorks --- tests/main_android/CMakeLists.txt | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/main_android/CMakeLists.txt b/tests/main_android/CMakeLists.txt index 154bd50..adfdb34 100644 --- a/tests/main_android/CMakeLists.txt +++ b/tests/main_android/CMakeLists.txt @@ -4,8 +4,8 @@ project(sjson-cpp_unit_tests) set(CMAKE_CXX_STANDARD 11) set(CMAKE_ANDROID_ARCH armv7-a) -set(CMAKE_ANDROID_API_MIN 21) -set(CMAKE_ANDROID_API 21) +set(CMAKE_ANDROID_API_MIN 24) +set(CMAKE_ANDROID_API 24) set(CMAKE_ANDROID_GUI 1) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") @@ -51,6 +51,7 @@ set_target_properties(${PROJECT_NAME} PROPERTIES ANDROID_SKIP_ANT_STEP 0) set_target_properties(${PROJECT_NAME} PROPERTIES ANDROID_PROGUARD 1) set_target_properties(${PROJECT_NAME} PROPERTIES ANDROID_PROGUARD_CONFIG_PATH proguard-android.txt) set_target_properties(${PROJECT_NAME} PROPERTIES ANDROID_SECURE_PROPS_PATH /definitely/insecure) +set_target_properties(${PROJECT_NAME} PROPERTIES VS_GLOBAL_AndroidBuildSystem "AntBuild") # Use Ant as our build system set_property(TARGET ${PROJECT_NAME} PROPERTY ANDROID_NATIVE_LIB_DIRECTORIES $) set_property(TARGET ${PROJECT_NAME} PROPERTY ANDROID_NATIVE_LIB_DEPENDENCIES ${PROJECT_NAME}.so) From c1f6d5050af7ff170673a1f17f691c264ca2d9df Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 14 Aug 2019 20:53:01 -0400 Subject: [PATCH 025/285] feat(test): run unit tests in parallel from CMake --- make.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/make.py b/make.py index c5811f8..331e4f9 100644 --- a/make.py +++ b/make.py @@ -216,7 +216,8 @@ def do_build(cmake_exe, args): def do_tests(ctest_exe, args): print('Running unit tests ...') - ctest_cmd = '"{}" --output-on-failure'.format(ctest_exe) + ctest_cmd = '"{}" --output-on-failure --parallel {}'.format(ctest_exe, args.num_threads) + if platform.system() == 'Windows' or platform.system() == 'Darwin': ctest_cmd += ' -C {}'.format(args.config) if args.tests_matching: From 7395b10557f5ade3d1ab826db1adfb052050dea5 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 14 Aug 2019 21:06:16 -0400 Subject: [PATCH 026/285] feat(parser): add support for try_read with integers --- includes/sjson/parser.h | 31 +++++++ tests/sources/test_parser.cpp | 147 ++++++++++++++++++++++++++++++++++ 2 files changed, 178 insertions(+) diff --git a/includes/sjson/parser.h b/includes/sjson/parser.h index 7a48850..879d6d3 100644 --- a/includes/sjson/parser.h +++ b/includes/sjson/parser.h @@ -252,6 +252,15 @@ namespace sjson return false; } + bool try_read(const char* key, int8_t& value, int8_t default_value) { return try_read_integer_impl(key, value, default_value); } + bool try_read(const char* key, uint8_t& value, uint8_t default_value) { return try_read_integer_impl(key, value, default_value); } + bool try_read(const char* key, int16_t& value, int16_t default_value) { return try_read_integer_impl(key, value, default_value); } + bool try_read(const char* key, uint16_t& value, uint16_t default_value) { return try_read_integer_impl(key, value, default_value); } + bool try_read(const char* key, int32_t& value, int32_t default_value) { return try_read_integer_impl(key, value, default_value); } + bool try_read(const char* key, uint32_t& value, uint32_t default_value) { return try_read_integer_impl(key, value, default_value); } + bool try_read(const char* key, int64_t& value, int64_t default_value) { return try_read_integer_impl(key, value, default_value); } + bool try_read(const char* key, uint64_t& value, uint64_t default_value) { return try_read_integer_impl(key, value, default_value); } + bool try_read(const char* key, double* values, uint32_t num_elements, double default_value) { ParserState s = save_state(); @@ -830,6 +839,28 @@ namespace sjson return true; } + template + bool try_read_integer_impl(const char* key, IntegerType& value, IntegerType default_value) + { + ParserState s = save_state(); + + if (read_key(key) && read_equal_sign()) + { + if (try_read_null()) + { + value = default_value; + return false; + } + + if (read_integer(value)) + return true; + } + + restore_state(s); + value = default_value; + return false; + } + static bool is_hex_digit(char value) { return std::isdigit(value) diff --git a/tests/sources/test_parser.cpp b/tests/sources/test_parser.cpp index 8284bb2..d104a2c 100644 --- a/tests/sources/test_parser.cpp +++ b/tests/sources/test_parser.cpp @@ -237,6 +237,7 @@ TEST_CASE("Parser String Reading", "[parser]") TEST_CASE("Parser Number Reading", "[parser]") { + // Number reading { Parser parser = parser_from_c_str("key = 123.456789"); double value; @@ -327,6 +328,8 @@ TEST_CASE("Parser Number Reading", "[parser]") REQUIRE(parser.is_valid()); } + // Number try reading + { Parser parser = parser_from_c_str("bad_key = \"bad\""); double value = 0.0; @@ -362,6 +365,150 @@ TEST_CASE("Parser Number Reading", "[parser]") REQUIRE(parser.eof()); REQUIRE(parser.is_valid()); } + + { + Parser parser = parser_from_c_str("bad_key = \"bad\""); + int8_t value = 0; + REQUIRE_FALSE(parser.try_read("key", value, 1)); + REQUIRE(value == 1); + REQUIRE_FALSE(parser.eof()); + REQUIRE(parser.is_valid()); + } + + { + Parser parser = parser_from_c_str("key = -123"); + int8_t value; + REQUIRE(parser.try_read("key", value, 1)); + REQUIRE(value == -123); + REQUIRE(parser.eof()); + REQUIRE(parser.is_valid()); + } + + { + Parser parser = parser_from_c_str("bad_key = \"bad\""); + uint8_t value = 0; + REQUIRE_FALSE(parser.try_read("key", value, 1)); + REQUIRE(value == 1); + REQUIRE_FALSE(parser.eof()); + REQUIRE(parser.is_valid()); + } + + { + Parser parser = parser_from_c_str("key = 123"); + uint8_t value; + REQUIRE(parser.try_read("key", value, 1)); + REQUIRE(value == 123); + REQUIRE(parser.eof()); + REQUIRE(parser.is_valid()); + } + + { + Parser parser = parser_from_c_str("bad_key = \"bad\""); + int16_t value = 0; + REQUIRE_FALSE(parser.try_read("key", value, 1)); + REQUIRE(value == 1); + REQUIRE_FALSE(parser.eof()); + REQUIRE(parser.is_valid()); + } + + { + Parser parser = parser_from_c_str("key = -1234"); + int16_t value; + REQUIRE(parser.try_read("key", value, 1)); + REQUIRE(value == -1234); + REQUIRE(parser.eof()); + REQUIRE(parser.is_valid()); + } + + { + Parser parser = parser_from_c_str("bad_key = \"bad\""); + uint16_t value = 0; + REQUIRE_FALSE(parser.try_read("key", value, 1)); + REQUIRE(value == 1); + REQUIRE_FALSE(parser.eof()); + REQUIRE(parser.is_valid()); + } + + { + Parser parser = parser_from_c_str("key = 1234"); + uint16_t value; + REQUIRE(parser.try_read("key", value, 1)); + REQUIRE(value == 1234); + REQUIRE(parser.eof()); + REQUIRE(parser.is_valid()); + } + + { + Parser parser = parser_from_c_str("bad_key = \"bad\""); + int32_t value = 0; + REQUIRE_FALSE(parser.try_read("key", value, 1)); + REQUIRE(value == 1); + REQUIRE_FALSE(parser.eof()); + REQUIRE(parser.is_valid()); + } + + { + Parser parser = parser_from_c_str("key = -123456"); + int32_t value; + REQUIRE(parser.try_read("key", value, 1)); + REQUIRE(value == -123456); + REQUIRE(parser.eof()); + REQUIRE(parser.is_valid()); + } + + { + Parser parser = parser_from_c_str("bad_key = \"bad\""); + uint32_t value = 0; + REQUIRE_FALSE(parser.try_read("key", value, 1)); + REQUIRE(value == 1); + REQUIRE_FALSE(parser.eof()); + REQUIRE(parser.is_valid()); + } + + { + Parser parser = parser_from_c_str("key = 123456"); + uint32_t value; + REQUIRE(parser.try_read("key", value, 1)); + REQUIRE(value == 123456); + REQUIRE(parser.eof()); + REQUIRE(parser.is_valid()); + } + + { + Parser parser = parser_from_c_str("bad_key = \"bad\""); + int64_t value = 0; + REQUIRE_FALSE(parser.try_read("key", value, 1)); + REQUIRE(value == 1); + REQUIRE_FALSE(parser.eof()); + REQUIRE(parser.is_valid()); + } + + { + Parser parser = parser_from_c_str("key = -1234567890123456"); + int64_t value; + REQUIRE(parser.try_read("key", value, 1)); + REQUIRE(value == -1234567890123456ll); + REQUIRE(parser.eof()); + REQUIRE(parser.is_valid()); + } + + { + Parser parser = parser_from_c_str("bad_key = \"bad\""); + uint64_t value = 0; + REQUIRE_FALSE(parser.try_read("key", value, 1)); + REQUIRE(value == 1); + REQUIRE_FALSE(parser.eof()); + REQUIRE(parser.is_valid()); + } + + { + Parser parser = parser_from_c_str("key = 1234567890123456"); + uint64_t value; + REQUIRE(parser.try_read("key", value, 1)); + REQUIRE(value == 1234567890123456ull); + REQUIRE(parser.eof()); + REQUIRE(parser.is_valid()); + } } TEST_CASE("Parser Array Reading", "[parser]") From 53ccb531f168d84f4082145c6c5d6ad8dfc4ade7 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Thu, 12 Sep 2019 18:26:04 -0400 Subject: [PATCH 027/285] docs: add mention for android compiler and platforms tested --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0b009ec..17e7b3d 100644 --- a/README.md +++ b/README.md @@ -38,7 +38,7 @@ Unicode formats other than UTF-8 aren't supported. * Windows VS2015 x86 and x64, VS2017/2019 x86, x64, and ARM64* * Linux (gcc5, gcc6, gcc7, gcc8, clang4, clang5, clang6) x86 and x64 * OS X (Xcode 8.3, Xcode 9.4, Xcode 10.1) x86 and x64 -* Android (NVIDIA CodeWorks) ARMv7-A and ARM64 +* Android (NVIDIA CodeWorks with clang5) ARMv7-A and ARM64 * iOS (Xcode 8.3, Xcode 9.4, Xcode 10.1) ARM64 The above supported platform list is only what is tested every release but if it compiles, it should run just fine. From 2d1ccb341a663f30371835e90e411aed4b96e4a4 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Thu, 12 Sep 2019 18:29:13 -0400 Subject: [PATCH 028/285] feat: convert make.py to support python2 This is needed to speed up Travis CI on OS X by avoiding the need to install python3. Removed unused imports. --- make.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/make.py b/make.py index 331e4f9..3ac7b67 100644 --- a/make.py +++ b/make.py @@ -1,13 +1,10 @@ import argparse +import multiprocessing import os import platform -import queue import shutil import subprocess import sys -import threading -import time -import zipfile def parse_argv(): parser = argparse.ArgumentParser(add_help=False) @@ -28,8 +25,8 @@ def parse_argv(): misc.add_argument('-help', action='help', help='Display this usage information') - num_threads = os.cpu_count() - if platform.system() == 'Linux': + num_threads = multiprocessing.cpu_count() + if platform.system() == 'Linux' and sys.version_info >= (3, 4): num_threads = len(os.sched_getaffinity(0)) if not num_threads or num_threads == 0: num_threads = 4 From 7091cfdfeb9dc3c692a9c7b49ca09bc1ba7aaea0 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Thu, 12 Sep 2019 18:29:57 -0400 Subject: [PATCH 029/285] chore: switch travis to use python2 No longer need to install python3 on OS X. --- .travis.yml | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/.travis.yml b/.travis.yml index 62e093c..1ffd2f5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -61,23 +61,19 @@ before_install: sudo -E apt-get -yq update; sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install ${PACKAGES}; fi' - - 'if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - brew update || true; - brew upgrade python || true; - fi' script: - - python3 make.py -clean -build -unit_test -compiler ${COMPILER} -config Debug -cpu x86 - - python3 make.py -clean -build -unit_test -compiler ${COMPILER} -config Release -cpu x86 - - python3 make.py -clean -build -unit_test -compiler ${COMPILER} -config Debug -cpu x64 - - python3 make.py -clean -build -unit_test -compiler ${COMPILER} -config Release -cpu x64 + - python make.py -clean -build -unit_test -compiler ${COMPILER} -config Debug -cpu x86 + - python make.py -clean -build -unit_test -compiler ${COMPILER} -config Release -cpu x86 + - python make.py -clean -build -unit_test -compiler ${COMPILER} -config Debug -cpu x64 + - python make.py -clean -build -unit_test -compiler ${COMPILER} -config Release -cpu x64 - 'if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - python3 make.py -clean -build -compiler ios -config Debug; - python3 make.py -clean -build -compiler ios -config Release; + python make.py -clean -build -compiler ios -config Debug; + python make.py -clean -build -compiler ios -config Release; fi' # Only run sonarcloud on non-PRs - 'if [[ "$SONARCLOUD" == "1" && "$TRAVIS_PULL_REQUEST" == "false" ]]; then - python3 make.py -clean -compiler ${COMPILER} -config Release -cpu x64; - build-wrapper-linux-x86-64 --out-dir bw_output python3 make.py -build -compiler ${COMPILER} -config Release -cpu x64; + python make.py -clean -compiler ${COMPILER} -config Release -cpu x64; + build-wrapper-linux-x86-64 --out-dir bw_output python make.py -build -compiler ${COMPILER} -config Release -cpu x64; sonar-scanner; fi' From 534d297f79cb18967c3aa9fc985e6ac1d830be31 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Thu, 12 Sep 2019 18:30:19 -0400 Subject: [PATCH 030/285] chore: switch travis XCode 10 image to 10.3 --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 1ffd2f5..880671c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,7 +48,7 @@ matrix: # OS X xcode10 - os: osx - osx_image: xcode10.1 + osx_image: xcode10.3 env: COMPILER=osx TOOLCHAIN=xcode before_install: From 61c7b039ec2e7a0cb22c191d5e9c380c17917fe5 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Thu, 12 Sep 2019 20:09:03 -0400 Subject: [PATCH 031/285] docs: update OS X and iOS platform list --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 17e7b3d..6f2e615 100644 --- a/README.md +++ b/README.md @@ -37,9 +37,9 @@ Unicode formats other than UTF-8 aren't supported. * Windows VS2015 x86 and x64, VS2017/2019 x86, x64, and ARM64* * Linux (gcc5, gcc6, gcc7, gcc8, clang4, clang5, clang6) x86 and x64 -* OS X (Xcode 8.3, Xcode 9.4, Xcode 10.1) x86 and x64 +* OS X (Xcode 8.3, 9.4, 10.3) x86 and x64 * Android (NVIDIA CodeWorks with clang5) ARMv7-A and ARM64 -* iOS (Xcode 8.3, Xcode 9.4, Xcode 10.1) ARM64 +* iOS (Xcode 8.3, 9.4, 10.3) ARM64 The above supported platform list is only what is tested every release but if it compiles, it should run just fine. @@ -56,7 +56,7 @@ This library is **100%** headers as such you just need to include them in your o ### Windows, Linux, and OS X for x86 and x64 -1. Install *CMake 3.2* or higher (*3.14* for Visual Studio 2019, or *3.10* on OS X with *Xcode 10*), *Python 3*, and the proper compiler for your platform. +1. Install *CMake 3.2* or higher (*3.14* for Visual Studio 2019, or *3.10* on OS X with *Xcode 10*), *Python 2.7 or 3*, and the proper compiler for your platform. 2. Execute `git submodule update --init` to get the files of thirdparty submodules (e.g. Catch2). 3. Generate the IDE solution with: `python make.py` The solution is generated under `./build` From bf06fd525e702a524e2d85fac9f8624cab3a6039 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Thu, 12 Sep 2019 20:59:19 -0400 Subject: [PATCH 032/285] docs: clarify wording --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6f2e615..398796a 100644 --- a/README.md +++ b/README.md @@ -57,7 +57,7 @@ This library is **100%** headers as such you just need to include them in your o ### Windows, Linux, and OS X for x86 and x64 1. Install *CMake 3.2* or higher (*3.14* for Visual Studio 2019, or *3.10* on OS X with *Xcode 10*), *Python 2.7 or 3*, and the proper compiler for your platform. -2. Execute `git submodule update --init` to get the files of thirdparty submodules (e.g. Catch2). +2. Execute `git submodule update --init` to get the files of external submodules (e.g. Catch2). 3. Generate the IDE solution with: `python make.py` The solution is generated under `./build` Note that if you do not have CMake in your `PATH`, you should define the `SJSON_CPP_CMAKE_HOME` environment variable to something like `C:\Program Files\CMake`. From 4ab301babfc960c3a0d4181a31e4aa6a8b4578db Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 16 Oct 2019 17:38:44 -0400 Subject: [PATCH 033/285] fix: fix sonarcloud missing sources --- sonar-project.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 01ef609..9503c7e 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -2,6 +2,6 @@ sonar.projectKey=nfrechette_sjson-cpp sonar.projectName=sjson-cpp sonar.projectVersion=0.6.0 -sonar.sources=includes +sonar.sources=includes,tests/sources,tests/main_generic sonar.cfamily.build-wrapper-output=bw_output From 69c00fde35d5bcb615e75d9017705a6cb74cdc1c Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 1 Nov 2019 20:47:38 -0400 Subject: [PATCH 034/285] feat: add support for reading and writing NaN/Inf values --- includes/sjson/parser.h | 50 +++++++++++++++- includes/sjson/writer.h | 82 ++++++++++++++++++++++---- tests/sources/test_parser.cpp | 58 ++++++++++++++++++ tests/sources/test_writer.cpp | 108 ++++++++++++++++++++++++++++++++++ 4 files changed, 284 insertions(+), 14 deletions(-) diff --git a/includes/sjson/parser.h b/includes/sjson/parser.h index 879d6d3..21ce8e8 100644 --- a/includes/sjson/parser.h +++ b/includes/sjson/parser.h @@ -34,11 +34,12 @@ #include "sjson/impl/compiler_utils.h" #include "sjson/string_view.h" +#include #include #include #include #include -#include +#include namespace sjson { @@ -671,6 +672,53 @@ namespace sjson size_t start_offset = m_state.offset; size_t end_offset; + if (m_state.symbol == '"') + { + advance(); + + if (m_state.symbol == 'n' && advance()) + { + if (m_state.symbol == 'a' && advance() && + m_state.symbol == 'n' && advance() && + m_state.symbol == '"' && advance()) + { + if (dbl_value != nullptr) + *dbl_value = std::nan(""); + else + *flt_value = std::nanf(""); + return true; + } + } + else if (m_state.symbol == '-' && advance()) + { + if (m_state.symbol == 'i' && advance() && + m_state.symbol == 'n' && advance() && + m_state.symbol == 'f' && advance() && + m_state.symbol == '"' && advance()) + { + if (dbl_value != nullptr) + *dbl_value = -std::numeric_limits::infinity(); + else + *flt_value = -std::numeric_limits::infinity(); + return true; + } + } + else if (m_state.symbol == 'i' && advance() && + m_state.symbol == 'n' && advance() && + m_state.symbol == 'f' && advance() && + m_state.symbol == '"' && advance()) + { + if (dbl_value != nullptr) + *dbl_value = std::numeric_limits::infinity(); + else + *flt_value = std::numeric_limits::infinity(); + return true; + } + + set_error(ParserError::NumberExpected); + return false; + } + if (m_state.symbol == '-') advance(); diff --git a/includes/sjson/writer.h b/includes/sjson/writer.h index 008c9a6..09e2c55 100644 --- a/includes/sjson/writer.h +++ b/includes/sjson/writer.h @@ -31,11 +31,13 @@ #include "sjson/error.h" -#include #include #include #include +#include #include +#include +#include #include namespace sjson @@ -276,10 +278,28 @@ namespace sjson m_stream_writer.write(key); m_stream_writer.write(" = "); - char buffer[256]; - size_t length = snprintf(buffer, sizeof(buffer), "%.17g%s", value, k_line_terminator); - SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to insert SJSON value: [%s = %.17g]", key, value); - m_stream_writer.write(buffer, length); + if (std::isnan(value)) + { + m_stream_writer.write("\"nan\""); + m_stream_writer.write(k_line_terminator); + } + else if (std::isinf(value)) + { + m_stream_writer.write("\""); + + if (value < 0.0) + m_stream_writer.write("-"); + + m_stream_writer.write("inf\""); + m_stream_writer.write(k_line_terminator); + } + else + { + char buffer[256]; + size_t length = snprintf(buffer, sizeof(buffer), "%.17g%s", value, k_line_terminator); + SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to insert SJSON value: [%s = %.17g]", key, value); + m_stream_writer.write(buffer, length); + } } inline void ObjectWriter::insert_signed_integer(const char* key, int64_t value) @@ -450,10 +470,29 @@ namespace sjson SJSON_CPP_ASSERT(m_object_writer != nullptr, "ValueRef not initialized"); SJSON_CPP_ASSERT(!m_is_locked, "Cannot assign a value when locked"); - char buffer[256]; - size_t length = snprintf(buffer, sizeof(buffer), "%.17g%s", value, k_line_terminator); - SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to assign SJSON value: %.17g", value); - m_object_writer->m_stream_writer.write(buffer, length); + if (std::isnan(value)) + { + m_object_writer->m_stream_writer.write("\"nan\""); + m_object_writer->m_stream_writer.write(k_line_terminator); + } + else if (std::isinf(value)) + { + m_object_writer->m_stream_writer.write("\""); + + if (value < 0.0) + m_object_writer->m_stream_writer.write("-"); + + m_object_writer->m_stream_writer.write("inf\""); + m_object_writer->m_stream_writer.write(k_line_terminator); + } + else + { + char buffer[256]; + size_t length = snprintf(buffer, sizeof(buffer), "%.17g%s", value, k_line_terminator); + SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to assign SJSON value: %.17g", value); + m_object_writer->m_stream_writer.write(buffer, length); + } + m_is_empty = false; } @@ -588,10 +627,27 @@ namespace sjson if (m_is_newline) write_indentation(); - char buffer[256]; - size_t length = snprintf(buffer, sizeof(buffer), "%.17g", value); - SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to push SJSON value: %.17g", value); - m_stream_writer.write(buffer, length); + if (std::isnan(value)) + { + m_stream_writer.write("\"nan\""); + } + else if (std::isinf(value)) + { + m_stream_writer.write("\""); + + if (value < 0.0) + m_stream_writer.write("-"); + + m_stream_writer.write("inf\""); + } + else + { + char buffer[256]; + size_t length = snprintf(buffer, sizeof(buffer), "%.17g", value); + SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to push SJSON value: %.17g", value); + m_stream_writer.write(buffer, length); + } + m_is_empty = false; m_is_newline = false; } diff --git a/tests/sources/test_parser.cpp b/tests/sources/test_parser.cpp index d104a2c..94753af 100644 --- a/tests/sources/test_parser.cpp +++ b/tests/sources/test_parser.cpp @@ -247,6 +247,35 @@ TEST_CASE("Parser Number Reading", "[parser]") REQUIRE(parser.is_valid()); } + { + Parser parser = parser_from_c_str("key = \"nan\""); + double value; + REQUIRE(parser.read("key", value)); + REQUIRE(std::isnan(value)); + REQUIRE(parser.eof()); + REQUIRE(parser.is_valid()); + } + + { + Parser parser = parser_from_c_str("key = \"inf\""); + double value; + REQUIRE(parser.read("key", value)); + REQUIRE(std::isinf(value)); + REQUIRE(value > 0.0); + REQUIRE(parser.eof()); + REQUIRE(parser.is_valid()); + } + + { + Parser parser = parser_from_c_str("key = \"-inf\""); + double value; + REQUIRE(parser.read("key", value)); + REQUIRE(std::isinf(value)); + REQUIRE(value < 0.0); + REQUIRE(parser.eof()); + REQUIRE(parser.is_valid()); + } + { Parser parser = parser_from_c_str("key = 123.456789"); float value; @@ -256,6 +285,35 @@ TEST_CASE("Parser Number Reading", "[parser]") REQUIRE(parser.is_valid()); } + { + Parser parser = parser_from_c_str("key = \"nan\""); + float value; + REQUIRE(parser.read("key", value)); + REQUIRE(std::isnan(value)); + REQUIRE(parser.eof()); + REQUIRE(parser.is_valid()); + } + + { + Parser parser = parser_from_c_str("key = \"inf\""); + float value; + REQUIRE(parser.read("key", value)); + REQUIRE(std::isinf(value)); + REQUIRE(value > 0.0f); + REQUIRE(parser.eof()); + REQUIRE(parser.is_valid()); + } + + { + Parser parser = parser_from_c_str("key = \"-inf\""); + float value; + REQUIRE(parser.read("key", value)); + REQUIRE(std::isinf(value)); + REQUIRE(value < 0.0f); + REQUIRE(parser.eof()); + REQUIRE(parser.is_valid()); + } + { Parser parser = parser_from_c_str("key = -123"); int8_t value; diff --git a/tests/sources/test_writer.cpp b/tests/sources/test_writer.cpp index 72f56bc..e02a8b5 100644 --- a/tests/sources/test_writer.cpp +++ b/tests/sources/test_writer.cpp @@ -169,6 +169,48 @@ TEST_CASE("Writer Object Number Writing", "[writer]") REQUIRE(str_writer.str() == "key = 123.456\r\n"); } + { + StringStreamWriter str_writer; + Writer writer(str_writer); + writer.insert("key", std::nan("")); + REQUIRE(str_writer.str() == "key = \"nan\"\r\n"); + } + + { + StringStreamWriter str_writer; + Writer writer(str_writer); + writer["key"] = std::nan(""); + REQUIRE(str_writer.str() == "key = \"nan\"\r\n"); + } + + { + StringStreamWriter str_writer; + Writer writer(str_writer); + writer.insert("key", std::numeric_limits::infinity()); + REQUIRE(str_writer.str() == "key = \"inf\"\r\n"); + } + + { + StringStreamWriter str_writer; + Writer writer(str_writer); + writer["key"] = std::numeric_limits::infinity(); + REQUIRE(str_writer.str() == "key = \"inf\"\r\n"); + } + + { + StringStreamWriter str_writer; + Writer writer(str_writer); + writer.insert("key", -std::numeric_limits::infinity()); + REQUIRE(str_writer.str() == "key = \"-inf\"\r\n"); + } + + { + StringStreamWriter str_writer; + Writer writer(str_writer); + writer["key"] = -std::numeric_limits::infinity(); + REQUIRE(str_writer.str() == "key = \"-inf\"\r\n"); + } + { StringStreamWriter str_writer; Writer writer(str_writer); @@ -197,6 +239,48 @@ TEST_CASE("Writer Object Number Writing", "[writer]") REQUIRE(str_writer.str() == "key = 123.5\r\n"); } + { + StringStreamWriter str_writer; + Writer writer(str_writer); + writer.insert("key", std::nanf("")); + REQUIRE(str_writer.str() == "key = \"nan\"\r\n"); + } + + { + StringStreamWriter str_writer; + Writer writer(str_writer); + writer["key"] = std::nanf(""); + REQUIRE(str_writer.str() == "key = \"nan\"\r\n"); + } + + { + StringStreamWriter str_writer; + Writer writer(str_writer); + writer.insert("key", std::numeric_limits::infinity()); + REQUIRE(str_writer.str() == "key = \"inf\"\r\n"); + } + + { + StringStreamWriter str_writer; + Writer writer(str_writer); + writer["key"] = std::numeric_limits::infinity(); + REQUIRE(str_writer.str() == "key = \"inf\"\r\n"); + } + + { + StringStreamWriter str_writer; + Writer writer(str_writer); + writer.insert("key", -std::numeric_limits::infinity()); + REQUIRE(str_writer.str() == "key = \"-inf\"\r\n"); + } + + { + StringStreamWriter str_writer; + Writer writer(str_writer); + writer["key"] = -std::numeric_limits::infinity(); + REQUIRE(str_writer.str() == "key = \"-inf\"\r\n"); + } + { StringStreamWriter str_writer; Writer writer(str_writer); @@ -482,6 +566,18 @@ TEST_CASE("Writer Array Number Writing", "[writer]") REQUIRE(str_writer.str() == "key = [ 123.456 ]\r\n"); } + { + StringStreamWriter str_writer; + Writer writer(str_writer); + writer.insert("key", [](ArrayWriter& array_writer) + { + array_writer.push(std::nan("")); + array_writer.push(std::numeric_limits::infinity()); + array_writer.push(-std::numeric_limits::infinity()); + }); + REQUIRE(str_writer.str() == "key = [ \"nan\", \"inf\", \"-inf\" ]\r\n"); + } + { StringStreamWriter str_writer; Writer writer(str_writer); @@ -502,6 +598,18 @@ TEST_CASE("Writer Array Number Writing", "[writer]") REQUIRE(str_writer.str() == "key = [ 123.5 ]\r\n"); } + { + StringStreamWriter str_writer; + Writer writer(str_writer); + writer.insert("key", [](ArrayWriter& array_writer) + { + array_writer.push(std::nanf("")); + array_writer.push(std::numeric_limits::infinity()); + array_writer.push(-std::numeric_limits::infinity()); + }); + REQUIRE(str_writer.str() == "key = [ \"nan\", \"inf\", \"-inf\" ]\r\n"); + } + { StringStreamWriter str_writer; Writer writer(str_writer); From efcf78d9bd9593c4a5ffad3f5f8a5fd8534e2acf Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 1 Nov 2019 22:07:02 -0400 Subject: [PATCH 035/285] fix: avoid calling memcmp with potential null pointer --- includes/sjson/string_view.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/sjson/string_view.h b/includes/sjson/string_view.h index b81b654..d308263 100644 --- a/includes/sjson/string_view.h +++ b/includes/sjson/string_view.h @@ -97,7 +97,7 @@ namespace sjson if (m_length != other.m_length) return false; - if (m_c_str == other.m_c_str) + if (m_c_str == other.m_c_str || m_length == 0) return true; return std::memcmp(m_c_str, other.m_c_str, m_length) == 0; From 4e42fee72502b4ae9c49eef3081d0341b2288536 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 1 Nov 2019 22:07:52 -0400 Subject: [PATCH 036/285] fix: add custom exception when throwing from asserts --- includes/sjson/error.h | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/includes/sjson/error.h b/includes/sjson/error.h index c0821a2..28c1e25 100644 --- a/includes/sjson/error.h +++ b/includes/sjson/error.h @@ -100,6 +100,13 @@ namespace sjson { + class runtime_assert final : public std::runtime_error + { + public: + explicit runtime_assert(const std::string& message) : std::runtime_error(message.c_str()) {} + explicit runtime_assert(const char* message) : std::runtime_error(message) {} + }; + namespace error_impl { inline void on_assert_throw(const char* expression, int line, const char* file, const char* format, ...) @@ -119,9 +126,9 @@ va_end(args); if (count >= 0 && count < buffer_size) - throw std::runtime_error(std::string(&buffer[0], count)); + throw runtime_assert(std::string(&buffer[0], count)); else - throw std::runtime_error("Failed to format assert message!\n"); + throw runtime_assert("Failed to format assert message!\n"); } } } From ceb80c9289cc443095727b29b3ef35ff5904461d Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 1 Nov 2019 22:08:14 -0400 Subject: [PATCH 037/285] fix: various sonarcloud fixes and suggestions --- includes/sjson/error.h | 6 +- includes/sjson/parser.h | 20 ++---- includes/sjson/writer.h | 119 +++++++++++++++++----------------- tests/sources/test_parser.cpp | 22 +++---- tests/sources/test_writer.cpp | 24 +++---- 5 files changed, 91 insertions(+), 100 deletions(-) diff --git a/includes/sjson/error.h b/includes/sjson/error.h index 28c1e25..97d77e2 100644 --- a/includes/sjson/error.h +++ b/includes/sjson/error.h @@ -88,7 +88,7 @@ } } - #define SJSON_CPP_ASSERT(expression, format, ...) if (!(expression)) sjson::error_impl::on_assert_abort(#expression, __LINE__, __FILE__, format, ## __VA_ARGS__) + #define SJSON_CPP_ASSERT(expression, format, ...) if (!(expression)) sjson::error_impl::on_assert_abort(#expression, __LINE__, __FILE__, (format), ## __VA_ARGS__) #define SJSON_CPP_HAS_ASSERT_CHECKS #elif defined(SJSON_CPP_ON_ASSERT_THROW) @@ -133,13 +133,13 @@ } } - #define SJSON_CPP_ASSERT(expression, format, ...) if (!(expression)) sjson::error_impl::on_assert_throw(#expression, __LINE__, __FILE__, format, ## __VA_ARGS__) + #define SJSON_CPP_ASSERT(expression, format, ...) if (!(expression)) sjson::error_impl::on_assert_throw(#expression, __LINE__, __FILE__, (format), ## __VA_ARGS__) #define SJSON_CPP_HAS_ASSERT_CHECKS #elif defined(SJSON_CPP_ON_ASSERT_CUSTOM) #if !defined(SJSON_CPP_ASSERT) - #define SJSON_CPP_ASSERT(expression, format, ...) if (!(expression)) SJSON_CPP_ON_ASSERT_CUSTOM(#expression, __LINE__, __FILE__, format, ## __VA_ARGS__) + #define SJSON_CPP_ASSERT(expression, format, ...) if (!(expression)) SJSON_CPP_ON_ASSERT_CUSTOM(#expression, __LINE__, __FILE__, (format), ## __VA_ARGS__) #endif #define SJSON_CPP_HAS_ASSERT_CHECKS diff --git a/includes/sjson/parser.h b/includes/sjson/parser.h index 21ce8e8..68d510f 100644 --- a/includes/sjson/parser.h +++ b/includes/sjson/parser.h @@ -53,25 +53,15 @@ namespace sjson { skip_bom(); } + ~Parser() = default; - // Prevent copying to reduce to avoid potential mistakes + // Prevent copying to avoid potential mistakes Parser(const Parser& other) = delete; Parser& operator=(const Parser& other) = delete; - Parser(Parser&& other) - : m_input(other.m_input) - , m_input_length(other.m_input_length) - , m_state(other.m_state) - {} - - Parser& operator=(Parser&& other) - { - m_input = other.m_input; - m_input_length = other.m_input_length; - m_state = other.m_state; - - return *this; - } + // Allow moving + Parser(Parser&& other) = default; + Parser& operator=(Parser&& other) = default; bool object_begins() { return read_opening_brace(); } bool object_begins(const char* having_name) { return read_key(having_name) && read_equal_sign() && object_begins(); } diff --git a/includes/sjson/writer.h b/includes/sjson/writer.h index 09e2c55..ba75f9b 100644 --- a/includes/sjson/writer.h +++ b/includes/sjson/writer.h @@ -65,7 +65,7 @@ namespace sjson class FileStreamWriter final : public StreamWriter { public: - FileStreamWriter(std::FILE* file) + explicit FileStreamWriter(std::FILE* file) : m_file(file) {} @@ -92,37 +92,37 @@ namespace sjson class ArrayWriter { public: - inline void push(const char* value); - inline void push(bool value); - inline void push(double value); - inline void push(float value) { push(double(value)); } - inline void push(int8_t value) { push_signed_integer(int64_t(value)); } - inline void push(uint8_t value) { push_unsigned_integer(uint64_t(value)); } - inline void push(int16_t value) { push_signed_integer(int64_t(value)); } - inline void push(uint16_t value) { push_unsigned_integer(uint64_t(value)); } - inline void push(int32_t value) { push_signed_integer(int64_t(value)); } - inline void push(uint32_t value) { push_unsigned_integer(uint64_t(value)); } - inline void push(int64_t value) { push_signed_integer(value); } - inline void push(uint64_t value) { push_unsigned_integer(value); } + void push(const char* value); + void push(bool value); + void push(double value); + void push(float value) { push(double(value)); } + void push(int8_t value) { push_signed_integer(int64_t(value)); } + void push(uint8_t value) { push_unsigned_integer(uint64_t(value)); } + void push(int16_t value) { push_signed_integer(int64_t(value)); } + void push(uint16_t value) { push_unsigned_integer(uint64_t(value)); } + void push(int32_t value) { push_signed_integer(int64_t(value)); } + void push(uint32_t value) { push_unsigned_integer(uint64_t(value)); } + void push(int64_t value) { push_signed_integer(value); } + void push(uint64_t value) { push_unsigned_integer(value); } template::type* requirement = nullptr> - inline void push(F writer_fun); + void push(F writer_fun); template::type* requirement = nullptr> - inline void push(F writer_fun); + void push(F writer_fun); // TODO: Introduce a newline type void push_newline(); private: - inline ArrayWriter(StreamWriter& stream_writer, uint32_t indent_level); + ArrayWriter(StreamWriter& stream_writer, uint32_t indent_level); ArrayWriter(const ArrayWriter&) = delete; ArrayWriter& operator=(const ArrayWriter&) = delete; - inline void push_signed_integer(int64_t value); - inline void push_unsigned_integer(uint64_t value); - inline void write_indentation(); + void push_signed_integer(int64_t value); + void push_unsigned_integer(uint64_t value); + void write_indentation(); StreamWriter& m_stream_writer; uint32_t m_indent_level; @@ -136,61 +136,61 @@ namespace sjson class ObjectWriter { public: - inline void insert(const char* key, const char* value); - inline void insert(const char* key, bool value); - inline void insert(const char* key, double value); - inline void insert(const char* key, float value) { insert(key, double(value)); } - inline void insert(const char* key, int8_t value) { insert_signed_integer(key, int64_t(value)); } - inline void insert(const char* key, uint8_t value) { insert_unsigned_integer(key, uint64_t(value)); } - inline void insert(const char* key, int16_t value) { insert_signed_integer(key, int64_t(value)); } - inline void insert(const char* key, uint16_t value) { insert_unsigned_integer(key, uint64_t(value)); } - inline void insert(const char* key, int32_t value) { insert_signed_integer(key, int64_t(value)); } - inline void insert(const char* key, uint32_t value) { insert_unsigned_integer(key, uint64_t(value)); } - inline void insert(const char* key, int64_t value) { insert_signed_integer(key, int64_t(value)); } - inline void insert(const char* key, uint64_t value) { insert_unsigned_integer(key, uint64_t(value)); } + void insert(const char* key, const char* value); + void insert(const char* key, bool value); + void insert(const char* key, double value); + void insert(const char* key, float value) { insert(key, double(value)); } + void insert(const char* key, int8_t value) { insert_signed_integer(key, int64_t(value)); } + void insert(const char* key, uint8_t value) { insert_unsigned_integer(key, uint64_t(value)); } + void insert(const char* key, int16_t value) { insert_signed_integer(key, int64_t(value)); } + void insert(const char* key, uint16_t value) { insert_unsigned_integer(key, uint64_t(value)); } + void insert(const char* key, int32_t value) { insert_signed_integer(key, int64_t(value)); } + void insert(const char* key, uint32_t value) { insert_unsigned_integer(key, uint64_t(value)); } + void insert(const char* key, int64_t value) { insert_signed_integer(key, int64_t(value)); } + void insert(const char* key, uint64_t value) { insert_unsigned_integer(key, uint64_t(value)); } template::type* requirement = nullptr> - inline void insert(const char* key, F writer_fun); + void insert(const char* key, F writer_fun); template::type* requirement = nullptr> - inline void insert(const char* key, F writer_fun); + void insert(const char* key, F writer_fun); void insert_newline(); // Implement operator[] for convenience - class ValueRef + class ValueRef final { public: - inline ValueRef(ValueRef&& other); - inline ~ValueRef(); - - inline void operator=(const char* value); - inline void operator=(bool value); - inline void operator=(double value); - inline void operator=(float value) { *this = double(value); } - inline void operator=(int8_t value) { assign_signed_integer(int64_t(value)); } - inline void operator=(uint8_t value) { assign_unsigned_integer(uint64_t(value)); } - inline void operator=(int16_t value) { assign_signed_integer(int64_t(value)); } - inline void operator=(uint16_t value) { assign_unsigned_integer(uint64_t(value)); } - inline void operator=(int32_t value) { assign_signed_integer(int64_t(value)); } - inline void operator=(uint32_t value) { assign_unsigned_integer(uint64_t(value)); } - inline void operator=(int64_t value) { assign_signed_integer(int64_t(value)); } - inline void operator=(uint64_t value) { assign_unsigned_integer(uint64_t(value)); } + ValueRef(ValueRef&& other); + ~ValueRef(); + + void operator=(const char* value); + void operator=(bool value); + void operator=(double value); + void operator=(float value) { *this = double(value); } + void operator=(int8_t value) { assign_signed_integer(int64_t(value)); } + void operator=(uint8_t value) { assign_unsigned_integer(uint64_t(value)); } + void operator=(int16_t value) { assign_signed_integer(int64_t(value)); } + void operator=(uint16_t value) { assign_unsigned_integer(uint64_t(value)); } + void operator=(int32_t value) { assign_signed_integer(int64_t(value)); } + void operator=(uint32_t value) { assign_unsigned_integer(uint64_t(value)); } + void operator=(int64_t value) { assign_signed_integer(int64_t(value)); } + void operator=(uint64_t value) { assign_unsigned_integer(uint64_t(value)); } template::type* requirement = nullptr> - inline void operator=(F writer_fun); + void operator=(F writer_fun); template::type* requirement = nullptr> - inline void operator=(F writer_fun); + void operator=(F writer_fun); private: - inline ValueRef(ObjectWriter& object_writer, const char* key); + ValueRef(ObjectWriter& object_writer, const char* key); ValueRef(const ValueRef&) = delete; ValueRef& operator=(const ValueRef&) = delete; - inline void assign_signed_integer(int64_t value); - inline void assign_unsigned_integer(uint64_t value); + void assign_signed_integer(int64_t value); + void assign_unsigned_integer(uint64_t value); ObjectWriter* m_object_writer; bool m_is_empty; @@ -199,7 +199,7 @@ namespace sjson friend ObjectWriter; }; - inline ValueRef operator[](const char* key) { return ValueRef(*this, key); } + ValueRef operator[](const char* key) { return ValueRef(*this, key); } protected: inline ObjectWriter(StreamWriter& stream_writer, uint32_t indent_level); @@ -207,10 +207,11 @@ namespace sjson ObjectWriter(const ObjectWriter&) = delete; ObjectWriter& operator=(const ObjectWriter&) = delete; - inline void insert_signed_integer(const char* key, int64_t value); - inline void insert_unsigned_integer(const char* key, uint64_t value); - inline void write_indentation(); + void insert_signed_integer(const char* key, int64_t value); + void insert_unsigned_integer(const char* key, uint64_t value); + void write_indentation(); + private: StreamWriter& m_stream_writer; uint32_t m_indent_level; bool m_is_locked; @@ -222,7 +223,7 @@ namespace sjson class Writer : public ObjectWriter { public: - inline Writer(StreamWriter& stream_writer); + explicit Writer(StreamWriter& stream_writer); private: Writer(const Writer&) = delete; diff --git a/tests/sources/test_parser.cpp b/tests/sources/test_parser.cpp index 94753af..1ff2dbe 100644 --- a/tests/sources/test_parser.cpp +++ b/tests/sources/test_parser.cpp @@ -280,7 +280,7 @@ TEST_CASE("Parser Number Reading", "[parser]") Parser parser = parser_from_c_str("key = 123.456789"); float value; REQUIRE(parser.read("key", value)); - REQUIRE(value == 123.456789f); + REQUIRE(value == 123.456789F); REQUIRE(parser.eof()); REQUIRE(parser.is_valid()); } @@ -372,7 +372,7 @@ TEST_CASE("Parser Number Reading", "[parser]") Parser parser = parser_from_c_str("key = -1234567890123456"); int64_t value; REQUIRE(parser.read("key", value)); - REQUIRE(value == -1234567890123456ll); + REQUIRE(value == -1234567890123456LL); REQUIRE(parser.eof()); REQUIRE(parser.is_valid()); } @@ -381,7 +381,7 @@ TEST_CASE("Parser Number Reading", "[parser]") Parser parser = parser_from_c_str("key = 1234567890123456"); uint64_t value; REQUIRE(parser.read("key", value)); - REQUIRE(value == 1234567890123456ull); + REQUIRE(value == 1234567890123456ULL); REQUIRE(parser.eof()); REQUIRE(parser.is_valid()); } @@ -408,18 +408,18 @@ TEST_CASE("Parser Number Reading", "[parser]") { Parser parser = parser_from_c_str("bad_key = \"bad\""); - float value = 0.0f; - REQUIRE_FALSE(parser.try_read("key", value, 1.0f)); - REQUIRE(value == 1.0f); + float value = 0.0F; + REQUIRE_FALSE(parser.try_read("key", value, 1.0F)); + REQUIRE(value == 1.0F); REQUIRE_FALSE(parser.eof()); REQUIRE(parser.is_valid()); } { Parser parser = parser_from_c_str("key = 2.0"); - float value = 0.0f; - REQUIRE(parser.try_read("key", value, 1.0f)); - REQUIRE(value == 2.0f); + float value = 0.0F; + REQUIRE(parser.try_read("key", value, 1.0F)); + REQUIRE(value == 2.0F); REQUIRE(parser.eof()); REQUIRE(parser.is_valid()); } @@ -545,7 +545,7 @@ TEST_CASE("Parser Number Reading", "[parser]") Parser parser = parser_from_c_str("key = -1234567890123456"); int64_t value; REQUIRE(parser.try_read("key", value, 1)); - REQUIRE(value == -1234567890123456ll); + REQUIRE(value == -1234567890123456LL); REQUIRE(parser.eof()); REQUIRE(parser.is_valid()); } @@ -563,7 +563,7 @@ TEST_CASE("Parser Number Reading", "[parser]") Parser parser = parser_from_c_str("key = 1234567890123456"); uint64_t value; REQUIRE(parser.try_read("key", value, 1)); - REQUIRE(value == 1234567890123456ull); + REQUIRE(value == 1234567890123456ULL); REQUIRE(parser.eof()); REQUIRE(parser.is_valid()); } diff --git a/tests/sources/test_writer.cpp b/tests/sources/test_writer.cpp index e02a8b5..606032d 100644 --- a/tests/sources/test_writer.cpp +++ b/tests/sources/test_writer.cpp @@ -214,28 +214,28 @@ TEST_CASE("Writer Object Number Writing", "[writer]") { StringStreamWriter str_writer; Writer writer(str_writer); - writer.insert("key", 123.0f); + writer.insert("key", 123.0F); REQUIRE(str_writer.str() == "key = 123\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); - writer["key"] = 123.0f; + writer["key"] = 123.0F; REQUIRE(str_writer.str() == "key = 123\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); - writer.insert("key", 123.5f); + writer.insert("key", 123.5F); REQUIRE(str_writer.str() == "key = 123.5\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); - writer["key"] = 123.5f; + writer["key"] = 123.5F; REQUIRE(str_writer.str() == "key = 123.5\r\n"); } @@ -380,7 +380,7 @@ TEST_CASE("Writer Object Number Writing", "[writer]") { StringStreamWriter str_writer; Writer writer(str_writer); - int64_t value = -1234567890123456ll; + int64_t value = -1234567890123456LL; writer.insert("key", value); REQUIRE(str_writer.str() == "key = -1234567890123456\r\n"); } @@ -388,7 +388,7 @@ TEST_CASE("Writer Object Number Writing", "[writer]") { StringStreamWriter str_writer; Writer writer(str_writer); - int64_t value = -1234567890123456ll; + int64_t value = -1234567890123456LL; writer["key"] = value; REQUIRE(str_writer.str() == "key = -1234567890123456\r\n"); } @@ -396,7 +396,7 @@ TEST_CASE("Writer Object Number Writing", "[writer]") { StringStreamWriter str_writer; Writer writer(str_writer); - uint64_t value = 1234567890123456ull; + uint64_t value = 1234567890123456ULL; writer.insert("key", value); REQUIRE(str_writer.str() == "key = 1234567890123456\r\n"); } @@ -404,7 +404,7 @@ TEST_CASE("Writer Object Number Writing", "[writer]") { StringStreamWriter str_writer; Writer writer(str_writer); - uint64_t value = 1234567890123456ull; + uint64_t value = 1234567890123456ULL; writer["key"] = value; REQUIRE(str_writer.str() == "key = 1234567890123456\r\n"); } @@ -583,7 +583,7 @@ TEST_CASE("Writer Array Number Writing", "[writer]") Writer writer(str_writer); writer.insert("key", [](ArrayWriter& array_writer) { - array_writer.push(123.0f); + array_writer.push(123.0F); }); REQUIRE(str_writer.str() == "key = [ 123 ]\r\n"); } @@ -593,7 +593,7 @@ TEST_CASE("Writer Array Number Writing", "[writer]") Writer writer(str_writer); writer.insert("key", [](ArrayWriter& array_writer) { - array_writer.push(123.5f); + array_writer.push(123.5F); }); REQUIRE(str_writer.str() == "key = [ 123.5 ]\r\n"); } @@ -681,7 +681,7 @@ TEST_CASE("Writer Array Number Writing", "[writer]") Writer writer(str_writer); writer.insert("key", [](ArrayWriter& array_writer) { - int64_t value = -1234567890123456ll; + int64_t value = -1234567890123456LL; array_writer.push(value); }); REQUIRE(str_writer.str() == "key = [ -1234567890123456 ]\r\n"); @@ -692,7 +692,7 @@ TEST_CASE("Writer Array Number Writing", "[writer]") Writer writer(str_writer); writer.insert("key", [](ArrayWriter& array_writer) { - uint64_t value = 1234567890123456ull; + uint64_t value = 1234567890123456ULL; array_writer.push(value); }); REQUIRE(str_writer.str() == "key = [ 1234567890123456 ]\r\n"); From 22ce7b425d4eebd3ccba440f27245300cf955417 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 3 Nov 2019 21:20:19 -0500 Subject: [PATCH 038/285] chore: create FUNDING.yml --- .github/FUNDING.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..724e02b --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1,14 @@ +# These are supported funding model platforms + +#github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +#patreon: # Replace with a single Patreon username +#open_collective: # Replace with a single Open Collective username +#ko_fi: # Replace with a single Ko-fi username +#tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel +#community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry +#liberapay: # Replace with a single Liberapay username +#issuehunt: # Replace with a single IssueHunt username +#otechie: # Replace with a single Otechie username +#custom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2'] + +github: [nfrechette] From 26a515c4b24620ee6b5d7b8347f4cb15b702fb9d Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 6 Nov 2019 18:16:12 -0500 Subject: [PATCH 039/285] feat: add support for GCC9 and clang7 --- make.py | 8 +++++++- tools/release_scripts/test_everything.py | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/make.py b/make.py index 3ac7b67..2d3e17a 100644 --- a/make.py +++ b/make.py @@ -15,7 +15,7 @@ def parse_argv(): actions.add_argument('-unit_test', action='store_true') target = parser.add_argument_group(title='Target') - target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'android', 'clang4', 'clang5', 'clang6', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'osx', 'ios'], help='Defaults to the host system\'s default compiler') + target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'osx', 'ios'], help='Defaults to the host system\'s default compiler') target.add_argument('-config', choices=['Debug', 'Release'], type=str.capitalize) target.add_argument('-cpu', choices=['x86', 'x64', 'arm64'], help='Only supported for Windows, OS X, and Linux; defaults to the host system\'s architecture') @@ -135,6 +135,9 @@ def set_compiler_env(compiler, args): elif compiler == 'clang6': os.environ['CC'] = 'clang-6.0' os.environ['CXX'] = 'clang++-6.0' + elif compiler == 'clang7': + os.environ['CC'] = 'clang-7' + os.environ['CXX'] = 'clang++-7' elif compiler == 'gcc5': os.environ['CC'] = 'gcc-5' os.environ['CXX'] = 'g++-5' @@ -147,6 +150,9 @@ def set_compiler_env(compiler, args): elif compiler == 'gcc8': os.environ['CC'] = 'gcc-8' os.environ['CXX'] = 'g++-8' + elif compiler == 'gcc9': + os.environ['CC'] = 'gcc-9' + os.environ['CXX'] = 'g++-9' else: print('Unknown compiler: {}'.format(compiler)) sys.exit(1) diff --git a/tools/release_scripts/test_everything.py b/tools/release_scripts/test_everything.py index 12661c2..830c51a 100644 --- a/tools/release_scripts/test_everything.py +++ b/tools/release_scripts/test_everything.py @@ -7,7 +7,7 @@ def get_platform_compilers(): if platform.system() == 'Windows': return [ 'vs2015', 'vs2017', 'vs2019' ] elif platform.system() == 'Linux': - return [ 'gcc5', 'gcc6', 'gcc7', 'clang4', 'clang5' ] + return [ 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'clang4', 'clang5', 'clang6', 'clang7' ] elif platform.system() == 'Darwin': return [ 'osx' ] else: From a6e81b93ce8a9f9099a86317e42105f35af40f50 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 6 Nov 2019 18:16:36 -0500 Subject: [PATCH 040/285] chore: switch travis to xenial and add GCC9/clang7 --- .travis.yml | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 880671c..5ceb13c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -dist: trusty +dist: xenial sudo: required language: cpp @@ -21,6 +21,10 @@ matrix: - os: linux env: COMPILER=gcc8 TOOLCHAIN=gcc PACKAGES="g++-8 g++-8-multilib g++-multilib" + # Linux gcc9 + - os: linux + env: COMPILER=gcc9 TOOLCHAIN=gcc PACKAGES="g++-9 g++-9-multilib g++-multilib" + # Linux clang4 - os: linux env: COMPILER=clang4 TOOLCHAIN=clang PACKAGES="clang-4.0 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" @@ -36,6 +40,10 @@ matrix: - os: linux env: COMPILER=clang6 TOOLCHAIN=clang PACKAGES="clang-6.0 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + # Linux clang7 + - os: linux + env: COMPILER=clang7 TOOLCHAIN=clang PACKAGES="clang-7 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + # OS X xcode8 - os: osx osx_image: xcode8.3 @@ -53,9 +61,10 @@ matrix: before_install: - if [[ "$TOOLCHAIN" == "clang" ]]; then curl -sSL "http://apt.llvm.org/llvm-snapshot.gpg.key" | sudo -E apt-key add - ; fi - - if [[ "$COMPILER" == "clang4" ]]; then echo "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-4.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - - if [[ "$COMPILER" == "clang5" ]]; then echo "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-5.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - - if [[ "$COMPILER" == "clang6" ]]; then echo "deb http://apt.llvm.org/trusty/ llvm-toolchain-trusty-6.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi + - if [[ "$COMPILER" == "clang4" ]]; then echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-4.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi + - if [[ "$COMPILER" == "clang5" ]]; then echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-5.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi + - if [[ "$COMPILER" == "clang6" ]]; then echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-6.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi + - if [[ "$COMPILER" == "clang7" ]]; then echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - 'if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test"; sudo -E apt-get -yq update; From 796e3311bbf1b5c0dff39ad21b5682cd52a00af1 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 6 Nov 2019 20:05:37 -0500 Subject: [PATCH 041/285] feat: fail build for x86 on Xcode 11 since it is no longer supported --- make.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/make.py b/make.py index 2d3e17a..a6f1b93 100644 --- a/make.py +++ b/make.py @@ -55,6 +55,12 @@ def parse_argv(): print('ARM64 is only supported with VS2017, VS2019, and iOS') sys.exit(1) + if platform.system() == 'Darwin' and args.cpu == 'x86': + result = subprocess.check_output(['xcodebuild', '-version']) + if 'Xcode 11' in result: + print('Versions of Xcode 11 and up no longer support x86') + sys.exit(1) + return args def get_cmake_exes(): From c7c83f230b854cbab6a0115cadedc61f81ba8a46 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 6 Nov 2019 20:57:27 -0500 Subject: [PATCH 042/285] style: fix whitespace --- includes/sjson/error.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/sjson/error.h b/includes/sjson/error.h index 97d77e2..58b5ff8 100644 --- a/includes/sjson/error.h +++ b/includes/sjson/error.h @@ -129,9 +129,9 @@ throw runtime_assert(std::string(&buffer[0], count)); else throw runtime_assert("Failed to format assert message!\n"); - } } } + } #define SJSON_CPP_ASSERT(expression, format, ...) if (!(expression)) sjson::error_impl::on_assert_throw(#expression, __LINE__, __FILE__, (format), ## __VA_ARGS__) #define SJSON_CPP_HAS_ASSERT_CHECKS From 3a54b9c5006e07926c63f913c32fe54a3d037f80 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 8 Nov 2019 12:15:00 -0500 Subject: [PATCH 043/285] fix: handle python3 properly --- make.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make.py b/make.py index a6f1b93..7359505 100644 --- a/make.py +++ b/make.py @@ -56,7 +56,7 @@ def parse_argv(): sys.exit(1) if platform.system() == 'Darwin' and args.cpu == 'x86': - result = subprocess.check_output(['xcodebuild', '-version']) + result = subprocess.check_output(['xcodebuild', '-version']).decode("utf-8") if 'Xcode 11' in result: print('Versions of Xcode 11 and up no longer support x86') sys.exit(1) From b4223425526a98027a1742b0e734135677da38ba Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 11 Nov 2019 23:10:47 -0500 Subject: [PATCH 044/285] fix: set sign identity to fix iOS on XCode 11 --- cmake/Toolchain-iOS.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/Toolchain-iOS.cmake b/cmake/Toolchain-iOS.cmake index 0124d44..115bf2f 100644 --- a/cmake/Toolchain-iOS.cmake +++ b/cmake/Toolchain-iOS.cmake @@ -11,6 +11,7 @@ execute_process(COMMAND xcrun --sdk iphoneos --find clang++ OUTPUT_VARIABLE CMAK set(CMAKE_MACOSX_BUNDLE YES) set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED NO) +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") set(CMAKE_OSX_SYSROOT iphoneos CACHE STRING "") set(CMAKE_OSX_ARCHITECTURES arm64 CACHE STRING "") set(CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 11.0) From c363bfad7435d14ddc20d73edcd41ee60cb1ac6e Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 12 Nov 2019 20:52:50 -0500 Subject: [PATCH 045/285] feat: add support for Xcode 11 on travis --- .travis.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5ceb13c..2c67ee3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -59,6 +59,11 @@ matrix: osx_image: xcode10.3 env: COMPILER=osx TOOLCHAIN=xcode + # OS X xcode11 + - os: osx + osx_image: xcode11.2 + env: COMPILER=osx TOOLCHAIN=xcode NOX86=1 + before_install: - if [[ "$TOOLCHAIN" == "clang" ]]; then curl -sSL "http://apt.llvm.org/llvm-snapshot.gpg.key" | sudo -E apt-key add - ; fi - if [[ "$COMPILER" == "clang4" ]]; then echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-4.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi @@ -72,8 +77,10 @@ before_install: fi' script: - - python make.py -clean -build -unit_test -compiler ${COMPILER} -config Debug -cpu x86 - - python make.py -clean -build -unit_test -compiler ${COMPILER} -config Release -cpu x86 + - 'if [[ "$NOX86" != "1" ]]; then + python make.py -clean -build -unit_test -compiler ${COMPILER} -config Debug -cpu x86; + python make.py -clean -build -unit_test -compiler ${COMPILER} -config Release -cpu x86; + fi' - python make.py -clean -build -unit_test -compiler ${COMPILER} -config Debug -cpu x64 - python make.py -clean -build -unit_test -compiler ${COMPILER} -config Release -cpu x64 - 'if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then From c12093744b7fb759f3def33c22342f41fb8ebc26 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 12 Nov 2019 20:59:19 -0500 Subject: [PATCH 046/285] docs: minor updates --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 398796a..fcafb06 100644 --- a/README.md +++ b/README.md @@ -36,14 +36,14 @@ Unicode formats other than UTF-8 aren't supported. ## Supported platforms * Windows VS2015 x86 and x64, VS2017/2019 x86, x64, and ARM64* -* Linux (gcc5, gcc6, gcc7, gcc8, clang4, clang5, clang6) x86 and x64 -* OS X (Xcode 8.3, 9.4, 10.3) x86 and x64 +* Linux (gcc5, gcc6, gcc7, gcc8, gcc9, clang4, clang5, clang6, clang7) x86 and x64 +* OS X (Xcode 8.3, 9.4, 10.3, 11.2*) x86 and x64 * Android (NVIDIA CodeWorks with clang5) ARMv7-A and ARM64 * iOS (Xcode 8.3, 9.4, 10.3) ARM64 The above supported platform list is only what is tested every release but if it compiles, it should run just fine. -Note: *VS2017* and *VS2019* compile with *ARM64* on *AppVeyor* but I have no device to test them with. +Notes: *VS2017* and *VS2019* compile with *ARM64* on *AppVeyor* but I have no device to test them with. Xcode 11 no longer supports x86. ## External dependencies From 76aee951db5ae5c3c39c5ebdab272c1095ce1d78 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 12 Nov 2019 20:59:36 -0500 Subject: [PATCH 047/285] docs: add release information --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index cb5a78e..ced6daa 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Significant changes per release +## 0.7.0 + +* Added support for VS 2019, GCC9, clang 7, and Xcode 11 +* Added custom support for NaN/Inf handling +* Cleanup and minor misc changes + ## 0.6.0 * Added support for Windows ARM64, GCC 8, clang 6, and Xcode 10 From f97ddcfae7f145c8cee3b68a4424bbee8754d89f Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 12 Nov 2019 20:59:51 -0500 Subject: [PATCH 048/285] chore: bump version numbers --- appveyor.yml | 2 +- sonar-project.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 9507506..ab44451 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 0.6.0.{build} +version: 0.7.0.{build} environment: PYTHON: "C:\\Python36-x64" diff --git a/sonar-project.properties b/sonar-project.properties index 9503c7e..f109e5b 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,6 +1,6 @@ sonar.projectKey=nfrechette_sjson-cpp sonar.projectName=sjson-cpp -sonar.projectVersion=0.6.0 +sonar.projectVersion=0.7.0 sonar.sources=includes,tests/sources,tests/main_generic From 7cb3af8b65c24e4072d1c9a6dd870a46f53d608d Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 18 Nov 2019 21:23:08 -0500 Subject: [PATCH 049/285] fix(android): rename package name to something meaningful and consistent --- tests/main_android/AndroidManifest.xml | 2 +- tests/main_android/CMakeLists.txt | 2 +- .../java/com/sjson/{cpp => unit_tests}/MainActivity.java | 2 +- tests/main_android/jni/main.cpp | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) rename tests/main_android/java/com/sjson/{cpp => unit_tests}/MainActivity.java (95%) diff --git a/tests/main_android/AndroidManifest.xml b/tests/main_android/AndroidManifest.xml index 16b6165..39eb42c 100644 --- a/tests/main_android/AndroidManifest.xml +++ b/tests/main_android/AndroidManifest.xml @@ -1,6 +1,6 @@ diff --git a/tests/main_android/CMakeLists.txt b/tests/main_android/CMakeLists.txt index adfdb34..8494a8a 100644 --- a/tests/main_android/CMakeLists.txt +++ b/tests/main_android/CMakeLists.txt @@ -31,7 +31,7 @@ file(GLOB_RECURSE ALL_MAIN_SOURCE_FILES LIST_DIRECTORIES false create_source_groups("${ALL_MAIN_SOURCE_FILES}" ${PROJECT_SOURCE_DIR}) # Add resource files -set(JAVA_FILES java/com/sjson/cpp/MainActivity.java) +set(JAVA_FILES java/com/sjson/unit_tests/MainActivity.java) set(RESOURCE_FILES res/values/strings.xml) set(ANDROID_FILES AndroidManifest.xml) diff --git a/tests/main_android/java/com/sjson/cpp/MainActivity.java b/tests/main_android/java/com/sjson/unit_tests/MainActivity.java similarity index 95% rename from tests/main_android/java/com/sjson/cpp/MainActivity.java rename to tests/main_android/java/com/sjson/unit_tests/MainActivity.java index 563094c..e46a65f 100644 --- a/tests/main_android/java/com/sjson/cpp/MainActivity.java +++ b/tests/main_android/java/com/sjson/unit_tests/MainActivity.java @@ -1,4 +1,4 @@ -package com.sjson.cpp; +package com.sjson.unit_tests; import android.app.Activity; import android.widget.TextView; diff --git a/tests/main_android/jni/main.cpp b/tests/main_android/jni/main.cpp index 48062b8..f95d032 100644 --- a/tests/main_android/jni/main.cpp +++ b/tests/main_android/jni/main.cpp @@ -27,12 +27,12 @@ #include -extern "C" jint Java_com_sjson_cpp_MainActivity_getNumUnitTestCases(JNIEnv* env, jobject caller) +extern "C" jint Java_com_sjson_unit_1tests_MainActivity_getNumUnitTestCases(JNIEnv* env, jobject caller) { return Catch::getRegistryHub().getTestCaseRegistry().getAllTests().size(); } -extern "C" jint Java_com_sjson_cpp_MainActivity_runUnitTests(JNIEnv* env, jobject caller) +extern "C" jint Java_com_sjson_unit_1tests_MainActivity_runUnitTests(JNIEnv* env, jobject caller) { int result = Catch::Session().run(); From b0568871cedcab433120da0f4b4930a542f83dbf Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 22 Nov 2019 20:16:49 -0500 Subject: [PATCH 050/285] chore: add support for clang8 and clang9 --- .travis.yml | 10 ++++++++++ make.py | 8 +++++++- tools/release_scripts/test_everything.py | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 2c67ee3..40d8088 100644 --- a/.travis.yml +++ b/.travis.yml @@ -44,6 +44,14 @@ matrix: - os: linux env: COMPILER=clang7 TOOLCHAIN=clang PACKAGES="clang-7 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + # Linux clang8 + - os: linux + env: COMPILER=clang8 TOOLCHAIN=clang PACKAGES="clang-8 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + + # Linux clang9 + - os: linux + env: COMPILER=clang9 TOOLCHAIN=clang PACKAGES="clang-9 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + # OS X xcode8 - os: osx osx_image: xcode8.3 @@ -70,6 +78,8 @@ before_install: - if [[ "$COMPILER" == "clang5" ]]; then echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-5.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - if [[ "$COMPILER" == "clang6" ]]; then echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-6.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - if [[ "$COMPILER" == "clang7" ]]; then echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi + - if [[ "$COMPILER" == "clang8" ]]; then echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi + - if [[ "$COMPILER" == "clang9" ]]; then echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - 'if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test"; sudo -E apt-get -yq update; diff --git a/make.py b/make.py index 7359505..0fd265d 100644 --- a/make.py +++ b/make.py @@ -15,7 +15,7 @@ def parse_argv(): actions.add_argument('-unit_test', action='store_true') target = parser.add_argument_group(title='Target') - target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'osx', 'ios'], help='Defaults to the host system\'s default compiler') + target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'osx', 'ios'], help='Defaults to the host system\'s default compiler') target.add_argument('-config', choices=['Debug', 'Release'], type=str.capitalize) target.add_argument('-cpu', choices=['x86', 'x64', 'arm64'], help='Only supported for Windows, OS X, and Linux; defaults to the host system\'s architecture') @@ -144,6 +144,12 @@ def set_compiler_env(compiler, args): elif compiler == 'clang7': os.environ['CC'] = 'clang-7' os.environ['CXX'] = 'clang++-7' + elif compiler == 'clang8': + os.environ['CC'] = 'clang-8' + os.environ['CXX'] = 'clang++-8' + elif compiler == 'clang9': + os.environ['CC'] = 'clang-9' + os.environ['CXX'] = 'clang++-9' elif compiler == 'gcc5': os.environ['CC'] = 'gcc-5' os.environ['CXX'] = 'g++-5' diff --git a/tools/release_scripts/test_everything.py b/tools/release_scripts/test_everything.py index 830c51a..bfbedf9 100644 --- a/tools/release_scripts/test_everything.py +++ b/tools/release_scripts/test_everything.py @@ -7,7 +7,7 @@ def get_platform_compilers(): if platform.system() == 'Windows': return [ 'vs2015', 'vs2017', 'vs2019' ] elif platform.system() == 'Linux': - return [ 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'clang4', 'clang5', 'clang6', 'clang7' ] + return [ 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9' ] elif platform.system() == 'Darwin': return [ 'osx' ] else: From 368c6d73c84ebfc2007d7950ce60e54d008ef20b Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 23 Nov 2019 10:42:30 -0500 Subject: [PATCH 051/285] docs: update readme with clang entries --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index fcafb06..0af1e13 100644 --- a/README.md +++ b/README.md @@ -36,7 +36,8 @@ Unicode formats other than UTF-8 aren't supported. ## Supported platforms * Windows VS2015 x86 and x64, VS2017/2019 x86, x64, and ARM64* -* Linux (gcc5, gcc6, gcc7, gcc8, gcc9, clang4, clang5, clang6, clang7) x86 and x64 +* Linux (gcc5, gcc6, gcc7, gcc8, gcc9) x86 and x64 +* Linux (clang4, clang5, clang6, clang7, clang8, clang9) x86 and x64 * OS X (Xcode 8.3, 9.4, 10.3, 11.2*) x86 and x64 * Android (NVIDIA CodeWorks with clang5) ARMv7-A and ARM64 * iOS (Xcode 8.3, 9.4, 10.3) ARM64 From d66896e80f1408a09204b5f7b4af6c04b52b1b05 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 10 Dec 2019 22:51:26 -0500 Subject: [PATCH 052/285] refactor: use CHECK instead of REQUIRE in unit tests --- tests/sources/test_parser.cpp | 550 ++++++++++++++--------------- tests/sources/test_string_view.cpp | 58 +-- tests/sources/test_writer.cpp | 156 ++++---- 3 files changed, 382 insertions(+), 382 deletions(-) diff --git a/tests/sources/test_parser.cpp b/tests/sources/test_parser.cpp index 1ff2dbe..d07d4f1 100644 --- a/tests/sources/test_parser.cpp +++ b/tests/sources/test_parser.cpp @@ -37,81 +37,81 @@ TEST_CASE("Parser Misc", "[parser]") { { Parser parser = parser_from_c_str(""); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str(""); - REQUIRE(parser.remainder_is_comments_and_whitespace()); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.remainder_is_comments_and_whitespace()); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str(" "); - REQUIRE(parser.remainder_is_comments_and_whitespace()); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.remainder_is_comments_and_whitespace()); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("// lol \\n "); - REQUIRE(parser.remainder_is_comments_and_whitespace()); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.remainder_is_comments_and_whitespace()); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("\"key-one\" = true"); bool value = false; - REQUIRE(parser.read("key-one", value)); - REQUIRE(value == true); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key-one", value)); + CHECK(value == true); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = /* bar */ true"); bool value = false; - REQUIRE(parser.read("key", value)); - REQUIRE(value == true); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(value == true); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = /* bar * true"); bool value = false; - REQUIRE_FALSE(parser.read("key", value)); - REQUIRE_FALSE(parser.is_valid()); + CHECK_FALSE(parser.read("key", value)); + CHECK_FALSE(parser.is_valid()); } { Parser parser = parser_from_c_str("key = // bar \ntrue"); bool value = false; - REQUIRE(parser.read("key", value)); - REQUIRE(value == true); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(value == true); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key /* bar */ = true"); bool value = false; - REQUIRE(parser.read("key", value)); - REQUIRE(value == true); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(value == true); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("/* bar */ key = true"); bool value = false; - REQUIRE(parser.read("key", value)); - REQUIRE(value == true); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(value == true); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } } @@ -120,37 +120,37 @@ TEST_CASE("Parser Bool Reading", "[parser]") { Parser parser = parser_from_c_str("key = true"); bool value = false; - REQUIRE(parser.read("key", value)); - REQUIRE(value == true); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(value == true); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = false"); bool value = true; - REQUIRE(parser.read("key", value)); - REQUIRE(value == false); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(value == false); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("bad_key = 0"); bool value = true; - REQUIRE_FALSE(parser.try_read("key", value, false)); - REQUIRE(value == false); - REQUIRE_FALSE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK_FALSE(parser.try_read("key", value, false)); + CHECK(value == false); + CHECK_FALSE(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = true"); bool value = false; - REQUIRE(parser.try_read("key", value, false)); - REQUIRE(value == true); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.try_read("key", value, false)); + CHECK(value == true); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } } @@ -159,79 +159,79 @@ TEST_CASE("Parser String Reading", "[parser]") { Parser parser = parser_from_c_str("key = \"Quoted string\""); StringView value; - REQUIRE(parser.read("key", value)); - REQUIRE(value == "Quoted string"); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(value == "Quoted string"); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { // Note: Escaped quotes \" are left escaped within the StringView because we do not allocate memory Parser parser = parser_from_c_str("key = \"Quoted \\\" string\""); StringView value; - REQUIRE(parser.read("key", value)); - REQUIRE(value == "Quoted \\\" string"); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(value == "Quoted \\\" string"); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = \"New\\nline\""); StringView value; - REQUIRE(parser.read("key", value)); - REQUIRE(value == "New\\nline"); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(value == "New\\nline"); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = \"Tab\\tulator\""); StringView value; - REQUIRE(parser.read("key", value)); - REQUIRE(value == "Tab\\tulator"); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(value == "Tab\\tulator"); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = \"Tab\\tulator\""); StringView value; - REQUIRE(parser.read("key", value)); - REQUIRE(value == "Tab\\tulator"); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(value == "Tab\\tulator"); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("bad_key = 0"); StringView value; - REQUIRE_FALSE(parser.try_read("key", value, "default")); - REQUIRE(value == "default"); - REQUIRE_FALSE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK_FALSE(parser.try_read("key", value, "default")); + CHECK(value == "default"); + CHECK_FALSE(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = \"good\""); StringView value; - REQUIRE(parser.try_read("key", value, "default")); - REQUIRE(value == "good"); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.try_read("key", value, "default")); + CHECK(value == "good"); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = \"bad"); StringView value; - REQUIRE_FALSE(parser.read("key", value)); - REQUIRE_FALSE(parser.is_valid()); + CHECK_FALSE(parser.read("key", value)); + CHECK_FALSE(parser.is_valid()); } { Parser parser = parser_from_c_str("key = bad"); StringView value; - REQUIRE_FALSE(parser.read("key", value)); - REQUIRE_FALSE(parser.is_valid()); + CHECK_FALSE(parser.read("key", value)); + CHECK_FALSE(parser.is_valid()); } } @@ -241,149 +241,149 @@ TEST_CASE("Parser Number Reading", "[parser]") { Parser parser = parser_from_c_str("key = 123.456789"); double value; - REQUIRE(parser.read("key", value)); - REQUIRE(value == 123.456789); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(value == 123.456789); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = \"nan\""); double value; - REQUIRE(parser.read("key", value)); - REQUIRE(std::isnan(value)); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(std::isnan(value)); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = \"inf\""); double value; - REQUIRE(parser.read("key", value)); - REQUIRE(std::isinf(value)); - REQUIRE(value > 0.0); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(std::isinf(value)); + CHECK(value > 0.0); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = \"-inf\""); double value; - REQUIRE(parser.read("key", value)); - REQUIRE(std::isinf(value)); - REQUIRE(value < 0.0); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(std::isinf(value)); + CHECK(value < 0.0); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = 123.456789"); float value; - REQUIRE(parser.read("key", value)); - REQUIRE(value == 123.456789F); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(value == 123.456789F); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = \"nan\""); float value; - REQUIRE(parser.read("key", value)); - REQUIRE(std::isnan(value)); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(std::isnan(value)); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = \"inf\""); float value; - REQUIRE(parser.read("key", value)); - REQUIRE(std::isinf(value)); - REQUIRE(value > 0.0f); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(std::isinf(value)); + CHECK(value > 0.0f); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = \"-inf\""); float value; - REQUIRE(parser.read("key", value)); - REQUIRE(std::isinf(value)); - REQUIRE(value < 0.0f); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(std::isinf(value)); + CHECK(value < 0.0f); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = -123"); int8_t value; - REQUIRE(parser.read("key", value)); - REQUIRE(value == -123); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(value == -123); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = 123"); uint8_t value; - REQUIRE(parser.read("key", value)); - REQUIRE(value == 123); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(value == 123); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = -1234"); int16_t value; - REQUIRE(parser.read("key", value)); - REQUIRE(value == -1234); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(value == -1234); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = 1234"); uint16_t value; - REQUIRE(parser.read("key", value)); - REQUIRE(value == 1234); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(value == 1234); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = -123456"); int32_t value; - REQUIRE(parser.read("key", value)); - REQUIRE(value == -123456); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(value == -123456); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = 123456"); uint32_t value; - REQUIRE(parser.read("key", value)); - REQUIRE(value == 123456); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(value == 123456); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = -1234567890123456"); int64_t value; - REQUIRE(parser.read("key", value)); - REQUIRE(value == -1234567890123456LL); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(value == -1234567890123456LL); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = 1234567890123456"); uint64_t value; - REQUIRE(parser.read("key", value)); - REQUIRE(value == 1234567890123456ULL); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value)); + CHECK(value == 1234567890123456ULL); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } // Number try reading @@ -391,181 +391,181 @@ TEST_CASE("Parser Number Reading", "[parser]") { Parser parser = parser_from_c_str("bad_key = \"bad\""); double value = 0.0; - REQUIRE_FALSE(parser.try_read("key", value, 1.0)); - REQUIRE(value == 1.0); - REQUIRE_FALSE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK_FALSE(parser.try_read("key", value, 1.0)); + CHECK(value == 1.0); + CHECK_FALSE(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = 2.0"); double value = 0.0; - REQUIRE(parser.try_read("key", value, 1.0)); - REQUIRE(value == 2.0); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.try_read("key", value, 1.0)); + CHECK(value == 2.0); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("bad_key = \"bad\""); float value = 0.0F; - REQUIRE_FALSE(parser.try_read("key", value, 1.0F)); - REQUIRE(value == 1.0F); - REQUIRE_FALSE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK_FALSE(parser.try_read("key", value, 1.0F)); + CHECK(value == 1.0F); + CHECK_FALSE(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = 2.0"); float value = 0.0F; - REQUIRE(parser.try_read("key", value, 1.0F)); - REQUIRE(value == 2.0F); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.try_read("key", value, 1.0F)); + CHECK(value == 2.0F); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("bad_key = \"bad\""); int8_t value = 0; - REQUIRE_FALSE(parser.try_read("key", value, 1)); - REQUIRE(value == 1); - REQUIRE_FALSE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK_FALSE(parser.try_read("key", value, 1)); + CHECK(value == 1); + CHECK_FALSE(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = -123"); int8_t value; - REQUIRE(parser.try_read("key", value, 1)); - REQUIRE(value == -123); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.try_read("key", value, 1)); + CHECK(value == -123); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("bad_key = \"bad\""); uint8_t value = 0; - REQUIRE_FALSE(parser.try_read("key", value, 1)); - REQUIRE(value == 1); - REQUIRE_FALSE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK_FALSE(parser.try_read("key", value, 1)); + CHECK(value == 1); + CHECK_FALSE(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = 123"); uint8_t value; - REQUIRE(parser.try_read("key", value, 1)); - REQUIRE(value == 123); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.try_read("key", value, 1)); + CHECK(value == 123); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("bad_key = \"bad\""); int16_t value = 0; - REQUIRE_FALSE(parser.try_read("key", value, 1)); - REQUIRE(value == 1); - REQUIRE_FALSE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK_FALSE(parser.try_read("key", value, 1)); + CHECK(value == 1); + CHECK_FALSE(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = -1234"); int16_t value; - REQUIRE(parser.try_read("key", value, 1)); - REQUIRE(value == -1234); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.try_read("key", value, 1)); + CHECK(value == -1234); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("bad_key = \"bad\""); uint16_t value = 0; - REQUIRE_FALSE(parser.try_read("key", value, 1)); - REQUIRE(value == 1); - REQUIRE_FALSE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK_FALSE(parser.try_read("key", value, 1)); + CHECK(value == 1); + CHECK_FALSE(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = 1234"); uint16_t value; - REQUIRE(parser.try_read("key", value, 1)); - REQUIRE(value == 1234); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.try_read("key", value, 1)); + CHECK(value == 1234); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("bad_key = \"bad\""); int32_t value = 0; - REQUIRE_FALSE(parser.try_read("key", value, 1)); - REQUIRE(value == 1); - REQUIRE_FALSE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK_FALSE(parser.try_read("key", value, 1)); + CHECK(value == 1); + CHECK_FALSE(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = -123456"); int32_t value; - REQUIRE(parser.try_read("key", value, 1)); - REQUIRE(value == -123456); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.try_read("key", value, 1)); + CHECK(value == -123456); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("bad_key = \"bad\""); uint32_t value = 0; - REQUIRE_FALSE(parser.try_read("key", value, 1)); - REQUIRE(value == 1); - REQUIRE_FALSE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK_FALSE(parser.try_read("key", value, 1)); + CHECK(value == 1); + CHECK_FALSE(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = 123456"); uint32_t value; - REQUIRE(parser.try_read("key", value, 1)); - REQUIRE(value == 123456); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.try_read("key", value, 1)); + CHECK(value == 123456); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("bad_key = \"bad\""); int64_t value = 0; - REQUIRE_FALSE(parser.try_read("key", value, 1)); - REQUIRE(value == 1); - REQUIRE_FALSE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK_FALSE(parser.try_read("key", value, 1)); + CHECK(value == 1); + CHECK_FALSE(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = -1234567890123456"); int64_t value; - REQUIRE(parser.try_read("key", value, 1)); - REQUIRE(value == -1234567890123456LL); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.try_read("key", value, 1)); + CHECK(value == -1234567890123456LL); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("bad_key = \"bad\""); uint64_t value = 0; - REQUIRE_FALSE(parser.try_read("key", value, 1)); - REQUIRE(value == 1); - REQUIRE_FALSE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK_FALSE(parser.try_read("key", value, 1)); + CHECK(value == 1); + CHECK_FALSE(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = 1234567890123456"); uint64_t value; - REQUIRE(parser.try_read("key", value, 1)); - REQUIRE(value == 1234567890123456ULL); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.try_read("key", value, 1)); + CHECK(value == 1234567890123456ULL); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } } @@ -574,78 +574,78 @@ TEST_CASE("Parser Array Reading", "[parser]") { Parser parser = parser_from_c_str("key = [ 123.456789, 456.789, 151.091 ]"); double value[3] = { 0.0, 0.0, 0.0 }; - REQUIRE(parser.read("key", value, 3)); - REQUIRE(value[0] == 123.456789); - REQUIRE(value[1] == 456.789); - REQUIRE(value[2] == 151.091); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value, 3)); + CHECK(value[0] == 123.456789); + CHECK(value[1] == 456.789); + CHECK(value[2] == 151.091); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = [ \"123.456789\", \"456.789\", \"151.091\" ]"); StringView value[3]; - REQUIRE(parser.read("key", value, 3)); - REQUIRE(value[0] == "123.456789"); - REQUIRE(value[1] == "456.789"); - REQUIRE(value[2] == "151.091"); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.read("key", value, 3)); + CHECK(value[0] == "123.456789"); + CHECK(value[1] == "456.789"); + CHECK(value[2] == "151.091"); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("bad_key = \"bad\""); double value[3] = { 0.0, 0.0, 0.0 }; - REQUIRE_FALSE(parser.try_read("key", value, 3, 1.0)); - REQUIRE(value[0] == 1.0); - REQUIRE(value[1] == 1.0); - REQUIRE(value[2] == 1.0); - REQUIRE_FALSE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK_FALSE(parser.try_read("key", value, 3, 1.0)); + CHECK(value[0] == 1.0); + CHECK(value[1] == 1.0); + CHECK(value[2] == 1.0); + CHECK_FALSE(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = [ 123.456789, 456.789, 151.091 ]"); double value[3] = { 0.0, 0.0, 0.0 }; - REQUIRE(parser.try_read("key", value, 3, 1.0)); - REQUIRE(value[0] == 123.456789); - REQUIRE(value[1] == 456.789); - REQUIRE(value[2] == 151.091); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.try_read("key", value, 3, 1.0)); + CHECK(value[0] == 123.456789); + CHECK(value[1] == 456.789); + CHECK(value[2] == 151.091); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("bad_key = \"bad\""); StringView value[3]; - REQUIRE_FALSE(parser.try_read("key", value, 3, "default")); - REQUIRE(value[0] == "default"); - REQUIRE(value[1] == "default"); - REQUIRE(value[2] == "default"); - REQUIRE_FALSE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK_FALSE(parser.try_read("key", value, 3, "default")); + CHECK(value[0] == "default"); + CHECK(value[1] == "default"); + CHECK(value[2] == "default"); + CHECK_FALSE(parser.eof()); + CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = [ \"123.456789\", \"456.789\", \"151.091\" ]"); StringView value[3]; - REQUIRE(parser.try_read("key", value, 3, "default")); - REQUIRE(value[0] == "123.456789"); - REQUIRE(value[1] == "456.789"); - REQUIRE(value[2] == "151.091"); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.try_read("key", value, 3, "default")); + CHECK(value[0] == "123.456789"); + CHECK(value[1] == "456.789"); + CHECK(value[2] == "151.091"); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } #if 0 { Parser parser = parser_from_c_str("key = [ 123.456789, \"456.789\", false, [ 1.0, true ], { key0 = 1.0, key1 = false } ]"); - REQUIRE(parser.array_begins("key")); + CHECK(parser.array_begins("key")); // TODO - REQUIRE(parser.array_ends()); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK(parser.array_ends()); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } #endif } @@ -655,12 +655,12 @@ TEST_CASE("Parser Null Reading", "[parser]") { Parser parser = parser_from_c_str("key = null"); bool value_bool = false; - REQUIRE_FALSE(parser.try_read("key", value_bool, true)); - REQUIRE(value_bool == true); + CHECK_FALSE(parser.try_read("key", value_bool, true)); + CHECK(value_bool == true); double value_dbl = 0.0; - REQUIRE_FALSE(parser.try_read("key", value_dbl, 1.0)); - REQUIRE(value_dbl == 1.0); - REQUIRE(parser.eof()); - REQUIRE(parser.is_valid()); + CHECK_FALSE(parser.try_read("key", value_dbl, 1.0)); + CHECK(value_dbl == 1.0); + CHECK(parser.eof()); + CHECK(parser.is_valid()); } } diff --git a/tests/sources/test_string_view.cpp b/tests/sources/test_string_view.cpp index 0941803..eefab2a 100644 --- a/tests/sources/test_string_view.cpp +++ b/tests/sources/test_string_view.cpp @@ -32,43 +32,43 @@ using namespace sjson; TEST_CASE("StringView", "[string]") { - REQUIRE(StringView() == StringView("")); - REQUIRE(StringView() == ""); - REQUIRE(StringView().size() == 0); - REQUIRE(StringView().c_str() != nullptr); - REQUIRE(StringView("").size() == 0); - REQUIRE(StringView("").c_str() != nullptr); + CHECK(StringView() == StringView("")); + CHECK(StringView() == ""); + CHECK(StringView().size() == 0); + CHECK(StringView().c_str() != nullptr); + CHECK(StringView("").size() == 0); + CHECK(StringView("").c_str() != nullptr); const char* str0 = "this is a test string"; const char* str1 = "this is not a test string"; const char* str2 = "this is a test asset!"; - REQUIRE(StringView(str0) == str0); - REQUIRE(StringView(str0) != str1); - REQUIRE(StringView(str0) != str2); - REQUIRE(StringView(str0) == StringView(str0)); - REQUIRE(StringView(str0) != StringView(str1)); - REQUIRE(StringView(str0) != StringView(str2)); - REQUIRE(StringView(str0).c_str() == str0); - REQUIRE(StringView(str0).size() == std::strlen(str0)); - REQUIRE(StringView(str0, 4) == StringView(str1, 4)); - REQUIRE(StringView(str0, 4) == StringView("this")); + CHECK(StringView(str0) == str0); + CHECK(StringView(str0) != str1); + CHECK(StringView(str0) != str2); + CHECK(StringView(str0) == StringView(str0)); + CHECK(StringView(str0) != StringView(str1)); + CHECK(StringView(str0) != StringView(str2)); + CHECK(StringView(str0).c_str() == str0); + CHECK(StringView(str0).size() == std::strlen(str0)); + CHECK(StringView(str0, 4) == StringView(str1, 4)); + CHECK(StringView(str0, 4) == StringView("this")); StringView view0(str0); - REQUIRE(view0 == str0); + CHECK(view0 == str0); view0 = str1; - REQUIRE(view0 == str1); + CHECK(view0 == str1); - REQUIRE(StringView().empty() == true); - REQUIRE(StringView("").empty() == true); - REQUIRE(view0.empty() == false); + CHECK(StringView().empty() == true); + CHECK(StringView("").empty() == true); + CHECK(view0.empty() == false); - REQUIRE(view0[0] == 't'); - REQUIRE(view0[1] == 'h'); - REQUIRE(view0[2] == 'i'); - REQUIRE(view0[3] == 's'); - REQUIRE(view0[4] == ' '); - REQUIRE(view0[5] == 'i'); - REQUIRE(view0[view0.size() - 1] == 'g'); - REQUIRE_THROWS(view0[view0.size()]); + CHECK(view0[0] == 't'); + CHECK(view0[1] == 'h'); + CHECK(view0[2] == 'i'); + CHECK(view0[3] == 's'); + CHECK(view0[4] == ' '); + CHECK(view0[5] == 'i'); + CHECK(view0[view0.size() - 1] == 'g'); + CHECK_THROWS(view0[view0.size()]); } diff --git a/tests/sources/test_writer.cpp b/tests/sources/test_writer.cpp index 606032d..519dd72 100644 --- a/tests/sources/test_writer.cpp +++ b/tests/sources/test_writer.cpp @@ -55,28 +55,28 @@ TEST_CASE("Writer Object Bool Writing", "[writer]") StringStreamWriter str_writer; Writer writer(str_writer); writer.insert("key", true); - REQUIRE(str_writer.str() == "key = true\r\n"); + CHECK(str_writer.str() == "key = true\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer.insert("key", false); - REQUIRE(str_writer.str() == "key = false\r\n"); + CHECK(str_writer.str() == "key = false\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer["key"] = true; - REQUIRE(str_writer.str() == "key = true\r\n"); + CHECK(str_writer.str() == "key = true\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer["key"] = false; - REQUIRE(str_writer.str() == "key = false\r\n"); + CHECK(str_writer.str() == "key = false\r\n"); } } @@ -86,56 +86,56 @@ TEST_CASE("Writer Object String Writing", "[writer]") StringStreamWriter str_writer; Writer writer(str_writer); writer.insert("key", "some string"); - REQUIRE(str_writer.str() == "key = \"some string\"\r\n"); + CHECK(str_writer.str() == "key = \"some string\"\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer["key"] = "some string"; - REQUIRE(str_writer.str() == "key = \"some string\"\r\n"); + CHECK(str_writer.str() == "key = \"some string\"\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer.insert("key", "some\tstring"); - REQUIRE(str_writer.str() == "key = \"some\tstring\"\r\n"); + CHECK(str_writer.str() == "key = \"some\tstring\"\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer["key"] = "some\tstring"; - REQUIRE(str_writer.str() == "key = \"some\tstring\"\r\n"); + CHECK(str_writer.str() == "key = \"some\tstring\"\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer.insert("key", "some\nstring"); - REQUIRE(str_writer.str() == "key = \"some\nstring\"\r\n"); + CHECK(str_writer.str() == "key = \"some\nstring\"\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer["key"] = "some\nstring"; - REQUIRE(str_writer.str() == "key = \"some\nstring\"\r\n"); + CHECK(str_writer.str() == "key = \"some\nstring\"\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer.insert("key", "some\"string"); - REQUIRE(str_writer.str() == "key = \"some\"string\"\r\n"); + CHECK(str_writer.str() == "key = \"some\"string\"\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer["key"] = "some\"string"; - REQUIRE(str_writer.str() == "key = \"some\"string\"\r\n"); + CHECK(str_writer.str() == "key = \"some\"string\"\r\n"); } } @@ -145,140 +145,140 @@ TEST_CASE("Writer Object Number Writing", "[writer]") StringStreamWriter str_writer; Writer writer(str_writer); writer.insert("key", 123.0); - REQUIRE(str_writer.str() == "key = 123\r\n"); + CHECK(str_writer.str() == "key = 123\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer["key"] = 123.0; - REQUIRE(str_writer.str() == "key = 123\r\n"); + CHECK(str_writer.str() == "key = 123\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer.insert("key", 123.456); - REQUIRE(str_writer.str() == "key = 123.456\r\n"); + CHECK(str_writer.str() == "key = 123.456\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer["key"] = 123.456; - REQUIRE(str_writer.str() == "key = 123.456\r\n"); + CHECK(str_writer.str() == "key = 123.456\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer.insert("key", std::nan("")); - REQUIRE(str_writer.str() == "key = \"nan\"\r\n"); + CHECK(str_writer.str() == "key = \"nan\"\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer["key"] = std::nan(""); - REQUIRE(str_writer.str() == "key = \"nan\"\r\n"); + CHECK(str_writer.str() == "key = \"nan\"\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer.insert("key", std::numeric_limits::infinity()); - REQUIRE(str_writer.str() == "key = \"inf\"\r\n"); + CHECK(str_writer.str() == "key = \"inf\"\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer["key"] = std::numeric_limits::infinity(); - REQUIRE(str_writer.str() == "key = \"inf\"\r\n"); + CHECK(str_writer.str() == "key = \"inf\"\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer.insert("key", -std::numeric_limits::infinity()); - REQUIRE(str_writer.str() == "key = \"-inf\"\r\n"); + CHECK(str_writer.str() == "key = \"-inf\"\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer["key"] = -std::numeric_limits::infinity(); - REQUIRE(str_writer.str() == "key = \"-inf\"\r\n"); + CHECK(str_writer.str() == "key = \"-inf\"\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer.insert("key", 123.0F); - REQUIRE(str_writer.str() == "key = 123\r\n"); + CHECK(str_writer.str() == "key = 123\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer["key"] = 123.0F; - REQUIRE(str_writer.str() == "key = 123\r\n"); + CHECK(str_writer.str() == "key = 123\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer.insert("key", 123.5F); - REQUIRE(str_writer.str() == "key = 123.5\r\n"); + CHECK(str_writer.str() == "key = 123.5\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer["key"] = 123.5F; - REQUIRE(str_writer.str() == "key = 123.5\r\n"); + CHECK(str_writer.str() == "key = 123.5\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer.insert("key", std::nanf("")); - REQUIRE(str_writer.str() == "key = \"nan\"\r\n"); + CHECK(str_writer.str() == "key = \"nan\"\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer["key"] = std::nanf(""); - REQUIRE(str_writer.str() == "key = \"nan\"\r\n"); + CHECK(str_writer.str() == "key = \"nan\"\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer.insert("key", std::numeric_limits::infinity()); - REQUIRE(str_writer.str() == "key = \"inf\"\r\n"); + CHECK(str_writer.str() == "key = \"inf\"\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer["key"] = std::numeric_limits::infinity(); - REQUIRE(str_writer.str() == "key = \"inf\"\r\n"); + CHECK(str_writer.str() == "key = \"inf\"\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer.insert("key", -std::numeric_limits::infinity()); - REQUIRE(str_writer.str() == "key = \"-inf\"\r\n"); + CHECK(str_writer.str() == "key = \"-inf\"\r\n"); } { StringStreamWriter str_writer; Writer writer(str_writer); writer["key"] = -std::numeric_limits::infinity(); - REQUIRE(str_writer.str() == "key = \"-inf\"\r\n"); + CHECK(str_writer.str() == "key = \"-inf\"\r\n"); } { @@ -286,7 +286,7 @@ TEST_CASE("Writer Object Number Writing", "[writer]") Writer writer(str_writer); int8_t value = -123; writer.insert("key", value); - REQUIRE(str_writer.str() == "key = -123\r\n"); + CHECK(str_writer.str() == "key = -123\r\n"); } { @@ -294,7 +294,7 @@ TEST_CASE("Writer Object Number Writing", "[writer]") Writer writer(str_writer); int8_t value = -123; writer["key"] = value; - REQUIRE(str_writer.str() == "key = -123\r\n"); + CHECK(str_writer.str() == "key = -123\r\n"); } { @@ -302,7 +302,7 @@ TEST_CASE("Writer Object Number Writing", "[writer]") Writer writer(str_writer); uint8_t value = 123; writer.insert("key", value); - REQUIRE(str_writer.str() == "key = 123\r\n"); + CHECK(str_writer.str() == "key = 123\r\n"); } { @@ -310,7 +310,7 @@ TEST_CASE("Writer Object Number Writing", "[writer]") Writer writer(str_writer); uint8_t value = 123; writer["key"] = value; - REQUIRE(str_writer.str() == "key = 123\r\n"); + CHECK(str_writer.str() == "key = 123\r\n"); } { @@ -318,7 +318,7 @@ TEST_CASE("Writer Object Number Writing", "[writer]") Writer writer(str_writer); int16_t value = -1234; writer.insert("key", value); - REQUIRE(str_writer.str() == "key = -1234\r\n"); + CHECK(str_writer.str() == "key = -1234\r\n"); } { @@ -326,7 +326,7 @@ TEST_CASE("Writer Object Number Writing", "[writer]") Writer writer(str_writer); int16_t value = -1234; writer["key"] = value; - REQUIRE(str_writer.str() == "key = -1234\r\n"); + CHECK(str_writer.str() == "key = -1234\r\n"); } { @@ -334,7 +334,7 @@ TEST_CASE("Writer Object Number Writing", "[writer]") Writer writer(str_writer); uint16_t value = 1234; writer.insert("key", value); - REQUIRE(str_writer.str() == "key = 1234\r\n"); + CHECK(str_writer.str() == "key = 1234\r\n"); } { @@ -342,7 +342,7 @@ TEST_CASE("Writer Object Number Writing", "[writer]") Writer writer(str_writer); uint16_t value = 1234; writer["key"] = value; - REQUIRE(str_writer.str() == "key = 1234\r\n"); + CHECK(str_writer.str() == "key = 1234\r\n"); } { @@ -350,7 +350,7 @@ TEST_CASE("Writer Object Number Writing", "[writer]") Writer writer(str_writer); int32_t value = -123456; writer.insert("key", value); - REQUIRE(str_writer.str() == "key = -123456\r\n"); + CHECK(str_writer.str() == "key = -123456\r\n"); } { @@ -358,7 +358,7 @@ TEST_CASE("Writer Object Number Writing", "[writer]") Writer writer(str_writer); int32_t value = -123456; writer["key"] = value; - REQUIRE(str_writer.str() == "key = -123456\r\n"); + CHECK(str_writer.str() == "key = -123456\r\n"); } { @@ -366,7 +366,7 @@ TEST_CASE("Writer Object Number Writing", "[writer]") Writer writer(str_writer); uint32_t value = 123456; writer.insert("key", value); - REQUIRE(str_writer.str() == "key = 123456\r\n"); + CHECK(str_writer.str() == "key = 123456\r\n"); } { @@ -374,7 +374,7 @@ TEST_CASE("Writer Object Number Writing", "[writer]") Writer writer(str_writer); uint32_t value = 123456; writer["key"] = value; - REQUIRE(str_writer.str() == "key = 123456\r\n"); + CHECK(str_writer.str() == "key = 123456\r\n"); } { @@ -382,7 +382,7 @@ TEST_CASE("Writer Object Number Writing", "[writer]") Writer writer(str_writer); int64_t value = -1234567890123456LL; writer.insert("key", value); - REQUIRE(str_writer.str() == "key = -1234567890123456\r\n"); + CHECK(str_writer.str() == "key = -1234567890123456\r\n"); } { @@ -390,7 +390,7 @@ TEST_CASE("Writer Object Number Writing", "[writer]") Writer writer(str_writer); int64_t value = -1234567890123456LL; writer["key"] = value; - REQUIRE(str_writer.str() == "key = -1234567890123456\r\n"); + CHECK(str_writer.str() == "key = -1234567890123456\r\n"); } { @@ -398,7 +398,7 @@ TEST_CASE("Writer Object Number Writing", "[writer]") Writer writer(str_writer); uint64_t value = 1234567890123456ULL; writer.insert("key", value); - REQUIRE(str_writer.str() == "key = 1234567890123456\r\n"); + CHECK(str_writer.str() == "key = 1234567890123456\r\n"); } { @@ -406,7 +406,7 @@ TEST_CASE("Writer Object Number Writing", "[writer]") Writer writer(str_writer); uint64_t value = 1234567890123456ULL; writer["key"] = value; - REQUIRE(str_writer.str() == "key = 1234567890123456\r\n"); + CHECK(str_writer.str() == "key = 1234567890123456\r\n"); } } @@ -418,7 +418,7 @@ TEST_CASE("Writer Object Array Writing", "[writer]") writer.insert("key", [](ArrayWriter& /*array_writer*/) { }); - REQUIRE(str_writer.str() == "key = [ ]\r\n"); + CHECK(str_writer.str() == "key = [ ]\r\n"); } { @@ -429,7 +429,7 @@ TEST_CASE("Writer Object Array Writing", "[writer]") array_writer.push(123.5); array_writer.push(456.5); }); - REQUIRE(str_writer.str() == "key = [ 123.5, 456.5 ]\r\n"); + CHECK(str_writer.str() == "key = [ 123.5, 456.5 ]\r\n"); } { @@ -440,7 +440,7 @@ TEST_CASE("Writer Object Array Writing", "[writer]") array_writer.push(123.5); array_writer.push(456.5); }; - REQUIRE(str_writer.str() == "key = [ 123.5, 456.5 ]\r\n"); + CHECK(str_writer.str() == "key = [ 123.5, 456.5 ]\r\n"); } } @@ -452,7 +452,7 @@ TEST_CASE("Writer Object Object Writing", "[writer]") writer.insert("key", [](ObjectWriter& /*object_writer*/) { }); - REQUIRE(str_writer.str() == "key = {\r\n}\r\n"); + CHECK(str_writer.str() == "key = {\r\n}\r\n"); } { @@ -463,7 +463,7 @@ TEST_CASE("Writer Object Object Writing", "[writer]") object_writer["key0"] = 123.5; object_writer["key1"] = 456.5; }); - REQUIRE(str_writer.str() == "key = {\r\n\tkey0 = 123.5\r\n\tkey1 = 456.5\r\n}\r\n"); + CHECK(str_writer.str() == "key = {\r\n\tkey0 = 123.5\r\n\tkey1 = 456.5\r\n}\r\n"); } { @@ -474,7 +474,7 @@ TEST_CASE("Writer Object Object Writing", "[writer]") object_writer["key0"] = 123.5; object_writer["key1"] = 456.5; }; - REQUIRE(str_writer.str() == "key = {\r\n\tkey0 = 123.5\r\n\tkey1 = 456.5\r\n}\r\n"); + CHECK(str_writer.str() == "key = {\r\n\tkey0 = 123.5\r\n\tkey1 = 456.5\r\n}\r\n"); } } @@ -487,7 +487,7 @@ TEST_CASE("Writer Array Bool Writing", "[writer]") { array_writer.push(true); }); - REQUIRE(str_writer.str() == "key = [ true ]\r\n"); + CHECK(str_writer.str() == "key = [ true ]\r\n"); } { @@ -497,7 +497,7 @@ TEST_CASE("Writer Array Bool Writing", "[writer]") { array_writer.push(false); }); - REQUIRE(str_writer.str() == "key = [ false ]\r\n"); + CHECK(str_writer.str() == "key = [ false ]\r\n"); } } @@ -510,7 +510,7 @@ TEST_CASE("Writer Array String Writing", "[writer]") { array_writer.push("some string"); }); - REQUIRE(str_writer.str() == "key = [ \"some string\" ]\r\n"); + CHECK(str_writer.str() == "key = [ \"some string\" ]\r\n"); } { @@ -520,7 +520,7 @@ TEST_CASE("Writer Array String Writing", "[writer]") { array_writer.push("some\tstring"); }); - REQUIRE(str_writer.str() == "key = [ \"some\tstring\" ]\r\n"); + CHECK(str_writer.str() == "key = [ \"some\tstring\" ]\r\n"); } { @@ -530,7 +530,7 @@ TEST_CASE("Writer Array String Writing", "[writer]") { array_writer.push("some\nstring"); }); - REQUIRE(str_writer.str() == "key = [ \"some\nstring\" ]\r\n"); + CHECK(str_writer.str() == "key = [ \"some\nstring\" ]\r\n"); } { @@ -540,7 +540,7 @@ TEST_CASE("Writer Array String Writing", "[writer]") { array_writer.push("some\"string"); }); - REQUIRE(str_writer.str() == "key = [ \"some\"string\" ]\r\n"); + CHECK(str_writer.str() == "key = [ \"some\"string\" ]\r\n"); } } @@ -553,7 +553,7 @@ TEST_CASE("Writer Array Number Writing", "[writer]") { array_writer.push(123.0); }); - REQUIRE(str_writer.str() == "key = [ 123 ]\r\n"); + CHECK(str_writer.str() == "key = [ 123 ]\r\n"); } { @@ -563,7 +563,7 @@ TEST_CASE("Writer Array Number Writing", "[writer]") { array_writer.push(123.456); }); - REQUIRE(str_writer.str() == "key = [ 123.456 ]\r\n"); + CHECK(str_writer.str() == "key = [ 123.456 ]\r\n"); } { @@ -575,7 +575,7 @@ TEST_CASE("Writer Array Number Writing", "[writer]") array_writer.push(std::numeric_limits::infinity()); array_writer.push(-std::numeric_limits::infinity()); }); - REQUIRE(str_writer.str() == "key = [ \"nan\", \"inf\", \"-inf\" ]\r\n"); + CHECK(str_writer.str() == "key = [ \"nan\", \"inf\", \"-inf\" ]\r\n"); } { @@ -585,7 +585,7 @@ TEST_CASE("Writer Array Number Writing", "[writer]") { array_writer.push(123.0F); }); - REQUIRE(str_writer.str() == "key = [ 123 ]\r\n"); + CHECK(str_writer.str() == "key = [ 123 ]\r\n"); } { @@ -595,7 +595,7 @@ TEST_CASE("Writer Array Number Writing", "[writer]") { array_writer.push(123.5F); }); - REQUIRE(str_writer.str() == "key = [ 123.5 ]\r\n"); + CHECK(str_writer.str() == "key = [ 123.5 ]\r\n"); } { @@ -607,7 +607,7 @@ TEST_CASE("Writer Array Number Writing", "[writer]") array_writer.push(std::numeric_limits::infinity()); array_writer.push(-std::numeric_limits::infinity()); }); - REQUIRE(str_writer.str() == "key = [ \"nan\", \"inf\", \"-inf\" ]\r\n"); + CHECK(str_writer.str() == "key = [ \"nan\", \"inf\", \"-inf\" ]\r\n"); } { @@ -618,7 +618,7 @@ TEST_CASE("Writer Array Number Writing", "[writer]") int8_t value = -123; array_writer.push(value); }); - REQUIRE(str_writer.str() == "key = [ -123 ]\r\n"); + CHECK(str_writer.str() == "key = [ -123 ]\r\n"); } { @@ -629,7 +629,7 @@ TEST_CASE("Writer Array Number Writing", "[writer]") uint8_t value = 123; array_writer.push(value); }); - REQUIRE(str_writer.str() == "key = [ 123 ]\r\n"); + CHECK(str_writer.str() == "key = [ 123 ]\r\n"); } { @@ -640,7 +640,7 @@ TEST_CASE("Writer Array Number Writing", "[writer]") int16_t value = -1234; array_writer.push(value); }); - REQUIRE(str_writer.str() == "key = [ -1234 ]\r\n"); + CHECK(str_writer.str() == "key = [ -1234 ]\r\n"); } { @@ -651,7 +651,7 @@ TEST_CASE("Writer Array Number Writing", "[writer]") uint16_t value = 1234; array_writer.push(value); }); - REQUIRE(str_writer.str() == "key = [ 1234 ]\r\n"); + CHECK(str_writer.str() == "key = [ 1234 ]\r\n"); } { @@ -662,7 +662,7 @@ TEST_CASE("Writer Array Number Writing", "[writer]") int32_t value = -123456; array_writer.push(value); }); - REQUIRE(str_writer.str() == "key = [ -123456 ]\r\n"); + CHECK(str_writer.str() == "key = [ -123456 ]\r\n"); } { @@ -673,7 +673,7 @@ TEST_CASE("Writer Array Number Writing", "[writer]") uint32_t value = 123456; array_writer.push(value); }); - REQUIRE(str_writer.str() == "key = [ 123456 ]\r\n"); + CHECK(str_writer.str() == "key = [ 123456 ]\r\n"); } { @@ -684,7 +684,7 @@ TEST_CASE("Writer Array Number Writing", "[writer]") int64_t value = -1234567890123456LL; array_writer.push(value); }); - REQUIRE(str_writer.str() == "key = [ -1234567890123456 ]\r\n"); + CHECK(str_writer.str() == "key = [ -1234567890123456 ]\r\n"); } { @@ -695,7 +695,7 @@ TEST_CASE("Writer Array Number Writing", "[writer]") uint64_t value = 1234567890123456ULL; array_writer.push(value); }); - REQUIRE(str_writer.str() == "key = [ 1234567890123456 ]\r\n"); + CHECK(str_writer.str() == "key = [ 1234567890123456 ]\r\n"); } } @@ -710,7 +710,7 @@ TEST_CASE("Writer Array Array Writing", "[writer]") { }); }); - REQUIRE(str_writer.str() == "key = [ [ ] ]\r\n"); + CHECK(str_writer.str() == "key = [ [ ] ]\r\n"); } { @@ -724,7 +724,7 @@ TEST_CASE("Writer Array Array Writing", "[writer]") array_writer1.push(456.5); }); }); - REQUIRE(str_writer.str() == "key = [ [ 123.5, 456.5 ] ]\r\n"); + CHECK(str_writer.str() == "key = [ [ 123.5, 456.5 ] ]\r\n"); } } @@ -739,7 +739,7 @@ TEST_CASE("Writer Array Object Writing", "[writer]") { }); }); - REQUIRE(str_writer.str() == "key = [ \r\n\t{\r\n\t}\r\n]\r\n"); + CHECK(str_writer.str() == "key = [ \r\n\t{\r\n\t}\r\n]\r\n"); } { @@ -753,6 +753,6 @@ TEST_CASE("Writer Array Object Writing", "[writer]") object_writer1["key1"] = 456.5; }); }); - REQUIRE(str_writer.str() == "key = [ \r\n\t{\r\n\t\tkey0 = 123.5\r\n\t\tkey1 = 456.5\r\n\t}\r\n]\r\n"); + CHECK(str_writer.str() == "key = [ \r\n\t{\r\n\t\tkey0 = 123.5\r\n\t\tkey1 = 456.5\r\n\t}\r\n]\r\n"); } } From 2f93638ace1c08e80eab1c2a68067ffa99ba045f Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 18 Feb 2020 21:31:19 -0500 Subject: [PATCH 053/285] chore: update Catch2 to v2.11.0 --- external/README.md | 2 +- external/catch2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/external/README.md b/external/README.md index 8666509..78396d8 100644 --- a/external/README.md +++ b/external/README.md @@ -4,4 +4,4 @@ Good news! There are no external dependencies needed by this library at runtime! ## Catch -[Catch2 v2.5.0](https://github.com/catchorg/Catch2/releases/tag/v2.5.0) is used by our [unit tests](../tests). You will only need it if you run the unit tests and it is included as-is without modifications. +[Catch2 v2.11.0](https://github.com/catchorg/Catch2/releases/tag/v2.11.0) is used by our [unit tests](../tests). You will only need it if you run the unit tests and it is included as-is without modifications. diff --git a/external/catch2 b/external/catch2 index 6ccd467..e1c9d55 160000 --- a/external/catch2 +++ b/external/catch2 @@ -1 +1 @@ -Subproject commit 6ccd467094973824d89efb16cbc553e279f79823 +Subproject commit e1c9d5569dc4135babb9c81891d70a8ba8ed938c From 890022d79b332e15ae2557dd7509997dda13007e Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 18 Feb 2020 22:42:45 -0500 Subject: [PATCH 054/285] chore: add support for clang with VS2019 --- README.md | 4 +++- appveyor.yml | 10 ++++++++++ make.py | 13 +++++++++---- 3 files changed, 22 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 0af1e13..2b9032f 100644 --- a/README.md +++ b/README.md @@ -35,7 +35,9 @@ Unicode formats other than UTF-8 aren't supported. ## Supported platforms -* Windows VS2015 x86 and x64, VS2017/2019 x86, x64, and ARM64* +* Windows VS2015 x86 and x64 +* Windows (VS2017, VS2019) x86, x64, and ARM64* +* Windows VS2019 with clang8 x86 and x64 * Linux (gcc5, gcc6, gcc7, gcc8, gcc9) x86 and x64 * Linux (clang4, clang5, clang6, clang7, clang8, clang9) x86 and x64 * OS X (Xcode 8.3, 9.4, 10.3, 11.2*) x86 and x64 diff --git a/appveyor.yml b/appveyor.yml index ab44451..cfdfef5 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -34,3 +34,13 @@ build_script: IF DEFINED ARM64_SUPPORTED %PYTHON%\\python.exe make.py -clean -build -compiler %COMPILER% -config Debug -cpu arm64 IF DEFINED ARM64_SUPPORTED %PYTHON%\\python.exe make.py -clean -build -compiler %COMPILER% -config Release -cpu arm64 + + IF "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019" (SET COMPILER=vs2019-clang && SET CLANG_SUPPORTED=1) + + IF DEFINED CLANG_SUPPORTED %PYTHON%\\python.exe make.py -clean -build -compiler %COMPILER% -config Debug -cpu x86 + + IF DEFINED CLANG_SUPPORTED %PYTHON%\\python.exe make.py -clean -build -compiler %COMPILER% -config Release -cpu x86 + + IF DEFINED CLANG_SUPPORTED %PYTHON%\\python.exe make.py -clean -build -compiler %COMPILER% -config Debug -cpu x64 + + IF DEFINED CLANG_SUPPORTED %PYTHON%\\python.exe make.py -clean -build -compiler %COMPILER% -config Release -cpu x64 diff --git a/make.py b/make.py index 0fd265d..e526675 100644 --- a/make.py +++ b/make.py @@ -15,7 +15,7 @@ def parse_argv(): actions.add_argument('-unit_test', action='store_true') target = parser.add_argument_group(title='Target') - target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'osx', 'ios'], help='Defaults to the host system\'s default compiler') + target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'vs2019-clang', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'osx', 'ios'], help='Defaults to the host system\'s default compiler') target.add_argument('-config', choices=['Debug', 'Release'], type=str.capitalize) target.add_argument('-cpu', choices=['x86', 'x64', 'arm64'], help='Only supported for Windows, OS X, and Linux; defaults to the host system\'s architecture') @@ -88,7 +88,7 @@ def get_generator(compiler, cpu): # VS2017 ARM/ARM64 support only works with cmake 3.13 and up and the architecture must be specified with # the -A cmake switch return 'Visual Studio 15 2017' - elif compiler == 'vs2019': + elif compiler == 'vs2019' or compiler == 'vs2019-clang': return 'Visual Studio 16 2019' elif compiler == 'android': return 'Visual Studio 14' @@ -110,7 +110,7 @@ def get_architecture(compiler, cpu): if compiler == 'vs2017': if cpu == 'arm64': return 'ARM64' - elif compiler == 'vs2019': + elif compiler == 'vs2019' or compiler == 'vs2019-clang': if cpu == 'x86': return 'Win32' else: @@ -187,6 +187,11 @@ def do_generate_solution(cmake_exe, build_dir, cmake_script_dir, args): if toolchain: extra_switches.append('-DCMAKE_TOOLCHAIN_FILE={}'.format(os.path.join(cmake_script_dir, toolchain))) + generator_suffix = '' + if compiler == 'vs2019-clang': + extra_switches.append('-T ClangCL') + generator_suffix = 'Clang CL' + # Generate IDE solution print('Generating build files ...') cmake_cmd = '"{}" .. -DCMAKE_INSTALL_PREFIX="{}" {}'.format(cmake_exe, build_dir, ' '.join(extra_switches)) @@ -194,7 +199,7 @@ def do_generate_solution(cmake_exe, build_dir, cmake_script_dir, args): if not cmake_generator: print('Using default generator') else: - print('Using generator: {}'.format(cmake_generator)) + print('Using generator: {} {}'.format(cmake_generator, generator_suffix)) cmake_cmd += ' -G "{}"'.format(cmake_generator) cmake_arch = get_architecture(compiler, cpu) From 2eba0ed3c1af1b1aa89fe17869e4a223bb87c098 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 18 Feb 2020 23:04:27 -0500 Subject: [PATCH 055/285] chore: fix version used by appveyor and add unit testing to appveyor --- README.md | 2 +- appveyor.yml | 8 ++++---- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 2b9032f..7f1ebc7 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Unicode formats other than UTF-8 aren't supported. * Windows VS2015 x86 and x64 * Windows (VS2017, VS2019) x86, x64, and ARM64* -* Windows VS2019 with clang8 x86 and x64 +* Windows VS2019 with clang9 x86 and x64 * Linux (gcc5, gcc6, gcc7, gcc8, gcc9) x86 and x64 * Linux (clang4, clang5, clang6, clang7, clang8, clang9) x86 and x64 * OS X (Xcode 8.3, 9.4, 10.3, 11.2*) x86 and x64 diff --git a/appveyor.yml b/appveyor.yml index cfdfef5..84c71b7 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -37,10 +37,10 @@ build_script: IF "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019" (SET COMPILER=vs2019-clang && SET CLANG_SUPPORTED=1) - IF DEFINED CLANG_SUPPORTED %PYTHON%\\python.exe make.py -clean -build -compiler %COMPILER% -config Debug -cpu x86 + IF DEFINED CLANG_SUPPORTED %PYTHON%\\python.exe make.py -clean -build -unit_test -compiler %COMPILER% -config Debug -cpu x86 - IF DEFINED CLANG_SUPPORTED %PYTHON%\\python.exe make.py -clean -build -compiler %COMPILER% -config Release -cpu x86 + IF DEFINED CLANG_SUPPORTED %PYTHON%\\python.exe make.py -clean -build -unit_test -compiler %COMPILER% -config Release -cpu x86 - IF DEFINED CLANG_SUPPORTED %PYTHON%\\python.exe make.py -clean -build -compiler %COMPILER% -config Debug -cpu x64 + IF DEFINED CLANG_SUPPORTED %PYTHON%\\python.exe make.py -clean -build -unit_test -compiler %COMPILER% -config Debug -cpu x64 - IF DEFINED CLANG_SUPPORTED %PYTHON%\\python.exe make.py -clean -build -compiler %COMPILER% -config Release -cpu x64 + IF DEFINED CLANG_SUPPORTED %PYTHON%\\python.exe make.py -clean -build -unit_test -compiler %COMPILER% -config Release -cpu x64 From 243f8fce911cd4e3ee2aef3f8289799b64156a55 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 29 Mar 2020 15:15:49 -0400 Subject: [PATCH 056/285] chore: extend .editorconfig support to gradle files --- .editorconfig | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/.editorconfig b/.editorconfig index 153e002..be3256d 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,11 +5,16 @@ end_of_line = lf insert_final_newline = true # Matches multiple files with brace expansion notation -[*.{cpp,h,py,txt}] +[*.{cpp,h,py,txt,java}] charset = utf-8 indent_style = tab indent_size = 4 trim_trailing_whitespace = true [*.md] -trim_trailing_whitespace = false \ No newline at end of file +trim_trailing_whitespace = false + +[*.{gradle,gradle.in}] +indent_style = space +indent_size = 4 +trim_trailing_whitespace = true From 9ad68ec27415a804458f6b4051401539be0b57a6 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 29 Mar 2020 15:16:16 -0400 Subject: [PATCH 057/285] chore: cleanup cmake file and early exit if already defined --- cmake/CMakePlatforms.cmake | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cmake/CMakePlatforms.cmake b/cmake/CMakePlatforms.cmake index bb8d696..bfa33a7 100644 --- a/cmake/CMakePlatforms.cmake +++ b/cmake/CMakePlatforms.cmake @@ -1,20 +1,24 @@ cmake_minimum_required(VERSION 3.2) +if(PLATFORM_NAME) + return() # Already set +endif() + # Detect which platform we have -if( ${CMAKE_SYSTEM_NAME} STREQUAL "Windows" ) +if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows") set(PLATFORM_WINDOWS 1) set(PLATFORM_NAME "Windows") -elseif( ${CMAKE_SYSTEM_NAME} STREQUAL "Darwin" ) +elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin") if(PLATFORM_IOS) set(PLATFORM_NAME "iOS") else() set(PLATFORM_OSX 1) set(PLATFORM_NAME "OS X") endif() -elseif( ${CMAKE_SYSTEM_NAME} STREQUAL "Linux" ) +elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") set(PLATFORM_LINUX 1) set(PLATFORM_NAME "Linux") -elseif( ${CMAKE_SYSTEM_NAME} STREQUAL "Android" ) +elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Android") set(PLATFORM_ANDROID 1) set(PLATFORM_NAME "Android") else() From 18a4f45af1d3b24a3bef40e4415da72c1431a7a3 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 29 Mar 2020 15:17:10 -0400 Subject: [PATCH 058/285] chore: change cmake projects to use no specific language instead of C++ --- CMakeLists.txt | 15 ++++++++------- tests/CMakeLists.txt | 2 +- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea1fd4a..0790ffa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required (VERSION 3.2) -project(sjson-cpp CXX) +project(sjson-cpp NONE) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake") @@ -9,6 +9,11 @@ include(CMakePlatforms) set(CPU_INSTRUCTION_SET false CACHE STRING "CPU instruction set") +if(CMAKE_CONFIGURATION_TYPES) + set(CMAKE_CONFIGURATION_TYPES Debug Release) + set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Reset the configurations to what we need" FORCE) +endif() + # Grab all of our include files file(GLOB_RECURSE SJSON_CPP_INCLUDE_FILES LIST_DIRECTORIES false ${PROJECT_SOURCE_DIR}/includes/*.h @@ -23,13 +28,9 @@ file(GLOB SJSON_CPP_ROOT_FILES LIST_DIRECTORIES false ${PROJECT_SOURCE_DIR}/*.py) # Create a dummy target so they show up in the IDE -add_custom_target(sjson-cpp SOURCES ${SJSON_CPP_INCLUDE_FILES} ${SJSON_CPP_ROOT_FILES}) - -if(CMAKE_CONFIGURATION_TYPES) - set(CMAKE_CONFIGURATION_TYPES Debug Release) - set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Reset the configurations to what we need" FORCE) -endif() +add_custom_target(${PROJECT_NAME} SOURCES ${SJSON_CPP_INCLUDE_FILES} ${SJSON_CPP_ROOT_FILES}) +# Enable CTest enable_testing() # Add other projects diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 0ca1004..df53b61 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required (VERSION 3.2) -project(sjson-cpp_unit_tests_root CXX) +project(sjson-cpp_unit_tests_root NONE) if(PLATFORM_ANDROID) add_subdirectory("${PROJECT_SOURCE_DIR}/main_android") From 5c203a56e2ba21e1e9acfd5d8dd4031c275c58cf Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 29 Mar 2020 15:30:25 -0400 Subject: [PATCH 059/285] refactor: support Android through the NDK and gradle NVIDIA CodeWorks is no longer supported and we instead rely on the standard NDK toolchains. CMake takes care to configure what we need and to build. Python drives unit testing deployment and execution on a device. --- README.md | 4 +- cmake/Toolchain-Android.cmake | 18 +- make.py | 89 +++++++-- tests/main_android/CMakeLists.txt | 66 ++----- tests/main_android/app/build.gradle.in | 47 +++++ tests/main_android/app/proguard-rules.pro | 21 +++ .../{ => app/src/main}/AndroidManifest.xml | 9 +- .../app/src/main/cpp/CMakeLists.txt | 30 +++ .../{jni => app/src/main/cpp}/main.cpp | 0 .../com/sjson/unit_tests/MainActivity.java | 6 +- .../{ => app/src/main}/res/values/strings.xml | 0 tests/main_android/build.gradle | 25 +++ tests/main_android/build.xml | 4 - tests/main_android/gradle.properties | 22 +++ .../gradle/wrapper/gradle-wrapper.jar | Bin 0 -> 54329 bytes .../gradle/wrapper/gradle-wrapper.properties | 6 + tests/main_android/gradlew | 172 ++++++++++++++++++ tests/main_android/gradlew.bat | 84 +++++++++ tests/main_android/proguard-android.txt | 56 ------ tests/main_android/settings.gradle | 2 + 20 files changed, 513 insertions(+), 148 deletions(-) create mode 100644 tests/main_android/app/build.gradle.in create mode 100644 tests/main_android/app/proguard-rules.pro rename tests/main_android/{ => app/src/main}/AndroidManifest.xml (62%) create mode 100644 tests/main_android/app/src/main/cpp/CMakeLists.txt rename tests/main_android/{jni => app/src/main/cpp}/main.cpp (100%) rename tests/main_android/{ => app/src/main}/java/com/sjson/unit_tests/MainActivity.java (98%) rename tests/main_android/{ => app/src/main}/res/values/strings.xml (100%) create mode 100644 tests/main_android/build.gradle delete mode 100644 tests/main_android/build.xml create mode 100644 tests/main_android/gradle.properties create mode 100644 tests/main_android/gradle/wrapper/gradle-wrapper.jar create mode 100644 tests/main_android/gradle/wrapper/gradle-wrapper.properties create mode 100644 tests/main_android/gradlew create mode 100644 tests/main_android/gradlew.bat delete mode 100644 tests/main_android/proguard-android.txt create mode 100644 tests/main_android/settings.gradle diff --git a/README.md b/README.md index 7f1ebc7..bf1d9b3 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Unicode formats other than UTF-8 aren't supported. * Linux (gcc5, gcc6, gcc7, gcc8, gcc9) x86 and x64 * Linux (clang4, clang5, clang6, clang7, clang8, clang9) x86 and x64 * OS X (Xcode 8.3, 9.4, 10.3, 11.2*) x86 and x64 -* Android (NVIDIA CodeWorks with clang5) ARMv7-A and ARM64 +* Android (NDK 21) ARMv7-A and ARM64 * iOS (Xcode 8.3, 9.4, 10.3) ARM64 The above supported platform list is only what is tested every release but if it compiles, it should run just fine. @@ -73,7 +73,7 @@ For *Windows on ARM64*, the steps are identical to *x86 and x64* but you will ne ### Android -For *Android*, the steps are identical to *Windows, Linux, and OS X* but you also need to install *NVIDIA CodeWorks 1R5* (or higher). +For *Android*, the steps are identical to *Windows, Linux, and OS X* but you also need to install *Android NDK 21* (or higher). The build uses `gradle` and `-unit_test` will deploy and run on the device when executed. ### iOS diff --git a/cmake/Toolchain-Android.cmake b/cmake/Toolchain-Android.cmake index 7910664..c5570d4 100644 --- a/cmake/Toolchain-Android.cmake +++ b/cmake/Toolchain-Android.cmake @@ -1,10 +1,14 @@ -cmake_minimum_required (VERSION 3.2) -include(ProcessorCount) +cmake_minimum_required(VERSION 3.2) -set(CMAKE_SYSTEM_NAME Android) +# For Android, we just set the platform name as we won't be using CMake to build anything. +# Instead Gradle is used through CMake. -# Use the clang tool set because it's support for C++11 is superior -set(CMAKE_GENERATOR_TOOLSET DefaultClang) +set(PLATFORM_ANDROID 1) +set(PLATFORM_NAME "Android") -# Make sure we use all our processors when building -ProcessorCount(CMAKE_ANDROID_PROCESS_MAX) +# Remap our CPU instruction set +if(CPU_INSTRUCTION_SET MATCHES "armv7") + set(CPU_INSTRUCTION_SET "armeabi-v7a") +elseif(CPU_INSTRUCTION_SET MATCHES "arm64") + set(CPU_INSTRUCTION_SET "arm64-v8a") +endif() diff --git a/make.py b/make.py index e526675..408d195 100644 --- a/make.py +++ b/make.py @@ -17,42 +17,61 @@ def parse_argv(): target = parser.add_argument_group(title='Target') target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'vs2019-clang', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'osx', 'ios'], help='Defaults to the host system\'s default compiler') target.add_argument('-config', choices=['Debug', 'Release'], type=str.capitalize) - target.add_argument('-cpu', choices=['x86', 'x64', 'arm64'], help='Only supported for Windows, OS X, and Linux; defaults to the host system\'s architecture') + target.add_argument('-cpu', choices=['x86', 'x64', 'armv7', 'arm64'], help='Defaults to the host system\'s architecture') misc = parser.add_argument_group(title='Miscellaneous') misc.add_argument('-num_threads', help='No. to use while compiling') misc.add_argument('-tests_matching', help='Only run tests whose names match this regex') misc.add_argument('-help', action='help', help='Display this usage information') - num_threads = multiprocessing.cpu_count() if platform.system() == 'Linux' and sys.version_info >= (3, 4): num_threads = len(os.sched_getaffinity(0)) if not num_threads or num_threads == 0: num_threads = 4 - parser.set_defaults(build=False, clean=False, unit_test=False, compiler=None, config='Release', cpu='x64', num_threads=num_threads, tests_matching='') + parser.set_defaults(build=False, clean=False, unit_test=False, compiler=None, config='Release', cpu=None, num_threads=num_threads, tests_matching='') args = parser.parse_args() # Sanitize and validate our options if args.compiler == 'android': - args.cpu = 'armv7-a' + if not args.cpu: + args.cpu = 'arm64' if not platform.system() == 'Windows': print('Android is only supported on Windows') sys.exit(1) - if args.compiler == 'ios': - args.cpu = 'arm64' + if not args.cpu in ['armv7', 'arm64']: + print('{} cpu architecture not in supported list [armv7, arm64] for Android'.format(args.cpu)) + sys.exit(1) + elif args.compiler == 'ios': + if not args.cpu: + args.cpu = 'arm64' if not platform.system() == 'Darwin': print('iOS is only supported on OS X') sys.exit(1) + if not args.cpu in ['arm64']: + print('{} cpu architecture not in supported list [arm64] for iOS'.format(args.cpu)) + sys.exit(1) + else: + if not args.cpu: + args.cpu = 'x64' + + if not args.cpu in ['x86', 'x64']: + print('{} cpu architecture not in supported list [x86, x64] for {}'.format(args.cpu, platform.system())) + sys.exit(1) + if args.cpu == 'arm64': - if not args.compiler in ['vs2017', 'vs2019', 'ios']: - print('ARM64 is only supported with VS2017, VS2019, and iOS') + if not args.compiler in ['vs2017', 'vs2019', 'ios', 'android']: + print('arm64 is only supported with VS2017, VS2019, Android, and iOS') + sys.exit(1) + elif args.cpu == 'armv7': + if not args.compiler == 'android': + print('armv7 is only supported with Android') sys.exit(1) if platform.system() == 'Darwin' and args.cpu == 'x86': @@ -91,7 +110,8 @@ def get_generator(compiler, cpu): elif compiler == 'vs2019' or compiler == 'vs2019-clang': return 'Visual Studio 16 2019' elif compiler == 'android': - return 'Visual Studio 14' + # For Android, we use the default generator since we don't build with CMake + return None elif platform.system() == 'Darwin': if compiler == 'osx' or compiler == 'ios': return 'Xcode' @@ -119,12 +139,11 @@ def get_architecture(compiler, cpu): # This compiler/cpu pair does not need the architecture switch return None - -def get_toolchain(compiler): +def get_toolchain(compiler, cmake_script_dir): if platform.system() == 'Windows' and compiler == 'android': - return 'Toolchain-Android.cmake' + return os.path.join(cmake_script_dir, 'Toolchain-Android.cmake') elif platform.system() == 'Darwin' and compiler == 'ios': - return 'Toolchain-iOS.cmake' + return os.path.join(cmake_script_dir, 'Toolchain-iOS.cmake') # No toolchain return None @@ -183,9 +202,9 @@ def do_generate_solution(cmake_exe, build_dir, cmake_script_dir, args): if not platform.system() == 'Windows' and not platform.system() == 'Darwin': extra_switches.append('-DCMAKE_BUILD_TYPE={}'.format(config.upper())) - toolchain = get_toolchain(compiler) + toolchain = get_toolchain(compiler, cmake_script_dir) if toolchain: - extra_switches.append('-DCMAKE_TOOLCHAIN_FILE={}'.format(os.path.join(cmake_script_dir, toolchain))) + extra_switches.append('-DCMAKE_TOOLCHAIN_FILE={}'.format(toolchain)) generator_suffix = '' if compiler == 'vs2019-clang': @@ -233,9 +252,35 @@ def do_build(cmake_exe, args): if result != 0: sys.exit(result) -def do_tests(ctest_exe, args): - print('Running unit tests ...') +def do_tests_android(build_dir, args): + # Switch our working directory to where we built everything + working_dir = os.path.join(build_dir, 'tests', 'main_android') + os.chdir(working_dir) + gradlew_exe = os.path.join(build_dir, '..', 'tests', 'main_android', 'gradlew.bat') + + # We uninstall first and then install + if args.config == 'Debug': + install_cmd = 'uninstallAll installDebug' + elif args.config == 'Release': + install_cmd = 'uninstallAll installRelease' + + # Install our app + test_cmd = '"{}" {}'.format(gradlew_exe, install_cmd) + result = subprocess.call(test_cmd, shell=True) + if result != 0: + sys.exit(result) + + # Execute through ADB + run_cmd = 'adb shell am start -n "com.sjson.unit_tests/com.sjson.unit_tests.MainActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER' + result = subprocess.call(run_cmd, shell=True) + if result != 0: + sys.exit(result) + + # Restore working directory + os.chdir(build_dir) + +def do_tests_cmake(build_dir, ctest_exe, args): ctest_cmd = '"{}" --output-on-failure --parallel {}'.format(ctest_exe, args.num_threads) if platform.system() == 'Windows' or platform.system() == 'Darwin': @@ -247,6 +292,14 @@ def do_tests(ctest_exe, args): if result != 0: sys.exit(result) +def do_tests(build_dir, ctest_exe, args): + print('Running unit tests ...') + + if args.compiler == 'android': + do_tests_android(build_dir, args) + else: + do_tests_cmake(ctest_exe, args) + if __name__ == "__main__": args = parse_argv() cmake_exe, ctest_exe = get_cmake_exes() @@ -282,4 +335,4 @@ def do_tests(ctest_exe, args): do_build(cmake_exe, args) if args.unit_test: - do_tests(ctest_exe, args) + do_tests(build_dir, ctest_exe, args) diff --git a/tests/main_android/CMakeLists.txt b/tests/main_android/CMakeLists.txt index 8494a8a..79e24ab 100644 --- a/tests/main_android/CMakeLists.txt +++ b/tests/main_android/CMakeLists.txt @@ -1,57 +1,19 @@ cmake_minimum_required(VERSION 3.2) -project(sjson-cpp_unit_tests) +project(sjson-cpp_unit_tests_gradle_shim NONE) -set(CMAKE_CXX_STANDARD 11) +# Set our project root since our gradle files used to build live in the binary output directory +# but the actual source files live in the source/current directory. +set(SJSON_PROJECT_ROOT ${CMAKE_CURRENT_BINARY_DIR}/app) +file(RELATIVE_PATH SJSON_PROJECT_ROOT ${SJSON_PROJECT_ROOT} ${PROJECT_SOURCE_DIR}/app) -set(CMAKE_ANDROID_ARCH armv7-a) -set(CMAKE_ANDROID_API_MIN 24) -set(CMAKE_ANDROID_API 24) -set(CMAKE_ANDROID_GUI 1) +# Configure gradle for our build configuration +configure_file(app/build.gradle.in app/build.gradle @ONLY) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin") -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib") +# Copy gradle related files +file(COPY build.gradle gradle.properties settings.gradle gradle DESTINATION .) -set(CMAKE_ANDROID_JAVA_SOURCE_DIR "${PROJECT_SOURCE_DIR}/java") - -include_directories("${PROJECT_SOURCE_DIR}/../../includes") -include_directories("${PROJECT_SOURCE_DIR}/../../external/catch2/single_include/catch2") - -# Grab all of our test source files -file(GLOB_RECURSE ALL_TEST_SOURCE_FILES LIST_DIRECTORIES false - ${PROJECT_SOURCE_DIR}/../sources/*.h - ${PROJECT_SOURCE_DIR}/../sources/*.cpp) - -create_source_groups("${ALL_TEST_SOURCE_FILES}" ${PROJECT_SOURCE_DIR}/..) - -# Grab all of our main source files -file(GLOB_RECURSE ALL_MAIN_SOURCE_FILES LIST_DIRECTORIES false - ${PROJECT_SOURCE_DIR}/*.cpp) - -create_source_groups("${ALL_MAIN_SOURCE_FILES}" ${PROJECT_SOURCE_DIR}) - -# Add resource files -set(JAVA_FILES java/com/sjson/unit_tests/MainActivity.java) -set(RESOURCE_FILES res/values/strings.xml) -set(ANDROID_FILES AndroidManifest.xml) - -add_executable(${PROJECT_NAME} ${ALL_TEST_SOURCE_FILES} ${ALL_MAIN_SOURCE_FILES} ${JAVA_FILES} ${RESOURCE_FILES} ${ANDROID_FILES}) - -target_compile_options(${PROJECT_NAME} PRIVATE -fexceptions) - -# Throw on failure to allow us to catch them and recover -add_definitions(-DSJSON_CPP_ON_ASSERT_THROW) - -target_include_directories(${PROJECT_NAME} PUBLIC jni) - -target_link_libraries(${PROJECT_NAME} m) - -set_property(TARGET ${PROJECT_NAME} PROPERTY C_STANDARD 11) -set_target_properties(${PROJECT_NAME} PROPERTIES ANDROID_SKIP_ANT_STEP 0) -set_target_properties(${PROJECT_NAME} PROPERTIES ANDROID_PROGUARD 1) -set_target_properties(${PROJECT_NAME} PROPERTIES ANDROID_PROGUARD_CONFIG_PATH proguard-android.txt) -set_target_properties(${PROJECT_NAME} PROPERTIES ANDROID_SECURE_PROPS_PATH /definitely/insecure) -set_target_properties(${PROJECT_NAME} PROPERTIES VS_GLOBAL_AndroidBuildSystem "AntBuild") # Use Ant as our build system - -set_property(TARGET ${PROJECT_NAME} PROPERTY ANDROID_NATIVE_LIB_DIRECTORIES $) -set_property(TARGET ${PROJECT_NAME} PROPERTY ANDROID_NATIVE_LIB_DEPENDENCIES ${PROJECT_NAME}.so) +add_custom_target(${PROJECT_NAME} ALL + COMMAND "${PROJECT_SOURCE_DIR}/gradlew.bat" + # Decide whether we should build Debug or Release + $<$:assembleDebug> + $<$:assembleRelease>) diff --git a/tests/main_android/app/build.gradle.in b/tests/main_android/app/build.gradle.in new file mode 100644 index 0000000..1323119 --- /dev/null +++ b/tests/main_android/app/build.gradle.in @@ -0,0 +1,47 @@ +apply plugin: 'com.android.application' + +android { + compileSdkVersion 28 + defaultConfig { + applicationId "com.sjson.unit_tests" + minSdkVersion 24 + targetSdkVersion 26 + versionCode 1 + versionName "1.0" + testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" + externalNativeBuild { + cmake { + } + } + ndk { + abiFilters '@CPU_INSTRUCTION_SET@' + } + + } + buildTypes { + release { + minifyEnabled false + proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' + debuggable = true + signingConfig signingConfigs.debug + } + } + externalNativeBuild { + cmake { + path '@SJSON_PROJECT_ROOT@/src/main/cpp/CMakeLists.txt' + } + } + sourceSets { + main { + manifest.srcFile '@SJSON_PROJECT_ROOT@/src/main/AndroidManifest.xml' + java.srcDirs = ['@SJSON_PROJECT_ROOT@/src/main/java'] + res.srcDirs = ['@SJSON_PROJECT_ROOT@/src/main/res'] + } + } +} + +dependencies { + implementation fileTree(dir: 'libs', include: ['*.jar']) + implementation 'androidx.appcompat:appcompat:1.0.2' + implementation 'androidx.constraintlayout:constraintlayout:1.1.3' +} diff --git a/tests/main_android/app/proguard-rules.pro b/tests/main_android/app/proguard-rules.pro new file mode 100644 index 0000000..f1b4245 --- /dev/null +++ b/tests/main_android/app/proguard-rules.pro @@ -0,0 +1,21 @@ +# Add project specific ProGuard rules here. +# You can control the set of applied configuration files using the +# proguardFiles setting in build.gradle. +# +# For more details, see +# http://developer.android.com/guide/developing/tools/proguard.html + +# If your project uses WebView with JS, uncomment the following +# and specify the fully qualified class name to the JavaScript interface +# class: +#-keepclassmembers class fqcn.of.javascript.interface.for.webview { +# public *; +#} + +# Uncomment this to preserve the line number information for +# debugging stack traces. +#-keepattributes SourceFile,LineNumberTable + +# If you keep the line number information, uncomment this to +# hide the original source file name. +#-renamesourcefileattribute SourceFile diff --git a/tests/main_android/AndroidManifest.xml b/tests/main_android/app/src/main/AndroidManifest.xml similarity index 62% rename from tests/main_android/AndroidManifest.xml rename to tests/main_android/app/src/main/AndroidManifest.xml index 39eb42c..6f8e201 100644 --- a/tests/main_android/AndroidManifest.xml +++ b/tests/main_android/app/src/main/AndroidManifest.xml @@ -1,12 +1,7 @@ - - + - + diff --git a/tests/main_android/app/src/main/cpp/CMakeLists.txt b/tests/main_android/app/src/main/cpp/CMakeLists.txt new file mode 100644 index 0000000..0a82eb5 --- /dev/null +++ b/tests/main_android/app/src/main/cpp/CMakeLists.txt @@ -0,0 +1,30 @@ +cmake_minimum_required(VERSION 3.2) +project(sjson-cpp_unit_tests CXX) + +set(CMAKE_CXX_STANDARD 11) + +# Project root is \tests\main_android +set(PROJECT_ROOT_DIR "${PROJECT_SOURCE_DIR}/../../../..") + +include_directories("${PROJECT_ROOT_DIR}/../../includes") +include_directories("${PROJECT_ROOT_DIR}/../../external/catch2/single_include/catch2") + +# Grab all of our test source files +file(GLOB_RECURSE ALL_TEST_SOURCE_FILES LIST_DIRECTORIES false + ${PROJECT_ROOT_DIR}/../sources/*.h + ${PROJECT_ROOT_DIR}/../sources/*.cpp) + +# Grab all of our main source files +file(GLOB_RECURSE ALL_MAIN_SOURCE_FILES LIST_DIRECTORIES false + ${PROJECT_SOURCE_DIR}/*.cpp) + +add_library(${PROJECT_NAME} SHARED ${ALL_TEST_SOURCE_FILES} ${ALL_MAIN_SOURCE_FILES}) + +target_compile_options(${PROJECT_NAME} PRIVATE -fexceptions) + +# Throw on failure to allow us to catch them and recover +add_definitions(-DSJSON_CPP_ON_ASSERT_THROW) + +target_include_directories(${PROJECT_NAME} PUBLIC jni) + +target_link_libraries(${PROJECT_NAME} m log) diff --git a/tests/main_android/jni/main.cpp b/tests/main_android/app/src/main/cpp/main.cpp similarity index 100% rename from tests/main_android/jni/main.cpp rename to tests/main_android/app/src/main/cpp/main.cpp diff --git a/tests/main_android/java/com/sjson/unit_tests/MainActivity.java b/tests/main_android/app/src/main/java/com/sjson/unit_tests/MainActivity.java similarity index 98% rename from tests/main_android/java/com/sjson/unit_tests/MainActivity.java rename to tests/main_android/app/src/main/java/com/sjson/unit_tests/MainActivity.java index e46a65f..b39b390 100644 --- a/tests/main_android/java/com/sjson/unit_tests/MainActivity.java +++ b/tests/main_android/app/src/main/java/com/sjson/unit_tests/MainActivity.java @@ -5,14 +5,16 @@ import android.os.Bundle; public class MainActivity extends Activity { + static { + System.loadLibrary("sjson-cpp_unit_tests"); + } + @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); TextView resultTextView = new TextView(this); - System.loadLibrary("sjson-cpp_unit_tests"); - int numUnitTestCases = getNumUnitTestCases(); int numFailed = runUnitTests(); diff --git a/tests/main_android/res/values/strings.xml b/tests/main_android/app/src/main/res/values/strings.xml similarity index 100% rename from tests/main_android/res/values/strings.xml rename to tests/main_android/app/src/main/res/values/strings.xml diff --git a/tests/main_android/build.gradle b/tests/main_android/build.gradle new file mode 100644 index 0000000..1606295 --- /dev/null +++ b/tests/main_android/build.gradle @@ -0,0 +1,25 @@ +// Top-level build file where you can add configuration options common to all sub-projects/modules. + +buildscript { + repositories { + google() + jcenter() + } + dependencies { + classpath 'com.android.tools.build:gradle:3.5.3' + + // NOTE: Do not place your application dependencies here; they belong + // in the individual module build.gradle files + } +} + +allprojects { + repositories { + google() + jcenter() + } +} + +task clean(type: Delete) { + delete rootProject.buildDir +} diff --git a/tests/main_android/build.xml b/tests/main_android/build.xml deleted file mode 100644 index 8fc6cc5..0000000 --- a/tests/main_android/build.xml +++ /dev/null @@ -1,4 +0,0 @@ - - - - diff --git a/tests/main_android/gradle.properties b/tests/main_android/gradle.properties new file mode 100644 index 0000000..fe2852f --- /dev/null +++ b/tests/main_android/gradle.properties @@ -0,0 +1,22 @@ +# Project-wide Gradle settings. +# IDE (e.g. Android Studio) users: +# Gradle settings configured through the IDE *will override* +# any settings specified in this file. +# For more details on how to configure your build environment visit +# http://www.gradle.org/docs/current/userguide/build_environment.html +# Specifies the JVM arguments used for the daemon process. +# The setting is particularly useful for tweaking memory settings. +org.gradle.jvmargs=-Xmx1536m +# When configured, Gradle will run in incubating parallel mode. +# This option should only be used with decoupled projects. More details, visit +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects +# org.gradle.parallel=true +# AndroidX package structure to make it clearer which packages are bundled with the +# Android operating system, and which are packaged with your app's APK +# https://developer.android.com/topic/libraries/support-library/androidx-rn +android.useAndroidX=true +# Automatically convert third-party libraries to use AndroidX +android.enableJetifier=true + +# Run tasks in parallel +org.gradle.parallel=true diff --git a/tests/main_android/gradle/wrapper/gradle-wrapper.jar b/tests/main_android/gradle/wrapper/gradle-wrapper.jar new file mode 100644 index 0000000000000000000000000000000000000000..f6b961fd5a86aa5fbfe90f707c3138408be7c718 GIT binary patch literal 54329 zcmagFV|ZrKvM!pAZQHhO+qP}9lTNj?q^^Y^VFp)SH8qbSJ)2BQ2giqr}t zFG7D6)c?v~^Z#E_K}1nTQbJ9gQ9<%vVRAxVj)8FwL5_iTdUB>&m3fhE=kRWl;g`&m z!W5kh{WsV%fO*%je&j+Lv4xxK~zsEYQls$Q-p&dwID|A)!7uWtJF-=Tm1{V@#x*+kUI$=%KUuf2ka zjiZ{oiL1MXE2EjciJM!jrjFNwCh`~hL>iemrqwqnX?T*MX;U>>8yRcZb{Oy+VKZos zLiFKYPw=LcaaQt8tj=eoo3-@bG_342HQ%?jpgAE?KCLEHC+DmjxAfJ%Og^$dpC8Xw zAcp-)tfJm}BPNq_+6m4gBgBm3+CvmL>4|$2N$^Bz7W(}fz1?U-u;nE`+9`KCLuqg} zwNstNM!J4Uw|78&Y9~9>MLf56to!@qGkJw5Thx%zkzj%Ek9Nn1QA@8NBXbwyWC>9H z#EPwjMNYPigE>*Ofz)HfTF&%PFj$U6mCe-AFw$U%-L?~-+nSXHHKkdgC5KJRTF}`G zE_HNdrE}S0zf4j{r_f-V2imSqW?}3w-4=f@o@-q+cZgaAbZ((hn))@|eWWhcT2pLpTpL!;_5*vM=sRL8 zqU##{U#lJKuyqW^X$ETU5ETeEVzhU|1m1750#f}38_5N9)B_2|v@1hUu=Kt7-@dhA zq_`OMgW01n`%1dB*}C)qxC8q;?zPeF_r;>}%JYmlER_1CUbKa07+=TV45~symC*g8 zW-8(gag#cAOuM0B1xG8eTp5HGVLE}+gYTmK=`XVVV*U!>H`~j4+ROIQ+NkN$LY>h4 zqpwdeE_@AX@PL};e5vTn`Ro(EjHVf$;^oiA%@IBQq>R7_D>m2D4OwwEepkg}R_k*M zM-o;+P27087eb+%*+6vWFCo9UEGw>t&WI17Pe7QVuoAoGHdJ(TEQNlJOqnjZ8adCb zI`}op16D@v7UOEo%8E-~m?c8FL1utPYlg@m$q@q7%mQ4?OK1h%ODjTjFvqd!C z-PI?8qX8{a@6d&Lb_X+hKxCImb*3GFemm?W_du5_&EqRq!+H?5#xiX#w$eLti-?E$;Dhu`{R(o>LzM4CjO>ICf z&DMfES#FW7npnbcuqREgjPQM#gs6h>`av_oEWwOJZ2i2|D|0~pYd#WazE2Bbsa}X@ zu;(9fi~%!VcjK6)?_wMAW-YXJAR{QHxrD5g(ou9mR6LPSA4BRG1QSZT6A?kelP_g- zH(JQjLc!`H4N=oLw=f3{+WmPA*s8QEeEUf6Vg}@!xwnsnR0bl~^2GSa5vb!Yl&4!> zWb|KQUsC$lT=3A|7vM9+d;mq=@L%uWKwXiO9}a~gP4s_4Yohc!fKEgV7WbVo>2ITbE*i`a|V!^p@~^<={#?Gz57 zyPWeM2@p>D*FW#W5Q`1`#5NW62XduP1XNO(bhg&cX`-LYZa|m-**bu|>}S;3)eP8_ zpNTnTfm8 ze+7wDH3KJ95p)5tlwk`S7mbD`SqHnYD*6`;gpp8VdHDz%RR_~I_Ar>5)vE-Pgu7^Y z|9Px+>pi3!DV%E%4N;ii0U3VBd2ZJNUY1YC^-e+{DYq+l@cGtmu(H#Oh%ibUBOd?C z{y5jW3v=0eV0r@qMLgv1JjZC|cZ9l9Q)k1lLgm))UR@#FrJd>w^`+iy$c9F@ic-|q zVHe@S2UAnc5VY_U4253QJxm&Ip!XKP8WNcnx9^cQ;KH6PlW8%pSihSH2(@{2m_o+m zr((MvBja2ctg0d0&U5XTD;5?d?h%JcRJp{_1BQW1xu&BrA3(a4Fh9hon-ly$pyeHq zG&;6q?m%NJ36K1Sq_=fdP(4f{Hop;_G_(i?sPzvB zDM}>*(uOsY0I1j^{$yn3#U(;B*g4cy$-1DTOkh3P!LQ;lJlP%jY8}Nya=h8$XD~%Y zbV&HJ%eCD9nui-0cw!+n`V~p6VCRqh5fRX z8`GbdZ@73r7~myQLBW%db;+BI?c-a>Y)m-FW~M=1^|<21_Sh9RT3iGbO{o-hpN%d6 z7%++#WekoBOP^d0$$|5npPe>u3PLvX_gjH2x(?{&z{jJ2tAOWTznPxv-pAv<*V7r$ z6&glt>7CAClWz6FEi3bToz-soY^{ScrjwVPV51=>n->c(NJngMj6TyHty`bfkF1hc zkJS%A@cL~QV0-aK4>Id!9dh7>0IV;1J9(myDO+gv76L3NLMUm9XyPauvNu$S<)-|F zZS}(kK_WnB)Cl`U?jsdYfAV4nrgzIF@+%1U8$poW&h^c6>kCx3;||fS1_7JvQT~CV zQ8Js+!p)3oW>Df(-}uqC`Tcd%E7GdJ0p}kYj5j8NKMp(KUs9u7?jQ94C)}0rba($~ zqyBx$(1ae^HEDG`Zc@-rXk1cqc7v0wibOR4qpgRDt#>-*8N3P;uKV0CgJE2SP>#8h z=+;i_CGlv+B^+$5a}SicVaSeaNn29K`C&=}`=#Nj&WJP9Xhz4mVa<+yP6hkrq1vo= z1rX4qg8dc4pmEvq%NAkpMK>mf2g?tg_1k2%v}<3`$6~Wlq@ItJ*PhHPoEh1Yi>v57 z4k0JMO)*=S`tKvR5gb-(VTEo>5Y>DZJZzgR+j6{Y`kd|jCVrg!>2hVjz({kZR z`dLlKhoqT!aI8=S+fVp(5*Dn6RrbpyO~0+?fy;bm$0jmTN|t5i6rxqr4=O}dY+ROd zo9Et|x}!u*xi~>-y>!M^+f&jc;IAsGiM_^}+4|pHRn{LThFFpD{bZ|TA*wcGm}XV^ zr*C6~@^5X-*R%FrHIgo-hJTBcyQ|3QEj+cSqp#>&t`ZzB?cXM6S(lRQw$I2?m5=wd z78ki`R?%;o%VUhXH?Z#(uwAn9$m`npJ=cA+lHGk@T7qq_M6Zoy1Lm9E0UUysN)I_x zW__OAqvku^>`J&CB=ie@yNWsaFmem}#L3T(x?a`oZ+$;3O-icj2(5z72Hnj=9Z0w% z<2#q-R=>hig*(t0^v)eGq2DHC%GymE-_j1WwBVGoU=GORGjtaqr0BNigOCqyt;O(S zKG+DoBsZU~okF<7ahjS}bzwXxbAxFfQAk&O@>LsZMsZ`?N?|CDWM(vOm%B3CBPC3o z%2t@%H$fwur}SSnckUm0-k)mOtht`?nwsDz=2#v=RBPGg39i#%odKq{K^;bTD!6A9 zskz$}t)sU^=a#jLZP@I=bPo?f-L}wpMs{Tc!m7-bi!Ldqj3EA~V;4(dltJmTXqH0r z%HAWKGutEc9vOo3P6Q;JdC^YTnby->VZ6&X8f{obffZ??1(cm&L2h7q)*w**+sE6dG*;(H|_Q!WxU{g)CeoT z(KY&bv!Usc|m+Fqfmk;h&RNF|LWuNZ!+DdX*L=s-=_iH=@i` z?Z+Okq^cFO4}_n|G*!)Wl_i%qiMBaH8(WuXtgI7EO=M>=i_+;MDjf3aY~6S9w0K zUuDO7O5Ta6+k40~xh~)D{=L&?Y0?c$s9cw*Ufe18)zzk%#ZY>Tr^|e%8KPb0ht`b( zuP@8#Ox@nQIqz9}AbW0RzE`Cf>39bOWz5N3qzS}ocxI=o$W|(nD~@EhW13Rj5nAp; zu2obEJa=kGC*#3=MkdkWy_%RKcN=?g$7!AZ8vBYKr$ePY(8aIQ&yRPlQ=mudv#q$q z4%WzAx=B{i)UdLFx4os?rZp6poShD7Vc&mSD@RdBJ=_m^&OlkEE1DFU@csgKcBifJ zz4N7+XEJhYzzO=86 z#%eBQZ$Nsf2+X0XPHUNmg#(sNt^NW1Y0|M(${e<0kW6f2q5M!2YE|hSEQ*X-%qo(V zHaFwyGZ0on=I{=fhe<=zo{=Og-_(to3?cvL4m6PymtNsdDINsBh8m>a%!5o3s(en) z=1I z6O+YNertC|OFNqd6P=$gMyvmfa`w~p9*gKDESFqNBy(~Zw3TFDYh}$iudn)9HxPBi zdokK@o~nu?%imcURr5Y~?6oo_JBe}t|pU5qjai|#JDyG=i^V~7+a{dEnO<(y>ahND#_X_fcEBNiZ)uc&%1HVtx8Ts z*H_Btvx^IhkfOB#{szN*n6;y05A>3eARDXslaE>tnLa>+`V&cgho?ED+&vv5KJszf zG4@G;7i;4_bVvZ>!mli3j7~tPgybF5|J6=Lt`u$D%X0l}#iY9nOXH@(%FFJLtzb%p zzHfABnSs;v-9(&nzbZytLiqqDIWzn>JQDk#JULcE5CyPq_m#4QV!}3421haQ+LcfO*>r;rg6K|r#5Sh|y@h1ao%Cl)t*u`4 zMTP!deC?aL7uTxm5^nUv#q2vS-5QbBKP|drbDXS%erB>fYM84Kpk^au99-BQBZR z7CDynflrIAi&ahza+kUryju5LR_}-Z27g)jqOc(!Lx9y)e z{cYc&_r947s9pteaa4}dc|!$$N9+M38sUr7h(%@Ehq`4HJtTpA>B8CLNO__@%(F5d z`SmX5jbux6i#qc}xOhumzbAELh*Mfr2SW99=WNOZRZgoCU4A2|4i|ZVFQt6qEhH#B zK_9G;&h*LO6tB`5dXRSBF0hq0tk{2q__aCKXYkP#9n^)@cq}`&Lo)1KM{W+>5mSed zKp~=}$p7>~nK@va`vN{mYzWN1(tE=u2BZhga5(VtPKk(*TvE&zmn5vSbjo zZLVobTl%;t@6;4SsZ>5+U-XEGUZGG;+~|V(pE&qqrp_f~{_1h@5ZrNETqe{bt9ioZ z#Qn~gWCH!t#Ha^n&fT2?{`}D@s4?9kXj;E;lWV9Zw8_4yM0Qg-6YSsKgvQ*fF{#Pq z{=(nyV>#*`RloBVCs;Lp*R1PBIQOY=EK4CQa*BD0MsYcg=opP?8;xYQDSAJBeJpw5 zPBc_Ft9?;<0?pBhCmOtWU*pN*;CkjJ_}qVic`}V@$TwFi15!mF1*m2wVX+>5p%(+R zQ~JUW*zWkalde{90@2v+oVlkxOZFihE&ZJ){c?hX3L2@R7jk*xjYtHi=}qb+4B(XJ z$gYcNudR~4Kz_WRq8eS((>ALWCO)&R-MXE+YxDn9V#X{_H@j616<|P(8h(7z?q*r+ zmpqR#7+g$cT@e&(%_|ipI&A%9+47%30TLY(yuf&*knx1wNx|%*H^;YB%ftt%5>QM= z^i;*6_KTSRzQm%qz*>cK&EISvF^ovbS4|R%)zKhTH_2K>jP3mBGn5{95&G9^a#4|K zv+!>fIsR8z{^x4)FIr*cYT@Q4Z{y}};rLHL+atCgHbfX*;+k&37DIgENn&=k(*lKD zG;uL-KAdLn*JQ?@r6Q!0V$xXP=J2i~;_+i3|F;_En;oAMG|I-RX#FwnmU&G}w`7R{ z788CrR-g1DW4h_`&$Z`ctN~{A)Hv_-Bl!%+pfif8wN32rMD zJDs$eVWBYQx1&2sCdB0!vU5~uf)=vy*{}t{2VBpcz<+~h0wb7F3?V^44*&83Z2#F` z32!rd4>uc63rQP$3lTH3zb-47IGR}f)8kZ4JvX#toIpXH`L%NnPDE~$QI1)0)|HS4 zVcITo$$oWWwCN@E-5h>N?Hua!N9CYb6f8vTFd>h3q5Jg-lCI6y%vu{Z_Uf z$MU{{^o~;nD_@m2|E{J)q;|BK7rx%`m``+OqZAqAVj-Dy+pD4-S3xK?($>wn5bi90CFAQ+ACd;&m6DQB8_o zjAq^=eUYc1o{#+p+ zn;K<)Pn*4u742P!;H^E3^Qu%2dM{2slouc$AN_3V^M7H_KY3H)#n7qd5_p~Za7zAj|s9{l)RdbV9e||_67`#Tu*c<8!I=zb@ z(MSvQ9;Wrkq6d)!9afh+G`!f$Ip!F<4ADdc*OY-y7BZMsau%y?EN6*hW4mOF%Q~bw z2==Z3^~?q<1GTeS>xGN-?CHZ7a#M4kDL zQxQr~1ZMzCSKFK5+32C%+C1kE#(2L=15AR!er7GKbp?Xd1qkkGipx5Q~FI-6zt< z*PTpeVI)Ngnnyaz5noIIgNZtb4bQdKG{Bs~&tf)?nM$a;7>r36djllw%hQxeCXeW^ z(i6@TEIuxD<2ulwLTt|&gZP%Ei+l!(%p5Yij6U(H#HMkqM8U$@OKB|5@vUiuY^d6X zW}fP3;Kps6051OEO(|JzmVU6SX(8q>*yf*x5QoxDK={PH^F?!VCzES_Qs>()_y|jg6LJlJWp;L zKM*g5DK7>W_*uv}{0WUB0>MHZ#oJZmO!b3MjEc}VhsLD~;E-qNNd?x7Q6~v zR=0$u>Zc2Xr}>x_5$-s#l!oz6I>W?lw;m9Ae{Tf9eMX;TI-Wf_mZ6sVrMnY#F}cDd z%CV*}fDsXUF7Vbw>PuDaGhu631+3|{xp<@Kl|%WxU+vuLlcrklMC!Aq+7n~I3cmQ! z`e3cA!XUEGdEPSu``&lZEKD1IKO(-VGvcnSc153m(i!8ohi`)N2n>U_BemYJ`uY>8B*Epj!oXRLV}XK}>D*^DHQ7?NY*&LJ9VSo`Ogi9J zGa;clWI8vIQqkngv2>xKd91K>?0`Sw;E&TMg&6dcd20|FcTsnUT7Yn{oI5V4@Ow~m zz#k~8TM!A9L7T!|colrC0P2WKZW7PNj_X4MfESbt<-soq*0LzShZ}fyUx!(xIIDwx zRHt^_GAWe0-Vm~bDZ(}XG%E+`XhKpPlMBo*5q_z$BGxYef8O!ToS8aT8pmjbPq)nV z%x*PF5ZuSHRJqJ!`5<4xC*xb2vC?7u1iljB_*iUGl6+yPyjn?F?GOF2_KW&gOkJ?w z3e^qc-te;zez`H$rsUCE0<@7PKGW?7sT1SPYWId|FJ8H`uEdNu4YJjre`8F*D}6Wh z|FQ`xf7yiphHIAkU&OYCn}w^ilY@o4larl?^M7&8YI;hzBIsX|i3UrLsx{QDKwCX< zy;a>yjfJ6!sz`NcVi+a!Fqk^VE^{6G53L?@Tif|j!3QZ0fk9QeUq8CWI;OmO-Hs+F zuZ4sHLA3{}LR2Qlyo+{d@?;`tpp6YB^BMoJt?&MHFY!JQwoa0nTSD+#Ku^4b{5SZVFwU9<~APYbaLO zu~Z)nS#dxI-5lmS-Bnw!(u15by(80LlC@|ynj{TzW)XcspC*}z0~8VRZq>#Z49G`I zgl|C#H&=}n-ajxfo{=pxPV(L*7g}gHET9b*s=cGV7VFa<;Htgjk>KyW@S!|z`lR1( zGSYkEl&@-bZ*d2WQ~hw3NpP=YNHF^XC{TMG$Gn+{b6pZn+5=<()>C!N^jncl0w6BJ zdHdnmSEGK5BlMeZD!v4t5m7ct7{k~$1Ie3GLFoHjAH*b?++s<|=yTF+^I&jT#zuMx z)MLhU+;LFk8bse|_{j+d*a=&cm2}M?*arjBPnfPgLwv)86D$6L zLJ0wPul7IenMvVAK$z^q5<^!)7aI|<&GGEbOr=E;UmGOIa}yO~EIr5xWU_(ol$&fa zR5E(2vB?S3EvJglTXdU#@qfDbCYs#82Yo^aZN6`{Ex#M)easBTe_J8utXu(fY1j|R z9o(sQbj$bKU{IjyhosYahY{63>}$9_+hWxB3j}VQkJ@2$D@vpeRSldU?&7I;qd2MF zSYmJ>zA(@N_iK}m*AMPIJG#Y&1KR)6`LJ83qg~`Do3v^B0>fU&wUx(qefuTgzFED{sJ65!iw{F2}1fQ3= ziFIP{kezQxmlx-!yo+sC4PEtG#K=5VM9YIN0z9~c4XTX?*4e@m;hFM!zVo>A`#566 z>f&3g94lJ{r)QJ5m7Xe3SLau_lOpL;A($wsjHR`;xTXgIiZ#o&vt~ zGR6KdU$FFbLfZCC3AEu$b`tj!9XgOGLSV=QPIYW zjI!hSP#?8pn0@ezuenOzoka8!8~jXTbiJ6+ZuItsWW03uzASFyn*zV2kIgPFR$Yzm zE<$cZlF>R8?Nr2_i?KiripBc+TGgJvG@vRTY2o?(_Di}D30!k&CT`>+7ry2!!iC*X z<@=U0_C#16=PN7bB39w+zPwDOHX}h20Ap);dx}kjXX0-QkRk=cr};GYsjSvyLZa-t zzHONWddi*)RDUH@RTAsGB_#&O+QJaaL+H<<9LLSE+nB@eGF1fALwjVOl8X_sdOYme z0lk!X=S(@25=TZHR7LlPp}fY~yNeThMIjD}pd9+q=j<_inh0$>mIzWVY+Z9p<{D^#0Xk+b_@eNSiR8;KzSZ#7lUsk~NGMcB8C2c=m2l5paHPq`q{S(kdA7Z1a zyfk2Y;w?^t`?@yC5Pz9&pzo}Hc#}mLgDmhKV|PJ3lKOY(Km@Fi2AV~CuET*YfUi}u zfInZnqDX(<#vaS<^fszuR=l)AbqG{}9{rnyx?PbZz3Pyu!eSJK`uwkJU!ORQXy4x83r!PNgOyD33}}L=>xX_93l6njNTuqL8J{l%*3FVn3MG4&Fv*`lBXZ z?=;kn6HTT^#SrPX-N)4EZiIZI!0ByXTWy;;J-Tht{jq1mjh`DSy7yGjHxIaY%*sTx zuy9#9CqE#qi>1misx=KRWm=qx4rk|}vd+LMY3M`ow8)}m$3Ggv&)Ri*ON+}<^P%T5 z_7JPVPfdM=Pv-oH<tecoE}(0O7|YZc*d8`Uv_M*3Rzv7$yZnJE6N_W=AQ3_BgU_TjA_T?a)U1csCmJ&YqMp-lJe`y6>N zt++Bi;ZMOD%%1c&-Q;bKsYg!SmS^#J@8UFY|G3!rtyaTFb!5@e(@l?1t(87ln8rG? z--$1)YC~vWnXiW3GXm`FNSyzu!m$qT=Eldf$sMl#PEfGmzQs^oUd=GIQfj(X=}dw+ zT*oa0*oS%@cLgvB&PKIQ=Ok?>x#c#dC#sQifgMwtAG^l3D9nIg(Zqi;D%807TtUUCL3_;kjyte#cAg?S%e4S2W>9^A(uy8Ss0Tc++ZTjJw1 z&Em2g!3lo@LlDyri(P^I8BPpn$RE7n*q9Q-c^>rfOMM6Pd5671I=ZBjAvpj8oIi$! zl0exNl(>NIiQpX~FRS9UgK|0l#s@#)p4?^?XAz}Gjb1?4Qe4?j&cL$C8u}n)?A@YC zfmbSM`Hl5pQFwv$CQBF=_$Sq zxsV?BHI5bGZTk?B6B&KLdIN-40S426X3j_|ceLla*M3}3gx3(_7MVY1++4mzhH#7# zD>2gTHy*%i$~}mqc#gK83288SKp@y3wz1L_e8fF$Rb}ex+`(h)j}%~Ld^3DUZkgez zOUNy^%>>HHE|-y$V@B}-M|_{h!vXpk01xaD%{l{oQ|~+^>rR*rv9iQen5t?{BHg|% zR`;S|KtUb!X<22RTBA4AAUM6#M?=w5VY-hEV)b`!y1^mPNEoy2K)a>OyA?Q~Q*&(O zRzQI~y_W=IPi?-OJX*&&8dvY0zWM2%yXdFI!D-n@6FsG)pEYdJbuA`g4yy;qrgR?G z8Mj7gv1oiWq)+_$GqqQ$(ZM@#|0j7})=#$S&hZwdoijFI4aCFLVI3tMH5fLreZ;KD zqA`)0l~D2tuIBYOy+LGw&hJ5OyE+@cnZ0L5+;yo2pIMdt@4$r^5Y!x7nHs{@>|W(MzJjATyWGNwZ^4j+EPU0RpAl-oTM@u{lx*i0^yyWPfHt6QwPvYpk9xFMWfBFt!+Gu6TlAmr zeQ#PX71vzN*_-xh&__N`IXv6`>CgV#eA_%e@7wjgkj8jlKzO~Ic6g$cT`^W{R{606 zCDP~+NVZ6DMO$jhL~#+!g*$T!XW63#(ngDn#Qwy71yj^gazS{e;3jGRM0HedGD@pt z?(ln3pCUA(ekqAvvnKy0G@?-|-dh=eS%4Civ&c}s%wF@0K5Bltaq^2Os1n6Z3%?-Q zAlC4goQ&vK6TpgtzkHVt*1!tBYt-`|5HLV1V7*#45Vb+GACuU+QB&hZ=N_flPy0TY zR^HIrdskB#<$aU;HY(K{a3(OQa$0<9qH(oa)lg@Uf>M5g2W0U5 zk!JSlhrw8quBx9A>RJ6}=;W&wt@2E$7J=9SVHsdC?K(L(KACb#z)@C$xXD8^!7|uv zZh$6fkq)aoD}^79VqdJ!Nz-8$IrU(_-&^cHBI;4 z^$B+1aPe|LG)C55LjP;jab{dTf$0~xbXS9!!QdcmDYLbL^jvxu2y*qnx2%jbL%rB z{aP85qBJe#(&O~Prk%IJARcdEypZ)vah%ZZ%;Zk{eW(U)Bx7VlzgOi8)x z`rh4l`@l_Ada7z&yUK>ZF;i6YLGwI*Sg#Fk#Qr0Jg&VLax(nNN$u-XJ5=MsP3|(lEdIOJ7|(x3iY;ea)5#BW*mDV%^=8qOeYO&gIdJVuLLN3cFaN=xZtFB=b zH{l)PZl_j^u+qx@89}gAQW7ofb+k)QwX=aegihossZq*+@PlCpb$rpp>Cbk9UJO<~ zDjlXQ_Ig#W0zdD3&*ei(FwlN#3b%FSR%&M^ywF@Fr>d~do@-kIS$e%wkIVfJ|Ohh=zc zF&Rnic^|>@R%v?@jO}a9;nY3Qrg_!xC=ZWUcYiA5R+|2nsM*$+c$TOs6pm!}Z}dfM zGeBhMGWw3$6KZXav^>YNA=r6Es>p<6HRYcZY)z{>yasbC81A*G-le8~QoV;rtKnkx z;+os8BvEe?0A6W*a#dOudsv3aWs?d% z0oNngyVMjavLjtjiG`!007#?62ClTqqU$@kIY`=x^$2e>iqIy1>o|@Tw@)P)B8_1$r#6>DB_5 zmaOaoE~^9TolgDgooKFuEFB#klSF%9-~d2~_|kQ0Y{Ek=HH5yq9s zDq#1S551c`kSiWPZbweN^A4kWiP#Qg6er1}HcKv{fxb1*BULboD0fwfaNM_<55>qM zETZ8TJDO4V)=aPp_eQjX%||Ud<>wkIzvDlpNjqW>I}W!-j7M^TNe5JIFh#-}zAV!$ICOju8Kx)N z0vLtzDdy*rQN!7r>Xz7rLw8J-(GzQlYYVH$WK#F`i_i^qVlzTNAh>gBWKV@XC$T-` z3|kj#iCquDhiO7NKum07i|<-NuVsX}Q}mIP$jBJDMfUiaWR3c|F_kWBMw0_Sr|6h4 zk`_r5=0&rCR^*tOy$A8K;@|NqwncjZ>Y-75vlpxq%Cl3EgH`}^^~=u zoll6xxY@a>0f%Ddpi;=cY}fyG!K2N-dEyXXmUP5u){4VnyS^T4?pjN@Ot4zjL(Puw z_U#wMH2Z#8Pts{olG5Dy0tZj;N@;fHheu>YKYQU=4Bk|wcD9MbA`3O4bj$hNRHwzb zSLcG0SLV%zywdbuwl(^E_!@&)TdXge4O{MRWk2RKOt@!8E{$BU-AH(@4{gxs=YAz9LIob|Hzto0}9cWoz6Tp2x0&xi#$ zHh$dwO&UCR1Ob2w00-2eG7d4=cN(Y>0R#$q8?||q@iTi+7-w-xR%uMr&StFIthC<# zvK(aPduwuNB}oJUV8+Zl)%cnfsHI%4`;x6XW^UF^e4s3Z@S<&EV8?56Wya;HNs0E> z`$0dgRdiUz9RO9Au3RmYq>K#G=X%*_dUbSJHP`lSfBaN8t-~@F>)BL1RT*9I851A3 z<-+Gb#_QRX>~av#Ni<#zLswtu-c6{jGHR>wflhKLzC4P@b%8&~u)fosoNjk4r#GvC zlU#UU9&0Hv;d%g72Wq?Ym<&&vtA3AB##L}=ZjiTR4hh7J)e>ei} zt*u+>h%MwN`%3}b4wYpV=QwbY!jwfIj#{me)TDOG`?tI!%l=AwL2G@9I~}?_dA5g6 zCKgK(;6Q0&P&K21Tx~k=o6jwV{dI_G+Ba*Zts|Tl6q1zeC?iYJTb{hel*x>^wb|2RkHkU$!+S4OU4ZOKPZjV>9OVsqNnv5jK8TRAE$A&^yRwK zj-MJ3Pl?)KA~fq#*K~W0l4$0=8GRx^9+?w z!QT8*-)w|S^B0)ZeY5gZPI2G(QtQf?DjuK(s^$rMA!C%P22vynZY4SuOE=wX2f8$R z)A}mzJi4WJnZ`!bHG1=$lwaxm!GOnRbR15F$nRC-M*H<*VfF|pQw(;tbSfp({>9^5 zw_M1-SJ9eGF~m(0dvp*P8uaA0Yw+EkP-SWqu zqal$hK8SmM7#Mrs0@OD+%_J%H*bMyZiWAZdsIBj#lkZ!l2c&IpLu(5^T0Ge5PHzR} zn;TXs$+IQ_&;O~u=Jz+XE0wbOy`=6>m9JVG} zJ~Kp1e5m?K3x@@>!D)piw^eMIHjD4RebtR`|IlckplP1;r21wTi8v((KqNqn%2CB< zifaQc&T}*M&0i|LW^LgdjIaX|o~I$`owHolRqeH_CFrqCUCleN130&vH}dK|^kC>) z-r2P~mApHotL4dRX$25lIcRh_*kJaxi^%ZN5-GAAMOxfB!6flLPY-p&QzL9TE%ho( zRwftE3sy5<*^)qYzKkL|rE>n@hyr;xPqncY6QJ8125!MWr`UCWuC~A#G1AqF1@V$kv>@NBvN&2ygy*{QvxolkRRb%Ui zsmKROR%{*g*WjUUod@@cS^4eF^}yQ1>;WlGwOli z+Y$(8I`0(^d|w>{eaf!_BBM;NpCoeem2>J}82*!em=}}ymoXk>QEfJ>G(3LNA2-46 z5PGvjr)Xh9>aSe>vEzM*>xp{tJyZox1ZRl}QjcvX2TEgNc^(_-hir@Es>NySoa1g^ zFow_twnHdx(j?Q_3q51t3XI7YlJ4_q&(0#)&a+RUy{IcBq?)eaWo*=H2UUVIqtp&lW9JTJiP&u zw8+4vo~_IJXZIJb_U^&=GI1nSD%e;P!c{kZALNCm5c%%oF+I3DrA63_@4)(v4(t~JiddILp7jmoy+>cD~ivwoctFfEL zP*#2Rx?_&bCpX26MBgp^4G>@h`Hxc(lnqyj!*t>9sOBcXN(hTwEDpn^X{x!!gPX?1 z*uM$}cYRwHXuf+gYTB}gDTcw{TXSOUU$S?8BeP&sc!Lc{{pEv}x#ELX>6*ipI1#>8 zKes$bHjiJ1OygZge_ak^Hz#k;=od1wZ=o71ba7oClBMq>Uk6hVq|ePPt)@FM5bW$I z;d2Or@wBjbTyZj|;+iHp%Bo!Vy(X3YM-}lasMItEV_QrP-Kk_J4C>)L&I3Xxj=E?| zsAF(IfVQ4w+dRRnJ>)}o^3_012YYgFWE)5TT=l2657*L8_u1KC>Y-R{7w^S&A^X^U}h20jpS zQsdeaA#WIE*<8KG*oXc~$izYilTc#z{5xhpXmdT-YUnGh9v4c#lrHG6X82F2-t35} zB`jo$HjKe~E*W$=g|j&P>70_cI`GnOQ;Jp*JK#CT zuEGCn{8A@bC)~0%wsEv?O^hSZF*iqjO~_h|>xv>PO+?525Nw2472(yqS>(#R)D7O( zg)Zrj9n9$}=~b00=Wjf?E418qP-@8%MQ%PBiCTX=$B)e5cHFDu$LnOeJ~NC;xmOk# z>z&TbsK>Qzk)!88lNI8fOE2$Uxso^j*1fz>6Ot49y@=po)j4hbTIcVR`ePHpuJSfp zxaD^Dn3X}Na3@<_Pc>a;-|^Pon(>|ytG_+U^8j_JxP=_d>L$Hj?|0lz>_qQ#a|$+( z(x=Lipuc8p4^}1EQhI|TubffZvB~lu$zz9ao%T?%ZLyV5S9}cLeT?c} z>yCN9<04NRi~1oR)CiBakoNhY9BPnv)kw%*iv8vdr&&VgLGIs(-FbJ?d_gfbL2={- zBk4lkdPk~7+jIxd4{M(-W1AC_WcN&Oza@jZoj zaE*9Y;g83#m(OhA!w~LNfUJNUuRz*H-=$s*z+q+;snKPRm9EptejugC-@7-a-}Tz0 z@KHra#Y@OXK+KsaSN9WiGf?&jlZ!V7L||%KHP;SLksMFfjkeIMf<1e~t?!G3{n)H8 zQAlFY#QwfKuj;l@<$YDATAk;%PtD%B(0<|8>rXU< zJ66rkAVW_~Dj!7JGdGGi4NFuE?7ZafdMxIh65Sz7yQoA7fBZCE@WwysB=+`kT^LFX zz8#FlSA5)6FG9(qL3~A24mpzL@@2D#>0J7mMS1T*9UJ zvOq!!a(%IYY69+h45CE?(&v9H4FCr>gK0>mK~F}5RdOuH2{4|}k@5XpsX7+LZo^Qa4sH5`eUj>iffoBVm+ zz4Mtf`h?NW$*q1yr|}E&eNl)J``SZvTf6Qr*&S%tVv_OBpbjnA0&Vz#(;QmGiq-k! zgS0br4I&+^2mgA15*~Cd00cXLYOLA#Ep}_)eED>m+K@JTPr_|lSN}(OzFXQSBc6fM z@f-%2;1@BzhZa*LFV z-LrLmkmB%<<&jEURBEW>soaZ*rSIJNwaV%-RSaCZi4X)qYy^PxZ=oL?6N-5OGOMD2 z;q_JK?zkwQ@b3~ln&sDtT5SpW9a0q+5Gm|fpVY2|zqlNYBR}E5+ahgdj!CvK$Tlk0 z9g$5N;aar=CqMsudQV>yb4l@hN(9Jcc=1(|OHsqH6|g=K-WBd8GxZ`AkT?OO z-z_Ued-??Z*R4~L7jwJ%-`s~FK|qNAJ;EmIVDVpk{Lr7T4l{}vL)|GuUuswe9c5F| zv*5%u01hlv08?00Vpwyk*Q&&fY8k6MjOfpZfKa@F-^6d=Zv|0@&4_544RP5(s|4VPVP-f>%u(J@23BHqo2=zJ#v9g=F!cP((h zpt0|(s++ej?|$;2PE%+kc6JMmJjDW)3BXvBK!h!E`8Y&*7hS{c_Z?4SFP&Y<3evqf z9-ke+bSj$%Pk{CJlJbWwlBg^mEC^@%Ou?o>*|O)rl&`KIbHrjcpqsc$Zqt0^^F-gU2O=BusO+(Op}!jNzLMc zT;0YT%$@ClS%V+6lMTfhuzzxomoat=1H?1$5Ei7&M|gxo`~{UiV5w64Np6xV zVK^nL$)#^tjhCpTQMspXI({TW^U5h&Wi1Jl8g?P1YCV4=%ZYyjSo#5$SX&`r&1PyC zzc;uzCd)VTIih|8eNqFNeBMe#j_FS6rq81b>5?aXg+E#&$m++Gz9<+2)h=K(xtn}F ziV{rmu+Y>A)qvF}ms}4X^Isy!M&1%$E!rTO~5(p+8{U6#hWu>(Ll1}eD64Xa>~73A*538wry?v$vW z>^O#FRdbj(k0Nr&)U`Tl(4PI*%IV~;ZcI2z&rmq=(k^}zGOYZF3b2~Klpzd2eZJl> zB=MOLwI1{$RxQ7Y4e30&yOx?BvAvDkTBvWPpl4V8B7o>4SJn*+h1Ms&fHso%XLN5j z-zEwT%dTefp~)J_C8;Q6i$t!dnlh-!%haR1X_NuYUuP-)`IGWjwzAvp!9@h`kPZhf zwLwFk{m3arCdx8rD~K2`42mIN4}m%OQ|f)4kf%pL?Af5Ul<3M2fv>;nlhEPR8b)u} zIV*2-wyyD%%) zl$G@KrC#cUwoL?YdQyf9WH)@gWB{jd5w4evI& zOFF)p_D8>;3-N1z6mES!OPe>B^<;9xsh)){Cw$Vs-ez5nXS95NOr3s$IU;>VZSzKn zBvub8_J~I%(DozZW@{)Vp37-zevxMRZ8$8iRfwHmYvyjOxIOAF2FUngKj289!(uxY zaClWm!%x&teKmr^ABrvZ(ikx{{I-lEzw5&4t3P0eX%M~>$wG0ZjA4Mb&op+0$#SO_ z--R`>X!aqFu^F|a!{Up-iF(K+alKB{MNMs>e(i@Tpy+7Z-dK%IEjQFO(G+2mOb@BO zP>WHlS#fSQm0et)bG8^ZDScGnh-qRKIFz zfUdnk=m){ej0i(VBd@RLtRq3Ep=>&2zZ2%&vvf?Iex01hx1X!8U+?>ER;yJlR-2q4 z;Y@hzhEC=d+Le%=esE>OQ!Q|E%6yG3V_2*uh&_nguPcZ{q?DNq8h_2ahaP6=pP-+x zK!(ve(yfoYC+n(_+chiJ6N(ZaN+XSZ{|H{TR1J_s8x4jpis-Z-rlRvRK#U%SMJ(`C z?T2 zF(NNfO_&W%2roEC2j#v*(nRgl1X)V-USp-H|CwFNs?n@&vpRcj@W@xCJwR6@T!jt377?XjZ06=`d*MFyTdyvW!`mQm~t3luzYzvh^F zM|V}rO>IlBjZc}9Z zd$&!tthvr>5)m;5;96LWiAV0?t)7suqdh0cZis`^Pyg@?t>Ms~7{nCU;z`Xl+raSr zXpp=W1oHB*98s!Tpw=R5C)O{{Inl>9l7M*kq%#w9a$6N~v?BY2GKOVRkXYCgg*d

<5G2M1WZP5 zzqSuO91lJod(SBDDw<*sX(+F6Uq~YAeYV#2A;XQu_p=N5X+#cmu19Qk>QAnV=k!?wbk5I;tDWgFc}0NkvC*G=V+Yh1cyeJVq~9czZiDXe+S=VfL2g`LWo8om z$Y~FQc6MFjV-t1Y`^D9XMwY*U_re2R?&(O~68T&D4S{X`6JYU-pz=}ew-)V0AOUT1 zVOkHAB-8uBcRjLvz<9HS#a@X*Kc@|W)nyiSgi|u5$Md|P()%2(?olGg@ypoJwp6>m z*dnfjjWC>?_1p;%1brqZyDRR;8EntVA92EJ3ByOxj6a+bhPl z;a?m4rQAV1@QU^#M1HX)0+}A<7TCO`ZR_RzF}X9-M>cRLyN4C+lCk2)kT^3gN^`IT zNP~fAm(wyIoR+l^lQDA(e1Yv}&$I!n?&*p6?lZcQ+vGLLd~fM)qt}wsbf3r=tmVYe zl)ntf#E!P7wlakP9MXS7m0nsAmqxZ*)#j;M&0De`oNmFgi$ov#!`6^4)iQyxg5Iuj zjLAhzQ)r`^hf7`*1`Rh`X;LVBtDSz@0T?kkT1o!ijeyTGt5vc^Cd*tmNgiNo^EaWvaC8$e+nb_{W01j3%=1Y&92YacjCi>eNbwk%-gPQ@H-+4xskQ}f_c=jg^S-# zYFBDf)2?@5cy@^@FHK5$YdAK9cI;!?Jgd}25lOW%xbCJ>By3=HiK@1EM+I46A)Lsd zeT|ZH;KlCml=@;5+hfYf>QNOr^XNH%J-lvev)$Omy8MZ`!{`j>(J5cG&ZXXgv)TaF zg;cz99i$4CX_@3MIb?GL0s*8J=3`#P(jXF(_(6DXZjc@(@h&=M&JG)9&Te1?(^XMW zjjC_70|b=9hB6pKQi`S^Ls7JyJw^@P>Ko^&q8F&?>6i;#CbxUiLz1ZH4lNyd@QACd zu>{!sqjB!2Dg}pbAXD>d!3jW}=5aN0b;rw*W>*PAxm7D)aw(c*RX2@bTGEI|RRp}vw7;NR2wa;rXN{L{Q#=Fa z$x@ms6pqb>!8AuV(prv>|aU8oWV={C&$c zMa=p=CDNOC2tISZcd8~18GN5oTbKY+Vrq;3_obJlfSKRMk;Hdp1`y`&LNSOqeauR_ z^j*Ojl3Ohzb5-a49A8s|UnM*NM8tg}BJXdci5%h&;$afbmRpN0&~9rCnBA`#lG!p zc{(9Y?A0Y9yo?wSYn>iigf~KP$0*@bGZ>*YM4&D;@{<%Gg5^uUJGRrV4 z(aZOGB&{_0f*O=Oi0k{@8vN^BU>s3jJRS&CJOl3o|BE{FAA&a#2YYiX3pZz@|Go-F z|Fly;7eX2OTs>R}<`4RwpHFs9nwh)B28*o5qK1Ge=_^w0m`uJOv!=&!tzt#Save(C zgKU=Bsgql|`ui(e1KVxR`?>Dx>(rD1$iWp&m`v)3A!j5(6vBm*z|aKm*T*)mo(W;R zNGo2`KM!^SS7+*9YxTm6YMm_oSrLceqN*nDOAtagULuZl5Q<7mOnB@Hq&P|#9y{5B z!2x+2s<%Cv2Aa0+u{bjZXS);#IFPk(Ph-K7K?3i|4ro> zRbqJoiOEYo(Im^((r}U4b8nvo_>4<`)ut`24?ILnglT;Pd&U}$lV3U$F9#PD(O=yV zgNNA=GW|(E=&m_1;uaNmipQe?pon4{T=zK!N!2_CJL0E*R^XXIKf*wi!>@l}3_P9Z zF~JyMbW!+n-+>!u=A1ESxzkJy$DRuG+$oioG7(@Et|xVbJ#BCt;J43Nvj@MKvTxzy zMmjNuc#LXBxFAwIGZJk~^!q$*`FME}yKE8d1f5Mp}KHNq(@=Z8YxV}0@;YS~|SpGg$_jG7>_8WWYcVx#4SxpzlV9N4aO>K{c z$P?a_fyDzGX$Of3@ykvedGd<@-R;M^Shlj*SswJLD+j@hi_&_>6WZ}#AYLR0iWMK|A zH_NBeu(tMyG=6VO-=Pb>-Q#$F*or}KmEGg*-n?vWQREURdB#+6AvOj*I%!R-4E_2$ zU5n9m>RWs|Wr;h2DaO&mFBdDb-Z{APGQx$(L`if?C|njd*fC=rTS%{o69U|meRvu?N;Z|Y zbT|ojL>j;q*?xXmnHH#3R4O-59NV1j=uapkK7}6@Wo*^Nd#(;$iuGsb;H315xh3pl zHaJ>h-_$hdNl{+|Zb%DZH%ES;*P*v0#}g|vrKm9;j-9e1M4qX@zkl&5OiwnCz=tb6 zz<6HXD+rGIVpGtkb{Q^LIgExOm zz?I|oO9)!BOLW#krLmWvX5(k!h{i>ots*EhpvAE;06K|u_c~y{#b|UxQ*O@Ks=bca z^_F0a@61j3I(Ziv{xLb8AXQj3;R{f_l6a#H5ukg5rxwF9A$?Qp-Mo54`N-SKc}fWp z0T)-L@V$$&my;l#Ha{O@!fK4-FSA)L&3<${Hcwa7ue`=f&YsXY(NgeDU#sRlT3+9J z6;(^(sjSK@3?oMo$%L-nqy*E;3pb0nZLx6 z;h5)T$y8GXK1DS-F@bGun8|J(v-9o=42&nLJy#}M5D0T^5VWBNn$RpC zZzG6Bt66VY4_?W=PX$DMpKAI!d`INr) zkMB{XPQ<52rvWVQqgI0OL_NWxoe`xxw&X8yVftdODPj5|t}S6*VMqN$-h9)1MBe0N zYq?g0+e8fJCoAksr0af1)FYtz?Me!Cxn`gUx&|T;)695GG6HF7!Kg1zzRf_{VWv^bo81v4$?F6u2g|wxHc6eJQAg&V z#%0DnWm2Rmu71rPJ8#xFUNFC*V{+N_qqFH@gYRLZ6C?GAcVRi>^n3zQxORPG)$-B~ z%_oB?-%Zf7d*Fe;cf%tQwcGv2S?rD$Z&>QC2X^vwYjnr5pa5u#38cHCt4G3|efuci z@3z=#A13`+ztmp;%zjXwPY_aq-;isu*hecWWX_=Z8paSqq7;XYnUjK*T>c4~PR4W7 z#C*%_H&tfGx`Y$w7`dXvVhmovDnT>btmy~SLf>>~84jkoQ%cv=MMb+a{JV&t0+1`I z32g_Y@yDhKe|K^PevP~MiiVl{Ou7^Mt9{lOnXEQ`xY^6L8D$705GON{!1?1&YJEl#fTf5Z)da=yiEQ zGgtC-soFGOEBEB~ZF_{7b(76En>d}mI~XIwNw{e>=Fv)sgcw@qOsykWr?+qAOZSVrQfg}TNI ztKNG)1SRrAt6#Q?(me%)>&A_^DM`pL>J{2xu>xa$3d@90xR61TQDl@fu%_85DuUUA za9tn64?At;{`BAW6oykwntxHeDpXsV#{tmt5RqdN7LtcF4vR~_kZNT|wqyR#z^Xcd zFdymVRZvyLfTpBT>w9<)Ozv@;Yk@dOSVWbbtm^y@@C>?flP^EgQPAwsy75bveo=}T zFxl(f)s)j(0#N_>Or(xEuV(n$M+`#;Pc$1@OjXEJZumkaekVqgP_i}p`oTx;terTx zZpT+0dpUya2hqlf`SpXN{}>PfhajNk_J0`H|2<5E;U5Vh4F8er z;RxLSFgpGhkU>W?IwdW~NZTyOBrQ84H7_?gviIf71l`EETodG9a1!8e{jW?DpwjL? zGEM&eCzwoZt^P*8KHZ$B<%{I}>46IT%jJ3AnnB5P%D2E2Z_ z1M!vr#8r}1|KTqWA4%67ZdbMW2YJ81b(KF&SQ2L1Qn(y-=J${p?xLMx3W7*MK;LFQ z6Z`aU;;mTL4XrrE;HY*Rkh6N%?qviUGNAKiCB~!P}Z->IpO6E(gGd7I#eDuT7j|?nZ zK}I(EJ>$Kb&@338M~O+em9(L!+=0zBR;JAQesx|3?Ok90)D1aS9P?yTh6Poh8Cr4X zk3zc=f2rE7jj+aP7nUsr@~?^EGP>Q>h#NHS?F{Cn`g-gD<8F&dqOh-0sa%pfL`b+1 zUsF*4a~)KGb4te&K0}bE>z3yb8% zibb5Q%Sfiv7feb1r0tfmiMv z@^4XYwg@KZI=;`wC)`1jUA9Kv{HKe2t$WmRcR4y8)VAFjRi zaz&O7Y2tDmc5+SX(bj6yGHYk$dBkWc96u3u&F)2yEE~*i0F%t9Kg^L6MJSb&?wrXi zGSc;_rln$!^ybwYBeacEFRsVGq-&4uC{F)*Y;<0y7~USXswMo>j4?~5%Zm!m@i@-> zXzi82sa-vpU{6MFRktJy+E0j#w`f`>Lbog{zP|9~hg(r{RCa!uGe>Yl536cn$;ouH za#@8XMvS-kddc1`!1LVq;h57~zV`7IYR}pp3u!JtE6Q67 zq3H9ZUcWPm2V4IukS}MCHSdF0qg2@~ufNx9+VMjQP&exiG_u9TZAeAEj*jw($G)zL zq9%#v{wVyOAC4A~AF=dPX|M}MZV)s(qI9@aIK?Pe+~ch|>QYb+78lDF*Nxz2-vpRbtQ*F4$0fDbvNM#CCatgQ@z1+EZWrt z2dZfywXkiW=no5jus-92>gXn5rFQ-COvKyegmL=4+NPzw6o@a?wGE-1Bt;pCHe;34K%Z z-FnOb%!nH;)gX+!a3nCk?5(f1HaWZBMmmC@lc({dUah+E;NOros{?ui1zPC-Q0);w zEbJmdE$oU$AVGQPdm{?xxI_0CKNG$LbY*i?YRQ$(&;NiA#h@DCxC(U@AJ$Yt}}^xt-EC_ z4!;QlLkjvSOhdx!bR~W|Ezmuf6A#@T`2tsjkr>TvW*lFCMY>Na_v8+{Y|=MCu1P8y z89vPiH5+CKcG-5lzk0oY>~aJC_0+4rS@c@ZVKLAp`G-sJB$$)^4*A!B zmcf}lIw|VxV9NSoJ8Ag3CwN&d7`|@>&B|l9G8tXT^BDHOUPrtC70NgwN4${$k~d_4 zJ@eo6%YQnOgq$th?0{h`KnqYa$Nz@vlHw<%!C5du6<*j1nwquk=uY}B8r7f|lY+v7 zm|JU$US08ugor8E$h3wH$c&i~;guC|3-tqJy#T;v(g( zBZtPMSyv%jzf->435yM(-UfyHq_D=6;ouL4!ZoD+xI5uCM5ay2m)RPmm$I}h>()hS zO!0gzMxc`BPkUZ)WXaXam%1;)gedA7SM8~8yIy@6TPg!hR0=T>4$Zxd)j&P-pXeSF z9W`lg6@~YDhd19B9ETv(%er^Xp8Yj@AuFVR_8t*KS;6VHkEDKI#!@l!l3v6`W1`1~ zP{C@keuV4Q`Rjc08lx?zmT$e$!3esc9&$XZf4nRL(Z*@keUbk!GZi(2Bmyq*saOD? z3Q$V<*P-X1p2}aQmuMw9nSMbOzuASsxten7DKd6A@ftZ=NhJ(0IM|Jr<91uAul4JR zADqY^AOVT3a(NIxg|U;fyc#ZnSzw2cr}#a5lZ38>nP{05D)7~ad7JPhw!LqOwATXtRhK!w0X4HgS1i<%AxbFmGJx9?sEURV+S{k~g zGYF$IWSlQonq6}e;B(X(sIH|;52+(LYW}v_gBcp|x%rEAVB`5LXg_d5{Q5tMDu0_2 z|LOm$@K2?lrLNF=mr%YP|U-t)~9bqd+wHb4KuPmNK<}PK6e@aosGZK57=Zt+kcszVOSbe;`E^dN! ze7`ha3WUUU7(nS0{?@!}{0+-VO4A{7+nL~UOPW9_P(6^GL0h${SLtqG!} zKl~Ng5#@Sy?65wk9z*3SA`Dpd4b4T^@C8Fhd8O)k_4%0RZL5?#b~jmgU+0|DB%0Z) zql-cPC>A9HPjdOTpPC` zQwvF}uB5kG$Xr4XnaH#ruSjM*xG?_hT7y3G+8Ox`flzU^QIgb_>2&-f+XB6MDr-na zSi#S+c!ToK84<&m6sCiGTd^8pNdXo+$3^l3FL_E`0 z>8it5YIDxtTp2Tm(?}FX^w{fbfgh7>^8mtvN>9fWgFN_*a1P`Gz*dyOZF{OV7BC#j zQV=FQM5m>47xXgapI$WbPM5V`V<7J9tD)oz@d~MDoM`R^Y6-Na(lO~uvZlpu?;zw6 zVO1faor3dg#JEb5Q*gz4<W8tgC3nE2BG2jeIQs1)<{In&7hJ39x=;ih;CJDy)>0S1at*7n?Wr0ahYCpFjZ|@u91Zl7( zv;CSBRC65-6f+*JPf4p1UZ)k=XivKTX6_bWT~7V#rq0Xjas6hMO!HJN8GdpBKg_$B zwDHJF6;z?h<;GXFZan8W{XFNPpOj!(&I1`&kWO86p?Xz`a$`7qV7Xqev|7nn_lQuX ziGpU1MMYt&5dE2A62iX3;*0WzNB9*nSTzI%62A+N?f?;S>N@8M=|ef3gtQTIA*=yq zQAAjOqa!CkHOQo4?TsqrrsJLclXcP?dlAVv?v`}YUjo1Htt;6djP@NPFH+&p1I+f_ z)Y279{7OWomY8baT(4TAOlz1OyD{4P?(DGv3XyJTA2IXe=kqD)^h(@*E3{I~w;ws8 z)ZWv7E)pbEM zd3MOXRH3mQhks9 zv6{s;k0y5vrcjXaVfw8^>YyPo=oIqd5IGI{)+TZq5Z5O&hXAw%ZlL}^6FugH;-%vP zAaKFtt3i^ag226=f0YjzdPn6|4(C2sC5wHFX{7QF!tG1E-JFA`>eZ`}$ymcRJK?0c zN363o{&ir)QySOFY0vcu6)kX#;l??|7o{HBDVJN+17rt|w3;(C_1b>d;g9Gp=8YVl zYTtA52@!7AUEkTm@P&h#eg+F*lR zQ7iotZTcMR1frJ0*V@Hw__~CL>_~2H2cCtuzYIUD24=Cv!1j6s{QS!v=PzwQ(a0HS zBKx04KA}-Ue+%9d`?PG*hIij@54RDSQpA7|>qYVIrK_G6%6;#ZkR}NjUgmGju)2F`>|WJoljo)DJgZr4eo1k1i1+o z1D{>^RlpIY8OUaOEf5EBu%a&~c5aWnqM zxBpJq98f=%M^{4mm~5`CWl%)nFR64U{(chmST&2jp+-r z3675V<;Qi-kJud%oWnCLdaU-)xTnMM%rx%Jw6v@=J|Ir=4n-1Z23r-EVf91CGMGNz zb~wyv4V{H-hkr3j3WbGnComiqmS0vn?n?5v2`Vi>{Ip3OZUEPN7N8XeUtF)Ry6>y> zvn0BTLCiqGroFu|m2zG-;Xb6;W`UyLw)@v}H&(M}XCEVXZQoWF=Ykr5lX3XWwyNyF z#jHv)A*L~2BZ4lX?AlN3X#axMwOC)PoVy^6lCGse9bkGjb=qz%kDa6}MOmSwK`cVO zt(e*MW-x}XtU?GY5}9{MKhRhYOlLhJE5=ca+-RmO04^ z66z{40J=s=ey9OCdc(RCzy zd7Zr1%!y3}MG(D=wM_ebhXnJ@MLi7cImDkhm0y{d-Vm81j`0mbi4lF=eirlr)oW~a zCd?26&j^m4AeXEsIUXiTal)+SPM4)HX%%YWF1?(FV47BaA`h9m67S9x>hWMVHx~Hg z1meUYoLL(p@b3?x|9DgWeI|AJ`Ia84*P{Mb%H$ZRROouR4wZhOPX15=KiBMHl!^JnCt$Az`KiH^_d>cev&f zaG2>cWf$=A@&GP~DubsgYb|L~o)cn5h%2`i^!2)bzOTw2UR!>q5^r&2Vy}JaWFUQE04v>2;Z@ZPwXr?y&G(B^@&y zsd6kC=hHdKV>!NDLIj+3rgZJ|dF`%N$DNd;B)9BbiT9Ju^Wt%%u}SvfM^=|q-nxDG zuWCQG9e#~Q5cyf8@y76#kkR^}{c<_KnZ0QsZcAT|YLRo~&tU|N@BjxOuy`#>`X~Q< z?R?-Gsk$$!oo(BveQLlUrcL#eirhgBLh`qHEMg`+sR1`A=1QX7)ZLMRT+GBy?&mM8 zQG^z-!Oa&J-k7I(3_2#Q6Bg=NX<|@X&+YMIOzfEO2$6Mnh}YV!m!e^__{W@-CTprr zbdh3f=BeCD$gHwCrmwgM3LAv3!Mh$wM)~KWzp^w)Cu6roO7uUG5z*}i0_0j47}pK; ztN530`ScGatLOL06~zO)Qmuv`h!gq5l#wx(EliKe&rz-5qH(hb1*fB#B+q`9=jLp@ zOa2)>JTl7ovxMbrif`Xe9;+fqB1K#l=Dv!iT;xF zdkCvS>C5q|O;}ns3AgoE({Ua-zNT-9_5|P0iANmC6O76Sq_(AN?UeEQJ>#b54fi3k zFmh+P%b1x3^)0M;QxXLP!BZ^h|AhOde*{9A=f3|Xq*JAs^Y{eViF|=EBfS6L%k4ip zk+7M$gEKI3?bQg?H3zaE@;cyv9kv;cqK$VxQbFEsy^iM{XXW0@2|DOu$!-k zSFl}Y=jt-VaT>Cx*KQnHTyXt}f9XswFB9ibYh+k2J!ofO+nD?1iw@mwtrqI4_i?nE zhLkPp41ED62me}J<`3RN80#vjW;wt`pP?%oQ!oqy7`miL>d-35a=qotK$p{IzeSk# ze_$CFYp_zIkrPFVaW^s#U4xT1lI^A0IBe~Y<4uS%zSV=wcuLr%gQT=&5$&K*bwqx| zWzCMiz>7t^Et@9CRUm9E+@hy~sBpm9fri$sE1zgLU((1?Yg{N1Sars=DiW&~Zw=3I zi7y)&oTC?UWD2w97xQ&5vx zRXEBGeJ(I?Y}eR0_O{$~)bMJRTsNUPIfR!xU9PE7A>AMNr_wbrFK>&vVw=Y;RH zO$mlpmMsQ}-FQ2cSj7s7GpC+~^Q~dC?y>M}%!-3kq(F3hGWo9B-Gn02AwUgJ>Z-pKOaj zysJBQx{1>Va=*e@sLb2z&RmQ7ira;aBijM-xQ&cpR>X3wP^foXM~u1>sv9xOjzZpX z0K;EGouSYD~oQ&lAafj3~EaXfFShC+>VsRlEMa9cg9i zFxhCKO}K0ax6g4@DEA?dg{mo>s+~RPI^ybb^u--^nTF>**0l5R9pocwB?_K)BG_)S zyLb&k%XZhBVr7U$wlhMqwL)_r&&n%*N$}~qijbkfM|dIWP{MyLx}X&}ES?}7i;9bW zmTVK@zR)7kE2+L42Q`n4m0VVg5l5(W`SC9HsfrLZ=v%lpef=Gj)W59VTLe+Z$8T8i z4V%5+T0t8LnM&H>Rsm5C%qpWBFqgTwL{=_4mE{S3EnBXknM&u8n}A^IIM4$s3m(Rd z>zq=CP-!9p9es2C*)_hoL@tDYABn+o#*l;6@7;knWIyDrt5EuakO99S$}n((Fj4y} zD!VvuRzghcE{!s;jC*<_H$y6!6QpePo2A3ZbX*ZzRnQq*b%KK^NF^z96CHaWmzU@f z#j;y?X=UP&+YS3kZx7;{ zDA{9(wfz7GF`1A6iB6fnXu0?&d|^p|6)%3$aG0Uor~8o? z*e}u#qz7Ri?8Uxp4m_u{a@%bztvz-BzewR6bh*1Xp+G=tQGpcy|4V_&*aOqu|32CM zz3r*E8o8SNea2hYJpLQ-_}R&M9^%@AMx&`1H8aDx4j%-gE+baf2+9zI*+Pmt+v{39 zDZ3Ix_vPYSc;Y;yn68kW4CG>PE5RoaV0n@#eVmk?p$u&Fy&KDTy!f^Hy6&^-H*)#u zdrSCTJPJw?(hLf56%2;_3n|ujUSJOU8VPOTlDULwt0jS@j^t1WS z!n7dZIoT+|O9hFUUMbID4Ec$!cc($DuQWkocVRcYSikFeM&RZ=?BW)mG4?fh#)KVG zcJ!<=-8{&MdE)+}?C8s{k@l49I|Zwswy^ZN3;E!FKyglY~Aq?4m74P-0)sMTGXqd5(S<-(DjjM z&7dL-Mr8jhUCAG$5^mI<|%`;JI5FVUnNj!VO2?Jiqa|c2;4^n!R z`5KK0hyB*F4w%cJ@Un6GC{mY&r%g`OX|1w2$B7wxu97%<@~9>NlXYd9RMF2UM>(z0 zouu4*+u+1*k;+nFPk%ly!nuMBgH4sL5Z`@Rok&?Ef=JrTmvBAS1h?C0)ty5+yEFRz zY$G=coQtNmT@1O5uk#_MQM1&bPPnspy5#>=_7%WcEL*n$;sSAZcXxMpcXxLe;_mLA z5F_paad+bGZV*oh@8h0(|D2P!q# zTHjmiphJ=AazSeKQPkGOR-D8``LjzToyx{lfK-1CDD6M7?pMZOdLKFtjZaZMPk4}k zW)97Fh(Z+_Fqv(Q_CMH-YYi?fR5fBnz7KOt0*t^cxmDoIokc=+`o# zrud|^h_?KW=Gv%byo~(Ln@({?3gnd?DUf-j2J}|$Mk>mOB+1{ZQ8HgY#SA8END(Zw z3T+W)a&;OO54~m}ffemh^oZ!Vv;!O&yhL0~hs(p^(Yv=(3c+PzPXlS5W79Er8B1o* z`c`NyS{Zj_mKChj+q=w)B}K za*zzPhs?c^`EQ;keH{-OXdXJet1EsQ)7;{3eF!-t^4_Srg4(Ot7M*E~91gwnfhqaM zNR7dFaWm7MlDYWS*m}CH${o?+YgHiPC|4?X?`vV+ws&Hf1ZO-w@OGG^o4|`b{bLZj z&9l=aA-Y(L11!EvRjc3Zpxk7lc@yH1e$a}8$_-r$)5++`_eUr1+dTb@ zU~2P1HM#W8qiNN3b*=f+FfG1!rFxnNlGx{15}BTIHgxO>Cq4 z;#9H9YjH%>Z2frJDJ8=xq>Z@H%GxXosS@Z>cY9ppF+)e~t_hWXYlrO6)0p7NBMa`+ z^L>-#GTh;k_XnE)Cgy|0Dw;(c0* zSzW14ZXozu)|I@5mRFF1eO%JM=f~R1dkNpZM+Jh(?&Zje3NgM{2ezg1N`AQg5%+3Y z64PZ0rPq6;_)Pj-hyIOgH_Gh`1$j1!jhml7ksHA1`CH3FDKiHLz+~=^u@kUM{ilI5 z^FPiJ7mSrzBs9{HXi2{sFhl5AyqwUnU{sPcUD{3+l-ZHAQ)C;c$=g1bdoxeG(5N01 zZy=t8i{*w9m?Y>V;uE&Uy~iY{pY4AV3_N;RL_jT_QtLFx^KjcUy~q9KcLE3$QJ{!)@$@En{UGG7&}lc*5Kuc^780;7Bj;)X?1CSy*^^ zPP^M)Pr5R>mvp3_hmCtS?5;W^e@5BjE>Cs<`lHDxj<|gtOK4De?Sf0YuK5GX9G93i zMYB{8X|hw|T6HqCf7Cv&r8A$S@AcgG1cF&iJ5=%+x;3yB`!lQ}2Hr(DE8=LuNb~Vs z=FO&2pdc16nD$1QL7j+!U^XWTI?2qQKt3H8=beVTdHHa9=MiJ&tM1RRQ-=+vy!~iz zj3O{pyRhCQ+b(>jC*H)J)%Wq}p>;?@W*Eut@P&?VU+Sdw^4kE8lvX|6czf{l*~L;J zFm*V~UC;3oQY(ytD|D*%*uVrBB}BbAfjK&%S;z;7$w68(8PV_whC~yvkZmX)xD^s6 z{$1Q}q;99W?*YkD2*;)tRCS{q2s@JzlO~<8x9}X<0?hCD5vpydvOw#Z$2;$@cZkYrp83J0PsS~!CFtY%BP=yxG?<@#{7%2sy zOc&^FJxsUYN36kSY)d7W=*1-{7ghPAQAXwT7z+NlESlkUH&8ODlpc8iC*iQ^MAe(B z?*xO4i{zFz^G=^G#9MsLKIN64rRJykiuIVX5~0#vAyDWc9-=6BDNT_aggS2G{B>dD ze-B%d3b6iCfc5{@yz$>=@1kdK^tX9qh0=ocv@9$ai``a_ofxT=>X7_Y0`X}a^M?d# z%EG)4@`^Ej_=%0_J-{ga!gFtji_byY&Vk@T1c|ucNAr(JNr@)nCWj?QnCyvXg&?FW;S-VOmNL6^km_dqiVjJuIASVGSFEos@EVF7St$WE&Z%)`Q##+0 zjaZ=JI1G@0!?l|^+-ZrNd$WrHBi)DA0-Eke>dp=_XpV<%CO_Wf5kQx}5e<90dt>8k zAi00d0rQ821nA>B4JHN7U8Zz=0;9&U6LOTKOaC1FC8GgO&kc=_wHIOGycL@c*$`ce703t%>S}mvxEnD-V!;6c`2(p74V7D0No1Xxt`urE66$0(ThaAZ1YVG#QP$ zy~NN%kB*zhZ2Y!kjn826pw4bh)75*e!dse+2Db(;bN34Uq7bLpr47XTX{8UEeC?2i z*{$`3dP}32${8pF$!$2Vq^gY|#w+VA_|o(oWmQX8^iw#n_crb(K3{69*iU?<%C-%H zuKi)3M1BhJ@3VW>JA`M>L~5*_bxH@Euy@niFrI$82C1}fwR$p2E&ZYnu?jlS}u7W9AyfdXh2pM>78bIt3 z)JBh&XE@zA!kyCDfvZ1qN^np20c1u#%P6;6tU&dx0phT1l=(mw7`u!-0e=PxEjDds z9E}{E!7f9>jaCQhw)&2TtG-qiD)lD(4jQ!q{`x|8l&nmtHkdul# zy+CIF8lKbp9_w{;oR+jSLtTfE+B@tOd6h=QePP>rh4@~!8c;Hlg9m%%&?e`*Z?qz5-zLEWfi>`ord5uHF-s{^bexKAoMEV@9nU z^5nA{f{dW&g$)BAGfkq@r5D)jr%!Ven~Q58c!Kr;*Li#`4Bu_?BU0`Y`nVQGhNZk@ z!>Yr$+nB=`z#o2nR0)V3M7-eVLuY`z@6CT#OTUXKnxZn$fNLPv7w1y7eGE=Qv@Hey`n;`U=xEl|q@CCV^#l)s0ZfT+mUf z^(j5r4)L5i2jnHW4+!6Si3q_LdOLQi<^fu?6WdohIkn79=jf%Fs3JkeXwF(?_tcF? z?z#j6iXEd(wJy4|p6v?xNk-)iIf2oX5^^Y3q3ziw16p9C6B;{COXul%)`>nuUoM*q zzmr|NJ5n)+sF$!yH5zwp=iM1#ZR`O%L83tyog-qh1I z0%dcj{NUs?{myT~33H^(%0QOM>-$hGFeP;U$puxoJ>>o-%Lk*8X^rx1>j|LtH$*)>1C!Pv&gd16%`qw5LdOIUbkNhaBBTo}5iuE%K&ZV^ zAr_)kkeNKNYJRgjsR%vexa~&8qMrQYY}+RbZ)egRg9_$vkoyV|Nc&MH@8L)`&rpqd zXnVaI@~A;Z^c3+{x=xgdhnocA&OP6^rr@rTvCnhG6^tMox$ulw2U7NgUtW%|-5VeH z_qyd47}1?IbuKtqNbNx$HR`*+9o=8`%vM8&SIKbkX9&%TS++x z5|&6P<%=F$C?owUI`%uvUq^yW0>`>yz!|WjzsoB9dT;2Dx8iSuK%%_XPgy0dTD4kd zDXF@&O_vBVVKQq(9YTClUPM30Sk7B!v7nOyV`XC!BA;BIVwphh+c)?5VJ^(C;GoQ$ zvBxr7_p*k$T%I1ke}`U&)$uf}I_T~#3XTi53OX)PoXVgxEcLJgZG^i47U&>LY(l%_ z;9vVDEtuMCyu2fqZeez|RbbIE7@)UtJvgAcVwVZNLccswxm+*L&w`&t=ttT=sv6Aq z!HouSc-24Y9;0q$>jX<1DnnGmAsP))- z^F~o99gHZw`S&Aw7e4id6Lg7kMk-e)B~=tZ!kE7sGTOJ)8@q}np@j7&7Sy{2`D^FH zI7aX%06vKsfJ168QnCM2=l|i>{I{%@gcr>ExM0Dw{PX6ozEuqFYEt z087%MKC;wVsMV}kIiuu9Zz9~H!21d!;Cu#b;hMDIP7nw3xSX~#?5#SSjyyg+Y@xh| z%(~fv3`0j#5CA2D8!M2TrG=8{%>YFr(j)I0DYlcz(2~92?G*?DeuoadkcjmZszH5& zKI@Lis%;RPJ8mNsbrxH@?J8Y2LaVjUIhRUiO-oqjy<&{2X~*f|)YxnUc6OU&5iac= z*^0qwD~L%FKiPmlzi&~a*9sk2$u<7Al=_`Ox^o2*kEv?p`#G(p(&i|ot8}T;8KLk- zPVf_4A9R`5^e`Om2LV*cK59EshYXse&IoByj}4WZaBomoHAPKqxRKbPcD`lMBI)g- zeMRY{gFaUuecSD6q!+b5(?vAnf>c`Z(8@RJy%Ulf?W~xB1dFAjw?CjSn$ph>st5bc zUac1aD_m6{l|$#g_v6;=32(mwpveQDWhmjR7{|B=$oBhz`7_g7qNp)n20|^^op3 zSfTdWV#Q>cb{CMKlWk91^;mHap{mk)o?udk$^Q^^u@&jd zfZ;)saW6{e*yoL6#0}oVPb2!}r{pAUYtn4{P~ES9tTfC5hXZnM{HrC8^=Pof{G4%Bh#8 ze~?C9m*|fd8MK;{L^!+wMy>=f^8b&y?yr6KnTq28$pFMBW9Oy7!oV5z|VM$s-cZ{I|Xf@}-)1=$V&x7e;9v81eiTi4O5-vs?^5pCKy2l>q);!MA zS!}M48l$scB~+Umz}7NbwyTn=rqt@`YtuwiQSMvCMFk2$83k50Q>OK5&fe*xCddIm)3D0I6vBU<+!3=6?(OhkO|b4fE_-j zimOzyfBB_*7*p8AmZi~X2bgVhyPy>KyGLAnOpou~sx9)S9%r)5dE%ADs4v%fFybDa_w*0?+>PsEHTbhKK^G=pFz z@IxLTCROWiKy*)cV3y%0FwrDvf53Ob_XuA1#tHbyn%Ko!1D#sdhBo`;VC*e1YlhrC z?*y3rp86m#qI|qeo8)_xH*G4q@70aXN|SP+6MQ!fJQqo1kwO_v7zqvUfU=Gwx`CR@ zRFb*O8+54%_8tS(ADh}-hUJzE`s*8wLI>1c4b@$al)l}^%GuIXjzBK!EWFO8W`>F^ ze7y#qPS0NI7*aU)g$_ziF(1ft;2<}6Hfz10cR8P}67FD=+}MfhrpOkF3hFhQu;Q1y zu%=jJHTr;0;oC94Hi@LAF5quAQ(rJG(uo%BiRQ@8U;nhX)j0i?0SL2g-A*YeAqF>RVCBOTrn{0R27vu}_S zS>tX4!#&U4W;ikTE!eFH+PKw%p+B(MR2I%n#+m0{#?qRP_tR@zpgCb=4rcrL!F=;A zh%EIF8m6%JG+qb&mEfuFTLHSxUAZEvC-+kvZKyX~SA3Umt`k}}c!5dy?-sLIM{h@> z!2=C)@nx>`;c9DdwZ&zeUc(7t<21D7qBj!|1^Mp1eZ6)PuvHx+poKSDCSBMFF{bKy z;9*&EyKitD99N}%mK8431rvbT+^%|O|HV23{;RhmS{$5tf!bIPoH9RKps`-EtoW5h zo6H_!s)Dl}2gCeGF6>aZtah9iLuGd19^z0*OryPNt{70RvJSM<#Ox9?HxGg04}b^f zrVEPceD%)#0)v5$YDE?f`73bQ6TA6wV;b^x*u2Ofe|S}+q{s5gr&m~4qGd!wOu|cZ||#h_u=k*fB;R6&k?FoM+c&J;ISg70h!J7*xGus)ta4veTdW)S^@sU@ z4$OBS=a~@F*V0ECic;ht4@?Jw<9kpjBgHfr2FDPykCCz|v2)`JxTH55?b3IM={@DU z!^|9nVO-R#s{`VHypWyH0%cs;0GO3E;It6W@0gX6wZ%W|Dzz&O%m17pa19db(er}C zUId1a4#I+Ou8E1MU$g=zo%g7K(=0Pn$)Rk z<4T2u<0rD)*j+tcy2XvY+0 z0d2pqm4)4lDewsAGThQi{2Kc3&C=|OQF!vOd#WB_`4gG3@inh-4>BoL!&#ij8bw7? zqjFRDaQz!J-YGitV4}$*$hg`vv%N)@#UdzHFI2E<&_@0Uw@h_ZHf}7)G;_NUD3@18 zH5;EtugNT0*RXVK*by>WS>jaDDfe!A61Da=VpIK?mcp^W?!1S2oah^wowRnrYjl~`lgP-mv$?yb6{{S55CCu{R z$9;`dyf0Y>uM1=XSl_$01Lc1Iy68IosWN8Q9Op=~I(F<0+_kKfgC*JggjxNgK6 z-3gQm6;sm?J&;bYe&(dx4BEjvq}b`OT^RqF$J4enP1YkeBK#>l1@-K`ajbn05`0J?0daOtnzh@l3^=BkedW1EahZlRp;`j*CaT;-21&f2wU z+Nh-gc4I36Cw+;3UAc<%ySb`#+c@5y ze~en&bYV|kn?Cn|@fqmGxgfz}U!98$=drjAkMi`43I4R%&H0GKEgx-=7PF}y`+j>r zg&JF`jomnu2G{%QV~Gf_-1gx<3Ky=Md9Q3VnK=;;u0lyTBCuf^aUi?+1+`4lLE6ZK zT#(Bf`5rmr(tgTbIt?yA@y`(Ar=f>-aZ}T~>G32EM%XyFvhn&@PWCm#-<&ApLDCXT zD#(9m|V(OOo7PmE@`vD4$S5;+9IQm19dd zvMEU`)E1_F+0o0-z>YCWqg0u8ciIknU#{q02{~YX)gc_u;8;i233D66pf(IkTDxeN zL=4z2)?S$TV9=ORVr&AkZMl<4tTh(v;Ix1{`pPVqI3n2ci&4Dg+W|N8TBUfZ*WeLF zqCH_1Q0W&f9T$lx3CFJ$o@Lz$99 zW!G&@zFHxTaP!o#z^~xgF|(vrHz8R_r9eo;TX9}2ZyjslrtH=%6O)?1?cL&BT(Amp zTGFU1%%#xl&6sH-UIJk_PGk_McFn7=%yd6tAjm|lnmr8bE2le3I~L{0(ffo}TQjyo zHZZI{-}{E4ohYTlZaS$blB!h$Jq^Rf#(ch}@S+Ww&$b);8+>g84IJcLU%B-W?+IY& zslcZIR>+U4v3O9RFEW;8NpCM0w1ROG84=WpKxQ^R`{=0MZCubg3st z48AyJNEvyxn-jCPTlTwp4EKvyEwD3e%kpdY?^BH0!3n6Eb57_L%J1=a*3>|k68A}v zaW`*4YitylfD}ua8V)vb79)N_Ixw_mpp}yJGbNu+5YYOP9K-7nf*jA1#<^rb4#AcS zKg%zCI)7cotx}L&J8Bqo8O1b0q;B1J#B5N5Z$Zq=wX~nQFgUfAE{@u0+EnmK{1hg> zC{vMfFLD;L8b4L+B51&LCm|scVLPe6h02rws@kGv@R+#IqE8>Xn8i|vRq_Z`V;x6F zNeot$1Zsu`lLS92QlLWF54za6vOEKGYQMdX($0JN*cjG7HP&qZ#3+bEN$8O_PfeAb z0R5;=zXac2IZ?fxu59?Nka;1lKm|;0)6|#RxkD05P5qz;*AL@ig!+f=lW5^Jbag%2 z%9@iM0ph$WFlxS!`p31t92z~TB}P-*CS+1Oo_g;7`6k(Jyj8m8U|Q3Sh7o-Icp4kV zK}%qri5>?%IPfamXIZ8pXbm-#{ytiam<{a5A+3dVP^xz!Pvirsq7Btv?*d7eYgx7q zWFxrzb3-%^lDgMc=Vl7^={=VDEKabTG?VWqOngE`Kt7hs236QKidsoeeUQ_^FzsXjprCDd@pW25rNx#6x&L6ZEpoX9Ffzv@olnH3rGOSW( zG-D|cV0Q~qJ>-L}NIyT?T-+x+wU%;+_GY{>t(l9dI%Ximm+Kmwhee;FK$%{dnF;C% zFjM2&$W68Sz#d*wtfX?*WIOXwT;P6NUw}IHdk|)fw*YnGa0rHx#paG!m=Y6GkS4VX zX`T$4eW9k1W!=q8!(#8A9h67fw))k_G)Q9~Q1e3f`aV@kbcSv7!priDUN}gX(iXTy zr$|kU0Vn%*ylmyDCO&G0Z3g>%JeEPFAW!5*H2Ydl>39w3W+gEUjL&vrRs(xGP{(ze zy7EMWF14@Qh>X>st8_029||TP0>7SG9on_xxeR2Iam3G~Em$}aGsNt$iES9zFa<3W zxtOF*!G@=PhfHO!=9pVPXMUVi30WmkPoy$02w}&6A7mF)G6-`~EVq5CwD2`9Zu`kd)52``#V zNSb`9dG~8(dooi1*-aSMf!fun7Sc`-C$-E(3BoSC$2kKrVcI!&yC*+ff2+C-@!AT_ zsvlAIV+%bRDfd{R*TMF><1&_a%@yZ0G0lg2K;F>7b+7A6pv3-S7qWIgx+Z?dt8}|S z>Qbb6x(+^aoV7FQ!Ph8|RUA6vXWQH*1$GJC+wXLXizNIc9p2yLzw9 z0=MdQ!{NnOwIICJc8!+Jp!zG}**r#E!<}&Te&}|B4q;U57$+pQI^}{qj669zMMe_I z&z0uUCqG%YwtUc8HVN7?0GHpu=bL7&{C>hcd5d(iFV{I5c~jpX&!(a{yS*4MEoYXh z*X4|Y@RVfn;piRm-C%b@{0R;aXrjBtvx^HO;6(>i*RnoG0Rtcd25BT6edxTNOgUAOjn zJ2)l{ipj8IP$KID2}*#F=M%^n&=bA0tY98@+2I+7~A&T-tw%W#3GV>GTmkHaqftl)#+E zMU*P(Rjo>8%P@_@#UNq(_L{}j(&-@1iY0TRizhiATJrnvwSH0v>lYfCI2ex^><3$q znzZgpW0JlQx?JB#0^^s-Js1}}wKh6f>(e%NrMwS`Q(FhazkZb|uyB@d%_9)_xb$6T zS*#-Bn)9gmobhAtvBmL+9H-+0_0US?g6^TOvE8f3v=z3o%NcPjOaf{5EMRnn(_z8- z$|m0D$FTU zDy;21v-#0i)9%_bZ7eo6B9@Q@&XprR&oKl4m>zIj-fiRy4Dqy@VVVs?rscG| zmzaDQ%>AQTi<^vYCmv#KOTd@l7#2VIpsj?nm_WfRZzJako`^uU%Nt3e;cU*y*|$7W zLm%fX#i_*HoUXu!NI$ey>BA<5HQB=|nRAwK!$L#n-Qz;~`zACig0PhAq#^5QS<8L2 zS3A+8%vbVMa7LOtTEM?55apt(DcWh#L}R^P2AY*c8B}Cx=6OFAdMPj1f>k3#^#+Hk z6uW1WJW&RlBRh*1DLb7mJ+KO>!t^t8hX1#_Wk`gjDio9)9IGbyCAGI4DJ~orK+YRv znjxRMtshZQHc$#Y-<-JOV6g^Cr@odj&Xw5B(FmI)*qJ9NHmIz_r{t)TxyB`L-%q5l ztzHgD;S6cw?7Atg*6E1!c6*gPRCb%t7D%z<(xm+K{%EJNiI2N0l8ud0Ch@_av_RW? zIr!nO4dL5466WslE6MsfMss7<)-S!e)2@r2o=7_W)OO`~CwklRWzHTfpB)_HYwgz=BzLhgZ9S<{nLBOwOIgJU=94uj6r!m>Xyn9>&xP+=5!zG_*yEoRgM0`aYts z^)&8(>z5C-QQ*o_s(8E4*?AX#S^0)aqB)OTyX>4BMy8h(cHjA8ji1PRlox@jB*1n? zDIfyDjzeg91Ao(;Q;KE@zei$}>EnrF6I}q&Xd=~&$WdDsyH0H7fJX|E+O~%LS*7^Q zYzZ4`pBdY{b7u72gZm6^5~O-57HwzwAz{)NvVaowo`X02tL3PpgLjwA`^i9F^vSpN zAqH3mRjG8VeJNHZ(1{%!XqC+)Z%D}58Qel{_weSEHoygT9pN@i zi=G;!Vj6XQk2tuJC>lza%ywz|`f7TIz*EN2Gdt!s199Dr4Tfd_%~fu8gXo~|ogt5Q zlEy_CXEe^BgsYM^o@L?s33WM14}7^T(kqohOX_iN@U?u;$l|rAvn{rwy>!yfZw13U zB@X9)qt&4;(C6dP?yRsoTMI!j-f1KC!<%~i1}u7yLXYn)(#a;Z6~r>hp~kfP));mi zcG%kdaB9H)z9M=H!f>kM->fTjRVOELNwh1amgKQT=I8J66kI)u_?0@$$~5f`u%;zl zC?pkr^p2Fe=J~WK%4ItSzKA+QHqJ@~m|Cduv=Q&-P8I5rQ-#G@bYH}YJr zUS(~(w|vKyU(T(*py}jTUp%I%{2!W!K(i$uvotcPjVddW z8_5HKY!oBCwGZcs-q`4Yt`Zk~>K?mcxg51wkZlX5e#B08I75F7#dgn5yf&Hrp`*%$ zQ;_Qg>TYRzBe$x=T(@WI9SC!ReSas9vDm(yslQjBJZde5z8GDU``r|N(MHcxNopGr z_}u39W_zwWDL*XYYt>#Xo!9kL#97|EAGyGBcRXtLTd59x%m=3i zL^9joWYA)HfL15l9%H?q`$mY27!<9$7GH(kxb%MV>`}hR4a?+*LH6aR{dzrX@?6X4 z3e`9L;cjqYb`cJmophbm(OX0b)!AFG?5`c#zLagzMW~o)?-!@e80lvk!p#&CD8u5_r&wp4O0zQ>y!k5U$h_K;rWGk=U)zX!#@Q%|9g*A zWx)qS1?fq6X<$mQTB$#3g;;5tHOYuAh;YKSBz%il3Ui6fPRv#v62SsrCdMRTav)Sg zTq1WOu&@v$Ey;@^+_!)cf|w_X<@RC>!=~+A1-65O0bOFYiH-)abINwZvFB;hJjL_$ z(9iScmUdMp2O$WW!520Hd0Q^Yj?DK%YgJD^ez$Z^?@9@Ab-=KgW@n8nC&88)TDC+E zlJM)L3r+ZJfZW_T$;Imq*#2<(j+FIk8ls7)WJ6CjUu#r5PoXxQs4b)mZza<8=v{o)VlLRM<9yw^0En#tXAj`Sylxvki{<1DPe^ zhjHwx^;c8tb?Vr$6ZB;$Ff$+3(*oinbwpN-#F)bTsXq@Sm?43MC#jQ~`F|twI=7oC zH4TJtu#;ngRA|Y~w5N=UfMZi?s0%ZmKUFTAye&6Y*y-%c1oD3yQ%IF2q2385Zl+=> zfz=o`Bedy|U;oxbyb^rB9ixG{Gb-{h$U0hVe`J;{ql!s_OJ_>>eoQn(G6h7+b^P48 zG<=Wg2;xGD-+d@UMZ!c;0>#3nws$9kIDkK13IfloGT@s14AY>&>>^#>`PT7GV$2Hp zN<{bN*ztlZu_%W=&3+=#3bE(mka6VoHEs~0BjZ$+=0`a@R$iaW)6>wp2w)=v2@|2d z%?34!+iOc5S@;AAC4hELWLH56RGxo4jw8MDMU0Wk2k_G}=Vo(>eRFo(g3@HjG|`H3 zm8b*dK=moM*oB<)*A$M9!!5o~4U``e)wxavm@O_R(`P|u%9^LGi(_%IF<6o;NLp*0 zKsfZ0#24GT8(G`i4UvoMh$^;kOhl?`0yNiyrC#HJH=tqOH^T_d<2Z+ zeN>Y9Zn!X4*DMCK^o75Zk2621bdmV7Rx@AX^alBG4%~;G_vUoxhfhFRlR&+3WwF^T zaL)8xPq|wCZoNT^>3J0K?e{J-kl+hu2rZI>CUv#-z&u@`hjeb+bBZ>bcciQVZ{SbW zez04s9oFEgc8Z+Kp{XFX`MVf-s&w9*dx7wLen(_@y34}Qz@&`$2+osqfxz4&d}{Ql z*g1ag00Gu+$C`0avds{Q65BfGsu9`_`dML*rX~hyWIe$T>CsPRoLIr%MTk3pJ^2zH1qub1MBzPG}PO;Wmav9w%F7?%l=xIf#LlP`! z_Nw;xBQY9anH5-c8A4mME}?{iewjz(Sq-29r{fV;Fc>fv%0!W@(+{={Xl-sJ6aMoc z)9Q+$bchoTGTyWU_oI19!)bD=IG&OImfy;VxNXoIO2hYEfO~MkE#IXTK(~?Z&!ae! zl8z{D&2PC$Q*OBC(rS~-*-GHNJ6AC$@eve>LB@Iq;jbBZj`wk4|LGogE||Ie=M5g= z9d`uYQ1^Sr_q2wmZE>w2WG)!F%^KiqyaDtIAct?}D~JP4shTJy5Bg+-(EA8aXaxbd~BKMtTf2iQ69jD1o* zZF9*S3!v-TdqwK$%&?91Sh2=e63;X0Lci@n7y3XOu2ofyL9^-I767eHESAq{m+@*r zbVDx!FQ|AjT;!bYsXv8ilQjy~Chiu&HNhFXt3R_6kMC8~ChEFqG@MWu#1Q1#=~#ix zrkHpJre_?#r=N0wv`-7cHHqU`phJX2M_^{H0~{VP79Dv{6YP)oA1&TSfKPEPZn2)G z9o{U1huZBLL;Tp_0OYw@+9z(jkrwIGdUrOhKJUbwy?WBt zlIK)*K0lQCY0qZ!$%1?3A#-S70F#YyUnmJF*`xx?aH5;gE5pe-15w)EB#nuf6B*c~ z8Z25NtY%6Wlb)bUA$w%HKs5$!Z*W?YKV-lE0@w^{4vw;J>=rn?u!rv$&eM+rpU6rc=j9>N2Op+C{D^mospMCjF2ZGhe4eADA#skp2EA26%p3Ex9wHW8l&Y@HX z$Qv)mHM}4*@M*#*ll5^hE9M^=q~eyWEai*P;4z<9ZYy!SlNE5nlc7gm;M&Q zKhKE4d*%A>^m0R?{N}y|i6i^k>^n4(wzKvlQeHq{l&JuFD~sTsdhs`(?lFK@Q{pU~ zb!M3c@*3IwN1RUOVjY5>uT+s-2QLWY z4T2>fiSn>>Fob+%B868-v9D@AfWr#M8eM6w#eAlhc#zk6jkLxGBGk`E3$!A@*am!R zy>29&ptYK6>cvP`b!syNp)Q$0UOW|-O@)8!?94GOYF_}+zlW%fCEl|Tep_zx05g6q z>tp47e-&R*hSNe{6{H!mL?+j$c^TXT{C&@T-xIaesNCl05 z9SLb@q&mSb)I{VXMaiWa3PWj=Ed!>*GwUe;^|uk=Pz$njNnfFY^MM>E?zqhf6^{}0 zx&~~dA5#}1ig~7HvOQ#;d9JZBeEQ+}-~v$at`m!(ai z$w(H&mWCC~;PQ1$%iuz3`>dWeb3_p}X>L2LK%2l59Tyc}4m0>9A!8rhoU3m>i2+hl zx?*qs*c^j}+WPs>&v1%1Ko8_ivAGIn@QK7A`hDz-Emkcgv2@wTbYhkiwX2l=xz*XG zaiNg+j4F-I>9v+LjosI-QECrtKjp&0T@xIMKVr+&)gyb4@b3y?2CA?=ooN zT#;rU86WLh(e@#mF*rk(NV-qSIZyr z$6!ZUmzD)%yO-ot`rw3rp6?*_l*@Z*IB0xn4|BGPWHNc-1ZUnNSMWmDh=EzWJRP`) zl%d%J613oXzh5;VY^XWJi{lB`f#u+ThvtP7 zq(HK<4>tw(=yzSBWtYO}XI`S1pMBe3!jFxBHIuwJ(@%zdQFi1Q_hU2eDuHqXte7Ki zOV55H2D6u#4oTfr7|u*3p75KF&jaLEDpxk!4*bhPc%mpfj)Us3XIG3 zIKMX^s^1wt8YK7Ky^UOG=w!o5e7W-<&c|fw2{;Q11vm@J{)@N3-p1U>!0~sKWHaL= zWV(0}1IIyt1p%=_-Fe5Kfzc71wg}`RDDntVZv;4!=&XXF-$48jS0Sc;eDy@Sg;+{A zFStc{dXT}kcIjMXb4F7MbX~2%i;UrBxm%qmLKb|2=?uPr00-$MEUIGR5+JG2l2Nq` zkM{{1RO_R)+8oQ6x&-^kCj)W8Z}TJjS*Wm4>hf+4#VJP)OBaDF%3pms7DclusBUw} z{ND#!*I6h85g6DzNvdAmnwWY{&+!KZM4DGzeHI?MR@+~|su0{y-5-nICz_MIT_#FE zm<5f3zlaKq!XyvY3H`9s&T};z!cK}G%;~!rpzk9-6L}4Rg7vXtKFsl}@sT#U#7)x- z7UWue5sa$R>N&b{J61&gvKcKlozH*;OjoDR+elkh|4bJ!_3AZNMOu?n9&|L>OTD78 z^i->ah_Mqc|Ev)KNDzfu1P3grBIM#%`QZqj5W{qu(HocQhjyS;UINoP`{J+DvV?|1 z_sw6Yr3z6%e7JKVDY<$P=M)dbk@~Yw9|2!Cw!io3%j92wTD!c^e9Vj+7VqXo3>u#= zv#M{HHJ=e$X5vQ>>ML?E8#UlmvJgTnb73{PSPTf*0)mcj6C z{KsfUbDK|F$E(k;ER%8HMdDi`=BfpZzP3cl5yJHu;v^o2FkHNk;cXc17tL8T!CsYI zfeZ6sw@;8ia|mY_AXjCS?kUfxdjDB28)~Tz1dGE|{VfBS9`0m2!m1yG?hR})er^pl4c@9Aq+|}ZlDaHL)K$O| z%9Jp-imI-Id0|(d5{v~w6mx)tUKfbuVD`xNt04Mry%M+jXzE>4(TBsx#&=@wT2Vh) z1yeEY&~17>0%P(eHP0HB^|7C+WJxQBTG$uyOWY@iDloRIb-Cf!p<{WQHR!422#F34 zG`v|#CJ^G}y9U*7jgTlD{D&y$Iv{6&PYG>{Ixg$pGk?lWrE#PJ8KunQC@}^6OP!|< zS;}p3to{S|uZz%kKe|;A0bL0XxPB&Q{J(9PyX`+Kr`k~r2}yP^ND{8!v7Q1&vtk& z2Y}l@J@{|2`oA%sxvM9i0V+8IXrZ4;tey)d;LZI70Kbim<4=WoTPZy=Yd|34v#$Kh zx|#YJ8s`J>W&jt#GcMpx84w2Z3ur-rK7gf-p5cE)=w1R2*|0mj12hvapuUWM0b~dG zMg9p8FmAZI@i{q~0@QuY44&mMUNXd7z>U58shA3o`p5eVLpq>+{(<3->DWuSFVZwC zxd50Uz(w~LxC4}bgag#q#NNokK@yNc+Q|Ap!u>Ddy+df>v;j@I12CDNN9do+0^n8p zMQs7X#+FVF0C5muGfN{r0|Nkql%BQT|K(DDNdR2pzM=_ea5+GO|J67`05AV92t@4l z0Qno0078PIHdaQGHZ~Scw!dzgqjK~3B7kf>BcP__&lLyU(cu3B^uLo%{j|Mb0NR)tkeT7Hcwp4O# z)yzu>cvG(d9~0a^)eZ;;%3ksk@F&1eEBje~ zW+-_s)&RgiweQc!otF>4%vbXKaOU41{!hw?|2`Ld3I8$&#WOsq>EG)1ANb!{N4z9@ zsU!bPG-~-bqCeIDzo^Q;gnucB{tRzm{ZH^Orphm2U+REA!*<*J6YQV83@&xoDl%#wnl5qcBqCcAF-vX5{30}(oJrnSH z{RY85hylK2dMOh2%oO1J8%)0?8TOL%rS8)+CsDv}aQ>4D)Jv+DLK)9gI^n-T^$)Tc zFPUD75qJm!Y-KBqj;JP4dV4 z`X{lGmn<)1IGz330}s}Jrjtf{(lnuuNHe5(ezA(pYa=1|Ff-LhPFK8 zyJh_b{yzu0yll6ZkpRzRjezyYivjyjW7QwO;@6X`m;2Apn2EK2!~7S}-*=;5*7K$B z`x(=!^?zgj(-`&ApZJXI09aDLXaT@<;CH=?fBOY5d|b~wBA@@p^K#nxr`)?i?SqTupI_PJ(A3cx`z~9mX_*)>L F{|7XC?P&l2 literal 0 HcmV?d00001 diff --git a/tests/main_android/gradle/wrapper/gradle-wrapper.properties b/tests/main_android/gradle/wrapper/gradle-wrapper.properties new file mode 100644 index 0000000..656c094 --- /dev/null +++ b/tests/main_android/gradle/wrapper/gradle-wrapper.properties @@ -0,0 +1,6 @@ +#Fri Mar 27 21:02:15 EDT 2020 +distributionBase=GRADLE_USER_HOME +distributionPath=wrapper/dists +zipStoreBase=GRADLE_USER_HOME +zipStorePath=wrapper/dists +distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip diff --git a/tests/main_android/gradlew b/tests/main_android/gradlew new file mode 100644 index 0000000..cccdd3d --- /dev/null +++ b/tests/main_android/gradlew @@ -0,0 +1,172 @@ +#!/usr/bin/env sh + +############################################################################## +## +## Gradle start up script for UN*X +## +############################################################################## + +# Attempt to set APP_HOME +# Resolve links: $0 may be a link +PRG="$0" +# Need this for relative symlinks. +while [ -h "$PRG" ] ; do + ls=`ls -ld "$PRG"` + link=`expr "$ls" : '.*-> \(.*\)$'` + if expr "$link" : '/.*' > /dev/null; then + PRG="$link" + else + PRG=`dirname "$PRG"`"/$link" + fi +done +SAVED="`pwd`" +cd "`dirname \"$PRG\"`/" >/dev/null +APP_HOME="`pwd -P`" +cd "$SAVED" >/dev/null + +APP_NAME="Gradle" +APP_BASE_NAME=`basename "$0"` + +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +DEFAULT_JVM_OPTS="" + +# Use the maximum available, or set MAX_FD != -1 to use that value. +MAX_FD="maximum" + +warn () { + echo "$*" +} + +die () { + echo + echo "$*" + echo + exit 1 +} + +# OS specific support (must be 'true' or 'false'). +cygwin=false +msys=false +darwin=false +nonstop=false +case "`uname`" in + CYGWIN* ) + cygwin=true + ;; + Darwin* ) + darwin=true + ;; + MINGW* ) + msys=true + ;; + NONSTOP* ) + nonstop=true + ;; +esac + +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar + +# Determine the Java command to use to start the JVM. +if [ -n "$JAVA_HOME" ] ; then + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then + # IBM's JDK on AIX uses strange locations for the executables + JAVACMD="$JAVA_HOME/jre/sh/java" + else + JAVACMD="$JAVA_HOME/bin/java" + fi + if [ ! -x "$JAVACMD" ] ; then + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." + fi +else + JAVACMD="java" + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. + +Please set the JAVA_HOME variable in your environment to match the +location of your Java installation." +fi + +# Increase the maximum file descriptors if we can. +if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then + MAX_FD_LIMIT=`ulimit -H -n` + if [ $? -eq 0 ] ; then + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then + MAX_FD="$MAX_FD_LIMIT" + fi + ulimit -n $MAX_FD + if [ $? -ne 0 ] ; then + warn "Could not set maximum file descriptor limit: $MAX_FD" + fi + else + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT" + fi +fi + +# For Darwin, add options to specify how the application appears in the dock +if $darwin; then + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\"" +fi + +# For Cygwin, switch paths to Windows format before running java +if $cygwin ; then + APP_HOME=`cygpath --path --mixed "$APP_HOME"` + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"` + JAVACMD=`cygpath --unix "$JAVACMD"` + + # We build the pattern for arguments to be converted via cygpath + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null` + SEP="" + for dir in $ROOTDIRSRAW ; do + ROOTDIRS="$ROOTDIRS$SEP$dir" + SEP="|" + done + OURCYGPATTERN="(^($ROOTDIRS))" + # Add a user-defined pattern to the cygpath arguments + if [ "$GRADLE_CYGPATTERN" != "" ] ; then + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)" + fi + # Now convert the arguments - kludge to limit ourselves to /bin/sh + i=0 + for arg in "$@" ; do + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -` + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option + + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"` + else + eval `echo args$i`="\"$arg\"" + fi + i=$((i+1)) + done + case $i in + (0) set -- ;; + (1) set -- "$args0" ;; + (2) set -- "$args0" "$args1" ;; + (3) set -- "$args0" "$args1" "$args2" ;; + (4) set -- "$args0" "$args1" "$args2" "$args3" ;; + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;; + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;; + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;; + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;; + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;; + esac +fi + +# Escape application args +save () { + for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done + echo " " +} +APP_ARGS=$(save "$@") + +# Collect all arguments for the java command, following the shell quoting and substitution rules +eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS" + +# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong +if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then + cd "$(dirname "$0")" +fi + +exec "$JAVACMD" "$@" diff --git a/tests/main_android/gradlew.bat b/tests/main_android/gradlew.bat new file mode 100644 index 0000000..f955316 --- /dev/null +++ b/tests/main_android/gradlew.bat @@ -0,0 +1,84 @@ +@if "%DEBUG%" == "" @echo off +@rem ########################################################################## +@rem +@rem Gradle startup script for Windows +@rem +@rem ########################################################################## + +@rem Set local scope for the variables with windows NT shell +if "%OS%"=="Windows_NT" setlocal + +set DIRNAME=%~dp0 +if "%DIRNAME%" == "" set DIRNAME=. +set APP_BASE_NAME=%~n0 +set APP_HOME=%DIRNAME% + +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script. +set DEFAULT_JVM_OPTS= + +@rem Find java.exe +if defined JAVA_HOME goto findJavaFromJavaHome + +set JAVA_EXE=java.exe +%JAVA_EXE% -version >NUL 2>&1 +if "%ERRORLEVEL%" == "0" goto init + +echo. +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:findJavaFromJavaHome +set JAVA_HOME=%JAVA_HOME:"=% +set JAVA_EXE=%JAVA_HOME%/bin/java.exe + +if exist "%JAVA_EXE%" goto init + +echo. +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% +echo. +echo Please set the JAVA_HOME variable in your environment to match the +echo location of your Java installation. + +goto fail + +:init +@rem Get command-line arguments, handling Windows variants + +if not "%OS%" == "Windows_NT" goto win9xME_args + +:win9xME_args +@rem Slurp the command line arguments. +set CMD_LINE_ARGS= +set _SKIP=2 + +:win9xME_args_slurp +if "x%~1" == "x" goto execute + +set CMD_LINE_ARGS=%* + +:execute +@rem Setup the command line + +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar + +@rem Execute Gradle +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS% + +:end +@rem End local scope for the variables with windows NT shell +if "%ERRORLEVEL%"=="0" goto mainEnd + +:fail +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of +rem the _cmd.exe /c_ return code! +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1 +exit /b 1 + +:mainEnd +if "%OS%"=="Windows_NT" endlocal + +:omega diff --git a/tests/main_android/proguard-android.txt b/tests/main_android/proguard-android.txt deleted file mode 100644 index dffe6e7..0000000 --- a/tests/main_android/proguard-android.txt +++ /dev/null @@ -1,56 +0,0 @@ -# This is a configuration file for ProGuard. -# http://proguard.sourceforge.net/index.html#manual/usage.html - --dontusemixedcaseclassnames --dontskipnonpubliclibraryclasses --verbose - -# Optimization is turned off by default. Dex does not like code run -# through the ProGuard optimize and preverify steps (and performs some -# of these optimizations on its own). --dontoptimize --dontpreverify -# Note that if you want to enable optimization, you cannot just -# include optimization flags in your own project configuration file; -# instead you will need to point to the -# "proguard-android-optimize.txt" file instead of this one from your -# project.properties file. - --keepattributes *Annotation* --keep public class com.google.vending.licensing.ILicensingService --keep public class com.android.vending.licensing.ILicensingService - --keepclasseswithmembernames class * { - native ; -} - -# keep setters in Views so that animations can still work. -# see http://proguard.sourceforge.net/manual/examples.html#beans --keepclassmembers public class * extends android.view.View { - void set*(***); - *** get*(); -} - -# We want to keep methods in Activity that could be used in the XML attribute onClick --keepclassmembers class * extends android.app.Activity { - public void *(android.view.View); -} - -# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations --keepclassmembers enum * { - public static **[] values(); - public static ** valueOf(java.lang.String); -} - --keep class * implements android.os.Parcelable { - public static final android.os.Parcelable$Creator *; -} - --keepclassmembers class **.R$* { - public static ; -} - -# The support library contains references to newer platform versions. -# Don't warn about those in case this app is linking against an older -# platform version. We know about them, and they are safe. --dontwarn android.support.** diff --git a/tests/main_android/settings.gradle b/tests/main_android/settings.gradle new file mode 100644 index 0000000..880ede1 --- /dev/null +++ b/tests/main_android/settings.gradle @@ -0,0 +1,2 @@ +include ':app' +rootProject.name='sjson-cpp Unit Tests' From d422520d5a70b9a9a127be77683d3f81157b4fa0 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 29 Mar 2020 15:35:35 -0400 Subject: [PATCH 060/285] fix: remove unnecessary argument --- make.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make.py b/make.py index 408d195..7f25b00 100644 --- a/make.py +++ b/make.py @@ -280,7 +280,7 @@ def do_tests_android(build_dir, args): # Restore working directory os.chdir(build_dir) -def do_tests_cmake(build_dir, ctest_exe, args): +def do_tests_cmake(ctest_exe, args): ctest_cmd = '"{}" --output-on-failure --parallel {}'.format(ctest_exe, args.num_threads) if platform.system() == 'Windows' or platform.system() == 'Darwin': From 71020e6660e9a6d5384667404bd5b01c3441d9a5 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 29 Mar 2020 15:44:08 -0400 Subject: [PATCH 061/285] fix: remove check which breaks VS+arm64 combination --- make.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/make.py b/make.py index 7f25b00..076514e 100644 --- a/make.py +++ b/make.py @@ -61,10 +61,6 @@ def parse_argv(): if not args.cpu: args.cpu = 'x64' - if not args.cpu in ['x86', 'x64']: - print('{} cpu architecture not in supported list [x86, x64] for {}'.format(args.cpu, platform.system())) - sys.exit(1) - if args.cpu == 'arm64': if not args.compiler in ['vs2017', 'vs2019', 'ios', 'android']: print('arm64 is only supported with VS2017, VS2019, Android, and iOS') From 5058e48ddfb7a6de0e311b620e4322809882d8fc Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 29 Mar 2020 23:13:09 -0400 Subject: [PATCH 062/285] chore: extend .editorconfig support to cmake files --- .editorconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.editorconfig b/.editorconfig index be3256d..2245211 100644 --- a/.editorconfig +++ b/.editorconfig @@ -5,7 +5,7 @@ end_of_line = lf insert_final_newline = true # Matches multiple files with brace expansion notation -[*.{cpp,h,py,txt,java}] +[*.{cpp,h,py,cmake,txt,java}] charset = utf-8 indent_style = tab indent_size = 4 From b23874d53d9383fab0ef450224b5b6d1ae4b15da Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 29 Mar 2020 23:14:17 -0400 Subject: [PATCH 063/285] chore: minor cleanup of make.py to make it consistent with other libs --- make.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/make.py b/make.py index 076514e..bb7c05a 100644 --- a/make.py +++ b/make.py @@ -54,6 +54,10 @@ def parse_argv(): print('iOS is only supported on OS X') sys.exit(1) + if args.unit_test: + print('Unit tests cannot run from the command line on iOS') + sys.exit(1) + if not args.cpu in ['arm64']: print('{} cpu architecture not in supported list [arm64] for iOS'.format(args.cpu)) sys.exit(1) @@ -182,6 +186,7 @@ def set_compiler_env(compiler, args): os.environ['CXX'] = 'g++-9' else: print('Unknown compiler: {}'.format(compiler)) + print('See help with: python make.py -help') sys.exit(1) def do_generate_solution(cmake_exe, build_dir, cmake_script_dir, args): @@ -195,7 +200,7 @@ def do_generate_solution(cmake_exe, build_dir, cmake_script_dir, args): extra_switches = ['--no-warn-unused-cli'] extra_switches.append('-DCPU_INSTRUCTION_SET:STRING={}'.format(cpu)) - if not platform.system() == 'Windows' and not platform.system() == 'Darwin': + if not platform.system() == 'Windows': extra_switches.append('-DCMAKE_BUILD_TYPE={}'.format(config.upper())) toolchain = get_toolchain(compiler, cmake_script_dir) @@ -321,7 +326,7 @@ def do_tests(build_dir, ctest_exe, args): print('Using config: {}'.format(args.config)) print('Using cpu: {}'.format(args.cpu)) - if not args.compiler == None: + if args.compiler: print('Using compiler: {}'.format(args.compiler)) print('Using {} threads'.format(args.num_threads)) @@ -332,3 +337,5 @@ def do_tests(build_dir, ctest_exe, args): if args.unit_test: do_tests(build_dir, ctest_exe, args) + + sys.exit(0) From 77b8a5d7974d033f1f6a6c3674595d64f355fa41 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 29 Mar 2020 23:14:38 -0400 Subject: [PATCH 064/285] fix: make sure release build has optimizations and debug symbols --- tests/main_android/app/build.gradle.in | 8 ++++++++ tests/main_android/app/src/main/cpp/CMakeLists.txt | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/tests/main_android/app/build.gradle.in b/tests/main_android/app/build.gradle.in index 1323119..ca59f4f 100644 --- a/tests/main_android/app/build.gradle.in +++ b/tests/main_android/app/build.gradle.in @@ -24,6 +24,14 @@ android { proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' debuggable = true signingConfig signingConfigs.debug + externalNativeBuild { + cmake { + // Because we want to debug 'release' builds, the 'debuggable' property above + // forces the build configuration to 'Debug' which disables optimizations. + // Force a release configutation anyway. + arguments '-DCMAKE_BUILD_TYPE=Release' + } + } } } externalNativeBuild { diff --git a/tests/main_android/app/src/main/cpp/CMakeLists.txt b/tests/main_android/app/src/main/cpp/CMakeLists.txt index 0a82eb5..503feff 100644 --- a/tests/main_android/app/src/main/cpp/CMakeLists.txt +++ b/tests/main_android/app/src/main/cpp/CMakeLists.txt @@ -20,8 +20,12 @@ file(GLOB_RECURSE ALL_MAIN_SOURCE_FILES LIST_DIRECTORIES false add_library(${PROJECT_NAME} SHARED ${ALL_TEST_SOURCE_FILES} ${ALL_MAIN_SOURCE_FILES}) +# Enable exceptions target_compile_options(${PROJECT_NAME} PRIVATE -fexceptions) +# Enable debug symbols +target_compile_options(${PROJECT_NAME} PRIVATE -g) + # Throw on failure to allow us to catch them and recover add_definitions(-DSJSON_CPP_ON_ASSERT_THROW) From 5f914eab5eec46e1ba51bcb3c5dfe145930028f2 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 30 Mar 2020 17:46:11 -0400 Subject: [PATCH 065/285] docs: minor clarification for Android instructions --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index bf1d9b3..537f274 100644 --- a/README.md +++ b/README.md @@ -73,7 +73,9 @@ For *Windows on ARM64*, the steps are identical to *x86 and x64* but you will ne ### Android -For *Android*, the steps are identical to *Windows, Linux, and OS X* but you also need to install *Android NDK 21* (or higher). The build uses `gradle` and `-unit_test` will deploy and run on the device when executed. +For *Android*, the steps are identical to *Windows, Linux, and OS X* but you also need to install *Android NDK 21* (or higher). The build uses `gradle` and `-unit_test` will deploy and run on the device when executed (make sure that the `adb` executable is in your `PATH` for this to work). + +*Android Studio v3.5* can be used to launch and debug. After running *CMake* to build and generate everything, the *Android Studio* projects can be found under the `./build` directory. ### iOS From 70fff12aa902d6400d81dd1ea4c78d1be4b3328a Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 1 Apr 2020 20:55:07 -0400 Subject: [PATCH 066/285] fix: remove unnecessary build type for OS X --- make.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/make.py b/make.py index bb7c05a..010fe8e 100644 --- a/make.py +++ b/make.py @@ -200,7 +200,7 @@ def do_generate_solution(cmake_exe, build_dir, cmake_script_dir, args): extra_switches = ['--no-warn-unused-cli'] extra_switches.append('-DCPU_INSTRUCTION_SET:STRING={}'.format(cpu)) - if not platform.system() == 'Windows': + if not platform.system() == 'Windows' and not platform.system() == 'Darwin': extra_switches.append('-DCMAKE_BUILD_TYPE={}'.format(config.upper())) toolchain = get_toolchain(compiler, cmake_script_dir) @@ -303,6 +303,7 @@ def do_tests(build_dir, ctest_exe, args): if __name__ == "__main__": args = parse_argv() + cmake_exe, ctest_exe = get_cmake_exes() # Set the SJSON_CPP_CMAKE_HOME environment variable to point to CMake From 523d64fefa5a3f48c01bde3bb8016eb128639472 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 1 Apr 2020 21:13:56 -0400 Subject: [PATCH 067/285] fix: various travis-ci warning fixes Removed deprecated 'sudo' key. Renamed deprecated 'matrix' key to 'jobs'. Add missing root 'os', defaulting to 'linux' and removed the 'os' key from linux jobs. --- .travis.yml | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/.travis.yml b/.travis.yml index 40d8088..4ebffad 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,56 +1,45 @@ +os: linux dist: xenial -sudo: required language: cpp -matrix: +jobs: include: # Linux gcc5 - - os: linux - env: COMPILER=gcc5 TOOLCHAIN=gcc PACKAGES="g++-5 g++-5-multilib g++-multilib" + - env: COMPILER=gcc5 TOOLCHAIN=gcc PACKAGES="g++-5 g++-5-multilib g++-multilib" # Linux gcc6 - - os: linux - env: COMPILER=gcc6 TOOLCHAIN=gcc PACKAGES="g++-6 g++-6-multilib g++-multilib" + - env: COMPILER=gcc6 TOOLCHAIN=gcc PACKAGES="g++-6 g++-6-multilib g++-multilib" # Linux gcc7 - - os: linux - env: COMPILER=gcc7 TOOLCHAIN=gcc PACKAGES="g++-7 g++-7-multilib g++-multilib" + - env: COMPILER=gcc7 TOOLCHAIN=gcc PACKAGES="g++-7 g++-7-multilib g++-multilib" # Linux gcc8 - - os: linux - env: COMPILER=gcc8 TOOLCHAIN=gcc PACKAGES="g++-8 g++-8-multilib g++-multilib" + - env: COMPILER=gcc8 TOOLCHAIN=gcc PACKAGES="g++-8 g++-8-multilib g++-multilib" # Linux gcc9 - - os: linux - env: COMPILER=gcc9 TOOLCHAIN=gcc PACKAGES="g++-9 g++-9-multilib g++-multilib" + - env: COMPILER=gcc9 TOOLCHAIN=gcc PACKAGES="g++-9 g++-9-multilib g++-multilib" # Linux clang4 - - os: linux - env: COMPILER=clang4 TOOLCHAIN=clang PACKAGES="clang-4.0 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + - env: COMPILER=clang4 TOOLCHAIN=clang PACKAGES="clang-4.0 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" # Linux clang5 - - os: linux - env: COMPILER=clang5 TOOLCHAIN=clang SONARCLOUD=1 PACKAGES="clang-5.0 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + - env: COMPILER=clang5 TOOLCHAIN=clang SONARCLOUD=1 PACKAGES="clang-5.0 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" addons: sonarcloud: organization: "nfrechette-github" # Linux clang6 - - os: linux - env: COMPILER=clang6 TOOLCHAIN=clang PACKAGES="clang-6.0 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + - env: COMPILER=clang6 TOOLCHAIN=clang PACKAGES="clang-6.0 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" # Linux clang7 - - os: linux - env: COMPILER=clang7 TOOLCHAIN=clang PACKAGES="clang-7 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + - env: COMPILER=clang7 TOOLCHAIN=clang PACKAGES="clang-7 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" # Linux clang8 - - os: linux - env: COMPILER=clang8 TOOLCHAIN=clang PACKAGES="clang-8 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + - env: COMPILER=clang8 TOOLCHAIN=clang PACKAGES="clang-8 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" # Linux clang9 - - os: linux - env: COMPILER=clang9 TOOLCHAIN=clang PACKAGES="clang-9 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + - env: COMPILER=clang9 TOOLCHAIN=clang PACKAGES="clang-9 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" # OS X xcode8 - os: osx From 83ebc22c48ae440029a9bb29cdd84a2856aab824 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 18 May 2020 21:58:53 -0400 Subject: [PATCH 068/285] chore: remove support for SJSON_CPP_CMAKE_HOME It isn't really useful since we should work with all reasonably recent cmake versions. --- README.md | 3 +-- make.py | 37 +++++++++++-------------------------- 2 files changed, 12 insertions(+), 28 deletions(-) diff --git a/README.md b/README.md index 537f274..c5e860f 100644 --- a/README.md +++ b/README.md @@ -62,8 +62,7 @@ This library is **100%** headers as such you just need to include them in your o 1. Install *CMake 3.2* or higher (*3.14* for Visual Studio 2019, or *3.10* on OS X with *Xcode 10*), *Python 2.7 or 3*, and the proper compiler for your platform. 2. Execute `git submodule update --init` to get the files of external submodules (e.g. Catch2). 3. Generate the IDE solution with: `python make.py` - The solution is generated under `./build` - Note that if you do not have CMake in your `PATH`, you should define the `SJSON_CPP_CMAKE_HOME` environment variable to something like `C:\Program Files\CMake`. + The solution is generated under `./build` 4. Build the IDE solution with: `python make.py -build` 5. Run the unit tests with: `python make.py -unit_test` diff --git a/make.py b/make.py index 010fe8e..d0850de 100644 --- a/make.py +++ b/make.py @@ -82,12 +82,6 @@ def parse_argv(): return args -def get_cmake_exes(): - if platform.system() == 'Windows': - return ('cmake.exe', 'ctest.exe') - else: - return ('cmake', 'ctest') - def get_generator(compiler, cpu): if compiler == None: return None @@ -189,7 +183,7 @@ def set_compiler_env(compiler, args): print('See help with: python make.py -help') sys.exit(1) -def do_generate_solution(cmake_exe, build_dir, cmake_script_dir, args): +def do_generate_solution(build_dir, cmake_script_dir, args): compiler = args.compiler cpu = args.cpu config = args.config @@ -214,7 +208,7 @@ def do_generate_solution(cmake_exe, build_dir, cmake_script_dir, args): # Generate IDE solution print('Generating build files ...') - cmake_cmd = '"{}" .. -DCMAKE_INSTALL_PREFIX="{}" {}'.format(cmake_exe, build_dir, ' '.join(extra_switches)) + cmake_cmd = 'cmake .. -DCMAKE_INSTALL_PREFIX="{}" {}'.format(build_dir, ' '.join(extra_switches)) cmake_generator = get_generator(compiler, cpu) if not cmake_generator: print('Using default generator') @@ -231,11 +225,11 @@ def do_generate_solution(cmake_exe, build_dir, cmake_script_dir, args): if result != 0: sys.exit(result) -def do_build(cmake_exe, args): +def do_build(args): config = args.config print('Building ...') - cmake_cmd = '"{}" --build .'.format(cmake_exe) + cmake_cmd = 'cmake --build .' if platform.system() == 'Windows': if args.compiler == 'android': cmake_cmd += ' --config {}'.format(config) @@ -281,8 +275,8 @@ def do_tests_android(build_dir, args): # Restore working directory os.chdir(build_dir) -def do_tests_cmake(ctest_exe, args): - ctest_cmd = '"{}" --output-on-failure --parallel {}'.format(ctest_exe, args.num_threads) +def do_tests_cmake(args): + ctest_cmd = 'ctest --output-on-failure --parallel {}'.format(args.num_threads) if platform.system() == 'Windows' or platform.system() == 'Darwin': ctest_cmd += ' -C {}'.format(args.config) @@ -293,26 +287,17 @@ def do_tests_cmake(ctest_exe, args): if result != 0: sys.exit(result) -def do_tests(build_dir, ctest_exe, args): +def do_tests(build_dir, args): print('Running unit tests ...') if args.compiler == 'android': do_tests_android(build_dir, args) else: - do_tests_cmake(ctest_exe, args) + do_tests_cmake(args) if __name__ == "__main__": args = parse_argv() - cmake_exe, ctest_exe = get_cmake_exes() - - # Set the SJSON_CPP_CMAKE_HOME environment variable to point to CMake - # otherwise we assume it is already in the user PATH - if 'SJSON_CPP_CMAKE_HOME' in os.environ: - cmake_home = os.environ['SJSON_CPP_CMAKE_HOME'] - cmake_exe = os.path.join(cmake_home, 'bin', cmake_exe) - ctest_exe = os.path.join(cmake_home, 'bin', ctest_exe) - build_dir = os.path.join(os.getcwd(), 'build') cmake_script_dir = os.path.join(os.getcwd(), 'cmake') @@ -331,12 +316,12 @@ def do_tests(build_dir, ctest_exe, args): print('Using compiler: {}'.format(args.compiler)) print('Using {} threads'.format(args.num_threads)) - do_generate_solution(cmake_exe, build_dir, cmake_script_dir, args) + do_generate_solution(build_dir, cmake_script_dir, args) if args.build: - do_build(cmake_exe, args) + do_build(args) if args.unit_test: - do_tests(build_dir, ctest_exe, args) + do_tests(build_dir, args) sys.exit(0) From d10b095251bd6090011a4ab4a466e6fa0d6d0ba5 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 18 May 2020 22:18:12 -0400 Subject: [PATCH 069/285] feat: add support for emscripten --- README.md | 5 ++ cmake/CMakePlatforms.cmake | 3 ++ make.py | 68 +++++++++++++++++------- tests/CMakeLists.txt | 2 + tests/main_emscripten/CMakeLists.txt | 48 +++++++++++++++++ tests/main_emscripten/main.cpp | 32 +++++++++++ tools/release_scripts/test_everything.py | 8 +++ 7 files changed, 146 insertions(+), 20 deletions(-) create mode 100644 tests/main_emscripten/CMakeLists.txt create mode 100644 tests/main_emscripten/main.cpp diff --git a/README.md b/README.md index c5e860f..8d3bcec 100644 --- a/README.md +++ b/README.md @@ -43,6 +43,7 @@ Unicode formats other than UTF-8 aren't supported. * OS X (Xcode 8.3, 9.4, 10.3, 11.2*) x86 and x64 * Android (NDK 21) ARMv7-A and ARM64 * iOS (Xcode 8.3, 9.4, 10.3) ARM64 +* Emscripten (1.39.11) WASM The above supported platform list is only what is tested every release but if it compiles, it should run just fine. @@ -80,6 +81,10 @@ For *Android*, the steps are identical to *Windows, Linux, and OS X* but you als For *iOS*, the steps are identical to the other platforms but due to code signing, you will need to perform the builds from *Xcode* manually. Note that this is only an issue if you attempt to use the tools or run the unit tests locally. +### Emscripten + +Emscripten support currently only has been tested on OS X and Linux. To use it, make sure to install a recent version of Emscripten SDK 1.39.11+. + ## Commit message format This library uses the [angular.js message format](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#commits) and it is enforced with commit linting through every pull request. diff --git a/cmake/CMakePlatforms.cmake b/cmake/CMakePlatforms.cmake index bfa33a7..8f88f16 100644 --- a/cmake/CMakePlatforms.cmake +++ b/cmake/CMakePlatforms.cmake @@ -21,6 +21,9 @@ elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux") elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Android") set(PLATFORM_ANDROID 1) set(PLATFORM_NAME "Android") +elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Emscripten") + set(PLATFORM_EMSCRIPTEN 1) + set(PLATFORM_NAME "Emscripten") else() message(FATAL_ERROR "Unknown platform ${CMAKE_SYSTEM_NAME}!") endif() diff --git a/make.py b/make.py index d0850de..bf70d5f 100644 --- a/make.py +++ b/make.py @@ -15,9 +15,9 @@ def parse_argv(): actions.add_argument('-unit_test', action='store_true') target = parser.add_argument_group(title='Target') - target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'vs2019-clang', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'osx', 'ios'], help='Defaults to the host system\'s default compiler') + target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'vs2019-clang', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'osx', 'ios', 'emscripten'], help='Defaults to the host system\'s default compiler') target.add_argument('-config', choices=['Debug', 'Release'], type=str.capitalize) - target.add_argument('-cpu', choices=['x86', 'x64', 'armv7', 'arm64'], help='Defaults to the host system\'s architecture') + target.add_argument('-cpu', choices=['x86', 'x64', 'armv7', 'arm64', 'wasm'], help='Defaults to the host system\'s architecture') misc = parser.add_argument_group(title='Miscellaneous') misc.add_argument('-num_threads', help='No. to use while compiling') @@ -61,6 +61,17 @@ def parse_argv(): if not args.cpu in ['arm64']: print('{} cpu architecture not in supported list [arm64] for iOS'.format(args.cpu)) sys.exit(1) + elif args.compiler == 'emscripten': + if not args.cpu: + args.cpu = 'wasm' + + if not platform.system() == 'Darwin' and not platform.system() == 'Linux': + print('Emscripten is only supported on OS X and Linux') + sys.exit(1) + + if not args.cpu in ['wasm']: + print('{} cpu architecture not in supported list [wasm] for Emscripten'.format(args.cpu)) + sys.exit(1) else: if not args.cpu: args.cpu = 'x64' @@ -73,6 +84,10 @@ def parse_argv(): if not args.compiler == 'android': print('armv7 is only supported with Android') sys.exit(1) + elif args.cpu == 'wasm': + if not args.compiler == 'emscripten': + print('wasm is only supported with Emscripten') + sys.exit(1) if platform.system() == 'Darwin' and args.cpu == 'x86': result = subprocess.check_output(['xcodebuild', '-version']).decode("utf-8") @@ -109,7 +124,14 @@ def get_generator(compiler, cpu): elif platform.system() == 'Darwin': if compiler == 'osx' or compiler == 'ios': return 'Xcode' - else: + elif compiler == 'emscripten': + # Emscripten uses the default generator + return None + elif platform.system() == 'Linux': + if compiler == 'emscripten': + # Emscripten uses the default generator + return None + return 'Unix Makefiles' print('Unknown compiler: {}'.format(compiler)) @@ -178,6 +200,9 @@ def set_compiler_env(compiler, args): elif compiler == 'gcc9': os.environ['CC'] = 'gcc-9' os.environ['CXX'] = 'g++-9' + elif compiler == 'emscripten': + # Nothing to do for Emscripten + return else: print('Unknown compiler: {}'.format(compiler)) print('See help with: python make.py -help') @@ -194,32 +219,35 @@ def do_generate_solution(build_dir, cmake_script_dir, args): extra_switches = ['--no-warn-unused-cli'] extra_switches.append('-DCPU_INSTRUCTION_SET:STRING={}'.format(cpu)) - if not platform.system() == 'Windows' and not platform.system() == 'Darwin': + if not platform.system() == 'Windows': extra_switches.append('-DCMAKE_BUILD_TYPE={}'.format(config.upper())) toolchain = get_toolchain(compiler, cmake_script_dir) if toolchain: extra_switches.append('-DCMAKE_TOOLCHAIN_FILE={}'.format(toolchain)) - generator_suffix = '' - if compiler == 'vs2019-clang': - extra_switches.append('-T ClangCL') - generator_suffix = 'Clang CL' - # Generate IDE solution print('Generating build files ...') - cmake_cmd = 'cmake .. -DCMAKE_INSTALL_PREFIX="{}" {}'.format(build_dir, ' '.join(extra_switches)) - cmake_generator = get_generator(compiler, cpu) - if not cmake_generator: - print('Using default generator') + if compiler == 'emscripten': + cmake_cmd = 'emcmake cmake .. -DCMAKE_INSTALL_PREFIX="{}" {}'.format(build_dir, ' '.join(extra_switches)) else: - print('Using generator: {} {}'.format(cmake_generator, generator_suffix)) - cmake_cmd += ' -G "{}"'.format(cmake_generator) - - cmake_arch = get_architecture(compiler, cpu) - if cmake_arch: - print('Using architecture: {}'.format(cmake_arch)) - cmake_cmd += ' -A {}'.format(cmake_arch) + cmake_cmd = 'cmake .. -DCMAKE_INSTALL_PREFIX="{}" {}'.format(build_dir, ' '.join(extra_switches)) + cmake_generator = get_generator(compiler, cpu) + if not cmake_generator: + print('Using default generator') + else: + generator_suffix = '' + if compiler == 'vs2019-clang': + extra_switches.append('-T ClangCL') + generator_suffix = 'Clang CL' + + print('Using generator: {} {}'.format(cmake_generator, generator_suffix)) + cmake_cmd += ' -G "{}"'.format(cmake_generator) + + cmake_arch = get_architecture(compiler, cpu) + if cmake_arch: + print('Using architecture: {}'.format(cmake_arch)) + cmake_cmd += ' -A {}'.format(cmake_arch) result = subprocess.call(cmake_cmd, shell=True) if result != 0: diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index df53b61..6ffef2c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -5,6 +5,8 @@ if(PLATFORM_ANDROID) add_subdirectory("${PROJECT_SOURCE_DIR}/main_android") elseif(PLATFORM_IOS) add_subdirectory("${PROJECT_SOURCE_DIR}/main_ios") +elseif(PLATFORM_EMSCRIPTEN) + add_subdirectory("${PROJECT_SOURCE_DIR}/main_emscripten") else() add_subdirectory("${PROJECT_SOURCE_DIR}/main_generic") endif() diff --git a/tests/main_emscripten/CMakeLists.txt b/tests/main_emscripten/CMakeLists.txt new file mode 100644 index 0000000..9eba55d --- /dev/null +++ b/tests/main_emscripten/CMakeLists.txt @@ -0,0 +1,48 @@ +cmake_minimum_required (VERSION 3.2) +project(sjson-cpp_unit_tests CXX) + +set(CMAKE_CXX_STANDARD 11) + +include_directories("${PROJECT_SOURCE_DIR}/../../includes") +include_directories("${PROJECT_SOURCE_DIR}/../../external/catch2/single_include/catch2") + +# Grab all of our test source files +file(GLOB_RECURSE ALL_TEST_SOURCE_FILES LIST_DIRECTORIES false + ${PROJECT_SOURCE_DIR}/../sources/*.h + ${PROJECT_SOURCE_DIR}/../sources/*.cpp) + +# Grab all of our main source files +file(GLOB_RECURSE ALL_MAIN_SOURCE_FILES LIST_DIRECTORIES false + ${PROJECT_SOURCE_DIR}/*.cpp) + +add_executable(${PROJECT_NAME} ${ALL_TEST_SOURCE_FILES} ${ALL_MAIN_SOURCE_FILES}) + +# Throw on failure to allow us to catch them and recover +add_definitions(-DSJSON_CPP_ON_ASSERT_THROW) + +target_compile_options(${PROJECT_NAME} PRIVATE -Wall -Wextra) # Enable all warnings +target_compile_options(${PROJECT_NAME} PRIVATE -Wshadow) # Enable shadowing warnings +target_compile_options(${PROJECT_NAME} PRIVATE -Werror) # Treat warnings as errors + +# Exceptions are not enabled by default, enable them +target_compile_options(${PROJECT_NAME} PRIVATE -fexceptions) +target_link_libraries(${PROJECT_NAME} "-s DISABLE_EXCEPTION_CATCHING=0") + +target_link_libraries(${PROJECT_NAME} "-s NODERAWFS=1") # Enable the raw node file system +target_link_libraries(${PROJECT_NAME} -lnodefs.js) # Link the node file system + +target_link_libraries(${PROJECT_NAME} "-s ENVIRONMENT=node") # Force the environment to node + +target_link_libraries(${PROJECT_NAME} "-s ALLOW_MEMORY_GROWTH=1") # Allow dynamic memory allocation + +# Setup Catch2 so we can find and execute the unit tests with CTest +set(OptionalCatchTestLauncher node) +list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/../../external/catch2/contrib") +include(CTest) +include(ParseAndAddCatchTests) +ParseAndAddCatchTests(${PROJECT_NAME}) + +install(FILES + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.js + ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.wasm + DESTINATION bin) diff --git a/tests/main_emscripten/main.cpp b/tests/main_emscripten/main.cpp new file mode 100644 index 0000000..6343f44 --- /dev/null +++ b/tests/main_emscripten/main.cpp @@ -0,0 +1,32 @@ +//////////////////////////////////////////////////////////////////////////////// +// The MIT License (MIT) +// +// Copyright (c) 2020 Nicholas Frechette, Cody Jones, and sjson-cpp contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +//////////////////////////////////////////////////////////////////////////////// + +#define CATCH_CONFIG_RUNNER +#include + +int main(int argc, char* argv[]) +{ + int result = Catch::Session().run(argc, argv); + return (result < 0xff ? result : 0xff); +} diff --git a/tools/release_scripts/test_everything.py b/tools/release_scripts/test_everything.py index bfbedf9..ddeaa7e 100644 --- a/tools/release_scripts/test_everything.py +++ b/tools/release_scripts/test_everything.py @@ -37,13 +37,21 @@ def get_python_exe_name(): if platform.system() == 'Windows': for config in configs: + # Windows ARM args = [python_exe, 'make.py', '-compiler', 'vs2017', '-cpu', 'arm64', '-config', config, '-build', '-clean'] cmd_args.append([x for x in args if x]) elif platform.system() == 'Darwin': for config in configs: + # iOS args = [python_exe, 'make.py', '-compiler', 'ios', '-config', config, '-build', '-clean'] cmd_args.append([x for x in args if x]) + if platform.system() == 'Darwin' or platform.system() == 'Linux': + for config in configs: + # Emscripten + args = [python_exe, 'make.py', '-compiler', 'emscripten', '-config', config, '-build', '-unit_test', '-clean'] + cmd_args.append([x for x in args if x]) + root_dir = os.path.join(os.getcwd(), '../..') os.chdir(root_dir) From d15894a3331f9f6dc790d396785f78e1bee96502 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 18 May 2020 22:20:06 -0400 Subject: [PATCH 070/285] feat: add github action to build and test emscripten --- .github/workflows/main.yml | 40 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 .github/workflows/main.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..66a923d --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,40 @@ +name: build + +on: [push, pull_request] + +jobs: + emscripten: + runs-on: ubuntu-latest + steps: + - name: Git checkout + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: Cache emsdk + uses: actions/cache@v1 + id: 'emsdk' + with: + path: 'emsdk-cache' + key: ${{ runner.os }}-emsdk-1.39.11 + - name: Setup emsdk + uses: mymindstorm/setup-emsdk@v4 + with: + version: 1.39.11 + no-cache: true + actions-cache-folder: 'emsdk-cache' + - name: Cache emsdk build artifacts + uses: actions/cache@v1 + id: 'emsdk-build-artifacts' + with: + path: '~/.emscripten_cache' + key: ${{ runner.os }}-emsdk-build-artifacts-1.39.11 + - name: Build (debug) + run: python3 make.py -compiler emscripten -config debug -build + - name: Unit tests (debug) + run: python3 make.py -compiler emscripten -config debug -unit_test + - name: Clean + run: python3 make.py -clean + - name: Build (release) + run: python3 make.py -compiler emscripten -config release -build + - name: Unit tests (release) + run: python3 make.py -compiler emscripten -config release -unit_test From d6300b20f13d7752c24f25a1e2094fa5ead44c7d Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 18 May 2020 22:22:00 -0400 Subject: [PATCH 071/285] chore: add badge for github actions build --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 8d3bcec..0f0bb6b 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,7 @@ [![CLA assistant](https://cla-assistant.io/readme/badge/nfrechette/sjson-cpp)](https://cla-assistant.io/nfrechette/sjson-cpp) [![Build status](https://ci.appveyor.com/api/projects/status/oynd3x3d9umjaruf/branch/develop?svg=true)](https://ci.appveyor.com/project/nfrechette/sjson-cpp) [![Build Status](https://travis-ci.org/nfrechette/sjson-cpp.svg?branch=develop)](https://travis-ci.org/nfrechette/sjson-cpp) +[![Build status](https://github.com/nfrechette/sjson-cpp/workflows/build/badge.svg)](https://github.com/nfrechette/sjson-cpp/actions) [![Sonar Status](https://sonarcloud.io/api/project_badges/measure?project=nfrechette_sjson-cpp&metric=alert_status)](https://sonarcloud.io/dashboard?id=nfrechette_sjson-cpp) [![GitHub (pre-)release](https://img.shields.io/github/release/nfrechette/sjson-cpp/all.svg)](https://github.com/nfrechette/sjson-cpp/releases) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nfrechette/sjson-cpp/master/LICENSE) From 43a5e72e51e38778e6f30c76f9da9827cff32875 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 6 Jun 2020 22:18:10 -0400 Subject: [PATCH 072/285] chore: add support for clang10 --- .travis.yml | 4 ++++ make.py | 5 ++++- tools/release_scripts/test_everything.py | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4ebffad..c159f49 100644 --- a/.travis.yml +++ b/.travis.yml @@ -41,6 +41,9 @@ jobs: # Linux clang9 - env: COMPILER=clang9 TOOLCHAIN=clang PACKAGES="clang-9 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + # Linux clang10 + - env: COMPILER=clang10 TOOLCHAIN=clang PACKAGES="clang-10 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + # OS X xcode8 - os: osx osx_image: xcode8.3 @@ -69,6 +72,7 @@ before_install: - if [[ "$COMPILER" == "clang7" ]]; then echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - if [[ "$COMPILER" == "clang8" ]]; then echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - if [[ "$COMPILER" == "clang9" ]]; then echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi + - if [[ "$COMPILER" == "clang10" ]]; then echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - 'if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test"; sudo -E apt-get -yq update; diff --git a/make.py b/make.py index bf70d5f..a8ba238 100644 --- a/make.py +++ b/make.py @@ -15,7 +15,7 @@ def parse_argv(): actions.add_argument('-unit_test', action='store_true') target = parser.add_argument_group(title='Target') - target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'vs2019-clang', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'osx', 'ios', 'emscripten'], help='Defaults to the host system\'s default compiler') + target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'vs2019-clang', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'clang10', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'osx', 'ios', 'emscripten'], help='Defaults to the host system\'s default compiler') target.add_argument('-config', choices=['Debug', 'Release'], type=str.capitalize) target.add_argument('-cpu', choices=['x86', 'x64', 'armv7', 'arm64', 'wasm'], help='Defaults to the host system\'s architecture') @@ -185,6 +185,9 @@ def set_compiler_env(compiler, args): elif compiler == 'clang9': os.environ['CC'] = 'clang-9' os.environ['CXX'] = 'clang++-9' + elif compiler == 'clang10': + os.environ['CC'] = 'clang-10' + os.environ['CXX'] = 'clang++-10' elif compiler == 'gcc5': os.environ['CC'] = 'gcc-5' os.environ['CXX'] = 'g++-5' diff --git a/tools/release_scripts/test_everything.py b/tools/release_scripts/test_everything.py index ddeaa7e..c5572a3 100644 --- a/tools/release_scripts/test_everything.py +++ b/tools/release_scripts/test_everything.py @@ -7,7 +7,7 @@ def get_platform_compilers(): if platform.system() == 'Windows': return [ 'vs2015', 'vs2017', 'vs2019' ] elif platform.system() == 'Linux': - return [ 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9' ] + return [ 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'clang10' ] elif platform.system() == 'Darwin': return [ 'osx' ] else: From eddf5ffee01a08b8b441c18d1263fa4cd3d9f999 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 6 Jun 2020 22:41:57 -0400 Subject: [PATCH 073/285] docs: update readme with clang10 mention --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0f0bb6b..01fa1fb 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ Unicode formats other than UTF-8 aren't supported. * Windows (VS2017, VS2019) x86, x64, and ARM64* * Windows VS2019 with clang9 x86 and x64 * Linux (gcc5, gcc6, gcc7, gcc8, gcc9) x86 and x64 -* Linux (clang4, clang5, clang6, clang7, clang8, clang9) x86 and x64 +* Linux (clang4, clang5, clang6, clang7, clang8, clang9, clang10) x86 and x64 * OS X (Xcode 8.3, 9.4, 10.3, 11.2*) x86 and x64 * Android (NDK 21) ARMv7-A and ARM64 * iOS (Xcode 8.3, 9.4, 10.3) ARM64 From 39dd8598b32f309da830bbd8b8b1adeb0e47f581 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 12 Jun 2020 17:24:25 -0400 Subject: [PATCH 074/285] chore: switch travis to Bionic Keep clang4 on Xenial since it isn't supported on Bionic --- .travis.yml | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/.travis.yml b/.travis.yml index c159f49..fde598b 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ os: linux -dist: xenial +dist: bionic language: cpp @@ -22,6 +22,7 @@ jobs: # Linux clang4 - env: COMPILER=clang4 TOOLCHAIN=clang PACKAGES="clang-4.0 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + dist: xenial # Linux clang5 - env: COMPILER=clang5 TOOLCHAIN=clang SONARCLOUD=1 PACKAGES="clang-5.0 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" @@ -67,12 +68,12 @@ jobs: before_install: - if [[ "$TOOLCHAIN" == "clang" ]]; then curl -sSL "http://apt.llvm.org/llvm-snapshot.gpg.key" | sudo -E apt-key add - ; fi - if [[ "$COMPILER" == "clang4" ]]; then echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-4.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - - if [[ "$COMPILER" == "clang5" ]]; then echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-5.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - - if [[ "$COMPILER" == "clang6" ]]; then echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-6.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - - if [[ "$COMPILER" == "clang7" ]]; then echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-7 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - - if [[ "$COMPILER" == "clang8" ]]; then echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-8 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - - if [[ "$COMPILER" == "clang9" ]]; then echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-9 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - - if [[ "$COMPILER" == "clang10" ]]; then echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-10 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi + - if [[ "$COMPILER" == "clang5" ]]; then echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-5.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi + - if [[ "$COMPILER" == "clang6" ]]; then echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-6.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi + - if [[ "$COMPILER" == "clang7" ]]; then echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-7 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi + - if [[ "$COMPILER" == "clang8" ]]; then echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi + - if [[ "$COMPILER" == "clang9" ]]; then echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi + - if [[ "$COMPILER" == "clang10" ]]; then echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - 'if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test"; sudo -E apt-get -yq update; From a96dc663644f1e344ad90464e84fc3c638257269 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 12 Jun 2020 17:24:51 -0400 Subject: [PATCH 075/285] chore: split commands to make sure we fail properly --- .travis.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.travis.yml b/.travis.yml index fde598b..4861a82 100644 --- a/.travis.yml +++ b/.travis.yml @@ -83,12 +83,16 @@ before_install: script: - 'if [[ "$NOX86" != "1" ]]; then python make.py -clean -build -unit_test -compiler ${COMPILER} -config Debug -cpu x86; + fi' + - 'if [[ "$NOX86" != "1" ]]; then python make.py -clean -build -unit_test -compiler ${COMPILER} -config Release -cpu x86; fi' - python make.py -clean -build -unit_test -compiler ${COMPILER} -config Debug -cpu x64 - python make.py -clean -build -unit_test -compiler ${COMPILER} -config Release -cpu x64 - 'if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then python make.py -clean -build -compiler ios -config Debug; + fi' + - 'if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then python make.py -clean -build -compiler ios -config Release; fi' # Only run sonarcloud on non-PRs From 9201acaaf62a2ff3d5e9b8f93cc1cfa69147a913 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 12 Jun 2020 17:25:37 -0400 Subject: [PATCH 076/285] chore: add support for GCC 10 --- .travis.yml | 3 +++ README.md | 2 +- make.py | 5 ++++- tools/release_scripts/test_everything.py | 2 +- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4861a82..c4bfda0 100644 --- a/.travis.yml +++ b/.travis.yml @@ -20,6 +20,9 @@ jobs: # Linux gcc9 - env: COMPILER=gcc9 TOOLCHAIN=gcc PACKAGES="g++-9 g++-9-multilib g++-multilib" + # Linux gcc10 + - env: COMPILER=gcc10 TOOLCHAIN=gcc PACKAGES="g++-10 g++-10-multilib g++-multilib" + # Linux clang4 - env: COMPILER=clang4 TOOLCHAIN=clang PACKAGES="clang-4.0 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" dist: xenial diff --git a/README.md b/README.md index 01fa1fb..28a8b1b 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ Unicode formats other than UTF-8 aren't supported. * Windows VS2015 x86 and x64 * Windows (VS2017, VS2019) x86, x64, and ARM64* * Windows VS2019 with clang9 x86 and x64 -* Linux (gcc5, gcc6, gcc7, gcc8, gcc9) x86 and x64 +* Linux (gcc5, gcc6, gcc7, gcc8, gcc9, gcc10) x86 and x64 * Linux (clang4, clang5, clang6, clang7, clang8, clang9, clang10) x86 and x64 * OS X (Xcode 8.3, 9.4, 10.3, 11.2*) x86 and x64 * Android (NDK 21) ARMv7-A and ARM64 diff --git a/make.py b/make.py index a8ba238..6103c89 100644 --- a/make.py +++ b/make.py @@ -15,7 +15,7 @@ def parse_argv(): actions.add_argument('-unit_test', action='store_true') target = parser.add_argument_group(title='Target') - target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'vs2019-clang', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'clang10', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'osx', 'ios', 'emscripten'], help='Defaults to the host system\'s default compiler') + target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'vs2019-clang', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'clang10', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'gcc10', 'osx', 'ios', 'emscripten'], help='Defaults to the host system\'s default compiler') target.add_argument('-config', choices=['Debug', 'Release'], type=str.capitalize) target.add_argument('-cpu', choices=['x86', 'x64', 'armv7', 'arm64', 'wasm'], help='Defaults to the host system\'s architecture') @@ -203,6 +203,9 @@ def set_compiler_env(compiler, args): elif compiler == 'gcc9': os.environ['CC'] = 'gcc-9' os.environ['CXX'] = 'g++-9' + elif compiler == 'gcc10': + os.environ['CC'] = 'gcc-10' + os.environ['CXX'] = 'g++-10' elif compiler == 'emscripten': # Nothing to do for Emscripten return diff --git a/tools/release_scripts/test_everything.py b/tools/release_scripts/test_everything.py index c5572a3..4cd4b5b 100644 --- a/tools/release_scripts/test_everything.py +++ b/tools/release_scripts/test_everything.py @@ -7,7 +7,7 @@ def get_platform_compilers(): if platform.system() == 'Windows': return [ 'vs2015', 'vs2017', 'vs2019' ] elif platform.system() == 'Linux': - return [ 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'clang10' ] + return [ 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'gcc10', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'clang10' ] elif platform.system() == 'Darwin': return [ 'osx' ] else: From cc08f4ce82cedd0cdaeff02722e8b361db514920 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 8 Jul 2020 21:57:14 -0400 Subject: [PATCH 077/285] feat: expose read_comma for custom array reading --- includes/sjson/parser.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/includes/sjson/parser.h b/includes/sjson/parser.h index 68d510f..926ed0d 100644 --- a/includes/sjson/parser.h +++ b/includes/sjson/parser.h @@ -328,6 +328,8 @@ namespace sjson return true; } + bool read_comma() { return read_symbol(',', ParserError::CommaExpected); } + bool remainder_is_comments_and_whitespace() { if (!skip_comments_and_whitespace()) @@ -396,7 +398,6 @@ namespace sjson bool read_closing_brace() { return read_symbol('}', ParserError::ClosingBraceExpected); } bool read_opening_bracket() { return read_symbol('[', ParserError::OpeningBracketExpected); } bool read_closing_bracket() { return read_symbol(']', ParserError::ClosingBracketExpected); } - bool read_comma() { return read_symbol(',', ParserError::CommaExpected); } bool read_symbol(char expected, int32_t reason_if_other_found) { From 57aa2f0025ff6b95cdc9c3d4431e274d82170c70 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Thu, 19 Nov 2020 14:22:35 -0500 Subject: [PATCH 078/285] chore: update emsdk setup action --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 66a923d..7a7c2f9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -17,7 +17,7 @@ jobs: path: 'emsdk-cache' key: ${{ runner.os }}-emsdk-1.39.11 - name: Setup emsdk - uses: mymindstorm/setup-emsdk@v4 + uses: mymindstorm/setup-emsdk@v7 with: version: 1.39.11 no-cache: true From 0ce5aa960485c6812dc21cadadbbc98d892f929a Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 1 Dec 2020 22:35:28 -0500 Subject: [PATCH 079/285] chore: add github actions to build with gcc --- .github/workflows/main.yml | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7a7c2f9..4c5e983 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,6 +3,24 @@ name: build on: [push, pull_request] jobs: + gcc: + runs-on: ubuntu-18.04 + strategy: + matrix: + compiler: [gcc5, gcc6, gcc7, gcc8, gcc9, gcc10] + flavor: [Debug, Release] + arch: [x86, x64] + steps: + - name: Git checkout + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: Setup compiler + run: ./tools/setup_compiler.sh + - name: Building ${{ matrix.flavor }}-${{ matrix.arch }} with ${{ matrix.compiler }} + run: python3 make.py -build -compiler ${{ matrix.compiler }} -config ${{ matrix.flavor }} -cpu ${{ matrix.arch }} + - name: Running unit tests + run: python3 make.py -unit_test -compiler ${{ matrix.compiler }} -config ${{ matrix.flavor }} -cpu ${{ matrix.arch }} emscripten: runs-on: ubuntu-latest steps: @@ -28,13 +46,13 @@ jobs: with: path: '~/.emscripten_cache' key: ${{ runner.os }}-emsdk-build-artifacts-1.39.11 - - name: Build (debug) + - name: Building (debug) run: python3 make.py -compiler emscripten -config debug -build - - name: Unit tests (debug) + - name: Running unit tests (debug) run: python3 make.py -compiler emscripten -config debug -unit_test - name: Clean run: python3 make.py -clean - - name: Build (release) + - name: Building (release) run: python3 make.py -compiler emscripten -config release -build - - name: Unit tests (release) + - name: Running unit tests (release) run: python3 make.py -compiler emscripten -config release -unit_test From 29b004e509e530b75be1e0793dc80a89068ed94b Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 1 Dec 2020 22:49:50 -0500 Subject: [PATCH 080/285] chore: add a script to setup the linux compiler --- tools/setup_linux_compiler.sh | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 tools/setup_linux_compiler.sh diff --git a/tools/setup_linux_compiler.sh b/tools/setup_linux_compiler.sh new file mode 100644 index 0000000..ae71ba4 --- /dev/null +++ b/tools/setup_linux_compiler.sh @@ -0,0 +1,24 @@ +#!/usr/bin/env bash + +# Extract our command line arguments +COMPILER=$1 + +# Convert our compiler into a list of packages it needs +if [[ $COMPILER == gcc5 ]]; then + PACKAGES=g++-5 g++-5-multilib g++-multilib +elif [[ $COMPILER == gcc6 ]]; then + PACKAGES=g++-6 g++-6-multilib g++-multilib +elif [[ $COMPILER == gcc7 ]]; then + PACKAGES=g++-7 g++-7-multilib g++-multilib +elif [[ $COMPILER == gcc8 ]]; then + PACKAGES=g++-8 g++-8-multilib g++-multilib +elif [[ $COMPILER == gcc9 ]]; then + PACKAGES=g++-9 g++-9-multilib g++-multilib +elif [[ $COMPILER == gcc10 ]]; then + PACKAGES=g++-10 g++-10-multilib g++-multilib +fi + +# Install the packages we need +sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test"; +sudo -E apt-get -yq update; +sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install $PACKAGES; From a3d516f7b0429d4771e873027e2c11c0e02ac62a Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 1 Dec 2020 22:51:03 -0500 Subject: [PATCH 081/285] chore: properly call the linux compiler setup script --- .github/workflows/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4c5e983..b7921ad 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,7 +16,7 @@ jobs: with: submodules: 'recursive' - name: Setup compiler - run: ./tools/setup_compiler.sh + run: ./tools/setup_linux_compiler.sh ${{ matrix.compiler }} - name: Building ${{ matrix.flavor }}-${{ matrix.arch }} with ${{ matrix.compiler }} run: python3 make.py -build -compiler ${{ matrix.compiler }} -config ${{ matrix.flavor }} -cpu ${{ matrix.arch }} - name: Running unit tests From 0bbdaf92271b9fa8adf9d58f6d805bcc3943cdab Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 1 Dec 2020 22:55:08 -0500 Subject: [PATCH 082/285] chore: make the setup_linux_compiler.sh script executable --- tools/setup_linux_compiler.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 tools/setup_linux_compiler.sh diff --git a/tools/setup_linux_compiler.sh b/tools/setup_linux_compiler.sh old mode 100644 new mode 100755 From 7fc39c16cf7d33ca5e1aacac7ca904acd1b6de35 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 1 Dec 2020 23:01:01 -0500 Subject: [PATCH 083/285] chore: convert bash variables to proper strings --- tools/setup_linux_compiler.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tools/setup_linux_compiler.sh b/tools/setup_linux_compiler.sh index ae71ba4..6d4c402 100755 --- a/tools/setup_linux_compiler.sh +++ b/tools/setup_linux_compiler.sh @@ -5,17 +5,17 @@ COMPILER=$1 # Convert our compiler into a list of packages it needs if [[ $COMPILER == gcc5 ]]; then - PACKAGES=g++-5 g++-5-multilib g++-multilib + PACKAGES="g++-5 g++-5-multilib g++-multilib" elif [[ $COMPILER == gcc6 ]]; then - PACKAGES=g++-6 g++-6-multilib g++-multilib + PACKAGES="g++-6 g++-6-multilib g++-multilib" elif [[ $COMPILER == gcc7 ]]; then - PACKAGES=g++-7 g++-7-multilib g++-multilib + PACKAGES="g++-7 g++-7-multilib g++-multilib" elif [[ $COMPILER == gcc8 ]]; then - PACKAGES=g++-8 g++-8-multilib g++-multilib + PACKAGES="g++-8 g++-8-multilib g++-multilib" elif [[ $COMPILER == gcc9 ]]; then - PACKAGES=g++-9 g++-9-multilib g++-multilib + PACKAGES="g++-9 g++-9-multilib g++-multilib" elif [[ $COMPILER == gcc10 ]]; then - PACKAGES=g++-10 g++-10-multilib g++-multilib + PACKAGES="g++-10 g++-10-multilib g++-multilib" fi # Install the packages we need From d14749df21643a21c4a65b3e30e5d4272d1b5514 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 1 Dec 2020 23:09:41 -0500 Subject: [PATCH 084/285] chore: simplify build matrix --- .github/workflows/main.yml | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index b7921ad..5f05c40 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,19 +8,35 @@ jobs: strategy: matrix: compiler: [gcc5, gcc6, gcc7, gcc8, gcc9, gcc10] - flavor: [Debug, Release] - arch: [x86, x64] steps: - name: Git checkout uses: actions/checkout@v2 with: submodules: 'recursive' - - name: Setup compiler + - name: Setup ${{ matrix.compiler }} compiler run: ./tools/setup_linux_compiler.sh ${{ matrix.compiler }} - - name: Building ${{ matrix.flavor }}-${{ matrix.arch }} with ${{ matrix.compiler }} - run: python3 make.py -build -compiler ${{ matrix.compiler }} -config ${{ matrix.flavor }} -cpu ${{ matrix.arch }} - - name: Running unit tests - run: python3 make.py -unit_test -compiler ${{ matrix.compiler }} -config ${{ matrix.flavor }} -cpu ${{ matrix.arch }} + - name: Building (debug-x86) + run: python3 make.py -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -build + - name: Running unit tests (debug-x86) + run: python3 make.py -compiler ${{ matrix.compiler }} -config Debug -cpu 86 -unit_test + - name: Clean + run: python3 make.py -clean + - name: Building (debug-x64) + run: python3 make.py -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -build + - name: Running unit tests (debug-x64) + run: python3 make.py -compiler ${{ matrix.compiler }} -config Debug -cpu 64 -unit_test + - name: Clean + run: python3 make.py -clean + - name: Building (release-x86) + run: python3 make.py -compiler ${{ matrix.compiler }} -config Release -cpu x86 -build + - name: Running unit tests (release-x86) + run: python3 make.py -compiler ${{ matrix.compiler }} -config Release -cpu 86 -unit_test + - name: Clean + run: python3 make.py -clean + - name: Building (release-x64) + run: python3 make.py -compiler ${{ matrix.compiler }} -config Release -cpu x64 -build + - name: Running unit tests (release-x64) + run: python3 make.py -compiler ${{ matrix.compiler }} -config Release -cpu 64 -unit_test emscripten: runs-on: ubuntu-latest steps: From c9dad853a765794c7b98229cb1b4944155d70563 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 1 Dec 2020 23:11:37 -0500 Subject: [PATCH 085/285] chore: fix typo --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5f05c40..79890b8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -18,25 +18,25 @@ jobs: - name: Building (debug-x86) run: python3 make.py -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -build - name: Running unit tests (debug-x86) - run: python3 make.py -compiler ${{ matrix.compiler }} -config Debug -cpu 86 -unit_test + run: python3 make.py -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -unit_test - name: Clean run: python3 make.py -clean - name: Building (debug-x64) run: python3 make.py -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -build - name: Running unit tests (debug-x64) - run: python3 make.py -compiler ${{ matrix.compiler }} -config Debug -cpu 64 -unit_test + run: python3 make.py -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -unit_test - name: Clean run: python3 make.py -clean - name: Building (release-x86) run: python3 make.py -compiler ${{ matrix.compiler }} -config Release -cpu x86 -build - name: Running unit tests (release-x86) - run: python3 make.py -compiler ${{ matrix.compiler }} -config Release -cpu 86 -unit_test + run: python3 make.py -compiler ${{ matrix.compiler }} -config Release -cpu x86 -unit_test - name: Clean run: python3 make.py -clean - name: Building (release-x64) run: python3 make.py -compiler ${{ matrix.compiler }} -config Release -cpu x64 -build - name: Running unit tests (release-x64) - run: python3 make.py -compiler ${{ matrix.compiler }} -config Release -cpu 64 -unit_test + run: python3 make.py -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test emscripten: runs-on: ubuntu-latest steps: From 9e2bb8a4ddf08bc613e88a06e017b050c36ed54e Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 1 Dec 2020 23:25:04 -0500 Subject: [PATCH 086/285] chore: add clang matrix and pin ubuntu version --- .github/workflows/main.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 79890b8..a8cbf01 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-18.04 strategy: matrix: - compiler: [gcc5, gcc6, gcc7, gcc8, gcc9, gcc10] + compiler: [gcc5, gcc6, gcc7, gcc8, gcc9, gcc10, clang4, clang5, clang6, clang7, clang8, clang9, clang10] steps: - name: Git checkout uses: actions/checkout@v2 @@ -38,7 +38,7 @@ jobs: - name: Running unit tests (release-x64) run: python3 make.py -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test emscripten: - runs-on: ubuntu-latest + runs-on: ubuntu-18.04 steps: - name: Git checkout uses: actions/checkout@v2 From 0469a12530bbff909162409fbe2a5b31c5c2a5ae Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 1 Dec 2020 23:25:33 -0500 Subject: [PATCH 087/285] chore: update script with clang requirements --- tools/setup_linux_compiler.sh | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/tools/setup_linux_compiler.sh b/tools/setup_linux_compiler.sh index 6d4c402..89cf67c 100755 --- a/tools/setup_linux_compiler.sh +++ b/tools/setup_linux_compiler.sh @@ -3,7 +3,7 @@ # Extract our command line arguments COMPILER=$1 -# Convert our compiler into a list of packages it needs +# Convert our GCC compiler into a list of packages it needs if [[ $COMPILER == gcc5 ]]; then PACKAGES="g++-5 g++-5-multilib g++-multilib" elif [[ $COMPILER == gcc6 ]]; then @@ -18,6 +18,36 @@ elif [[ $COMPILER == gcc10 ]]; then PACKAGES="g++-10 g++-10-multilib g++-multilib" fi +# If using clang, add our apt source key +if [[ $COMPILER == clang* ]]; then + curl -sSL "http://apt.llvm.org/llvm-snapshot.gpg.key" | sudo -E apt-key add - ; +fi + +# Convert our clang compiler into a list of packages it needs and its source +if [[ $COMPILER == clang4 ]]; then + # clang4 isn't available after xenial + PACKAGES="clang-4.0 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-4.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; +elif [[ $COMPILER == clang5 ]]; then + PACKAGES="clang-5.0 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-5.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; +elif [[ $COMPILER == clang6 ]]; then + PACKAGES="clang-6.0 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-6.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; +elif [[ $COMPILER == clang7 ]]; then + PACKAGES="clang-7 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-7 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; +elif [[ $COMPILER == clang8 ]]; then + PACKAGES="clang-8 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; +elif [[ $COMPILER == clang9 ]]; then + PACKAGES="clang-9 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; +elif [[ $COMPILER == clang10 ]]; then + PACKAGES="clang-10 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; +fi + # Install the packages we need sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test"; sudo -E apt-get -yq update; From 3b03363539c3bc0889133cf657d447723b8ca201 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 1 Dec 2020 23:34:04 -0500 Subject: [PATCH 088/285] chore: add ability to perform only a clean operation --- make.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/make.py b/make.py index 6103c89..6a23e88 100644 --- a/make.py +++ b/make.py @@ -12,6 +12,7 @@ def parse_argv(): actions = parser.add_argument_group(title='Actions', description='If no action is specified, on Windows, OS X, and Linux the solution/make files are generated. Multiple actions can be used simultaneously.') actions.add_argument('-build', action='store_true') actions.add_argument('-clean', action='store_true') + actions.add_argument('-clean_only', action='store_true') actions.add_argument('-unit_test', action='store_true') target = parser.add_argument_group(title='Target') @@ -30,7 +31,7 @@ def parse_argv(): if not num_threads or num_threads == 0: num_threads = 4 - parser.set_defaults(build=False, clean=False, unit_test=False, compiler=None, config='Release', cpu=None, num_threads=num_threads, tests_matching='') + parser.set_defaults(build=False, clean=False, clean_only=False, unit_test=False, compiler=None, config='Release', cpu=None, num_threads=num_threads, tests_matching='') args = parser.parse_args() @@ -335,10 +336,14 @@ def do_tests(build_dir, args): build_dir = os.path.join(os.getcwd(), 'build') cmake_script_dir = os.path.join(os.getcwd(), 'cmake') - if args.clean and os.path.exists(build_dir): + is_clean_requested = args.clean or args.clean_only + if is_clean_requested and os.path.exists(build_dir): print('Cleaning previous build ...') shutil.rmtree(build_dir) + if args.clean_only: + sys.exit(0) + if not os.path.exists(build_dir): os.makedirs(build_dir) From 8160eea823a36328598762ec0da6bea445a134ea Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 1 Dec 2020 23:36:27 -0500 Subject: [PATCH 089/285] chore: change cleaning method for safety --- .github/workflows/main.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a8cbf01..f24a312 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -20,19 +20,19 @@ jobs: - name: Running unit tests (debug-x86) run: python3 make.py -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -unit_test - name: Clean - run: python3 make.py -clean + run: python3 make.py -clean_only - name: Building (debug-x64) run: python3 make.py -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -build - name: Running unit tests (debug-x64) run: python3 make.py -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -unit_test - name: Clean - run: python3 make.py -clean + run: python3 make.py -clean_only - name: Building (release-x86) run: python3 make.py -compiler ${{ matrix.compiler }} -config Release -cpu x86 -build - name: Running unit tests (release-x86) run: python3 make.py -compiler ${{ matrix.compiler }} -config Release -cpu x86 -unit_test - name: Clean - run: python3 make.py -clean + run: python3 make.py -clean_only - name: Building (release-x64) run: python3 make.py -compiler ${{ matrix.compiler }} -config Release -cpu x64 -build - name: Running unit tests (release-x64) @@ -67,7 +67,7 @@ jobs: - name: Running unit tests (debug) run: python3 make.py -compiler emscripten -config debug -unit_test - name: Clean - run: python3 make.py -clean + run: python3 make.py -clean_only - name: Building (release) run: python3 make.py -compiler emscripten -config release -build - name: Running unit tests (release) From 400c92b33484f861dd66435b37f74793985ed974 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 1 Dec 2020 23:53:15 -0500 Subject: [PATCH 090/285] chore: remove gcc and clang from travis --- .travis.yml | 43 ------------------------------------------- 1 file changed, 43 deletions(-) diff --git a/.travis.yml b/.travis.yml index c4bfda0..7feb4e5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -5,49 +5,12 @@ language: cpp jobs: include: - # Linux gcc5 - - env: COMPILER=gcc5 TOOLCHAIN=gcc PACKAGES="g++-5 g++-5-multilib g++-multilib" - - # Linux gcc6 - - env: COMPILER=gcc6 TOOLCHAIN=gcc PACKAGES="g++-6 g++-6-multilib g++-multilib" - - # Linux gcc7 - - env: COMPILER=gcc7 TOOLCHAIN=gcc PACKAGES="g++-7 g++-7-multilib g++-multilib" - - # Linux gcc8 - - env: COMPILER=gcc8 TOOLCHAIN=gcc PACKAGES="g++-8 g++-8-multilib g++-multilib" - - # Linux gcc9 - - env: COMPILER=gcc9 TOOLCHAIN=gcc PACKAGES="g++-9 g++-9-multilib g++-multilib" - - # Linux gcc10 - - env: COMPILER=gcc10 TOOLCHAIN=gcc PACKAGES="g++-10 g++-10-multilib g++-multilib" - - # Linux clang4 - - env: COMPILER=clang4 TOOLCHAIN=clang PACKAGES="clang-4.0 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" - dist: xenial - # Linux clang5 - env: COMPILER=clang5 TOOLCHAIN=clang SONARCLOUD=1 PACKAGES="clang-5.0 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" addons: sonarcloud: organization: "nfrechette-github" - # Linux clang6 - - env: COMPILER=clang6 TOOLCHAIN=clang PACKAGES="clang-6.0 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" - - # Linux clang7 - - env: COMPILER=clang7 TOOLCHAIN=clang PACKAGES="clang-7 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" - - # Linux clang8 - - env: COMPILER=clang8 TOOLCHAIN=clang PACKAGES="clang-8 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" - - # Linux clang9 - - env: COMPILER=clang9 TOOLCHAIN=clang PACKAGES="clang-9 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" - - # Linux clang10 - - env: COMPILER=clang10 TOOLCHAIN=clang PACKAGES="clang-10 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" - # OS X xcode8 - os: osx osx_image: xcode8.3 @@ -70,13 +33,7 @@ jobs: before_install: - if [[ "$TOOLCHAIN" == "clang" ]]; then curl -sSL "http://apt.llvm.org/llvm-snapshot.gpg.key" | sudo -E apt-key add - ; fi - - if [[ "$COMPILER" == "clang4" ]]; then echo "deb http://apt.llvm.org/xenial/ llvm-toolchain-xenial-4.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - if [[ "$COMPILER" == "clang5" ]]; then echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-5.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - - if [[ "$COMPILER" == "clang6" ]]; then echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-6.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - - if [[ "$COMPILER" == "clang7" ]]; then echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-7 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - - if [[ "$COMPILER" == "clang8" ]]; then echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-8 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - - if [[ "$COMPILER" == "clang9" ]]; then echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - - if [[ "$COMPILER" == "clang10" ]]; then echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - 'if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test"; sudo -E apt-get -yq update; From 30ffb32052cb344a718e8767dd6832556270bed5 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 2 Dec 2020 17:49:35 -0500 Subject: [PATCH 091/285] fix: use do/while(false) with assert macros to avoid fallthrough --- includes/sjson/error.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/sjson/error.h b/includes/sjson/error.h index 58b5ff8..6560598 100644 --- a/includes/sjson/error.h +++ b/includes/sjson/error.h @@ -88,7 +88,7 @@ } } - #define SJSON_CPP_ASSERT(expression, format, ...) if (!(expression)) sjson::error_impl::on_assert_abort(#expression, __LINE__, __FILE__, (format), ## __VA_ARGS__) + #define SJSON_CPP_ASSERT(expression, format, ...) do { if (!(expression)) sjson::error_impl::on_assert_abort(#expression, __LINE__, __FILE__, (format), ## __VA_ARGS__); } while (false) #define SJSON_CPP_HAS_ASSERT_CHECKS #elif defined(SJSON_CPP_ON_ASSERT_THROW) @@ -133,13 +133,13 @@ } } - #define SJSON_CPP_ASSERT(expression, format, ...) if (!(expression)) sjson::error_impl::on_assert_throw(#expression, __LINE__, __FILE__, (format), ## __VA_ARGS__) + #define SJSON_CPP_ASSERT(expression, format, ...) do { if (!(expression)) sjson::error_impl::on_assert_throw(#expression, __LINE__, __FILE__, (format), ## __VA_ARGS__); } while(false) #define SJSON_CPP_HAS_ASSERT_CHECKS #elif defined(SJSON_CPP_ON_ASSERT_CUSTOM) #if !defined(SJSON_CPP_ASSERT) - #define SJSON_CPP_ASSERT(expression, format, ...) if (!(expression)) SJSON_CPP_ON_ASSERT_CUSTOM(#expression, __LINE__, __FILE__, (format), ## __VA_ARGS__) + #define SJSON_CPP_ASSERT(expression, format, ...) do { if (!(expression)) SJSON_CPP_ON_ASSERT_CUSTOM(#expression, __LINE__, __FILE__, (format), ## __VA_ARGS__); } while(false) #endif #define SJSON_CPP_HAS_ASSERT_CHECKS From cd624e6b32901ca3e69b509b2409e4598d9ec274 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 2 Dec 2020 18:16:50 -0500 Subject: [PATCH 092/285] chore: add xcode compiler setup script --- tools/setup_osx_compiler.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100755 tools/setup_osx_compiler.sh diff --git a/tools/setup_osx_compiler.sh b/tools/setup_osx_compiler.sh new file mode 100755 index 0000000..6120fc2 --- /dev/null +++ b/tools/setup_osx_compiler.sh @@ -0,0 +1,17 @@ +#!/usr/bin/env bash + +# Extract our command line arguments +COMPILER=$1 + +# Convert our compiler string into our XCode path +# Paths must match Github Action virtual images +if [[ $COMPILER == xcode10 ]]; then + XCODE_PATH="/Applications/Xcode_10.3.app" +elif [[ $COMPILER == xcode11 ]]; then + XCODE_PATH="/Applications/Xcode_11.7.app" +elif [[ $COMPILER == xcode12 ]]; then + XCODE_PATH="/Applications/Xcode_12.3.app" +fi + +# Select our XCode version +sudo xcode-select -s $XCODE_PATH/Contents/Developer; From 69655612089afdb29bda9fecf23fb66837de1fed Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 2 Dec 2020 18:21:40 -0500 Subject: [PATCH 093/285] chore: add xcode10/11 to github action build --- .github/workflows/main.yml | 51 +++++++++++++++++++++++++++++++++++++- 1 file changed, 50 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index f24a312..7c75178 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -3,7 +3,7 @@ name: build on: [push, pull_request] jobs: - gcc: + linux: runs-on: ubuntu-18.04 strategy: matrix: @@ -37,6 +37,55 @@ jobs: run: python3 make.py -compiler ${{ matrix.compiler }} -config Release -cpu x64 -build - name: Running unit tests (release-x64) run: python3 make.py -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test + osx: + runs-on: macos-10.15 + strategy: + matrix: + compiler: [xcode10, xcode11] + steps: + - name: Git checkout + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: Building (debug-x86) + if: ${{ matrix.compiler == xcode10 }} + run: python3 make.py -compiler osx -config Debug -cpu x86 -build + - name: Running unit tests (debug-x86) + if: ${{ matrix.compiler == xcode10 }} + run: python3 make.py -compiler osx -config Debug -cpu x86 -unit_test + - name: Clean + if: ${{ matrix.compiler == xcode10 }} + run: python3 make.py -clean_only + - name: Building (debug-x64) + if: ${{ matrix.compiler == xcode10 }} + run: python3 make.py -compiler osx -config Debug -cpu x64 -build + - name: Running unit tests (debug-x64) + if: ${{ matrix.compiler == xcode10 }} + run: python3 make.py -compiler osx -config Debug -cpu x64 -unit_test + - name: Clean + if: ${{ matrix.compiler == xcode10 }} + run: python3 make.py -clean_only + - name: Building (release-x86) + if: ${{ matrix.compiler == xcode10 }} + run: python3 make.py -compiler osx -config Release -cpu x86 -build + - name: Running unit tests (release-x86) + if: ${{ matrix.compiler == xcode10 }} + run: python3 make.py -compiler osx -config Release -cpu x86 -unit_test + - name: Clean + if: ${{ matrix.compiler == xcode10 }} + run: python3 make.py -clean_only + - name: Building (release-x64) + run: python3 make.py -compiler osx -config Release -cpu x64 -build + - name: Running unit tests (release-x64) + run: python3 make.py -compiler osx -config Release -cpu x64 -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building for iOS (debug-arm64) + run: python3 make.py -compiler ios -config Debug -build + - name: Clean + run: python3 make.py -clean_only + - name: Building for iOS (release-arm64) + run: python3 make.py -compiler ios -config Release -build emscripten: runs-on: ubuntu-18.04 steps: From fc9ff2617d27f0911fdf43c608649d896b817036 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 2 Dec 2020 18:23:02 -0500 Subject: [PATCH 094/285] chore: add missing quotations --- .github/workflows/main.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 7c75178..242faf0 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -48,31 +48,31 @@ jobs: with: submodules: 'recursive' - name: Building (debug-x86) - if: ${{ matrix.compiler == xcode10 }} + if: ${{ matrix.compiler == 'xcode10' }} run: python3 make.py -compiler osx -config Debug -cpu x86 -build - name: Running unit tests (debug-x86) - if: ${{ matrix.compiler == xcode10 }} + if: ${{ matrix.compiler == 'xcode10' }} run: python3 make.py -compiler osx -config Debug -cpu x86 -unit_test - name: Clean - if: ${{ matrix.compiler == xcode10 }} + if: ${{ matrix.compiler == 'xcode10' }} run: python3 make.py -clean_only - name: Building (debug-x64) - if: ${{ matrix.compiler == xcode10 }} + if: ${{ matrix.compiler == 'xcode10' }} run: python3 make.py -compiler osx -config Debug -cpu x64 -build - name: Running unit tests (debug-x64) - if: ${{ matrix.compiler == xcode10 }} + if: ${{ matrix.compiler == 'xcode10' }} run: python3 make.py -compiler osx -config Debug -cpu x64 -unit_test - name: Clean - if: ${{ matrix.compiler == xcode10 }} + if: ${{ matrix.compiler == 'xcode10' }} run: python3 make.py -clean_only - name: Building (release-x86) - if: ${{ matrix.compiler == xcode10 }} + if: ${{ matrix.compiler == 'xcode10' }} run: python3 make.py -compiler osx -config Release -cpu x86 -build - name: Running unit tests (release-x86) - if: ${{ matrix.compiler == xcode10 }} + if: ${{ matrix.compiler == 'xcode10' }} run: python3 make.py -compiler osx -config Release -cpu x86 -unit_test - name: Clean - if: ${{ matrix.compiler == xcode10 }} + if: ${{ matrix.compiler == 'xcode10' }} run: python3 make.py -clean_only - name: Building (release-x64) run: python3 make.py -compiler osx -config Release -cpu x64 -build From 95314dfe9f3ddaa79830a40ae345cf44834c5db4 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 2 Dec 2020 18:29:21 -0500 Subject: [PATCH 095/285] chore: add osx compiler selection --- .github/workflows/main.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 242faf0..188e9d6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -47,6 +47,8 @@ jobs: uses: actions/checkout@v2 with: submodules: 'recursive' + - name: Setup ${{ matrix.compiler }} compiler + run: ./tools/setup_osx_compiler.sh ${{ matrix.compiler }} - name: Building (debug-x86) if: ${{ matrix.compiler == 'xcode10' }} run: python3 make.py -compiler osx -config Debug -cpu x86 -build @@ -57,13 +59,10 @@ jobs: if: ${{ matrix.compiler == 'xcode10' }} run: python3 make.py -clean_only - name: Building (debug-x64) - if: ${{ matrix.compiler == 'xcode10' }} run: python3 make.py -compiler osx -config Debug -cpu x64 -build - name: Running unit tests (debug-x64) - if: ${{ matrix.compiler == 'xcode10' }} run: python3 make.py -compiler osx -config Debug -cpu x64 -unit_test - name: Clean - if: ${{ matrix.compiler == 'xcode10' }} run: python3 make.py -clean_only - name: Building (release-x86) if: ${{ matrix.compiler == 'xcode10' }} From 229ab2ad62bc5607227ec29a820f111b014657e3 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 5 Dec 2020 19:13:51 -0500 Subject: [PATCH 096/285] chore: remove xcode from travis builds and clean sonarcloud build --- .travis.yml | 34 ---------------------------------- 1 file changed, 34 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7feb4e5..b4086df 100644 --- a/.travis.yml +++ b/.travis.yml @@ -11,26 +11,6 @@ jobs: sonarcloud: organization: "nfrechette-github" - # OS X xcode8 - - os: osx - osx_image: xcode8.3 - env: COMPILER=osx TOOLCHAIN=xcode - - # OS X xcode9 - - os: osx - osx_image: xcode9.4 - env: COMPILER=osx TOOLCHAIN=xcode - - # OS X xcode10 - - os: osx - osx_image: xcode10.3 - env: COMPILER=osx TOOLCHAIN=xcode - - # OS X xcode11 - - os: osx - osx_image: xcode11.2 - env: COMPILER=osx TOOLCHAIN=xcode NOX86=1 - before_install: - if [[ "$TOOLCHAIN" == "clang" ]]; then curl -sSL "http://apt.llvm.org/llvm-snapshot.gpg.key" | sudo -E apt-key add - ; fi - if [[ "$COMPILER" == "clang5" ]]; then echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-5.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi @@ -41,20 +21,6 @@ before_install: fi' script: - - 'if [[ "$NOX86" != "1" ]]; then - python make.py -clean -build -unit_test -compiler ${COMPILER} -config Debug -cpu x86; - fi' - - 'if [[ "$NOX86" != "1" ]]; then - python make.py -clean -build -unit_test -compiler ${COMPILER} -config Release -cpu x86; - fi' - - python make.py -clean -build -unit_test -compiler ${COMPILER} -config Debug -cpu x64 - - python make.py -clean -build -unit_test -compiler ${COMPILER} -config Release -cpu x64 - - 'if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - python make.py -clean -build -compiler ios -config Debug; - fi' - - 'if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then - python make.py -clean -build -compiler ios -config Release; - fi' # Only run sonarcloud on non-PRs - 'if [[ "$SONARCLOUD" == "1" && "$TRAVIS_PULL_REQUEST" == "false" ]]; then python make.py -clean -compiler ${COMPILER} -config Release -cpu x64; From 8c082d711b66b9ecbf65af4ff6d766a95846204c Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 5 Dec 2020 19:24:01 -0500 Subject: [PATCH 097/285] chore: update readme to reflect CI changes --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 28a8b1b..a780aca 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ [![CLA assistant](https://cla-assistant.io/readme/badge/nfrechette/sjson-cpp)](https://cla-assistant.io/nfrechette/sjson-cpp) [![Build status](https://ci.appveyor.com/api/projects/status/oynd3x3d9umjaruf/branch/develop?svg=true)](https://ci.appveyor.com/project/nfrechette/sjson-cpp) -[![Build Status](https://travis-ci.org/nfrechette/sjson-cpp.svg?branch=develop)](https://travis-ci.org/nfrechette/sjson-cpp) [![Build status](https://github.com/nfrechette/sjson-cpp/workflows/build/badge.svg)](https://github.com/nfrechette/sjson-cpp/actions) [![Sonar Status](https://sonarcloud.io/api/project_badges/measure?project=nfrechette_sjson-cpp&metric=alert_status)](https://sonarcloud.io/dashboard?id=nfrechette_sjson-cpp) [![GitHub (pre-)release](https://img.shields.io/github/release/nfrechette/sjson-cpp/all.svg)](https://github.com/nfrechette/sjson-cpp/releases) @@ -37,13 +36,13 @@ Unicode formats other than UTF-8 aren't supported. ## Supported platforms * Windows VS2015 x86 and x64 -* Windows (VS2017, VS2019) x86, x64, and ARM64* +* Windows (VS2017, VS2019) x86, x64, and ARM64 * Windows VS2019 with clang9 x86 and x64 * Linux (gcc5, gcc6, gcc7, gcc8, gcc9, gcc10) x86 and x64 * Linux (clang4, clang5, clang6, clang7, clang8, clang9, clang10) x86 and x64 -* OS X (Xcode 8.3, 9.4, 10.3, 11.2*) x86 and x64 +* OS X (Xcode 10.3, 11.7) x86 and x64 * Android (NDK 21) ARMv7-A and ARM64 -* iOS (Xcode 8.3, 9.4, 10.3) ARM64 +* iOS (Xcode 10.3) ARM64 * Emscripten (1.39.11) WASM The above supported platform list is only what is tested every release but if it compiles, it should run just fine. From 8f7d5b770ff91305bf9c6095fcdce791c036e2bd Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 8 Dec 2020 23:12:09 -0500 Subject: [PATCH 098/285] chore: remove Travis CI integration --- .travis.yml | 29 ----------------------------- 1 file changed, 29 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index b4086df..0000000 --- a/.travis.yml +++ /dev/null @@ -1,29 +0,0 @@ -os: linux -dist: bionic - -language: cpp - -jobs: - include: - # Linux clang5 - - env: COMPILER=clang5 TOOLCHAIN=clang SONARCLOUD=1 PACKAGES="clang-5.0 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" - addons: - sonarcloud: - organization: "nfrechette-github" - -before_install: - - if [[ "$TOOLCHAIN" == "clang" ]]; then curl -sSL "http://apt.llvm.org/llvm-snapshot.gpg.key" | sudo -E apt-key add - ; fi - - if [[ "$COMPILER" == "clang5" ]]; then echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-5.0 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi - - 'if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then - sudo -E apt-add-repository -y "ppa:ubuntu-toolchain-r/test"; - sudo -E apt-get -yq update; - sudo -E apt-get -yq --no-install-suggests --no-install-recommends --force-yes install ${PACKAGES}; - fi' - -script: - # Only run sonarcloud on non-PRs - - 'if [[ "$SONARCLOUD" == "1" && "$TRAVIS_PULL_REQUEST" == "false" ]]; then - python make.py -clean -compiler ${COMPILER} -config Release -cpu x64; - build-wrapper-linux-x86-64 --out-dir bw_output python make.py -build -compiler ${COMPILER} -config Release -cpu x64; - sonar-scanner; - fi' From 29f6772bea0fa3bc0a55281aad859710ff0b7886 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 8 Dec 2020 23:12:44 -0500 Subject: [PATCH 099/285] chore: update sonarcloud properties --- sonar-project.properties | 3 +++ 1 file changed, 3 insertions(+) diff --git a/sonar-project.properties b/sonar-project.properties index f109e5b..755b50e 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -1,3 +1,5 @@ +sonar.organization=nfrechette-github + sonar.projectKey=nfrechette_sjson-cpp sonar.projectName=sjson-cpp sonar.projectVersion=0.7.0 @@ -5,3 +7,4 @@ sonar.projectVersion=0.7.0 sonar.sources=includes,tests/sources,tests/main_generic sonar.cfamily.build-wrapper-output=bw_output +sonar.cfamily.threads=2 From da39af8976f43c2966d80c9952f73004bd8fbf45 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 8 Dec 2020 23:18:13 -0500 Subject: [PATCH 100/285] chore: add new sonarcloud github action --- .github/workflows/sonarcloud.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/sonarcloud.yml diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml new file mode 100644 index 0000000..d3c11e8 --- /dev/null +++ b/.github/workflows/sonarcloud.yml @@ -0,0 +1,30 @@ +name: sonarcloud + +on: [push, pull_request] + +jobs: + sonarcloud: + runs-on: ubuntu-18.04 + steps: + - name: Git checkout + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: Setup build wrapper + run: | + wget -q https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip + unzip build-wrapper-linux-x86.zip + - name: Setup Sonar Scanner + run: | + wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.2.0.1873-linux.zip + unzip sonar-scanner-cli-4.2.0.1873-linux.zip + - name: Setup compiler + run: ./tools/setup_linux_compiler.sh clang5 + - name: Build with wrapper + run: ./build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw_output python3 make.py -compiler clang5 -config Release -cpu x64 -build + - name: Run Sonar Scanner and upload to Sonarcloud + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: https://sonarcloud.io + run: ./sonar-scanner-4.2.0.1873-linux/bin/sonar-scanner From 45e071428bd75ad5dfdf8f555f8f0c3192beb262 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 8 Dec 2020 23:23:55 -0500 Subject: [PATCH 101/285] chore: rename main build file for clarity --- .github/workflows/{main.yml => build.yml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/workflows/{main.yml => build.yml} (100%) diff --git a/.github/workflows/main.yml b/.github/workflows/build.yml similarity index 100% rename from .github/workflows/main.yml rename to .github/workflows/build.yml From e3ca9a9246e7dbd0935d9576c6cb6f711913dd62 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 8 Dec 2020 23:26:05 -0500 Subject: [PATCH 102/285] chore: skip build for markdown only changes --- .github/workflows/build.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 188e9d6..5343d35 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,16 @@ name: build -on: [push, pull_request] +on: + push: + branches: + - '**' + paths-ignore: + - '**/*.md' + pull_request: + branches: + - '**' + paths-ignore: + - '**/*.md' jobs: linux: From 078e66a0e270dd24ad0f4d1ad894fc75704b4e40 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 8 Dec 2020 23:26:44 -0500 Subject: [PATCH 103/285] chore: skip sonarcloud for markdown only changes --- .github/workflows/sonarcloud.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index d3c11e8..34a96e7 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -1,6 +1,16 @@ name: sonarcloud -on: [push, pull_request] +on: + push: + branches: + - '**' + paths-ignore: + - '**/*.md' + pull_request: + branches: + - '**' + paths-ignore: + - '**/*.md' jobs: sonarcloud: From d49cf0f10463a57f0799009ea9d03ae54b4002f0 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 27 Dec 2020 22:46:14 -0500 Subject: [PATCH 104/285] chore: add support for clang 11 --- README.md | 4 ++-- make.py | 5 ++++- tools/release_scripts/test_everything.py | 2 +- tools/setup_linux_compiler.sh | 3 +++ 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index a780aca..9a3ff40 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,8 @@ Unicode formats other than UTF-8 aren't supported. * Windows VS2015 x86 and x64 * Windows (VS2017, VS2019) x86, x64, and ARM64 * Windows VS2019 with clang9 x86 and x64 -* Linux (gcc5, gcc6, gcc7, gcc8, gcc9, gcc10) x86 and x64 -* Linux (clang4, clang5, clang6, clang7, clang8, clang9, clang10) x86 and x64 +* Linux (gcc 5 to 10) x86 and x64 +* Linux (clang 4 to 11) x86 and x64 * OS X (Xcode 10.3, 11.7) x86 and x64 * Android (NDK 21) ARMv7-A and ARM64 * iOS (Xcode 10.3) ARM64 diff --git a/make.py b/make.py index 6a23e88..3ba926d 100644 --- a/make.py +++ b/make.py @@ -16,7 +16,7 @@ def parse_argv(): actions.add_argument('-unit_test', action='store_true') target = parser.add_argument_group(title='Target') - target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'vs2019-clang', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'clang10', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'gcc10', 'osx', 'ios', 'emscripten'], help='Defaults to the host system\'s default compiler') + target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'vs2019-clang', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'clang10', 'clang11', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'gcc10', 'osx', 'ios', 'emscripten'], help='Defaults to the host system\'s default compiler') target.add_argument('-config', choices=['Debug', 'Release'], type=str.capitalize) target.add_argument('-cpu', choices=['x86', 'x64', 'armv7', 'arm64', 'wasm'], help='Defaults to the host system\'s architecture') @@ -189,6 +189,9 @@ def set_compiler_env(compiler, args): elif compiler == 'clang10': os.environ['CC'] = 'clang-10' os.environ['CXX'] = 'clang++-10' + elif compiler == 'clang11': + os.environ['CC'] = 'clang-11' + os.environ['CXX'] = 'clang++-11' elif compiler == 'gcc5': os.environ['CC'] = 'gcc-5' os.environ['CXX'] = 'g++-5' diff --git a/tools/release_scripts/test_everything.py b/tools/release_scripts/test_everything.py index 4cd4b5b..9e84541 100644 --- a/tools/release_scripts/test_everything.py +++ b/tools/release_scripts/test_everything.py @@ -7,7 +7,7 @@ def get_platform_compilers(): if platform.system() == 'Windows': return [ 'vs2015', 'vs2017', 'vs2019' ] elif platform.system() == 'Linux': - return [ 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'gcc10', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'clang10' ] + return [ 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'gcc10', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'clang10', 'clang11' ] elif platform.system() == 'Darwin': return [ 'osx' ] else: diff --git a/tools/setup_linux_compiler.sh b/tools/setup_linux_compiler.sh index 89cf67c..621bfda 100755 --- a/tools/setup_linux_compiler.sh +++ b/tools/setup_linux_compiler.sh @@ -46,6 +46,9 @@ elif [[ $COMPILER == clang9 ]]; then elif [[ $COMPILER == clang10 ]]; then PACKAGES="clang-10 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; +elif [[ $COMPILER == clang11 ]]; then + PACKAGES="clang-11 libstdc++-5-dev libc6-dev-i386 g++-5-multilib g++-multilib" + echo "deb http://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main" | sudo tee -a /etc/apt/sources.list > /dev/null ; fi # Install the packages we need From 65472efbb90ae4f35e554e62a85ccfcf05beded0 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 27 Dec 2020 22:50:19 -0500 Subject: [PATCH 105/285] chore: add clang 11 to CI --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5343d35..5d79359 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -17,7 +17,7 @@ jobs: runs-on: ubuntu-18.04 strategy: matrix: - compiler: [gcc5, gcc6, gcc7, gcc8, gcc9, gcc10, clang4, clang5, clang6, clang7, clang8, clang9, clang10] + compiler: [gcc5, gcc6, gcc7, gcc8, gcc9, gcc10, clang4, clang5, clang6, clang7, clang8, clang9, clang10, clang11] steps: - name: Git checkout uses: actions/checkout@v2 From 29b5babf253c8d510c204d3df9d53f8d1fd8d67f Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 2 Feb 2021 10:23:57 -0500 Subject: [PATCH 106/285] fix(tests): use proper catch2 include path --- tests/main_android/app/src/main/cpp/CMakeLists.txt | 2 +- tests/main_android/app/src/main/cpp/main.cpp | 2 +- tests/main_emscripten/CMakeLists.txt | 2 +- tests/main_emscripten/main.cpp | 2 +- tests/main_generic/CMakeLists.txt | 2 +- tests/main_generic/main.cpp | 2 +- tests/main_ios/CMakeLists.txt | 2 +- tests/main_ios/main.cpp | 2 +- tests/sources/test_parser.cpp | 2 +- tests/sources/test_string_view.cpp | 2 +- tests/sources/test_writer.cpp | 2 +- 11 files changed, 11 insertions(+), 11 deletions(-) diff --git a/tests/main_android/app/src/main/cpp/CMakeLists.txt b/tests/main_android/app/src/main/cpp/CMakeLists.txt index 503feff..552d9d3 100644 --- a/tests/main_android/app/src/main/cpp/CMakeLists.txt +++ b/tests/main_android/app/src/main/cpp/CMakeLists.txt @@ -7,7 +7,7 @@ set(CMAKE_CXX_STANDARD 11) set(PROJECT_ROOT_DIR "${PROJECT_SOURCE_DIR}/../../../..") include_directories("${PROJECT_ROOT_DIR}/../../includes") -include_directories("${PROJECT_ROOT_DIR}/../../external/catch2/single_include/catch2") +include_directories("${PROJECT_ROOT_DIR}/../../external/catch2/single_include") # Grab all of our test source files file(GLOB_RECURSE ALL_TEST_SOURCE_FILES LIST_DIRECTORIES false diff --git a/tests/main_android/app/src/main/cpp/main.cpp b/tests/main_android/app/src/main/cpp/main.cpp index f95d032..d19f914 100644 --- a/tests/main_android/app/src/main/cpp/main.cpp +++ b/tests/main_android/app/src/main/cpp/main.cpp @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////////////////// #define CATCH_CONFIG_RUNNER -#include +#include #include diff --git a/tests/main_emscripten/CMakeLists.txt b/tests/main_emscripten/CMakeLists.txt index 9eba55d..601106a 100644 --- a/tests/main_emscripten/CMakeLists.txt +++ b/tests/main_emscripten/CMakeLists.txt @@ -4,7 +4,7 @@ project(sjson-cpp_unit_tests CXX) set(CMAKE_CXX_STANDARD 11) include_directories("${PROJECT_SOURCE_DIR}/../../includes") -include_directories("${PROJECT_SOURCE_DIR}/../../external/catch2/single_include/catch2") +include_directories("${PROJECT_SOURCE_DIR}/../../external/catch2/single_include") # Grab all of our test source files file(GLOB_RECURSE ALL_TEST_SOURCE_FILES LIST_DIRECTORIES false diff --git a/tests/main_emscripten/main.cpp b/tests/main_emscripten/main.cpp index 6343f44..7295628 100644 --- a/tests/main_emscripten/main.cpp +++ b/tests/main_emscripten/main.cpp @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////////////////// #define CATCH_CONFIG_RUNNER -#include +#include int main(int argc, char* argv[]) { diff --git a/tests/main_generic/CMakeLists.txt b/tests/main_generic/CMakeLists.txt index 943acca..b979bc1 100644 --- a/tests/main_generic/CMakeLists.txt +++ b/tests/main_generic/CMakeLists.txt @@ -4,7 +4,7 @@ project(sjson-cpp_unit_tests CXX) set(CMAKE_CXX_STANDARD 11) include_directories("${PROJECT_SOURCE_DIR}/../../includes") -include_directories("${PROJECT_SOURCE_DIR}/../../external/catch2/single_include/catch2") +include_directories("${PROJECT_SOURCE_DIR}/../../external/catch2/single_include") # Grab all of our test source files file(GLOB_RECURSE ALL_TEST_SOURCE_FILES LIST_DIRECTORIES false diff --git a/tests/main_generic/main.cpp b/tests/main_generic/main.cpp index 3454f85..990a85f 100644 --- a/tests/main_generic/main.cpp +++ b/tests/main_generic/main.cpp @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////////////////// #define CATCH_CONFIG_RUNNER -#include +#include #ifdef _WIN32 #include diff --git a/tests/main_ios/CMakeLists.txt b/tests/main_ios/CMakeLists.txt index c0f841d..3e323cd 100644 --- a/tests/main_ios/CMakeLists.txt +++ b/tests/main_ios/CMakeLists.txt @@ -16,7 +16,7 @@ set(MACOSX_BUNDLE_GUI_IDENTIFIER "com.sjson.cpp.unit-tests") set(MACOSX_BUNDLE_BUNDLE_NAME "sjson-cpp-unit-tests") include_directories("${PROJECT_SOURCE_DIR}/../../includes") -include_directories("${PROJECT_SOURCE_DIR}/../../external/catch2/single_include/catch2") +include_directories("${PROJECT_SOURCE_DIR}/../../external/catch2/single_include") # Grab all of our test source files file(GLOB_RECURSE ALL_TEST_SOURCE_FILES LIST_DIRECTORIES false diff --git a/tests/main_ios/main.cpp b/tests/main_ios/main.cpp index 8c52bc7..e2341ac 100644 --- a/tests/main_ios/main.cpp +++ b/tests/main_ios/main.cpp @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////////////////// #define CATCH_CONFIG_RUNNER -#include +#include int main(int argc, char* argv[]) { diff --git a/tests/sources/test_parser.cpp b/tests/sources/test_parser.cpp index d07d4f1..83769aa 100644 --- a/tests/sources/test_parser.cpp +++ b/tests/sources/test_parser.cpp @@ -22,7 +22,7 @@ // SOFTWARE. //////////////////////////////////////////////////////////////////////////////// -#include +#include #include diff --git a/tests/sources/test_string_view.cpp b/tests/sources/test_string_view.cpp index eefab2a..9346320 100644 --- a/tests/sources/test_string_view.cpp +++ b/tests/sources/test_string_view.cpp @@ -22,7 +22,7 @@ // SOFTWARE. //////////////////////////////////////////////////////////////////////////////// -#include +#include #include diff --git a/tests/sources/test_writer.cpp b/tests/sources/test_writer.cpp index 519dd72..ca02c00 100644 --- a/tests/sources/test_writer.cpp +++ b/tests/sources/test_writer.cpp @@ -22,7 +22,7 @@ // SOFTWARE. //////////////////////////////////////////////////////////////////////////////// -#include +#include #include From 5896d5a9d6ba8efe7c3321ee4b023251c3a41357 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 2 Feb 2021 10:24:18 -0500 Subject: [PATCH 107/285] fix(tests): set variables as private --- tests/main_emscripten/CMakeLists.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/main_emscripten/CMakeLists.txt b/tests/main_emscripten/CMakeLists.txt index 601106a..424b7d3 100644 --- a/tests/main_emscripten/CMakeLists.txt +++ b/tests/main_emscripten/CMakeLists.txt @@ -26,14 +26,14 @@ target_compile_options(${PROJECT_NAME} PRIVATE -Werror) # Treat warnings as e # Exceptions are not enabled by default, enable them target_compile_options(${PROJECT_NAME} PRIVATE -fexceptions) -target_link_libraries(${PROJECT_NAME} "-s DISABLE_EXCEPTION_CATCHING=0") +target_link_libraries(${PROJECT_NAME} PRIVATE "-s DISABLE_EXCEPTION_CATCHING=0") -target_link_libraries(${PROJECT_NAME} "-s NODERAWFS=1") # Enable the raw node file system -target_link_libraries(${PROJECT_NAME} -lnodefs.js) # Link the node file system +target_link_libraries(${PROJECT_NAME} PRIVATE "-s NODERAWFS=1") # Enable the raw node file system +target_link_libraries(${PROJECT_NAME} PRIVATE -lnodefs.js) # Link the node file system -target_link_libraries(${PROJECT_NAME} "-s ENVIRONMENT=node") # Force the environment to node +target_link_libraries(${PROJECT_NAME} PRIVATE "-s ENVIRONMENT=node") # Force the environment to node -target_link_libraries(${PROJECT_NAME} "-s ALLOW_MEMORY_GROWTH=1") # Allow dynamic memory allocation +target_link_libraries(${PROJECT_NAME} PRIVATE "-s ALLOW_MEMORY_GROWTH=1") # Allow dynamic memory allocation # Setup Catch2 so we can find and execute the unit tests with CTest set(OptionalCatchTestLauncher node) From b7c074e9436e51a9b0bf4fac7fcd15e84eaf574b Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 2 Feb 2021 10:27:11 -0500 Subject: [PATCH 108/285] fix(tests): change catch2 test discovery --- tests/main_generic/CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/main_generic/CMakeLists.txt b/tests/main_generic/CMakeLists.txt index b979bc1..4c66857 100644 --- a/tests/main_generic/CMakeLists.txt +++ b/tests/main_generic/CMakeLists.txt @@ -23,8 +23,8 @@ add_executable(${PROJECT_NAME} ${ALL_TEST_SOURCE_FILES} ${ALL_MAIN_SOURCE_FILES} list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/../../external/catch2/contrib") include(CTest) -include(ParseAndAddCatchTests) -ParseAndAddCatchTests(${PROJECT_NAME}) +include(Catch) +catch_discover_tests(${PROJECT_NAME}) setup_default_compiler_flags(${PROJECT_NAME}) From 650bf8ee58b3eb96d6a427134a505e3ec9ec0141 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 2 Feb 2021 10:33:41 -0500 Subject: [PATCH 109/285] fix(tools): properly pass arguments to cmake Fixes VS2019 clang support --- make.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/make.py b/make.py index 3ba926d..8c84ba7 100644 --- a/make.py +++ b/make.py @@ -241,7 +241,6 @@ def do_generate_solution(build_dir, cmake_script_dir, args): if compiler == 'emscripten': cmake_cmd = 'emcmake cmake .. -DCMAKE_INSTALL_PREFIX="{}" {}'.format(build_dir, ' '.join(extra_switches)) else: - cmake_cmd = 'cmake .. -DCMAKE_INSTALL_PREFIX="{}" {}'.format(build_dir, ' '.join(extra_switches)) cmake_generator = get_generator(compiler, cpu) if not cmake_generator: print('Using default generator') @@ -252,12 +251,14 @@ def do_generate_solution(build_dir, cmake_script_dir, args): generator_suffix = 'Clang CL' print('Using generator: {} {}'.format(cmake_generator, generator_suffix)) - cmake_cmd += ' -G "{}"'.format(cmake_generator) + extra_switches.append('-G "{}"'.format(cmake_generator)) cmake_arch = get_architecture(compiler, cpu) if cmake_arch: print('Using architecture: {}'.format(cmake_arch)) - cmake_cmd += ' -A {}'.format(cmake_arch) + extra_switches.append('-A {}'.format(cmake_arch)) + + cmake_cmd = 'cmake .. -DCMAKE_INSTALL_PREFIX="{}" {}'.format(build_dir, ' '.join(extra_switches)) result = subprocess.call(cmake_cmd, shell=True) if result != 0: From c2cccc95c44ff86de40f3df14dde7f93270e1cc7 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 2 Feb 2021 14:04:34 -0500 Subject: [PATCH 110/285] chore: change appveyor to use a batch file for easier maintenance --- appveyor.yml | 66 +++++++++++++++++++++---------------------- tools/appveyor_ci.bat | 52 ++++++++++++++++++++++++++++++++++ 2 files changed, 84 insertions(+), 34 deletions(-) create mode 100644 tools/appveyor_ci.bat diff --git a/appveyor.yml b/appveyor.yml index 84c71b7..49f0eaf 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,13 +1,39 @@ version: 0.7.0.{build} environment: - PYTHON: "C:\\Python36-x64" - VISUAL_STUDIO: "C:\\Program Files (x86)\\Microsoft Visual Studio" + PYTHON: "C:\\Python36-x64\\python.exe" + matrix: + - toolchain: msvc + - toolchain: clang image: -- Visual Studio 2015 -- Visual Studio 2017 -- Visual Studio 2019 + - Visual Studio 2015 + - Visual Studio 2017 + - Visual Studio 2019 + +configuration: + - Debug + - Release + +platform: + - x86 + - x64 + - arm64 + +matrix: + exclude: + - image: Visual Studio 2015 + platform: arm64 + - image: Visual Studio 2015 + toolchain: clang + - image: Visual Studio 2017 + toolchain: clang + - image: Visual Studio 2019 + platform: arm64 + toolchain: clang + - image: Previous Visual Studio 2019 + platform: arm64 + toolchain: clang install: - cmd: >- @@ -15,32 +41,4 @@ install: build_script: - cmd: >- - IF "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2015" (SET COMPILER=vs2015) - - IF "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2017" (SET COMPILER=vs2017 && SET ARM64_SUPPORTED=1) - - IF "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019" (SET COMPILER=vs2019 && SET ARM64_SUPPORTED=1) - - IF "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019" "%VISUAL_STUDIO%\\Installer\\vs_installershell.exe" modify --productId Microsoft.VisualStudio.Product.Community --channelId VisualStudio.16.Release --add Microsoft.VisualStudio.Component.VC.Tools.ARM64 --add Microsoft.VisualStudio.Component.VC.Runtimes.ARM64.Spectre --quiet - - %PYTHON%\\python.exe make.py -clean -build -unit_test -compiler %COMPILER% -config Debug -cpu x86 - - %PYTHON%\\python.exe make.py -clean -build -unit_test -compiler %COMPILER% -config Release -cpu x86 - - %PYTHON%\\python.exe make.py -clean -build -unit_test -compiler %COMPILER% -config Debug -cpu x64 - - %PYTHON%\\python.exe make.py -clean -build -unit_test -compiler %COMPILER% -config Release -cpu x64 - - IF DEFINED ARM64_SUPPORTED %PYTHON%\\python.exe make.py -clean -build -compiler %COMPILER% -config Debug -cpu arm64 - - IF DEFINED ARM64_SUPPORTED %PYTHON%\\python.exe make.py -clean -build -compiler %COMPILER% -config Release -cpu arm64 - - IF "%APPVEYOR_BUILD_WORKER_IMAGE%"=="Visual Studio 2019" (SET COMPILER=vs2019-clang && SET CLANG_SUPPORTED=1) - - IF DEFINED CLANG_SUPPORTED %PYTHON%\\python.exe make.py -clean -build -unit_test -compiler %COMPILER% -config Debug -cpu x86 - - IF DEFINED CLANG_SUPPORTED %PYTHON%\\python.exe make.py -clean -build -unit_test -compiler %COMPILER% -config Release -cpu x86 - - IF DEFINED CLANG_SUPPORTED %PYTHON%\\python.exe make.py -clean -build -unit_test -compiler %COMPILER% -config Debug -cpu x64 - - IF DEFINED CLANG_SUPPORTED %PYTHON%\\python.exe make.py -clean -build -unit_test -compiler %COMPILER% -config Release -cpu x64 + .\tools\appveyor_ci.bat "%APPVEYOR_BUILD_WORKER_IMAGE%" %platform% %configuration% %toolchain% "%PYTHON%" diff --git a/tools/appveyor_ci.bat b/tools/appveyor_ci.bat new file mode 100644 index 0000000..aa4efa7 --- /dev/null +++ b/tools/appveyor_ci.bat @@ -0,0 +1,52 @@ +@echo off + +REM Unpack arguments +SET WORKER_IMAGE=%1 +SET PLATFORM=%2 +SET CONFIG=%3 +SET TOOLCHAIN=%4 +SET PYTHON_PATH=%5 + +echo Worker image: %WORKER_IMAGE% +echo Platform: %PLATFORM% +echo Config: %CONFIG% +echo Toolchain: %TOOLCHAIN% +echo Python path: %PYTHON_PATH% + +REM Convert the build image and toolchain into our compiler string +IF /i %TOOLCHAIN%==msvc GOTO :msvc +IF /i %TOOLCHAIN%==clang GOTO :clang + +echo Unknown toolchain: %TOOLCHAIN% +exit /B 1 + +:msvc +IF /i %WORKER_IMAGE%=="Visual Studio 2015" SET COMPILER=vs2015 +IF /i %WORKER_IMAGE%=="Visual Studio 2017" SET COMPILER=vs2017 +IF /i %WORKER_IMAGE%=="Visual Studio 2019" SET COMPILER=vs2019 +IF /i %WORKER_IMAGE%=="Previous Visual Studio 2019" SET COMPILER=vs2019 +GOTO :next + +:clang +IF /i %WORKER_IMAGE%=="Visual Studio 2019" SET COMPILER=vs2019-clang +IF /i %WORKER_IMAGE%=="Previous Visual Studio 2019" SET COMPILER=vs2019-clang +GOTO :next + +:next +REM Set our switch if we need to run unit tests +SET UNIT_TEST_FLAG=-unit_test +IF /i %PLATFORM%==arm64 SET UNIT_TEST_FLAG= + +REM If PYTHON_PATH isn't set, assume it is in PATH +IF NOT DEFINED PYTHON_PATH SET PYTHON_PATH=python.exe + +REM Build and run unit tests +%PYTHON_PATH% make.py -build %UNIT_TEST_FLAG% -compiler %COMPILER% -config %CONFIG% -cpu %PLATFORM% -clean +IF NOT %ERRORLEVEL% EQU 0 GOTO :build_failure + +REM Done! +exit /B 0 + +:build_failure +echo Build failed! +exit /B 1 From 89fa4af538e90c6da2e6e15f49053605d65e3425 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 2 Feb 2021 14:06:27 -0500 Subject: [PATCH 111/285] chore: disable clang build with appveyor vcpkg breaks cmake clang detection --- tools/appveyor_ci.bat | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/tools/appveyor_ci.bat b/tools/appveyor_ci.bat index aa4efa7..179866b 100644 --- a/tools/appveyor_ci.bat +++ b/tools/appveyor_ci.bat @@ -30,6 +30,11 @@ GOTO :next :clang IF /i %WORKER_IMAGE%=="Visual Studio 2019" SET COMPILER=vs2019-clang IF /i %WORKER_IMAGE%=="Previous Visual Studio 2019" SET COMPILER=vs2019-clang + +REM HACK!!! Disable clang build for now with appveyor since vcpkg breaks the compiler detection of cmake +REM Fake build success +exit /B 0 + GOTO :next :next From 4305ceb143f56b8f15676808ed035697ae51b80c Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 3 Feb 2021 09:32:29 -0500 Subject: [PATCH 112/285] style: fix comment to reflect the correct exception type used --- includes/sjson/error.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/sjson/error.h b/includes/sjson/error.h index 6560598..d7e9c04 100644 --- a/includes/sjson/error.h +++ b/includes/sjson/error.h @@ -41,7 +41,7 @@ // Throwing: // In order to enable the throwing behavior, simply define the macro SJSON_CPP_ON_ASSERT_THROW: // #define SJSON_CPP_ON_ASSERT_THROW -// Note that the type of the exception thrown is std::runtime_error. +// Note that the type of the exception thrown is sjson::runtime_assert. // // Custom function: // In order to enable the custom function calling behavior, define the macro SJSON_CPP_ON_ASSERT_CUSTOM From 9b7966db7e1d90d613d7e105aa8b4a391170126e Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 19 Feb 2021 10:59:38 -0500 Subject: [PATCH 113/285] chore: update change log --- CHANGELOG.md | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ced6daa..91e8dae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,19 @@ # Significant changes per release +## 0.8.0 + +* Added support for clang 8, 9, and 10 +* Added support for GCC 10 +* Added support for clang with VS 2019 +* Added support for emscripten +* Converted android to use gradle instead of NVIDIA CodeWorks +* Updated Catch2 to 2.11.0 +* Migrated from Travis to GitHub Actions +* Cleanup and minor misc changes + ## 0.7.0 -* Added support for VS 2019, GCC9, clang 7, and Xcode 11 +* Added support for VS 2019, GCC 9, clang 7, and Xcode 11 * Added custom support for NaN/Inf handling * Cleanup and minor misc changes From 79541691f2b8c56ae922fbcf47d8c3b37bd14273 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 19 Feb 2021 11:00:59 -0500 Subject: [PATCH 114/285] chore: update build numbers --- appveyor.yml | 2 +- sonar-project.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 49f0eaf..651717d 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 0.7.0.{build} +version: 0.8.0.{build} environment: PYTHON: "C:\\Python36-x64\\python.exe" diff --git a/sonar-project.properties b/sonar-project.properties index 755b50e..84ec563 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -2,7 +2,7 @@ sonar.organization=nfrechette-github sonar.projectKey=nfrechette_sjson-cpp sonar.projectName=sjson-cpp -sonar.projectVersion=0.7.0 +sonar.projectVersion=0.8.0 sonar.sources=includes,tests/sources,tests/main_generic From b40f0d598f9079fbf8bacf8135cf606f325cdae3 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 19 Feb 2021 11:09:38 -0500 Subject: [PATCH 115/285] fix: inherit constructors properly --- includes/sjson/error.h | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/includes/sjson/error.h b/includes/sjson/error.h index d7e9c04..65936df 100644 --- a/includes/sjson/error.h +++ b/includes/sjson/error.h @@ -102,9 +102,7 @@ { class runtime_assert final : public std::runtime_error { - public: - explicit runtime_assert(const std::string& message) : std::runtime_error(message.c_str()) {} - explicit runtime_assert(const char* message) : std::runtime_error(message) {} + using std::runtime_error::runtime_error; // Inherit constructors }; namespace error_impl From b199b72bb740edb9f98201742b28a8d8d2b58752 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 19 Feb 2021 11:09:57 -0500 Subject: [PATCH 116/285] fix: prefer const usage --- includes/sjson/parser.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/includes/sjson/parser.h b/includes/sjson/parser.h index 926ed0d..6262d55 100644 --- a/includes/sjson/parser.h +++ b/includes/sjson/parser.h @@ -371,15 +371,15 @@ namespace sjson } } - void get_position(uint32_t& line, uint32_t& column) + void get_position(uint32_t& line, uint32_t& column) const { line = m_state.line; column = m_state.column; } - bool eof() { return m_state.offset >= m_input_length; } + bool eof() const { return m_state.offset >= m_input_length; } - ParserError get_error() { return m_state.error; } + ParserError get_error() const { return m_state.error; } bool is_valid() const { return m_state.error.error == ParserError::None; } ParserState save_state() const { return m_state; } From a1b68cdf64db435b403ffac534030aba807dc707 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 19 Feb 2021 11:11:57 -0500 Subject: [PATCH 117/285] fix: prefer the in-class initializer --- includes/sjson/parser_error.h | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/includes/sjson/parser_error.h b/includes/sjson/parser_error.h index d816168..16bb22f 100644 --- a/includes/sjson/parser_error.h +++ b/includes/sjson/parser_error.h @@ -30,13 +30,6 @@ namespace sjson { struct ParserError { - ParserError() - : error(ParserError::None) - , line() - , column() - { - } - enum : uint32_t { None, @@ -62,9 +55,9 @@ namespace sjson Last }; - uint32_t error; - uint32_t line; - uint32_t column; + uint32_t error = None; + uint32_t line = 0; + uint32_t column = 0; virtual const char* get_description() const { From 9b9e74023155e9e64839f759a8f0a341b264624e Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 19 Feb 2021 11:15:42 -0500 Subject: [PATCH 118/285] fix: avoid calling memcmp with potential null pointer --- includes/sjson/string_view.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/sjson/string_view.h b/includes/sjson/string_view.h index d308263..fc6be9e 100644 --- a/includes/sjson/string_view.h +++ b/includes/sjson/string_view.h @@ -84,7 +84,7 @@ namespace sjson if (m_length != length) return false; - if (m_c_str == c_str) + if (m_c_str == c_str || length == 0) return true; return std::memcmp(m_c_str, c_str, length) == 0; From e35b8c0059297b96ca93be75a924fe5ccd7ab40e Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 19 Feb 2021 11:18:39 -0500 Subject: [PATCH 119/285] fix: use default implementation --- includes/sjson/writer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/sjson/writer.h b/includes/sjson/writer.h index ba75f9b..9dc1e35 100644 --- a/includes/sjson/writer.h +++ b/includes/sjson/writer.h @@ -55,7 +55,7 @@ namespace sjson class StreamWriter { public: - virtual ~StreamWriter() {} + virtual ~StreamWriter() = default; virtual void write(const void* buffer, size_t buffer_size) = 0; From dcd4999a3feb7b21551b4b8f4b10cdcd5d5a544f Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 19 Feb 2021 11:28:32 -0500 Subject: [PATCH 120/285] fix: mark move constructor as noexcept --- includes/sjson/writer.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/sjson/writer.h b/includes/sjson/writer.h index 9dc1e35..d63dcea 100644 --- a/includes/sjson/writer.h +++ b/includes/sjson/writer.h @@ -161,7 +161,7 @@ namespace sjson class ValueRef final { public: - ValueRef(ValueRef&& other); + ValueRef(ValueRef&& other) noexcept; ~ValueRef(); void operator=(const char* value); @@ -417,7 +417,7 @@ namespace sjson object_writer.m_is_locked = true; } - inline ObjectWriter::ValueRef::ValueRef(ValueRef&& other) + inline ObjectWriter::ValueRef::ValueRef(ValueRef&& other) noexcept : m_object_writer(other.m_object_writer) , m_is_empty(other.m_is_empty) , m_is_locked(other.m_is_locked) From 61c855b84edd769b8b3bcf7648a44766f793f51f Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 19 Feb 2021 11:28:42 -0500 Subject: [PATCH 121/285] fix: use default implementation --- tests/sources/test_writer.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/tests/sources/test_writer.cpp b/tests/sources/test_writer.cpp index ca02c00..936a0ab 100644 --- a/tests/sources/test_writer.cpp +++ b/tests/sources/test_writer.cpp @@ -34,9 +34,7 @@ using namespace sjson; class StringStreamWriter final : public StreamWriter { public: - StringStreamWriter() - : m_buffer() - {} + StringStreamWriter() = default; virtual void write(const void* buffer, size_t buffer_size) override { From aee9fe6c1eca677d54288f7ac73fe13f7c7276a9 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 19 Feb 2021 11:47:04 -0500 Subject: [PATCH 122/285] chore: update release test script --- tools/release_scripts/test_everything.py | 52 ++++++++++++++++++++++-- 1 file changed, 49 insertions(+), 3 deletions(-) diff --git a/tools/release_scripts/test_everything.py b/tools/release_scripts/test_everything.py index 9e84541..abd36d9 100644 --- a/tools/release_scripts/test_everything.py +++ b/tools/release_scripts/test_everything.py @@ -1,13 +1,45 @@ import os import platform +import shutil import subprocess import sys def get_platform_compilers(): if platform.system() == 'Windows': - return [ 'vs2015', 'vs2017', 'vs2019' ] + return [ 'vs2015', 'vs2017', 'vs2019', 'vs2019-clang' ] elif platform.system() == 'Linux': - return [ 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'gcc10', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'clang10', 'clang11' ] + compilers = [] + if shutil.which('g++-5'): + compilers.append('gcc5') + if shutil.which('g++-6'): + compilers.append('gcc6') + if shutil.which('g++-7'): + compilers.append('gcc7') + if shutil.which('g++-8'): + compilers.append('gcc8') + if shutil.which('g++-9'): + compilers.append('gcc9') + if shutil.which('g++-10'): + compilers.append('gcc10') + + if shutil.which('clang++-4.0'): + compilers.append('clang4') + if shutil.which('clang++-5.0'): + compilers.append('clang5') + if shutil.which('clang++-6.0'): + compilers.append('clang6') + if shutil.which('clang++-7'): + compilers.append('clang7') + if shutil.which('clang++-8'): + compilers.append('clang8') + if shutil.which('clang++-9'): + compilers.append('clang9') + if shutil.which('clang++-10'): + compilers.append('clang10') + if shutil.which('clang++-11'): + compilers.append('clang11') + + return compilers elif platform.system() == 'Darwin': return [ 'osx' ] else: @@ -28,6 +60,11 @@ def get_python_exe_name(): compilers = get_platform_compilers() python_exe = get_python_exe_name() + if platform.system() == 'Darwin': + result = subprocess.check_output(['xcodebuild', '-version']).decode("utf-8") + if 'Xcode 11' in result: + archs.remove('x86') + cmd_args = [] for config in configs: for arch in archs: @@ -40,6 +77,12 @@ def get_python_exe_name(): # Windows ARM args = [python_exe, 'make.py', '-compiler', 'vs2017', '-cpu', 'arm64', '-config', config, '-build', '-clean'] cmd_args.append([x for x in args if x]) + + # Android + args = [python_exe, 'make.py', '-compiler', 'android', '-cpu', 'armv7', '-config', config, '-build', '-clean'] + cmd_args.append([x for x in args if x]) + args = [python_exe, 'make.py', '-compiler', 'android', '-cpu', 'arm64', '-config', config, '-build', '-clean'] + cmd_args.append([x for x in args if x]) elif platform.system() == 'Darwin': for config in configs: # iOS @@ -58,7 +101,10 @@ def get_python_exe_name(): for args in cmd_args: print('Running command: "{}" ...'.format(" ".join(args))) try: - subprocess.check_output(args) + if 'android' in args: + subprocess.check_call(args) + else: + subprocess.check_output(args) except subprocess.CalledProcessError as e: print('Failed command: {}'.format(" ".join(args))) print(e.output.decode(sys.stdout.encoding)) From 664c1fdd0588a0cf7aed3f2db6885757c840865c Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 19 Feb 2021 19:46:50 +0000 Subject: [PATCH 123/285] docs: update README.md [skip ci] --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index 9a3ff40..57ff24b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,7 @@ [![CLA assistant](https://cla-assistant.io/readme/badge/nfrechette/sjson-cpp)](https://cla-assistant.io/nfrechette/sjson-cpp) + +[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-) + [![Build status](https://ci.appveyor.com/api/projects/status/oynd3x3d9umjaruf/branch/develop?svg=true)](https://ci.appveyor.com/project/nfrechette/sjson-cpp) [![Build status](https://github.com/nfrechette/sjson-cpp/workflows/build/badge.svg)](https://github.com/nfrechette/sjson-cpp/actions) [![Sonar Status](https://sonarcloud.io/api/project_badges/measure?project=nfrechette_sjson-cpp&metric=alert_status)](https://sonarcloud.io/dashboard?id=nfrechette_sjson-cpp) @@ -101,3 +104,23 @@ This project uses the [MIT license](LICENSE). Copyright (c) 2017 Nicholas Frechette, Cody Jones, and sjson-cpp contributors Please note that this project is released with a [Contributor Code of Conduct](CODE_OF_CONDUCT.md). By participating in this project you agree to abide by its terms. + +## Contributors ✨ + +Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)): + + + + + + + + +

CodyDWJones

💻 🚧
+ + + + + + +This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! \ No newline at end of file From 5b61c4583cef6608c13b3dba2ba709cf78061b06 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 19 Feb 2021 19:46:51 +0000 Subject: [PATCH 124/285] docs: create .all-contributorsrc [skip ci] --- .all-contributorsrc | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .all-contributorsrc diff --git a/.all-contributorsrc b/.all-contributorsrc new file mode 100644 index 0000000..e596e8f --- /dev/null +++ b/.all-contributorsrc @@ -0,0 +1,25 @@ +{ + "files": [ + "README.md" + ], + "imageSize": 100, + "commit": false, + "contributors": [ + { + "login": "CodyDWJones", + "name": "CodyDWJones", + "avatar_url": "https://avatars.githubusercontent.com/u/28773740?v=4", + "profile": "https://github.com/CodyDWJones", + "contributions": [ + "code", + "maintenance" + ] + } + ], + "contributorsPerLine": 7, + "projectName": "sjson-cpp", + "projectOwner": "nfrechette", + "repoType": "github", + "repoHost": "https://github.com", + "skipCi": true +} From ef1c43431b89aecfa41247c88db8a0b57ad956bb Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 19 Feb 2021 15:06:28 -0500 Subject: [PATCH 125/285] chore: update contributor badge --- README.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 57ff24b..1da40d3 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,5 @@ [![CLA assistant](https://cla-assistant.io/readme/badge/nfrechette/sjson-cpp)](https://cla-assistant.io/nfrechette/sjson-cpp) - -[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-) - +[![All Contributors](https://img.shields.io/github/all-contributors/nfrechette/sjson-cpp)](#contributors-) [![Build status](https://ci.appveyor.com/api/projects/status/oynd3x3d9umjaruf/branch/develop?svg=true)](https://ci.appveyor.com/project/nfrechette/sjson-cpp) [![Build status](https://github.com/nfrechette/sjson-cpp/workflows/build/badge.svg)](https://github.com/nfrechette/sjson-cpp/actions) [![Sonar Status](https://sonarcloud.io/api/project_badges/measure?project=nfrechette_sjson-cpp&metric=alert_status)](https://sonarcloud.io/dashboard?id=nfrechette_sjson-cpp) From 55854b2b1d565365586e160835b69de7ac343229 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 19 Feb 2021 20:50:40 +0000 Subject: [PATCH 126/285] docs: update README.md [skip ci] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 1da40d3..0c764c9 100644 --- a/README.md +++ b/README.md @@ -113,6 +113,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d +

CodyDWJones

💻 🚧

Michał Janiszewski

💻 🚧
From fd5f58d3c4f3cb05645fd7a8341d7f1913b70bf4 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 19 Feb 2021 20:50:41 +0000 Subject: [PATCH 127/285] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index e596e8f..16603cc 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -14,6 +14,16 @@ "code", "maintenance" ] + }, + { + "login": "janisozaur", + "name": "Michał Janiszewski", + "avatar_url": "https://avatars.githubusercontent.com/u/550290?v=4", + "profile": "https://github.com/janisozaur", + "contributions": [ + "code", + "maintenance" + ] } ], "contributorsPerLine": 7, From f8549287706d57a956e49e85d1c45dde190689e2 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 19 Feb 2021 20:52:53 +0000 Subject: [PATCH 128/285] docs: update README.md [skip ci] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 0c764c9..4b11e8b 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
CodyDWJones

💻 🚧
Michał Janiszewski

💻 🚧 +
Martin Turcotte

🚧 From 1fd49083f201eb66eaa831148bb9c9f5bd4b0c5b Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 19 Feb 2021 20:52:54 +0000 Subject: [PATCH 129/285] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 16603cc..33d083e 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -24,6 +24,15 @@ "code", "maintenance" ] + }, + { + "login": "tirpidz", + "name": "Martin Turcotte", + "avatar_url": "https://avatars.githubusercontent.com/u/9991876?v=4", + "profile": "https://github.com/tirpidz", + "contributions": [ + "maintenance" + ] } ], "contributorsPerLine": 7, From 38c43afbccb39070a1b941dfc675095fb8f4613c Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 19 Feb 2021 20:54:34 +0000 Subject: [PATCH 130/285] docs: update README.md [skip ci] --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 4b11e8b..2b776a9 100644 --- a/README.md +++ b/README.md @@ -115,6 +115,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
CodyDWJones

💻 🚧
Michał Janiszewski

💻 🚧
Martin Turcotte

🚧 +
Meradrin

🐛 From a8337d84066d814c13fef9d7885c18b1ba9ec030 Mon Sep 17 00:00:00 2001 From: "allcontributors[bot]" <46447321+allcontributors[bot]@users.noreply.github.com> Date: Fri, 19 Feb 2021 20:54:35 +0000 Subject: [PATCH 131/285] docs: update .all-contributorsrc [skip ci] --- .all-contributorsrc | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/.all-contributorsrc b/.all-contributorsrc index 33d083e..4f9c925 100644 --- a/.all-contributorsrc +++ b/.all-contributorsrc @@ -33,6 +33,15 @@ "contributions": [ "maintenance" ] + }, + { + "login": "Meradrin", + "name": "Meradrin", + "avatar_url": "https://avatars.githubusercontent.com/u/7066278?v=4", + "profile": "https://github.com/Meradrin", + "contributions": [ + "bug" + ] } ], "contributorsPerLine": 7, From 9cda0ee53afdf643683dd8333f5af4a312239da9 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Thu, 18 Mar 2021 20:58:13 -0400 Subject: [PATCH 132/285] feat: add python release scripts to solution --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0790ffa..8d214e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -19,7 +19,9 @@ file(GLOB_RECURSE SJSON_CPP_INCLUDE_FILES LIST_DIRECTORIES false ${PROJECT_SOURCE_DIR}/includes/*.h ${PROJECT_SOURCE_DIR}/*.md ${PROJECT_SOURCE_DIR}/cmake/*.cmake - ${PROJECT_SOURCE_DIR}/tools/vs_visualizers/*.natvis) + ${PROJECT_SOURCE_DIR}/tools/release_scripts/*.py + ${PROJECT_SOURCE_DIR}/tools/vs_visualizers/*.natvis + ) create_source_groups("${SJSON_CPP_INCLUDE_FILES}" ${PROJECT_SOURCE_DIR}) From ad571f0af69f5159e0de45efb16c10b5a008eca5 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Thu, 18 Mar 2021 20:58:40 -0400 Subject: [PATCH 133/285] fix(parser): ensure std::isspace() is called with an unsigned char --- includes/sjson/parser.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/sjson/parser.h b/includes/sjson/parser.h index 6262d55..ee82f8a 100644 --- a/includes/sjson/parser.h +++ b/includes/sjson/parser.h @@ -351,7 +351,7 @@ namespace sjson if (eof()) return true; - if (std::isspace(m_state.symbol)) + if (std::isspace(static_cast(m_state.symbol))) { advance(); continue; @@ -603,7 +603,7 @@ namespace sjson break; } - if (std::isspace(m_state.symbol)) + if (std::isspace(static_cast(m_state.symbol))) { end_offset = m_state.offset - 1; advance(); From fe137372f8e3a9ce7247ae33821f7de9807ef577 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Thu, 18 Mar 2021 21:08:38 -0400 Subject: [PATCH 134/285] fix(parser): ensure std::isdigit() is called with an unsigned char --- includes/sjson/parser.h | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/includes/sjson/parser.h b/includes/sjson/parser.h index ee82f8a..e19c660 100644 --- a/includes/sjson/parser.h +++ b/includes/sjson/parser.h @@ -717,9 +717,9 @@ namespace sjson { advance(); } - else if (std::isdigit(m_state.symbol)) + else if (std::isdigit(static_cast(m_state.symbol))) { - while (std::isdigit(m_state.symbol)) + while (std::isdigit(static_cast(m_state.symbol))) advance(); } else @@ -732,7 +732,7 @@ namespace sjson { advance(); - while (std::isdigit(m_state.symbol)) + while (std::isdigit(static_cast(m_state.symbol))) advance(); } @@ -744,13 +744,13 @@ namespace sjson { advance(); } - else if (!std::isdigit(m_state.symbol)) + else if (!std::isdigit(static_cast(m_state.symbol))) { set_error(ParserError::InvalidNumber); return false; } - while (std::isdigit(m_state.symbol)) + while (std::isdigit(static_cast(m_state.symbol))) advance(); } @@ -811,13 +811,13 @@ namespace sjson { base = 8; - while (std::isdigit(m_state.symbol)) + while (std::isdigit(static_cast(m_state.symbol))) advance(); } } - else if (std::isdigit(m_state.symbol)) + else if (std::isdigit(static_cast(m_state.symbol))) { - while (std::isdigit(m_state.symbol)) + while (std::isdigit(static_cast(m_state.symbol))) advance(); } else @@ -902,7 +902,7 @@ namespace sjson static bool is_hex_digit(char value) { - return std::isdigit(value) + return std::isdigit(static_cast(value)) || value == 'a' || value == 'A' || value == 'b' || value == 'B' || value == 'c' || value == 'C' From 54c3738fd72515017d3d8a9d97493aaaa5d45710 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Thu, 18 Mar 2021 21:10:02 -0400 Subject: [PATCH 135/285] chore: bump version numbers --- appveyor.yml | 2 +- sonar-project.properties | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 651717d..e869dc4 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 0.8.0.{build} +version: 0.8.1.{build} environment: PYTHON: "C:\\Python36-x64\\python.exe" diff --git a/sonar-project.properties b/sonar-project.properties index 84ec563..5d8972a 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -2,7 +2,7 @@ sonar.organization=nfrechette-github sonar.projectKey=nfrechette_sjson-cpp sonar.projectName=sjson-cpp -sonar.projectVersion=0.8.0 +sonar.projectVersion=0.8.1 sonar.sources=includes,tests/sources,tests/main_generic From 31eb8d0bf01e6655ca5f6ef2ba12d4ffcb55d941 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Thu, 18 Mar 2021 21:10:11 -0400 Subject: [PATCH 136/285] chore: update change log --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 91e8dae..3b4bde5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Significant changes per release +## 0.8.1 + +* Minor static analysis fixes + ## 0.8.0 * Added support for clang 8, 9, and 10 From cc5685d5b2f7c53e604ea4c745efcf41e4944833 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 27 Mar 2021 17:44:33 -0400 Subject: [PATCH 137/285] fix(tests): initialize values to avoid static analysis warnings --- tests/sources/test_parser.cpp | 52 +++++++++++++++++------------------ 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/tests/sources/test_parser.cpp b/tests/sources/test_parser.cpp index 83769aa..7b28684 100644 --- a/tests/sources/test_parser.cpp +++ b/tests/sources/test_parser.cpp @@ -240,7 +240,7 @@ TEST_CASE("Parser Number Reading", "[parser]") // Number reading { Parser parser = parser_from_c_str("key = 123.456789"); - double value; + double value = 0.0; CHECK(parser.read("key", value)); CHECK(value == 123.456789); CHECK(parser.eof()); @@ -249,7 +249,7 @@ TEST_CASE("Parser Number Reading", "[parser]") { Parser parser = parser_from_c_str("key = \"nan\""); - double value; + double value = 0.0; CHECK(parser.read("key", value)); CHECK(std::isnan(value)); CHECK(parser.eof()); @@ -258,7 +258,7 @@ TEST_CASE("Parser Number Reading", "[parser]") { Parser parser = parser_from_c_str("key = \"inf\""); - double value; + double value = 0.0; CHECK(parser.read("key", value)); CHECK(std::isinf(value)); CHECK(value > 0.0); @@ -268,7 +268,7 @@ TEST_CASE("Parser Number Reading", "[parser]") { Parser parser = parser_from_c_str("key = \"-inf\""); - double value; + double value = 0.0; CHECK(parser.read("key", value)); CHECK(std::isinf(value)); CHECK(value < 0.0); @@ -278,7 +278,7 @@ TEST_CASE("Parser Number Reading", "[parser]") { Parser parser = parser_from_c_str("key = 123.456789"); - float value; + float value = 0.0F; CHECK(parser.read("key", value)); CHECK(value == 123.456789F); CHECK(parser.eof()); @@ -287,7 +287,7 @@ TEST_CASE("Parser Number Reading", "[parser]") { Parser parser = parser_from_c_str("key = \"nan\""); - float value; + float value = 0.0F; CHECK(parser.read("key", value)); CHECK(std::isnan(value)); CHECK(parser.eof()); @@ -296,27 +296,27 @@ TEST_CASE("Parser Number Reading", "[parser]") { Parser parser = parser_from_c_str("key = \"inf\""); - float value; + float value = 0.0F; CHECK(parser.read("key", value)); CHECK(std::isinf(value)); - CHECK(value > 0.0f); + CHECK(value > 0.0F); CHECK(parser.eof()); CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = \"-inf\""); - float value; + float value = 0.0F; CHECK(parser.read("key", value)); CHECK(std::isinf(value)); - CHECK(value < 0.0f); + CHECK(value < 0.0F); CHECK(parser.eof()); CHECK(parser.is_valid()); } { Parser parser = parser_from_c_str("key = -123"); - int8_t value; + int8_t value = 0; CHECK(parser.read("key", value)); CHECK(value == -123); CHECK(parser.eof()); @@ -325,7 +325,7 @@ TEST_CASE("Parser Number Reading", "[parser]") { Parser parser = parser_from_c_str("key = 123"); - uint8_t value; + uint8_t value = 0; CHECK(parser.read("key", value)); CHECK(value == 123); CHECK(parser.eof()); @@ -334,7 +334,7 @@ TEST_CASE("Parser Number Reading", "[parser]") { Parser parser = parser_from_c_str("key = -1234"); - int16_t value; + int16_t value = 0; CHECK(parser.read("key", value)); CHECK(value == -1234); CHECK(parser.eof()); @@ -343,7 +343,7 @@ TEST_CASE("Parser Number Reading", "[parser]") { Parser parser = parser_from_c_str("key = 1234"); - uint16_t value; + uint16_t value = 0; CHECK(parser.read("key", value)); CHECK(value == 1234); CHECK(parser.eof()); @@ -352,7 +352,7 @@ TEST_CASE("Parser Number Reading", "[parser]") { Parser parser = parser_from_c_str("key = -123456"); - int32_t value; + int32_t value = 0; CHECK(parser.read("key", value)); CHECK(value == -123456); CHECK(parser.eof()); @@ -361,7 +361,7 @@ TEST_CASE("Parser Number Reading", "[parser]") { Parser parser = parser_from_c_str("key = 123456"); - uint32_t value; + uint32_t value = 0; CHECK(parser.read("key", value)); CHECK(value == 123456); CHECK(parser.eof()); @@ -370,7 +370,7 @@ TEST_CASE("Parser Number Reading", "[parser]") { Parser parser = parser_from_c_str("key = -1234567890123456"); - int64_t value; + int64_t value = 0; CHECK(parser.read("key", value)); CHECK(value == -1234567890123456LL); CHECK(parser.eof()); @@ -379,7 +379,7 @@ TEST_CASE("Parser Number Reading", "[parser]") { Parser parser = parser_from_c_str("key = 1234567890123456"); - uint64_t value; + uint64_t value = 0; CHECK(parser.read("key", value)); CHECK(value == 1234567890123456ULL); CHECK(parser.eof()); @@ -435,7 +435,7 @@ TEST_CASE("Parser Number Reading", "[parser]") { Parser parser = parser_from_c_str("key = -123"); - int8_t value; + int8_t value = 0; CHECK(parser.try_read("key", value, 1)); CHECK(value == -123); CHECK(parser.eof()); @@ -453,7 +453,7 @@ TEST_CASE("Parser Number Reading", "[parser]") { Parser parser = parser_from_c_str("key = 123"); - uint8_t value; + uint8_t value = 0; CHECK(parser.try_read("key", value, 1)); CHECK(value == 123); CHECK(parser.eof()); @@ -471,7 +471,7 @@ TEST_CASE("Parser Number Reading", "[parser]") { Parser parser = parser_from_c_str("key = -1234"); - int16_t value; + int16_t value = 0; CHECK(parser.try_read("key", value, 1)); CHECK(value == -1234); CHECK(parser.eof()); @@ -489,7 +489,7 @@ TEST_CASE("Parser Number Reading", "[parser]") { Parser parser = parser_from_c_str("key = 1234"); - uint16_t value; + uint16_t value = 0; CHECK(parser.try_read("key", value, 1)); CHECK(value == 1234); CHECK(parser.eof()); @@ -507,7 +507,7 @@ TEST_CASE("Parser Number Reading", "[parser]") { Parser parser = parser_from_c_str("key = -123456"); - int32_t value; + int32_t value = 0; CHECK(parser.try_read("key", value, 1)); CHECK(value == -123456); CHECK(parser.eof()); @@ -525,7 +525,7 @@ TEST_CASE("Parser Number Reading", "[parser]") { Parser parser = parser_from_c_str("key = 123456"); - uint32_t value; + uint32_t value = 0; CHECK(parser.try_read("key", value, 1)); CHECK(value == 123456); CHECK(parser.eof()); @@ -543,7 +543,7 @@ TEST_CASE("Parser Number Reading", "[parser]") { Parser parser = parser_from_c_str("key = -1234567890123456"); - int64_t value; + int64_t value = 0; CHECK(parser.try_read("key", value, 1)); CHECK(value == -1234567890123456LL); CHECK(parser.eof()); @@ -561,7 +561,7 @@ TEST_CASE("Parser Number Reading", "[parser]") { Parser parser = parser_from_c_str("key = 1234567890123456"); - uint64_t value; + uint64_t value = 0; CHECK(parser.try_read("key", value, 1)); CHECK(value == 1234567890123456ULL); CHECK(parser.eof()); From 1e89ab4221a3e66459c36f89f5944cc3548e9078 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 19 Dec 2021 16:30:18 -0500 Subject: [PATCH 138/285] chore: update Catch2 to v2.13.7 --- external/README.md | 2 +- external/catch2 | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/external/README.md b/external/README.md index 78396d8..e71e8c2 100644 --- a/external/README.md +++ b/external/README.md @@ -4,4 +4,4 @@ Good news! There are no external dependencies needed by this library at runtime! ## Catch -[Catch2 v2.11.0](https://github.com/catchorg/Catch2/releases/tag/v2.11.0) is used by our [unit tests](../tests). You will only need it if you run the unit tests and it is included as-is without modifications. +[Catch2 v2.13.7](https://github.com/catchorg/Catch2/releases/tag/v2.13.7) is used by our [unit tests](../tests). You will only need it if you run the unit tests and it is included as-is without modifications. diff --git a/external/catch2 b/external/catch2 index e1c9d55..c4e3767 160000 --- a/external/catch2 +++ b/external/catch2 @@ -1 +1 @@ -Subproject commit e1c9d5569dc4135babb9c81891d70a8ba8ed938c +Subproject commit c4e3767e265808590986d5db6ca1b5532a7f3d13 From aabce110339931821e61d0b4c44fa8bd9e1ad3b4 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 19 Dec 2021 16:30:45 -0500 Subject: [PATCH 139/285] feat: add support for arm64 on OS X --- make.py | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/make.py b/make.py index 8c84ba7..977fc10 100644 --- a/make.py +++ b/make.py @@ -75,11 +75,20 @@ def parse_argv(): sys.exit(1) else: if not args.cpu: - args.cpu = 'x64' + if platform.system() == 'Darwin' and platform.processor() == 'arm': + args.cpu = 'arm64' + else: + args.cpu = 'x64' if args.cpu == 'arm64': - if not args.compiler in ['vs2017', 'vs2019', 'ios', 'android']: - print('arm64 is only supported with VS2017, VS2019, Android, and iOS') + is_arm_supported = False + if args.compiler in ['vs2017', 'vs2019', 'ios', 'android']: + is_arm_supported = True + if platform.system() == 'Darwin' and platform.processor() == 'arm': + is_arm_supported = True + + if not is_arm_supported: + print('arm64 is only supported with VS2017, VS2019, Android, OS X (M1 processors), and iOS') sys.exit(1) elif args.cpu == 'armv7': if not args.compiler == 'android': From 711f9953d64507540801aaf9df90955083a715c7 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 22 Dec 2021 14:47:42 -0500 Subject: [PATCH 140/285] fix: xcode 13 ios compilation As of XCode 12 or 13, iOS compilation requires CODE_SIGNING_ALLOWED=NO to disable code signing for CI builds. --- cmake/Toolchain-iOS.cmake | 2 +- make.py | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/cmake/Toolchain-iOS.cmake b/cmake/Toolchain-iOS.cmake index 115bf2f..4bc4c44 100644 --- a/cmake/Toolchain-iOS.cmake +++ b/cmake/Toolchain-iOS.cmake @@ -10,8 +10,8 @@ execute_process(COMMAND xcrun --sdk iphoneos --find clang OUTPUT_VARIABLE CMAKE_ execute_process(COMMAND xcrun --sdk iphoneos --find clang++ OUTPUT_VARIABLE CMAKE_CXX_COMPILER OUTPUT_STRIP_TRAILING_WHITESPACE) set(CMAKE_MACOSX_BUNDLE YES) -set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED NO) set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") +set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "") set(CMAKE_OSX_SYSROOT iphoneos CACHE STRING "") set(CMAKE_OSX_ARCHITECTURES arm64 CACHE STRING "") set(CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 11.0) diff --git a/make.py b/make.py index 977fc10..6d38dbc 100644 --- a/make.py +++ b/make.py @@ -23,6 +23,7 @@ def parse_argv(): misc = parser.add_argument_group(title='Miscellaneous') misc.add_argument('-num_threads', help='No. to use while compiling') misc.add_argument('-tests_matching', help='Only run tests whose names match this regex') + misc.add_argument('-ci', action='store_true', help='Whether or not this is a Continuous Integration build') misc.add_argument('-help', action='help', help='Display this usage information') num_threads = multiprocessing.cpu_count() @@ -241,6 +242,11 @@ def do_generate_solution(build_dir, cmake_script_dir, args): if not platform.system() == 'Windows': extra_switches.append('-DCMAKE_BUILD_TYPE={}'.format(config.upper())) + if platform.system() == 'Darwin' and compiler == 'ios' and args.ci: + # Disable code signing for CI iOS builds since we just test compilation + extra_switches.append('-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED=NO') + extra_switches.append('-DCMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_ALLOWED=NO') + toolchain = get_toolchain(compiler, cmake_script_dir) if toolchain: extra_switches.append('-DCMAKE_TOOLCHAIN_FILE={}'.format(toolchain)) From 4e3e5b8a2813cd8f27739ecd8484b884710f9629 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 22 Dec 2021 16:55:55 -0500 Subject: [PATCH 141/285] chore: add -ci switch to GitHub actions --- .github/workflows/build.yml | 44 ++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5d79359..71e1404 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -26,27 +26,27 @@ jobs: - name: Setup ${{ matrix.compiler }} compiler run: ./tools/setup_linux_compiler.sh ${{ matrix.compiler }} - name: Building (debug-x86) - run: python3 make.py -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -build + run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -build - name: Running unit tests (debug-x86) - run: python3 make.py -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -unit_test + run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -unit_test - name: Clean run: python3 make.py -clean_only - name: Building (debug-x64) - run: python3 make.py -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -build + run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -build - name: Running unit tests (debug-x64) - run: python3 make.py -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -unit_test + run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -unit_test - name: Clean run: python3 make.py -clean_only - name: Building (release-x86) - run: python3 make.py -compiler ${{ matrix.compiler }} -config Release -cpu x86 -build + run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -build - name: Running unit tests (release-x86) - run: python3 make.py -compiler ${{ matrix.compiler }} -config Release -cpu x86 -unit_test + run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -unit_test - name: Clean run: python3 make.py -clean_only - name: Building (release-x64) - run: python3 make.py -compiler ${{ matrix.compiler }} -config Release -cpu x64 -build + run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -build - name: Running unit tests (release-x64) - run: python3 make.py -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test + run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test osx: runs-on: macos-10.15 strategy: @@ -61,40 +61,40 @@ jobs: run: ./tools/setup_osx_compiler.sh ${{ matrix.compiler }} - name: Building (debug-x86) if: ${{ matrix.compiler == 'xcode10' }} - run: python3 make.py -compiler osx -config Debug -cpu x86 -build + run: python3 make.py -ci -compiler osx -config Debug -cpu x86 -build - name: Running unit tests (debug-x86) if: ${{ matrix.compiler == 'xcode10' }} - run: python3 make.py -compiler osx -config Debug -cpu x86 -unit_test + run: python3 make.py -ci -compiler osx -config Debug -cpu x86 -unit_test - name: Clean if: ${{ matrix.compiler == 'xcode10' }} run: python3 make.py -clean_only - name: Building (debug-x64) - run: python3 make.py -compiler osx -config Debug -cpu x64 -build + run: python3 make.py -ci -compiler osx -config Debug -cpu x64 -build - name: Running unit tests (debug-x64) - run: python3 make.py -compiler osx -config Debug -cpu x64 -unit_test + run: python3 make.py -ci -compiler osx -config Debug -cpu x64 -unit_test - name: Clean run: python3 make.py -clean_only - name: Building (release-x86) if: ${{ matrix.compiler == 'xcode10' }} - run: python3 make.py -compiler osx -config Release -cpu x86 -build + run: python3 make.py -ci -compiler osx -config Release -cpu x86 -build - name: Running unit tests (release-x86) if: ${{ matrix.compiler == 'xcode10' }} - run: python3 make.py -compiler osx -config Release -cpu x86 -unit_test + run: python3 make.py -ci -compiler osx -config Release -cpu x86 -unit_test - name: Clean if: ${{ matrix.compiler == 'xcode10' }} run: python3 make.py -clean_only - name: Building (release-x64) - run: python3 make.py -compiler osx -config Release -cpu x64 -build + run: python3 make.py -ci -compiler osx -config Release -cpu x64 -build - name: Running unit tests (release-x64) - run: python3 make.py -compiler osx -config Release -cpu x64 -unit_test + run: python3 make.py -ci -compiler osx -config Release -cpu x64 -unit_test - name: Clean run: python3 make.py -clean_only - name: Building for iOS (debug-arm64) - run: python3 make.py -compiler ios -config Debug -build + run: python3 make.py -ci -compiler ios -config Debug -build - name: Clean run: python3 make.py -clean_only - name: Building for iOS (release-arm64) - run: python3 make.py -compiler ios -config Release -build + run: python3 make.py -ci -compiler ios -config Release -build emscripten: runs-on: ubuntu-18.04 steps: @@ -121,12 +121,12 @@ jobs: path: '~/.emscripten_cache' key: ${{ runner.os }}-emsdk-build-artifacts-1.39.11 - name: Building (debug) - run: python3 make.py -compiler emscripten -config debug -build + run: python3 make.py -ci -compiler emscripten -config debug -build - name: Running unit tests (debug) - run: python3 make.py -compiler emscripten -config debug -unit_test + run: python3 make.py -ci -compiler emscripten -config debug -unit_test - name: Clean run: python3 make.py -clean_only - name: Building (release) - run: python3 make.py -compiler emscripten -config release -build + run: python3 make.py -ci -compiler emscripten -config release -build - name: Running unit tests (release) - run: python3 make.py -compiler emscripten -config release -unit_test + run: python3 make.py -ci -compiler emscripten -config release -unit_test From 322a24b80c65cdd25f47251df0b12d6d3599c94b Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 22 Dec 2021 17:10:31 -0500 Subject: [PATCH 142/285] docs: update OS X architecture list --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2b776a9..d8659e1 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Unicode formats other than UTF-8 aren't supported. * Windows VS2019 with clang9 x86 and x64 * Linux (gcc 5 to 10) x86 and x64 * Linux (clang 4 to 11) x86 and x64 -* OS X (Xcode 10.3, 11.7) x86 and x64 +* OS X (Xcode 10.3, 11.7) x86, x64, and ARM64 * Android (NDK 21) ARMv7-A and ARM64 * iOS (Xcode 10.3) ARM64 * Emscripten (1.39.11) WASM From 8182d07e5a4cfdf682708e1740f6314aa73432da Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Thu, 23 Dec 2021 16:41:55 -0500 Subject: [PATCH 143/285] chore: add support for XCode 12 and 13 through CI --- README.md | 2 +- tools/setup_osx_compiler.sh | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d8659e1..d18d9a8 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Unicode formats other than UTF-8 aren't supported. * Windows VS2019 with clang9 x86 and x64 * Linux (gcc 5 to 10) x86 and x64 * Linux (clang 4 to 11) x86 and x64 -* OS X (Xcode 10.3, 11.7) x86, x64, and ARM64 +* OS X (Xcode 10.3, 11.7, 12.5, 13.2) x86, x64, and ARM64 * Android (NDK 21) ARMv7-A and ARM64 * iOS (Xcode 10.3) ARM64 * Emscripten (1.39.11) WASM diff --git a/tools/setup_osx_compiler.sh b/tools/setup_osx_compiler.sh index 6120fc2..dd98a3c 100755 --- a/tools/setup_osx_compiler.sh +++ b/tools/setup_osx_compiler.sh @@ -10,7 +10,9 @@ if [[ $COMPILER == xcode10 ]]; then elif [[ $COMPILER == xcode11 ]]; then XCODE_PATH="/Applications/Xcode_11.7.app" elif [[ $COMPILER == xcode12 ]]; then - XCODE_PATH="/Applications/Xcode_12.3.app" + XCODE_PATH="/Applications/Xcode_12.5.1.app" +elif [[ $COMPILER == xcode13 ]]; then + XCODE_PATH="/Applications/Xcode_13.2.1.app" fi # Select our XCode version From 594556debd4133cb663d33f2d19b3d4987f67459 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Thu, 23 Dec 2021 16:46:03 -0500 Subject: [PATCH 144/285] chore: add XCode 12 and 13 to CI --- .github/workflows/build.yml | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 71e1404..3bed8f4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,7 +47,7 @@ jobs: run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -build - name: Running unit tests (release-x64) run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test - osx: + osx-10: runs-on: macos-10.15 strategy: matrix: @@ -95,6 +95,36 @@ jobs: run: python3 make.py -clean_only - name: Building for iOS (release-arm64) run: python3 make.py -ci -compiler ios -config Release -build + osx-11: + runs-on: macos-11 + strategy: + matrix: + compiler: [xcode12, xcode13] + steps: + - name: Git checkout + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: Setup ${{ matrix.compiler }} compiler + run: ./tools/setup_osx_compiler.sh ${{ matrix.compiler }} + - name: Building (debug-x64) + run: python3 make.py -ci -compiler osx -config Debug -cpu x64 -build + - name: Running unit tests (debug-x64) + run: python3 make.py -ci -compiler osx -config Debug -cpu x64 -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building (release-x64) + run: python3 make.py -ci -compiler osx -config Release -cpu x64 -build + - name: Running unit tests (release-x64) + run: python3 make.py -ci -compiler osx -config Release -cpu x64 -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building for iOS (debug-arm64) + run: python3 make.py -ci -compiler ios -config Debug -build + - name: Clean + run: python3 make.py -clean_only + - name: Building for iOS (release-arm64) + run: python3 make.py -ci -compiler ios -config Release -build emscripten: runs-on: ubuntu-18.04 steps: From 3bd8ad478c8264025acd0f3472e01744297f61af Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 29 Dec 2021 16:34:39 -0500 Subject: [PATCH 145/285] feat: add support for native linux arm64 compilation --- make.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/make.py b/make.py index 6d38dbc..eb32c42 100644 --- a/make.py +++ b/make.py @@ -36,6 +36,10 @@ def parse_argv(): args = parser.parse_args() + is_arm64_cpu = False + if platform.machine() == 'arm64' or platform.machine() == 'aarch64': + is_arm64_cpu = True + # Sanitize and validate our options if args.compiler == 'android': if not args.cpu: @@ -76,20 +80,26 @@ def parse_argv(): sys.exit(1) else: if not args.cpu: - if platform.system() == 'Darwin' and platform.processor() == 'arm': + if is_arm64_cpu: args.cpu = 'arm64' else: args.cpu = 'x64' if args.cpu == 'arm64': is_arm_supported = False + + # Cross compilation if args.compiler in ['vs2017', 'vs2019', 'ios', 'android']: is_arm_supported = True - if platform.system() == 'Darwin' and platform.processor() == 'arm': + + # Native compilation + if platform.system() == 'Darwin' and is_arm64_cpu: + is_arm_supported = True + elif platform.system() == 'Linux' and is_arm64_cpu: is_arm_supported = True if not is_arm_supported: - print('arm64 is only supported with VS2017, VS2019, Android, OS X (M1 processors), and iOS') + print('arm64 is only supported with VS2017, VS2019, OS X (M1 processors), Linux, Android, and iOS') sys.exit(1) elif args.cpu == 'armv7': if not args.compiler == 'android': From eeb8997aa5eca36f2788fd679870f8014beae1e2 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 29 Dec 2021 17:18:19 -0500 Subject: [PATCH 146/285] feat: add CI job for arm64 linux --- .github/workflows/build.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3bed8f4..dcbdc2d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -47,6 +47,7 @@ jobs: run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -build - name: Running unit tests (release-x64) run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test + osx-10: runs-on: macos-10.15 strategy: @@ -95,6 +96,7 @@ jobs: run: python3 make.py -clean_only - name: Building for iOS (release-arm64) run: python3 make.py -ci -compiler ios -config Release -build + osx-11: runs-on: macos-11 strategy: @@ -125,6 +127,7 @@ jobs: run: python3 make.py -clean_only - name: Building for iOS (release-arm64) run: python3 make.py -ci -compiler ios -config Release -build + emscripten: runs-on: ubuntu-18.04 steps: @@ -160,3 +163,27 @@ jobs: run: python3 make.py -ci -compiler emscripten -config release -build - name: Running unit tests (release) run: python3 make.py -ci -compiler emscripten -config release -unit_test + + linux-arm64: + runs-on: ubuntu-latest + steps: + - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset + - uses: docker://multiarch/ubuntu-core:arm64-focal + with: + args: 'uname -a' + - name: Git checkout + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: Setup build tools + uses: docker://multiarch/ubuntu-core:arm64-focal + with: + args: 'bash -c "apt-get update && apt-get install -y build-essential"' + - name: Building (release) + uses: docker://multiarch/ubuntu-core:arm64-focal + with: + args: 'bash -c "python3 make.py -ci -config release -build"' + - name: Running unit tests (release) + uses: docker://multiarch/ubuntu-core:arm64-focal + with: + args: 'bash -c "python3 make.py -ci -config release -unit_test"' From beee2f87abcf34c46815fe7dee572eb4c822e65a Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 29 Dec 2021 17:21:55 -0500 Subject: [PATCH 147/285] fix: add missing python3 and cmake dependencies --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index dcbdc2d..7e10c42 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -178,7 +178,7 @@ jobs: - name: Setup build tools uses: docker://multiarch/ubuntu-core:arm64-focal with: - args: 'bash -c "apt-get update && apt-get install -y build-essential"' + args: 'bash -c "apt-get update && apt-get install -y build-essential python3 cmake"' - name: Building (release) uses: docker://multiarch/ubuntu-core:arm64-focal with: From fa79d59e18cfb8f36d48e7d74ae43e8143f8e025 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 29 Dec 2021 17:29:46 -0500 Subject: [PATCH 148/285] fix: make apt-get non interactive to avoid tzdata selection --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7e10c42..5dfd2f4 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -178,7 +178,7 @@ jobs: - name: Setup build tools uses: docker://multiarch/ubuntu-core:arm64-focal with: - args: 'bash -c "apt-get update && apt-get install -y build-essential python3 cmake"' + args: 'bash -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential python3 cmake"' - name: Building (release) uses: docker://multiarch/ubuntu-core:arm64-focal with: From a857a5e8f8b8caffed5c9feadc52ed814f424472 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 29 Dec 2021 17:36:16 -0500 Subject: [PATCH 149/285] fix: run everything in a single step --- .github/workflows/build.yml | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 5dfd2f4..72d21a1 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -175,15 +175,7 @@ jobs: uses: actions/checkout@v2 with: submodules: 'recursive' - - name: Setup build tools + - name: Build and run unit tests (release) uses: docker://multiarch/ubuntu-core:arm64-focal with: - args: 'bash -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential python3 cmake"' - - name: Building (release) - uses: docker://multiarch/ubuntu-core:arm64-focal - with: - args: 'bash -c "python3 make.py -ci -config release -build"' - - name: Running unit tests (release) - uses: docker://multiarch/ubuntu-core:arm64-focal - with: - args: 'bash -c "python3 make.py -ci -config release -unit_test"' + args: 'bash -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential python3 cmake && python3 make.py -ci -config release -build -unit_test"' From d9a6053d18e919cecbdef111472cfae8925aaff9 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 29 Dec 2021 17:48:05 -0500 Subject: [PATCH 150/285] fix: remove arm64 linux CI Build is too slow at 10mins to compile 4 cpp files. Keeping history to revisit this at a later date. --- .github/workflows/build.yml | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 72d21a1..c008342 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -163,19 +163,3 @@ jobs: run: python3 make.py -ci -compiler emscripten -config release -build - name: Running unit tests (release) run: python3 make.py -ci -compiler emscripten -config release -unit_test - - linux-arm64: - runs-on: ubuntu-latest - steps: - - run: docker run --rm --privileged multiarch/qemu-user-static:register --reset - - uses: docker://multiarch/ubuntu-core:arm64-focal - with: - args: 'uname -a' - - name: Git checkout - uses: actions/checkout@v2 - with: - submodules: 'recursive' - - name: Build and run unit tests (release) - uses: docker://multiarch/ubuntu-core:arm64-focal - with: - args: 'bash -c "apt-get update && DEBIAN_FRONTEND=noninteractive apt-get install -y build-essential python3 cmake && python3 make.py -ci -config release -build -unit_test"' From d222547ec687c01b7d299c82b2458cc2456da991 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 8 Jan 2022 15:23:29 -0500 Subject: [PATCH 151/285] docs: update supported platform list --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index d18d9a8..e402aa6 100644 --- a/README.md +++ b/README.md @@ -41,15 +41,14 @@ Unicode formats other than UTF-8 aren't supported. * Windows VS2019 with clang9 x86 and x64 * Linux (gcc 5 to 10) x86 and x64 * Linux (clang 4 to 11) x86 and x64 -* OS X (Xcode 10.3, 11.7, 12.5, 13.2) x86, x64, and ARM64 +* OS X (Xcode 10.3) x86 and x64 +* OS X (Xcode 11.7, 12.5, 13.2) x64 and ARM64 * Android (NDK 21) ARMv7-A and ARM64 -* iOS (Xcode 10.3) ARM64 +* iOS (Xcode 10.3, 11.7, 12.5, 13.2) ARM64 * Emscripten (1.39.11) WASM The above supported platform list is only what is tested every release but if it compiles, it should run just fine. -Notes: *VS2017* and *VS2019* compile with *ARM64* on *AppVeyor* but I have no device to test them with. Xcode 11 no longer supports x86. - ## External dependencies There are none! You don't need anything else to get started: everything is self contained. From faae529bce8efa34799b7624216e0419804102a7 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 17 Jan 2022 22:01:48 -0500 Subject: [PATCH 152/285] chore: add secrets guard to avoid running in PR from fork --- .github/workflows/sonarcloud.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 34a96e7..03f738b 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -13,7 +13,21 @@ on: - '**/*.md' jobs: + condition-check: + runs-on: ubuntu-latest + outputs: + ok: ${{ steps.check-secrets.outputs.ok }} + steps: + - name: Secret guard + id: check-secrets + run: | + if [ ! -z "${{ secrets.SONAR_TOKEN }}" ]; then + echo "::set-output name=ok::true" + fi sonarcloud: + needs: + - condition-check + if: ${{ needs.condition-check.outputs.ok == 'true' }} runs-on: ubuntu-18.04 steps: - name: Git checkout From 1c64b47abb599610e16b07d19201da0ef3ba21aa Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 17 Jan 2022 22:07:12 -0500 Subject: [PATCH 153/285] chore: pin ubuntu version --- .github/workflows/sonarcloud.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 03f738b..fad8aa8 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -14,7 +14,7 @@ on: jobs: condition-check: - runs-on: ubuntu-latest + runs-on: ubuntu-18.04 outputs: ok: ${{ steps.check-secrets.outputs.ok }} steps: From 3f521eaa5c89a361cdf4c257d98edc922cc10501 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 20 Feb 2022 12:32:03 -0500 Subject: [PATCH 154/285] chore: rename and split build workflow --- .github/workflows/{build.yml => build_pull_request.yml} | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) rename .github/workflows/{build.yml => build_pull_request.yml} (98%) diff --git a/.github/workflows/build.yml b/.github/workflows/build_pull_request.yml similarity index 98% rename from .github/workflows/build.yml rename to .github/workflows/build_pull_request.yml index c008342..8c1f419 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build_pull_request.yml @@ -1,11 +1,6 @@ -name: build +name: build pull request on: - push: - branches: - - '**' - paths-ignore: - - '**/*.md' pull_request: branches: - '**' From 5baf23c66ecd977f1f49a459198a522a70da8a0e Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 20 Feb 2022 12:33:20 -0500 Subject: [PATCH 155/285] chore: add push workflow Only test latest compilers --- .github/workflows/build_push.yml | 111 +++++++++++++++++++++++++++++++ 1 file changed, 111 insertions(+) create mode 100644 .github/workflows/build_push.yml diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml new file mode 100644 index 0000000..b8bd47c --- /dev/null +++ b/.github/workflows/build_push.yml @@ -0,0 +1,111 @@ +name: build + +on: + push: + branches: + - '**' + paths-ignore: + - '**/*.md' + +jobs: + linux: + runs-on: ubuntu-18.04 + strategy: + matrix: + compiler: [gcc10, clang11] + steps: + - name: Git checkout + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: Setup ${{ matrix.compiler }} compiler + run: ./tools/setup_linux_compiler.sh ${{ matrix.compiler }} + - name: Building (debug-x86) + run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -build + - name: Running unit tests (debug-x86) + run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building (debug-x64) + run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -build + - name: Running unit tests (debug-x64) + run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building (release-x86) + run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -build + - name: Running unit tests (release-x86) + run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building (release-x64) + run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -build + - name: Running unit tests (release-x64) + run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test + + osx-11: + runs-on: macos-11 + strategy: + matrix: + compiler: [xcode13] + steps: + - name: Git checkout + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: Setup ${{ matrix.compiler }} compiler + run: ./tools/setup_osx_compiler.sh ${{ matrix.compiler }} + - name: Building (debug-x64) + run: python3 make.py -ci -compiler osx -config Debug -cpu x64 -build + - name: Running unit tests (debug-x64) + run: python3 make.py -ci -compiler osx -config Debug -cpu x64 -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building (release-x64) + run: python3 make.py -ci -compiler osx -config Release -cpu x64 -build + - name: Running unit tests (release-x64) + run: python3 make.py -ci -compiler osx -config Release -cpu x64 -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building for iOS (debug-arm64) + run: python3 make.py -ci -compiler ios -config Debug -build + - name: Clean + run: python3 make.py -clean_only + - name: Building for iOS (release-arm64) + run: python3 make.py -ci -compiler ios -config Release -build + + emscripten: + runs-on: ubuntu-18.04 + steps: + - name: Git checkout + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: Cache emsdk + uses: actions/cache@v1 + id: 'emsdk' + with: + path: 'emsdk-cache' + key: ${{ runner.os }}-emsdk-1.39.11 + - name: Setup emsdk + uses: mymindstorm/setup-emsdk@v7 + with: + version: 1.39.11 + no-cache: true + actions-cache-folder: 'emsdk-cache' + - name: Cache emsdk build artifacts + uses: actions/cache@v1 + id: 'emsdk-build-artifacts' + with: + path: '~/.emscripten_cache' + key: ${{ runner.os }}-emsdk-build-artifacts-1.39.11 + - name: Building (debug) + run: python3 make.py -ci -compiler emscripten -config debug -build + - name: Running unit tests (debug) + run: python3 make.py -ci -compiler emscripten -config debug -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building (release) + run: python3 make.py -ci -compiler emscripten -config release -build + - name: Running unit tests (release) + run: python3 make.py -ci -compiler emscripten -config release -unit_test From a5c8ff1f185d0d6f0884e18fccad0f54d84652a3 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 20 Feb 2022 12:34:22 -0500 Subject: [PATCH 156/285] chore: only run latest compiler on push --- appveyor.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/appveyor.yml b/appveyor.yml index e869dc4..47e02dd 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -35,6 +35,11 @@ matrix: platform: arm64 toolchain: clang + +init: +# Only run latest compiler on push, run everything on pull request +- ps: if (!$env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_WORKER_IMAGE -ne "Visual Studio 2019") {Exit-AppveyorBuild} + install: - cmd: >- git submodule update --init --recursive From b2cfbab2fea627e5b2878828788e9d10aebbfbe2 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 13 Mar 2022 16:28:05 -0400 Subject: [PATCH 157/285] fix: clarify polyfill usage and clean up --- includes/sjson/impl/compiler_utils.h | 35 ++++++++++++++-------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/includes/sjson/impl/compiler_utils.h b/includes/sjson/impl/compiler_utils.h index 1293a8c..2f04b17 100644 --- a/includes/sjson/impl/compiler_utils.h +++ b/includes/sjson/impl/compiler_utils.h @@ -24,33 +24,34 @@ // SOFTWARE. //////////////////////////////////////////////////////////////////////////////// -#if !defined(__GNUG__) || defined(_LIBCPP_VERSION) || defined(_GLIBCXX_USE_CXX11_ABI) - #include -#else +////////////////////////////////////////////////////////////////////////// +// The Android NDK r10 and possibly earlier used a STD lib that poorly supported C++11. +// As such, it is necessary to polyfill a few missing things. +////////////////////////////////////////////////////////////////////////// +#if defined(__GNUG__) && defined(__ANDROID__) && __GNUC__ < 5 + #define SJSON_CPP_IMPL_POLYFILL_STD +#endif + +#if defined(SJSON_CPP_IMPL_POLYFILL_STD) #include +#else + #include #endif namespace sjson { - ////////////////////////////////////////////////////////////////////////// - // The version of the STL shipped with versions of GCC older than 5.1 are missing a number of type traits and functions, - // such as std::is_trivially_default_constructible. - // In this case, we polyfill the proper standard names using the deprecated std::has_trivial_default_constructor. - // This must also be done when the compiler is clang when it makes use of the GCC implementation of the STL, - // which is the default behavior on linux. Properly detecting the version of the GCC STL used by clang cannot - // be done with the __GNUC__ macro, which are overridden by clang. Instead, we check for the definition - // of the macro ``_GLIBCXX_USE_CXX11_ABI`` which is only defined with GCC versions greater than 5. - ////////////////////////////////////////////////////////////////////////// namespace sjson_impl { -#if !defined(__GNUG__) || defined(_LIBCPP_VERSION) || defined(_GLIBCXX_USE_CXX11_ABI) - using std::strtoull; - using std::strtoll; - using std::strtof; -#else +#if defined(SJSON_CPP_IMPL_POLYFILL_STD) + // We need to polyfill these, bring the C version into our namespace using ::strtoull; using ::strtoll; using ::strtof; +#else + // These properly exist in the C++ version, use them + using std::strtoull; + using std::strtoll; + using std::strtof; #endif } } From a9b51f9b3eb01ab2820f2aeffc54fda1ca69cb50 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 13 Mar 2022 16:28:20 -0400 Subject: [PATCH 158/285] fix: avoid shadow warning on older GCC versions --- includes/sjson/string_view.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/includes/sjson/string_view.h b/includes/sjson/string_view.h index fc6be9e..07c4764 100644 --- a/includes/sjson/string_view.h +++ b/includes/sjson/string_view.h @@ -52,25 +52,25 @@ namespace sjson , m_length(0) {} - StringView(const char* c_str, size_t length) - : m_c_str(c_str) + StringView(const char* str, size_t length) + : m_c_str(str) , m_length(length) { #if defined(SJSON_CPP_USE_ERROR_CHECKS) && !defined(NDEBUG) for (size_t i = 0; i < length; ++i) - SJSON_CPP_ASSERT(c_str[i] != '\0', "StringView cannot contain NULL terminators"); + SJSON_CPP_ASSERT(str[i] != '\0', "StringView cannot contain NULL terminators"); #endif } - StringView(const char* c_str) - : m_c_str(c_str) - , m_length(c_str == nullptr ? 0 : std::strlen(c_str)) + StringView(const char* str) + : m_c_str(str) + , m_length(str == nullptr ? 0 : std::strlen(str)) {} - StringView& operator=(const char* c_str) + StringView& operator=(const char* str) { - m_c_str = c_str; - m_length = c_str == nullptr ? 0 : std::strlen(c_str); + m_c_str = str; + m_length = str == nullptr ? 0 : std::strlen(str); return *this; } @@ -78,19 +78,19 @@ namespace sjson constexpr size_t size() const { return m_length; } constexpr bool empty() const { return m_length == 0; } - bool operator==(const char* c_str) const + bool operator==(const char* str) const { - const size_t length = c_str == nullptr ? 0 : std::strlen(c_str); + const size_t length = str == nullptr ? 0 : std::strlen(str); if (m_length != length) return false; - if (m_c_str == c_str || length == 0) + if (m_c_str == str || length == 0) return true; - return std::memcmp(m_c_str, c_str, length) == 0; + return std::memcmp(m_c_str, str, length) == 0; } - bool operator!=(const char* c_str) const { return !(*this == c_str); } + bool operator!=(const char* str) const { return !(*this == str); } bool operator==(const StringView& other) const { From 777341bf623b546bd5f7f81b2de66c218c2a095b Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 13 Mar 2022 16:29:56 -0400 Subject: [PATCH 159/285] feat: add support for GCC 4.8 and 4.9 --- make.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/make.py b/make.py index eb32c42..aa54974 100644 --- a/make.py +++ b/make.py @@ -16,7 +16,7 @@ def parse_argv(): actions.add_argument('-unit_test', action='store_true') target = parser.add_argument_group(title='Target') - target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'vs2019-clang', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'clang10', 'clang11', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'gcc10', 'osx', 'ios', 'emscripten'], help='Defaults to the host system\'s default compiler') + target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'vs2019-clang', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'clang10', 'clang11', 'gcc4.8', 'gcc4.9', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'gcc10', 'osx', 'ios', 'emscripten'], help='Defaults to the host system\'s default compiler') target.add_argument('-config', choices=['Debug', 'Release'], type=str.capitalize) target.add_argument('-cpu', choices=['x86', 'x64', 'armv7', 'arm64', 'wasm'], help='Defaults to the host system\'s architecture') @@ -212,6 +212,12 @@ def set_compiler_env(compiler, args): elif compiler == 'clang11': os.environ['CC'] = 'clang-11' os.environ['CXX'] = 'clang++-11' + elif compiler == 'gcc4.8': + os.environ['CC'] = 'gcc-4.8' + os.environ['CXX'] = 'g++-4.8' + elif compiler == 'gcc4.9': + os.environ['CC'] = 'gcc-4.9' + os.environ['CXX'] = 'g++-4.9' elif compiler == 'gcc5': os.environ['CC'] = 'gcc-5' os.environ['CXX'] = 'g++-5' From 26c3d8412f24c6b2c4b5f6ffb38fe2756ef0f6aa Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 13 Mar 2022 16:33:52 -0400 Subject: [PATCH 160/285] style: rename header --- includes/sjson/impl/{compiler_utils.h => cstdlib.impl.h} | 0 includes/sjson/parser.h | 2 +- 2 files changed, 1 insertion(+), 1 deletion(-) rename includes/sjson/impl/{compiler_utils.h => cstdlib.impl.h} (100%) diff --git a/includes/sjson/impl/compiler_utils.h b/includes/sjson/impl/cstdlib.impl.h similarity index 100% rename from includes/sjson/impl/compiler_utils.h rename to includes/sjson/impl/cstdlib.impl.h diff --git a/includes/sjson/parser.h b/includes/sjson/parser.h index e19c660..f897830 100644 --- a/includes/sjson/parser.h +++ b/includes/sjson/parser.h @@ -31,7 +31,7 @@ #include "sjson/parser_error.h" #include "sjson/parser_state.h" -#include "sjson/impl/compiler_utils.h" +#include "sjson/impl/cstdlib.impl.h" #include "sjson/string_view.h" #include From c4ec5cfa54258581a42d2ae74bc64d4b6c50f668 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 13 Mar 2022 16:34:07 -0400 Subject: [PATCH 161/285] fix: always set makeflags --- make.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/make.py b/make.py index aa54974..d2e4bf5 100644 --- a/make.py +++ b/make.py @@ -187,7 +187,6 @@ def get_toolchain(compiler, cmake_script_dir): def set_compiler_env(compiler, args): if platform.system() == 'Linux': - os.environ['MAKEFLAGS'] = '-j{}'.format(args.num_threads) if compiler == 'clang4': os.environ['CC'] = 'clang-4.0' os.environ['CXX'] = 'clang++-4.0' @@ -390,6 +389,9 @@ def do_tests(build_dir, args): print('Using compiler: {}'.format(args.compiler)) print('Using {} threads'.format(args.num_threads)) + # Make sure 'make' runs with all available cores + os.environ['MAKEFLAGS'] = '-j{}'.format(args.num_threads) + do_generate_solution(build_dir, cmake_script_dir, args) if args.build: From c249b614cbd126be6f5e58a92da74d8e6fec6eed Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 13 Mar 2022 16:52:35 -0400 Subject: [PATCH 162/285] feat: add a versioned namespace This allows multiple cpp/obj files to coexist with different versions of sjson-cpp since symbols will be unique per version. --- includes/sjson/error.h | 16 +++++++- includes/sjson/impl/cstdlib.impl.h | 6 +++ includes/sjson/parser.h | 5 +++ includes/sjson/parser_error.h | 6 +++ includes/sjson/parser_state.h | 5 +++ includes/sjson/string_view.h | 5 +++ includes/sjson/version.h | 65 ++++++++++++++++++++++++++++++ includes/sjson/writer.h | 5 +++ 8 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 includes/sjson/version.h diff --git a/includes/sjson/error.h b/includes/sjson/error.h index 65936df..90a2286 100644 --- a/includes/sjson/error.h +++ b/includes/sjson/error.h @@ -61,12 +61,16 @@ #if defined(SJSON_CPP_ON_ASSERT_ABORT) + #include "sjson/version.h" + #include #include #include namespace sjson { + SJSON_IMPL_VERSION_NAMESPACE_BEGIN + namespace error_impl { inline void on_assert_abort(const char* expression, int line, const char* file, const char* format, ...) @@ -86,13 +90,17 @@ std::abort(); } } + + SJSON_IMPL_VERSION_NAMESPACE_END } - #define SJSON_CPP_ASSERT(expression, format, ...) do { if (!(expression)) sjson::error_impl::on_assert_abort(#expression, __LINE__, __FILE__, (format), ## __VA_ARGS__); } while (false) + #define SJSON_CPP_ASSERT(expression, format, ...) do { if (!(expression)) SJSON_IMPL_NAMESPACE::error_impl::on_assert_abort(#expression, __LINE__, __FILE__, (format), ## __VA_ARGS__); } while (false) #define SJSON_CPP_HAS_ASSERT_CHECKS #elif defined(SJSON_CPP_ON_ASSERT_THROW) + #include "sjson/version.h" + #include #include #include @@ -100,6 +108,8 @@ namespace sjson { + SJSON_IMPL_VERSION_NAMESPACE_BEGIN + class runtime_assert final : public std::runtime_error { using std::runtime_error::runtime_error; // Inherit constructors @@ -129,9 +139,11 @@ throw runtime_assert("Failed to format assert message!\n"); } } + + SJSON_IMPL_VERSION_NAMESPACE_END } - #define SJSON_CPP_ASSERT(expression, format, ...) do { if (!(expression)) sjson::error_impl::on_assert_throw(#expression, __LINE__, __FILE__, (format), ## __VA_ARGS__); } while(false) + #define SJSON_CPP_ASSERT(expression, format, ...) do { if (!(expression)) SJSON_IMPL_NAMESPACE::error_impl::on_assert_throw(#expression, __LINE__, __FILE__, (format), ## __VA_ARGS__); } while(false) #define SJSON_CPP_HAS_ASSERT_CHECKS #elif defined(SJSON_CPP_ON_ASSERT_CUSTOM) diff --git a/includes/sjson/impl/cstdlib.impl.h b/includes/sjson/impl/cstdlib.impl.h index 2f04b17..65cfefb 100644 --- a/includes/sjson/impl/cstdlib.impl.h +++ b/includes/sjson/impl/cstdlib.impl.h @@ -24,6 +24,8 @@ // SOFTWARE. //////////////////////////////////////////////////////////////////////////////// +#include "sjson/version.h" + ////////////////////////////////////////////////////////////////////////// // The Android NDK r10 and possibly earlier used a STD lib that poorly supported C++11. // As such, it is necessary to polyfill a few missing things. @@ -40,6 +42,8 @@ namespace sjson { + SJSON_IMPL_VERSION_NAMESPACE_BEGIN + namespace sjson_impl { #if defined(SJSON_CPP_IMPL_POLYFILL_STD) @@ -54,4 +58,6 @@ namespace sjson using std::strtof; #endif } + + SJSON_IMPL_VERSION_NAMESPACE_END } diff --git a/includes/sjson/parser.h b/includes/sjson/parser.h index f897830..6051936 100644 --- a/includes/sjson/parser.h +++ b/includes/sjson/parser.h @@ -31,6 +31,7 @@ #include "sjson/parser_error.h" #include "sjson/parser_state.h" +#include "sjson/version.h" #include "sjson/impl/cstdlib.impl.h" #include "sjson/string_view.h" @@ -43,6 +44,8 @@ namespace sjson { + SJSON_IMPL_VERSION_NAMESPACE_BEGIN + class Parser { public: @@ -1009,4 +1012,6 @@ namespace sjson m_state.error.column = m_state.column; } }; + + SJSON_IMPL_VERSION_NAMESPACE_END } diff --git a/includes/sjson/parser_error.h b/includes/sjson/parser_error.h index 16bb22f..2e773a2 100644 --- a/includes/sjson/parser_error.h +++ b/includes/sjson/parser_error.h @@ -24,10 +24,14 @@ // SOFTWARE. //////////////////////////////////////////////////////////////////////////////// +#include "sjson/version.h" + #include namespace sjson { + SJSON_IMPL_VERSION_NAMESPACE_BEGIN + struct ParserError { enum : uint32_t @@ -106,4 +110,6 @@ namespace sjson } } }; + + SJSON_IMPL_VERSION_NAMESPACE_END } diff --git a/includes/sjson/parser_state.h b/includes/sjson/parser_state.h index e95bcab..387551a 100644 --- a/includes/sjson/parser_state.h +++ b/includes/sjson/parser_state.h @@ -25,12 +25,15 @@ //////////////////////////////////////////////////////////////////////////////// #include "sjson/parser_error.h" +#include "sjson/version.h" #include #include namespace sjson { + SJSON_IMPL_VERSION_NAMESPACE_BEGIN + struct ParserState { ParserState(const char* input, size_t input_length) @@ -49,4 +52,6 @@ namespace sjson ParserError error; }; + + SJSON_IMPL_VERSION_NAMESPACE_END } diff --git a/includes/sjson/string_view.h b/includes/sjson/string_view.h index 07c4764..c504034 100644 --- a/includes/sjson/string_view.h +++ b/includes/sjson/string_view.h @@ -25,12 +25,15 @@ //////////////////////////////////////////////////////////////////////////////// #include "sjson/error.h" +#include "sjson/version.h" #include #include namespace sjson { + SJSON_IMPL_VERSION_NAMESPACE_BEGIN + ////////////////////////////////////////////////////////////////////////// // A StringView is just a pointer to a string and an associated length. // It does NOT own the memory and no allocation or deallocation ever takes place. @@ -115,4 +118,6 @@ namespace sjson const char* m_c_str; size_t m_length; }; + + SJSON_IMPL_VERSION_NAMESPACE_END } diff --git a/includes/sjson/version.h b/includes/sjson/version.h new file mode 100644 index 0000000..ecaa06f --- /dev/null +++ b/includes/sjson/version.h @@ -0,0 +1,65 @@ +#pragma once + +//////////////////////////////////////////////////////////////////////////////// +// The MIT License (MIT) +// +// Copyright (c) 2022 Nicholas Frechette, Cody Jones, and sjson-cpp contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +//////////////////////////////////////////////////////////////////////////////// + +//////////////////////////////////////////////////////////////////////////////// +// Macros to detect the sjson-cpp version +//////////////////////////////////////////////////////////////////////////////// + +#define SJSON_CPP_VERSION_MAJOR 0 +#define SJSON_CPP_VERSION_MINOR 8 +#define SJSON_CPP_VERSION_PATCH 1 + +//////////////////////////////////////////////////////////////////////////////// +// In order to allow multiple versions of this library to coexist side by side +// within the same executable/library, the symbols have to be unique per version. +// We achieve this by using a versioned namespace that we optionally inline. +// To disable namespace inlining, define SJSON_NO_INLINE_NAMESPACE before including +// any sjson-cpp header. +//////////////////////////////////////////////////////////////////////////////// + +// Name of the namespace, e.g. v08 +#define SJSON_IMPL_VERSION_NAMESPACE_NAME v ## SJSON_CPP_VERSION_MAJOR ## SJSON_CPP_VERSION_MINOR + +#if defined(SJSON_NO_INLINE_NAMESPACE) + // Namespace won't be inlined, its usage will have to be qualified with the + // full version everywhere + #define SJSON_IMPL_NAMESPACE sjson::SJSON_IMPL_VERSION_NAMESPACE_NAME + + #define SJSON_IMPL_VERSION_NAMESPACE_BEGIN \ + namespace SJSON_IMPL_VERSION_NAMESPACE_NAME \ + { +#else + // Namespace is inlined, its usage does not need to be qualified with the + // full version everywhere + #define SJSON_IMPL_NAMESPACE sjson + + #define SJSON_IMPL_VERSION_NAMESPACE_BEGIN \ + inline namespace SJSON_IMPL_VERSION_NAMESPACE_NAME \ + { +#endif + +#define SJSON_IMPL_VERSION_NAMESPACE_END \ + } diff --git a/includes/sjson/writer.h b/includes/sjson/writer.h index d63dcea..7853983 100644 --- a/includes/sjson/writer.h +++ b/includes/sjson/writer.h @@ -30,6 +30,7 @@ #endif #include "sjson/error.h" +#include "sjson/version.h" #include #include @@ -42,6 +43,8 @@ namespace sjson { + SJSON_IMPL_VERSION_NAMESPACE_BEGIN + // TODO: Cleanup the locking stuff, wrap it in #ifdef to strip when asserts are disabled class Writer; @@ -761,4 +764,6 @@ namespace sjson inline Writer::Writer(StreamWriter& stream_writer) : ObjectWriter(stream_writer, 0) {} + + SJSON_IMPL_VERSION_NAMESPACE_END } From 7dcd187cdbed44b5137ebfe752c0c98159724275 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 13 Mar 2022 16:59:06 -0400 Subject: [PATCH 163/285] style: rename macro names for consistency --- includes/sjson/error.h | 12 ++++++------ includes/sjson/impl/cstdlib.impl.h | 4 ++-- includes/sjson/parser.h | 4 ++-- includes/sjson/parser_error.h | 4 ++-- includes/sjson/parser_state.h | 4 ++-- includes/sjson/string_view.h | 4 ++-- includes/sjson/version.h | 20 ++++++++++---------- includes/sjson/writer.h | 4 ++-- 8 files changed, 28 insertions(+), 28 deletions(-) diff --git a/includes/sjson/error.h b/includes/sjson/error.h index 90a2286..aae9211 100644 --- a/includes/sjson/error.h +++ b/includes/sjson/error.h @@ -69,7 +69,7 @@ namespace sjson { - SJSON_IMPL_VERSION_NAMESPACE_BEGIN + SJSON_CPP_IMPL_VERSION_NAMESPACE_BEGIN namespace error_impl { @@ -91,10 +91,10 @@ } } - SJSON_IMPL_VERSION_NAMESPACE_END + SJSON_CPP_IMPL_VERSION_NAMESPACE_END } - #define SJSON_CPP_ASSERT(expression, format, ...) do { if (!(expression)) SJSON_IMPL_NAMESPACE::error_impl::on_assert_abort(#expression, __LINE__, __FILE__, (format), ## __VA_ARGS__); } while (false) + #define SJSON_CPP_ASSERT(expression, format, ...) do { if (!(expression)) SJSON_CPP_IMPL_NAMESPACE::error_impl::on_assert_abort(#expression, __LINE__, __FILE__, (format), ## __VA_ARGS__); } while (false) #define SJSON_CPP_HAS_ASSERT_CHECKS #elif defined(SJSON_CPP_ON_ASSERT_THROW) @@ -108,7 +108,7 @@ namespace sjson { - SJSON_IMPL_VERSION_NAMESPACE_BEGIN + SJSON_CPP_IMPL_VERSION_NAMESPACE_BEGIN class runtime_assert final : public std::runtime_error { @@ -140,10 +140,10 @@ } } - SJSON_IMPL_VERSION_NAMESPACE_END + SJSON_CPP_IMPL_VERSION_NAMESPACE_END } - #define SJSON_CPP_ASSERT(expression, format, ...) do { if (!(expression)) SJSON_IMPL_NAMESPACE::error_impl::on_assert_throw(#expression, __LINE__, __FILE__, (format), ## __VA_ARGS__); } while(false) + #define SJSON_CPP_ASSERT(expression, format, ...) do { if (!(expression)) SJSON_CPP_IMPL_NAMESPACE::error_impl::on_assert_throw(#expression, __LINE__, __FILE__, (format), ## __VA_ARGS__); } while(false) #define SJSON_CPP_HAS_ASSERT_CHECKS #elif defined(SJSON_CPP_ON_ASSERT_CUSTOM) diff --git a/includes/sjson/impl/cstdlib.impl.h b/includes/sjson/impl/cstdlib.impl.h index 65cfefb..79a0279 100644 --- a/includes/sjson/impl/cstdlib.impl.h +++ b/includes/sjson/impl/cstdlib.impl.h @@ -42,7 +42,7 @@ namespace sjson { - SJSON_IMPL_VERSION_NAMESPACE_BEGIN + SJSON_CPP_IMPL_VERSION_NAMESPACE_BEGIN namespace sjson_impl { @@ -59,5 +59,5 @@ namespace sjson #endif } - SJSON_IMPL_VERSION_NAMESPACE_END + SJSON_CPP_IMPL_VERSION_NAMESPACE_END } diff --git a/includes/sjson/parser.h b/includes/sjson/parser.h index 6051936..60cdca5 100644 --- a/includes/sjson/parser.h +++ b/includes/sjson/parser.h @@ -44,7 +44,7 @@ namespace sjson { - SJSON_IMPL_VERSION_NAMESPACE_BEGIN + SJSON_CPP_IMPL_VERSION_NAMESPACE_BEGIN class Parser { @@ -1013,5 +1013,5 @@ namespace sjson } }; - SJSON_IMPL_VERSION_NAMESPACE_END + SJSON_CPP_IMPL_VERSION_NAMESPACE_END } diff --git a/includes/sjson/parser_error.h b/includes/sjson/parser_error.h index 2e773a2..f0de3f1 100644 --- a/includes/sjson/parser_error.h +++ b/includes/sjson/parser_error.h @@ -30,7 +30,7 @@ namespace sjson { - SJSON_IMPL_VERSION_NAMESPACE_BEGIN + SJSON_CPP_IMPL_VERSION_NAMESPACE_BEGIN struct ParserError { @@ -111,5 +111,5 @@ namespace sjson } }; - SJSON_IMPL_VERSION_NAMESPACE_END + SJSON_CPP_IMPL_VERSION_NAMESPACE_END } diff --git a/includes/sjson/parser_state.h b/includes/sjson/parser_state.h index 387551a..05611c1 100644 --- a/includes/sjson/parser_state.h +++ b/includes/sjson/parser_state.h @@ -32,7 +32,7 @@ namespace sjson { - SJSON_IMPL_VERSION_NAMESPACE_BEGIN + SJSON_CPP_IMPL_VERSION_NAMESPACE_BEGIN struct ParserState { @@ -53,5 +53,5 @@ namespace sjson ParserError error; }; - SJSON_IMPL_VERSION_NAMESPACE_END + SJSON_CPP_IMPL_VERSION_NAMESPACE_END } diff --git a/includes/sjson/string_view.h b/includes/sjson/string_view.h index c504034..d7d2f77 100644 --- a/includes/sjson/string_view.h +++ b/includes/sjson/string_view.h @@ -32,7 +32,7 @@ namespace sjson { - SJSON_IMPL_VERSION_NAMESPACE_BEGIN + SJSON_CPP_IMPL_VERSION_NAMESPACE_BEGIN ////////////////////////////////////////////////////////////////////////// // A StringView is just a pointer to a string and an associated length. @@ -119,5 +119,5 @@ namespace sjson size_t m_length; }; - SJSON_IMPL_VERSION_NAMESPACE_END + SJSON_CPP_IMPL_VERSION_NAMESPACE_END } diff --git a/includes/sjson/version.h b/includes/sjson/version.h index ecaa06f..fdbda25 100644 --- a/includes/sjson/version.h +++ b/includes/sjson/version.h @@ -36,30 +36,30 @@ // In order to allow multiple versions of this library to coexist side by side // within the same executable/library, the symbols have to be unique per version. // We achieve this by using a versioned namespace that we optionally inline. -// To disable namespace inlining, define SJSON_NO_INLINE_NAMESPACE before including +// To disable namespace inlining, define SJSON_CPP_NO_INLINE_NAMESPACE before including // any sjson-cpp header. //////////////////////////////////////////////////////////////////////////////// // Name of the namespace, e.g. v08 -#define SJSON_IMPL_VERSION_NAMESPACE_NAME v ## SJSON_CPP_VERSION_MAJOR ## SJSON_CPP_VERSION_MINOR +#define SJSON_CPP_IMPL_VERSION_NAMESPACE_NAME v ## SJSON_CPP_VERSION_MAJOR ## SJSON_CPP_VERSION_MINOR -#if defined(SJSON_NO_INLINE_NAMESPACE) +#if defined(SJSON_CPP_NO_INLINE_NAMESPACE) // Namespace won't be inlined, its usage will have to be qualified with the // full version everywhere - #define SJSON_IMPL_NAMESPACE sjson::SJSON_IMPL_VERSION_NAMESPACE_NAME + #define SJSON_CPP_IMPL_NAMESPACE sjson::SJSON_CPP_IMPL_VERSION_NAMESPACE_NAME - #define SJSON_IMPL_VERSION_NAMESPACE_BEGIN \ - namespace SJSON_IMPL_VERSION_NAMESPACE_NAME \ + #define SJSON_CPP_IMPL_VERSION_NAMESPACE_BEGIN \ + namespace SJSON_CPP_IMPL_VERSION_NAMESPACE_NAME \ { #else // Namespace is inlined, its usage does not need to be qualified with the // full version everywhere - #define SJSON_IMPL_NAMESPACE sjson + #define SJSON_CPP_IMPL_NAMESPACE sjson - #define SJSON_IMPL_VERSION_NAMESPACE_BEGIN \ - inline namespace SJSON_IMPL_VERSION_NAMESPACE_NAME \ + #define SJSON_CPP_IMPL_VERSION_NAMESPACE_BEGIN \ + inline namespace SJSON_CPP_IMPL_VERSION_NAMESPACE_NAME \ { #endif -#define SJSON_IMPL_VERSION_NAMESPACE_END \ +#define SJSON_CPP_IMPL_VERSION_NAMESPACE_END \ } diff --git a/includes/sjson/writer.h b/includes/sjson/writer.h index 7853983..bd1badc 100644 --- a/includes/sjson/writer.h +++ b/includes/sjson/writer.h @@ -43,7 +43,7 @@ namespace sjson { - SJSON_IMPL_VERSION_NAMESPACE_BEGIN + SJSON_CPP_IMPL_VERSION_NAMESPACE_BEGIN // TODO: Cleanup the locking stuff, wrap it in #ifdef to strip when asserts are disabled @@ -765,5 +765,5 @@ namespace sjson : ObjectWriter(stream_writer, 0) {} - SJSON_IMPL_VERSION_NAMESPACE_END + SJSON_CPP_IMPL_VERSION_NAMESPACE_END } From f2db2e090deec7664456fa30afb326f909593cd9 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 13 Mar 2022 17:35:12 -0400 Subject: [PATCH 164/285] chore: bump version numbers --- appveyor.yml | 2 +- includes/sjson/version.h | 2 +- sonar-project.properties | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index 47e02dd..d4c0ff1 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 0.8.1.{build} +version: 0.8.2.{build} environment: PYTHON: "C:\\Python36-x64\\python.exe" diff --git a/includes/sjson/version.h b/includes/sjson/version.h index fdbda25..255f659 100644 --- a/includes/sjson/version.h +++ b/includes/sjson/version.h @@ -30,7 +30,7 @@ #define SJSON_CPP_VERSION_MAJOR 0 #define SJSON_CPP_VERSION_MINOR 8 -#define SJSON_CPP_VERSION_PATCH 1 +#define SJSON_CPP_VERSION_PATCH 2 //////////////////////////////////////////////////////////////////////////////// // In order to allow multiple versions of this library to coexist side by side diff --git a/sonar-project.properties b/sonar-project.properties index 5d8972a..fdd36b4 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -2,7 +2,7 @@ sonar.organization=nfrechette-github sonar.projectKey=nfrechette_sjson-cpp sonar.projectName=sjson-cpp -sonar.projectVersion=0.8.1 +sonar.projectVersion=0.8.2 sonar.sources=includes,tests/sources,tests/main_generic From bd43e0ce839bd9a9b23db2785d341257a7682402 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 13 Mar 2022 17:36:15 -0400 Subject: [PATCH 165/285] chore: update change log --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3b4bde5..ce25737 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Significant changes per release +## 0.8.2 + +* Add versioned namespace to allow multiple versions to coexist within a binary +* Add OS X/Linux ARM development support +* Other minor changes + ## 0.8.1 * Minor static analysis fixes From 97088e8a154fed6f5edf13fe4f4cb71b7c36113d Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 19 Mar 2022 12:01:30 -0400 Subject: [PATCH 166/285] feat: add forward declaration header --- includes/sjson/fwd.h | 57 +++++++++++++++++++++++++++++++ tests/sources/test_header_fwd.cpp | 25 ++++++++++++++ 2 files changed, 82 insertions(+) create mode 100644 includes/sjson/fwd.h create mode 100644 tests/sources/test_header_fwd.cpp diff --git a/includes/sjson/fwd.h b/includes/sjson/fwd.h new file mode 100644 index 0000000..8a5a2d4 --- /dev/null +++ b/includes/sjson/fwd.h @@ -0,0 +1,57 @@ +#pragma once + +//////////////////////////////////////////////////////////////////////////////// +// The MIT License (MIT) +// +// Copyright (c) 2022 Nicholas Frechette, Cody Jones, and sjson-cpp contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +//////////////////////////////////////////////////////////////////////////////// + +#include "sjson/version.h" + +//////////////////////////////////////////////////////////////////////////////// +// This header provides forward declarations for all public sjson-cpp types. +// Forward declaring symbols from a 3rd party library is a bad idea, use this +// header instead. +// See also: https://blog.libtorrent.org/2017/12/forward-declarations-and-abi/ +//////////////////////////////////////////////////////////////////////////////// + +namespace sjson +{ + SJSON_CPP_IMPL_VERSION_NAMESPACE_BEGIN + + // Core + class runtime_assert; + class StringView; + + // Parser + struct ParserError; + struct ParserState; + struct Parser; + + // Writer + class StreamWriter; + class FileStreamWriter; + class ArrayWriter; + class ObjectWriter; + class Writer; + + SJSON_CPP_IMPL_VERSION_NAMESPACE_END +} diff --git a/tests/sources/test_header_fwd.cpp b/tests/sources/test_header_fwd.cpp new file mode 100644 index 0000000..24185ff --- /dev/null +++ b/tests/sources/test_header_fwd.cpp @@ -0,0 +1,25 @@ +//////////////////////////////////////////////////////////////////////////////// +// The MIT License (MIT) +// +// Copyright (c) 2022 Nicholas Frechette, Cody Jones, and sjson-cpp contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +//////////////////////////////////////////////////////////////////////////////// + +#include From b6723ea1b67a1c2a74a6512c40050b0d8fb328bb Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 3 Apr 2022 22:37:37 -0400 Subject: [PATCH 167/285] fix: avoid vs2015 type resolution confusion due to inline namespace --- includes/sjson/version.h | 53 +++++++++++++++++++++++++++------------- 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/includes/sjson/version.h b/includes/sjson/version.h index 255f659..ac445a1 100644 --- a/includes/sjson/version.h +++ b/includes/sjson/version.h @@ -37,29 +37,48 @@ // within the same executable/library, the symbols have to be unique per version. // We achieve this by using a versioned namespace that we optionally inline. // To disable namespace inlining, define SJSON_CPP_NO_INLINE_NAMESPACE before including -// any sjson-cpp header. +// any sjson-cpp header. To disable the versioned namespace altogether, +// define SJSON_CPP_NO_VERSION_NAMESPACE before including any sjson-cpp header. //////////////////////////////////////////////////////////////////////////////// +#if !defined(SJSON_CPP_NO_VERSION_NAMESPACE) + #if defined(_MSC_VER) && !defined(__clang__) && _MSC_VER == 1900 + // VS2015 struggles with type resolution when inline namespaces are used + // For that reason, we disable it explicitly + #define SJSON_CPP_NO_VERSION_NAMESPACE + #endif +#endif + // Name of the namespace, e.g. v08 #define SJSON_CPP_IMPL_VERSION_NAMESPACE_NAME v ## SJSON_CPP_VERSION_MAJOR ## SJSON_CPP_VERSION_MINOR -#if defined(SJSON_CPP_NO_INLINE_NAMESPACE) - // Namespace won't be inlined, its usage will have to be qualified with the - // full version everywhere - #define SJSON_CPP_IMPL_NAMESPACE sjson::SJSON_CPP_IMPL_VERSION_NAMESPACE_NAME +#if defined(SJSON_CPP_NO_VERSION_NAMESPACE) + // Namespace is inlined, its usage does not need to be qualified with the + // full version everywhere + #define SJSON_CPP_IMPL_NAMESPACE sjson + + #define SJSON_CPP_IMPL_VERSION_NAMESPACE_BEGIN + #define SJSON_CPP_IMPL_VERSION_NAMESPACE_END +#elif defined(SJSON_CPP_NO_INLINE_NAMESPACE) + // Namespace won't be inlined, its usage will have to be qualified with the + // full version everywhere + #define SJSON_CPP_IMPL_NAMESPACE sjson::SJSON_CPP_IMPL_VERSION_NAMESPACE_NAME - #define SJSON_CPP_IMPL_VERSION_NAMESPACE_BEGIN \ - namespace SJSON_CPP_IMPL_VERSION_NAMESPACE_NAME \ - { + #define SJSON_CPP_IMPL_VERSION_NAMESPACE_BEGIN \ + namespace SJSON_CPP_IMPL_VERSION_NAMESPACE_NAME \ + { + + #define SJSON_CPP_IMPL_VERSION_NAMESPACE_END \ + } #else - // Namespace is inlined, its usage does not need to be qualified with the - // full version everywhere - #define SJSON_CPP_IMPL_NAMESPACE sjson + // Namespace is inlined, its usage does not need to be qualified with the + // full version everywhere + #define SJSON_CPP_IMPL_NAMESPACE sjson - #define SJSON_CPP_IMPL_VERSION_NAMESPACE_BEGIN \ - inline namespace SJSON_CPP_IMPL_VERSION_NAMESPACE_NAME \ - { -#endif + #define SJSON_CPP_IMPL_VERSION_NAMESPACE_BEGIN \ + inline namespace SJSON_CPP_IMPL_VERSION_NAMESPACE_NAME \ + { -#define SJSON_CPP_IMPL_VERSION_NAMESPACE_END \ - } + #define SJSON_CPP_IMPL_VERSION_NAMESPACE_END \ + } +#endif From 9a58e9ad3a5aafb2bfc8f36cc67e40f0c20b3d04 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 4 Apr 2022 21:20:51 -0400 Subject: [PATCH 168/285] fix: disable versioned namespace by default for now --- includes/sjson/version.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/includes/sjson/version.h b/includes/sjson/version.h index ac445a1..f60dadd 100644 --- a/includes/sjson/version.h +++ b/includes/sjson/version.h @@ -52,7 +52,11 @@ // Name of the namespace, e.g. v08 #define SJSON_CPP_IMPL_VERSION_NAMESPACE_NAME v ## SJSON_CPP_VERSION_MAJOR ## SJSON_CPP_VERSION_MINOR -#if defined(SJSON_CPP_NO_VERSION_NAMESPACE) +// Because this is being introduced in a patch release, as caution, it is disabled +// by default. It does break ABI if host runtimes forward declare types but that +// is something they shouldn't do with a 3rd party library. Now, we offer forward +// declaration headers to help prepare the migration in the next minor release. +#if defined(SJSON_CPP_NO_VERSION_NAMESPACE) || !defined(SJSON_CPP_ENABLE_VERSION_NAMESPACE) // Namespace is inlined, its usage does not need to be qualified with the // full version everywhere #define SJSON_CPP_IMPL_NAMESPACE sjson From 7c2ba4dda2c6a01a82d985e060ce4f254785168b Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 26 Mar 2022 23:10:49 -0400 Subject: [PATCH 169/285] chore: add bionic docker image test --- .github/workflows/build_push.yml | 34 ++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index b8bd47c..a7d203c 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -8,6 +8,40 @@ on: - '**/*.md' jobs: + linux-bionic: + runs-on: ubuntu-latest + container: ghcr.io/nfrechette/toolchain-arm64-bionic:v1 + strategy: + matrix: + compiler: [gcc8, clang10] + steps: + - name: Git checkout + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: Building (debug-x86) + run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -build + - name: Running unit tests (debug-x86) + run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building (debug-x64) + run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -build + - name: Running unit tests (debug-x64) + run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building (release-x86) + run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -build + - name: Running unit tests (release-x86) + run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building (release-x64) + run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -build + - name: Running unit tests (release-x64) + run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test + linux: runs-on: ubuntu-18.04 strategy: From c9e45180d9dad30c4cc7e535a5dd41ea40f825a8 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 27 Mar 2022 09:33:13 -0400 Subject: [PATCH 170/285] chore: use amd64 image --- .github/workflows/build_push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index a7d203c..66439e0 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -10,7 +10,7 @@ on: jobs: linux-bionic: runs-on: ubuntu-latest - container: ghcr.io/nfrechette/toolchain-arm64-bionic:v1 + container: ghcr.io/nfrechette/toolchain-amd64-bionic:v1 strategy: matrix: compiler: [gcc8, clang10] From bbdcbc99d6703a146e7b8b9be633f8099056bb03 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 27 Mar 2022 09:42:08 -0400 Subject: [PATCH 171/285] chore: switch steps to use container to avoid git version issue --- .github/workflows/build_push.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 66439e0..37c4eba 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -1,4 +1,4 @@ -name: build +name: build_push on: push: @@ -10,7 +10,6 @@ on: jobs: linux-bionic: runs-on: ubuntu-latest - container: ghcr.io/nfrechette/toolchain-amd64-bionic:v1 strategy: matrix: compiler: [gcc8, clang10] @@ -20,8 +19,10 @@ jobs: with: submodules: 'recursive' - name: Building (debug-x86) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -build - name: Running unit tests (debug-x86) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -unit_test - name: Clean run: python3 make.py -clean_only From 7b6f62290607ed72878ebcd7b7d3bcb65986ac09 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 27 Mar 2022 09:46:51 -0400 Subject: [PATCH 172/285] chore: add arguments --- .github/workflows/build_push.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 37c4eba..999f3ed 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -20,10 +20,12 @@ jobs: submodules: 'recursive' - name: Building (debug-x86) uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 - run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -build + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -build' - name: Running unit tests (debug-x86) uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 - run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -unit_test + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -unit_test' - name: Clean run: python3 make.py -clean_only - name: Building (debug-x64) From 77563983cb627943486ff8ba61771f3e47de2dd6 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 27 Mar 2022 09:50:46 -0400 Subject: [PATCH 173/285] chore: add docker to all steps --- .github/workflows/build_push.yml | 37 +++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 999f3ed..d33ba67 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -1,4 +1,4 @@ -name: build_push +name: build push on: push: @@ -27,23 +27,40 @@ jobs: with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -unit_test' - name: Clean - run: python3 make.py -clean_only + with: + args: 'python3 make.py -clean_only' - name: Building (debug-x64) - run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -build + uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -build' - name: Running unit tests (debug-x64) - run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -unit_test + uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -unit_test' - name: Clean - run: python3 make.py -clean_only + uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + with: + args: 'python3 make.py -clean_only' - name: Building (release-x86) - run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -build + uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -build' - name: Running unit tests (release-x86) - run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -unit_test + uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -unit_test' - name: Clean - run: python3 make.py -clean_only + uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + with: + args: 'python3 make.py -clean_only' - name: Building (release-x64) - run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -build + uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -build' - name: Running unit tests (release-x64) - run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test + uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test' linux: runs-on: ubuntu-18.04 From 7f5ccb362edd50c9555993513e129f005d50d1a6 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 27 Mar 2022 09:51:56 -0400 Subject: [PATCH 174/285] chore: add missing uses --- .github/workflows/build_push.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index d33ba67..74f809f 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -27,6 +27,7 @@ jobs: with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -unit_test' - name: Clean + uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 with: args: 'python3 make.py -clean_only' - name: Building (debug-x64) From ae9e7cd23e518001c90f04f4eef454bb3f5d1de7 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 27 Mar 2022 10:03:32 -0400 Subject: [PATCH 175/285] chore: switch to focal --- .github/workflows/build_push.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 74f809f..67be23e 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -12,54 +12,54 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - compiler: [gcc8, clang10] + compiler: [gcc10, clang11] steps: - name: Git checkout uses: actions/checkout@v2 with: submodules: 'recursive' - name: Building (debug-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -build' - name: Running unit tests (debug-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -unit_test' - name: Clean - uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 with: args: 'python3 make.py -clean_only' - name: Building (debug-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -build' - name: Running unit tests (debug-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -unit_test' - name: Clean - uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 with: args: 'python3 make.py -clean_only' - name: Building (release-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -build' - name: Running unit tests (release-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -unit_test' - name: Clean - uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 with: args: 'python3 make.py -clean_only' - name: Building (release-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -build' - name: Running unit tests (release-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test' From 3b5051dc496f9dfd54c793ffd6d87edd6c3d37aa Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 27 Mar 2022 10:14:08 -0400 Subject: [PATCH 176/285] chore: remove old linux job --- .github/workflows/build_push.yml | 37 +------------------------------- 1 file changed, 1 insertion(+), 36 deletions(-) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 67be23e..07ba613 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -8,7 +8,7 @@ on: - '**/*.md' jobs: - linux-bionic: + linux: runs-on: ubuntu-latest strategy: matrix: @@ -63,41 +63,6 @@ jobs: with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test' - linux: - runs-on: ubuntu-18.04 - strategy: - matrix: - compiler: [gcc10, clang11] - steps: - - name: Git checkout - uses: actions/checkout@v2 - with: - submodules: 'recursive' - - name: Setup ${{ matrix.compiler }} compiler - run: ./tools/setup_linux_compiler.sh ${{ matrix.compiler }} - - name: Building (debug-x86) - run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -build - - name: Running unit tests (debug-x86) - run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -unit_test - - name: Clean - run: python3 make.py -clean_only - - name: Building (debug-x64) - run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -build - - name: Running unit tests (debug-x64) - run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -unit_test - - name: Clean - run: python3 make.py -clean_only - - name: Building (release-x86) - run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -build - - name: Running unit tests (release-x86) - run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -unit_test - - name: Clean - run: python3 make.py -clean_only - - name: Building (release-x64) - run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -build - - name: Running unit tests (release-x64) - run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test - osx-11: runs-on: macos-11 strategy: From dec9a3b203eb3a11a54a74ed293a2321ba205d23 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 30 Apr 2022 21:44:57 -0400 Subject: [PATCH 177/285] chore: add xenial clang4 docker image --- .github/workflows/build_pull_request.yml | 55 ++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml index 8c1f419..44a95da 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build_pull_request.yml @@ -43,6 +43,61 @@ jobs: - name: Running unit tests (release-x64) run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test + linux-xenial: + runs-on: ubuntu-latest + strategy: + matrix: + compiler: [clang4] + steps: + - name: Git checkout + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: Building (debug-x86) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-xenial:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -build' + - name: Running unit tests (debug-x86) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-xenial:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -unit_test' + - name: Clean + uses: docker://ghcr.io/nfrechette/toolchain-amd64-xenial:v1 + with: + args: 'python3 make.py -clean_only' + - name: Building (debug-x64) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-xenial:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -build' + - name: Running unit tests (debug-x64) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-xenial:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -unit_test' + - name: Clean + uses: docker://ghcr.io/nfrechette/toolchain-amd64-xenial:v1 + with: + args: 'python3 make.py -clean_only' + - name: Building (release-x86) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-xenial:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -build' + - name: Running unit tests (release-x86) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-xenial:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -unit_test' + - name: Clean + uses: docker://ghcr.io/nfrechette/toolchain-amd64-xenial:v1 + with: + args: 'python3 make.py -clean_only' + - name: Building (release-x64) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-xenial:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -build' + - name: Running unit tests (release-x64) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-xenial:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test' + osx-10: runs-on: macos-10.15 strategy: From dec40ec1912cc42ebd5b538f1719377bd042183a Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 30 Apr 2022 22:05:47 -0400 Subject: [PATCH 178/285] chore: add bionic and focal docker builds --- .github/workflows/build_pull_request.yml | 110 +++++++++++++++++++++++ 1 file changed, 110 insertions(+) diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml index 44a95da..c6af86a 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build_pull_request.yml @@ -98,6 +98,116 @@ jobs: with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test' + linux-bionic: + runs-on: ubuntu-latest + strategy: + matrix: + compiler: [gcc5, gcc6, gcc7, gcc8, clang5, clang6, clang7, clang8, clang9, clang10] + steps: + - name: Git checkout + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: Building (debug-x86) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -build' + - name: Running unit tests (debug-x86) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -unit_test' + - name: Clean + uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + with: + args: 'python3 make.py -clean_only' + - name: Building (debug-x64) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -build' + - name: Running unit tests (debug-x64) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -unit_test' + - name: Clean + uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + with: + args: 'python3 make.py -clean_only' + - name: Building (release-x86) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -build' + - name: Running unit tests (release-x86) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -unit_test' + - name: Clean + uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + with: + args: 'python3 make.py -clean_only' + - name: Building (release-x64) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -build' + - name: Running unit tests (release-x64) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test' + + linux-focal: + runs-on: ubuntu-latest + strategy: + matrix: + compiler: [gcc9, gcc10, clang11] + steps: + - name: Git checkout + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: Building (debug-x86) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -build' + - name: Running unit tests (debug-x86) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -unit_test' + - name: Clean + uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 + with: + args: 'python3 make.py -clean_only' + - name: Building (debug-x64) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -build' + - name: Running unit tests (debug-x64) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -unit_test' + - name: Clean + uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 + with: + args: 'python3 make.py -clean_only' + - name: Building (release-x86) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -build' + - name: Running unit tests (release-x86) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -unit_test' + - name: Clean + uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 + with: + args: 'python3 make.py -clean_only' + - name: Building (release-x64) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -build' + - name: Running unit tests (release-x64) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test' + osx-10: runs-on: macos-10.15 strategy: From 5aba72461ba57c5886dcacc9d73db49c429c7177 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 30 Apr 2022 22:10:18 -0400 Subject: [PATCH 179/285] chore: remove non-docker linux job --- .github/workflows/build_pull_request.yml | 35 ------------------------ 1 file changed, 35 deletions(-) diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml index c6af86a..627d780 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build_pull_request.yml @@ -8,41 +8,6 @@ on: - '**/*.md' jobs: - linux: - runs-on: ubuntu-18.04 - strategy: - matrix: - compiler: [gcc5, gcc6, gcc7, gcc8, gcc9, gcc10, clang4, clang5, clang6, clang7, clang8, clang9, clang10, clang11] - steps: - - name: Git checkout - uses: actions/checkout@v2 - with: - submodules: 'recursive' - - name: Setup ${{ matrix.compiler }} compiler - run: ./tools/setup_linux_compiler.sh ${{ matrix.compiler }} - - name: Building (debug-x86) - run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -build - - name: Running unit tests (debug-x86) - run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -unit_test - - name: Clean - run: python3 make.py -clean_only - - name: Building (debug-x64) - run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -build - - name: Running unit tests (debug-x64) - run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -unit_test - - name: Clean - run: python3 make.py -clean_only - - name: Building (release-x86) - run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -build - - name: Running unit tests (release-x86) - run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -unit_test - - name: Clean - run: python3 make.py -clean_only - - name: Building (release-x64) - run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -build - - name: Running unit tests (release-x64) - run: python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test - linux-xenial: runs-on: ubuntu-latest strategy: From 2c564d04e2ecf47bed438c96fbf37ddb2b896fa6 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 30 Apr 2022 23:14:49 -0400 Subject: [PATCH 180/285] chore: add emscripten docker image --- .github/workflows/build_pull_request.yml | 28 ++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml index 627d780..f906712 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build_pull_request.yml @@ -288,3 +288,31 @@ jobs: run: python3 make.py -ci -compiler emscripten -config release -build - name: Running unit tests (release) run: python3 make.py -ci -compiler emscripten -config release -unit_test + + emscripten-docker: + runs-on: ubuntu-latest + steps: + - name: Git checkout + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: Building (debug) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-linux-emscripten:v1 + with: + args: 'python3 make.py -ci -compiler emscripten -config debug -build' + - name: Running unit tests (debug) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-linux-emscripten:v1 + with: + args: 'python3 make.py -ci -compiler emscripten -config debug -unit_test' + - name: Clean + uses: docker://ghcr.io/nfrechette/toolchain-amd64-linux-emscripten:v1 + with: + args: 'python3 make.py -clean_only' + - name: Building (release) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-linux-emscripten:v1 + with: + args: 'python3 make.py -ci -compiler emscripten -config release -build' + - name: Running unit tests (release) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-linux-emscripten:v1 + with: + args: 'python3 make.py -ci -compiler emscripten -config release -unit_test' From d55fe95b93c2295baf3b86b99268b4405f498566 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 30 Apr 2022 23:19:17 -0400 Subject: [PATCH 181/285] chore: remove non-docker emscripten --- .github/workflows/build_pull_request.yml | 36 ------------------------ 1 file changed, 36 deletions(-) diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml index f906712..7353724 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build_pull_request.yml @@ -254,42 +254,6 @@ jobs: run: python3 make.py -ci -compiler ios -config Release -build emscripten: - runs-on: ubuntu-18.04 - steps: - - name: Git checkout - uses: actions/checkout@v2 - with: - submodules: 'recursive' - - name: Cache emsdk - uses: actions/cache@v1 - id: 'emsdk' - with: - path: 'emsdk-cache' - key: ${{ runner.os }}-emsdk-1.39.11 - - name: Setup emsdk - uses: mymindstorm/setup-emsdk@v7 - with: - version: 1.39.11 - no-cache: true - actions-cache-folder: 'emsdk-cache' - - name: Cache emsdk build artifacts - uses: actions/cache@v1 - id: 'emsdk-build-artifacts' - with: - path: '~/.emscripten_cache' - key: ${{ runner.os }}-emsdk-build-artifacts-1.39.11 - - name: Building (debug) - run: python3 make.py -ci -compiler emscripten -config debug -build - - name: Running unit tests (debug) - run: python3 make.py -ci -compiler emscripten -config debug -unit_test - - name: Clean - run: python3 make.py -clean_only - - name: Building (release) - run: python3 make.py -ci -compiler emscripten -config release -build - - name: Running unit tests (release) - run: python3 make.py -ci -compiler emscripten -config release -unit_test - - emscripten-docker: runs-on: ubuntu-latest steps: - name: Git checkout From 0908bf823b3dda7bddc800b831054016daecaa4c Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 30 Apr 2022 23:20:24 -0400 Subject: [PATCH 182/285] chore: switch emscripten to docker image --- .github/workflows/build_push.yml | 40 +++++++++++++------------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 07ba613..d2463fd 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -95,37 +95,29 @@ jobs: run: python3 make.py -ci -compiler ios -config Release -build emscripten: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - name: Git checkout uses: actions/checkout@v2 with: submodules: 'recursive' - - name: Cache emsdk - uses: actions/cache@v1 - id: 'emsdk' - with: - path: 'emsdk-cache' - key: ${{ runner.os }}-emsdk-1.39.11 - - name: Setup emsdk - uses: mymindstorm/setup-emsdk@v7 - with: - version: 1.39.11 - no-cache: true - actions-cache-folder: 'emsdk-cache' - - name: Cache emsdk build artifacts - uses: actions/cache@v1 - id: 'emsdk-build-artifacts' - with: - path: '~/.emscripten_cache' - key: ${{ runner.os }}-emsdk-build-artifacts-1.39.11 - name: Building (debug) - run: python3 make.py -ci -compiler emscripten -config debug -build + uses: docker://ghcr.io/nfrechette/toolchain-amd64-linux-emscripten:v1 + with: + args: 'python3 make.py -ci -compiler emscripten -config debug -build' - name: Running unit tests (debug) - run: python3 make.py -ci -compiler emscripten -config debug -unit_test + uses: docker://ghcr.io/nfrechette/toolchain-amd64-linux-emscripten:v1 + with: + args: 'python3 make.py -ci -compiler emscripten -config debug -unit_test' - name: Clean - run: python3 make.py -clean_only + uses: docker://ghcr.io/nfrechette/toolchain-amd64-linux-emscripten:v1 + with: + args: 'python3 make.py -clean_only' - name: Building (release) - run: python3 make.py -ci -compiler emscripten -config release -build + uses: docker://ghcr.io/nfrechette/toolchain-amd64-linux-emscripten:v1 + with: + args: 'python3 make.py -ci -compiler emscripten -config release -build' - name: Running unit tests (release) - run: python3 make.py -ci -compiler emscripten -config release -unit_test + uses: docker://ghcr.io/nfrechette/toolchain-amd64-linux-emscripten:v1 + with: + args: 'python3 make.py -ci -compiler emscripten -config release -unit_test' From 8c50f5d89d39187b0c932e6a7de78fa896ced92c Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 1 May 2022 11:15:11 -0400 Subject: [PATCH 183/285] chore: add support for clang 12, 13, and 14 and gcc 11 --- README.md | 4 ++-- make.py | 14 +++++++++++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index e402aa6..f0429db 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,8 @@ Unicode formats other than UTF-8 aren't supported. * Windows VS2015 x86 and x64 * Windows (VS2017, VS2019) x86, x64, and ARM64 * Windows VS2019 with clang9 x86 and x64 -* Linux (gcc 5 to 10) x86 and x64 -* Linux (clang 4 to 11) x86 and x64 +* Linux (gcc 5 to 11) x86 and x64 +* Linux (clang 4 to 14) x86 and x64 * OS X (Xcode 10.3) x86 and x64 * OS X (Xcode 11.7, 12.5, 13.2) x64 and ARM64 * Android (NDK 21) ARMv7-A and ARM64 diff --git a/make.py b/make.py index d2e4bf5..318782f 100644 --- a/make.py +++ b/make.py @@ -16,7 +16,7 @@ def parse_argv(): actions.add_argument('-unit_test', action='store_true') target = parser.add_argument_group(title='Target') - target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'vs2019-clang', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'clang10', 'clang11', 'gcc4.8', 'gcc4.9', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'gcc10', 'osx', 'ios', 'emscripten'], help='Defaults to the host system\'s default compiler') + target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'vs2019-clang', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'clang10', 'clang11', 'clang12', 'clang13', 'clang14', 'gcc4.8', 'gcc4.9', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'gcc10', 'gcc11', 'osx', 'ios', 'emscripten'], help='Defaults to the host system\'s default compiler') target.add_argument('-config', choices=['Debug', 'Release'], type=str.capitalize) target.add_argument('-cpu', choices=['x86', 'x64', 'armv7', 'arm64', 'wasm'], help='Defaults to the host system\'s architecture') @@ -211,6 +211,15 @@ def set_compiler_env(compiler, args): elif compiler == 'clang11': os.environ['CC'] = 'clang-11' os.environ['CXX'] = 'clang++-11' + elif compiler == 'clang12': + os.environ['CC'] = 'clang-12' + os.environ['CXX'] = 'clang++-12' + elif compiler == 'clang13': + os.environ['CC'] = 'clang-13' + os.environ['CXX'] = 'clang++-13' + elif compiler == 'clang14': + os.environ['CC'] = 'clang-14' + os.environ['CXX'] = 'clang++-14' elif compiler == 'gcc4.8': os.environ['CC'] = 'gcc-4.8' os.environ['CXX'] = 'g++-4.8' @@ -235,6 +244,9 @@ def set_compiler_env(compiler, args): elif compiler == 'gcc10': os.environ['CC'] = 'gcc-10' os.environ['CXX'] = 'g++-10' + elif compiler == 'gcc11': + os.environ['CC'] = 'gcc-11' + os.environ['CXX'] = 'g++-11' elif compiler == 'emscripten': # Nothing to do for Emscripten return From 3b713821c5a9a1d3bba853ae317e52ffcc84825a Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 1 May 2022 11:17:31 -0400 Subject: [PATCH 184/285] chore: switch to latest compilers --- .github/workflows/build_push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index d2463fd..07c00c2 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - compiler: [gcc10, clang11] + compiler: [gcc11, clang14] steps: - name: Git checkout uses: actions/checkout@v2 From ec79afd59a28347edc7097fedc5d23993a4039c7 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 1 May 2022 11:22:45 -0400 Subject: [PATCH 185/285] chore: add gcc11 and clang 12-14 --- .github/workflows/build_pull_request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml index 7353724..e27db31 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build_pull_request.yml @@ -122,7 +122,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - compiler: [gcc9, gcc10, clang11] + compiler: [gcc9, gcc10, gcc11, clang11, clang12, clang13, clang14] steps: - name: Git checkout uses: actions/checkout@v2 From 96df5517171e85e88a668e2cd0300a906612adc0 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 23 May 2022 13:46:09 -0400 Subject: [PATCH 186/285] chore: use docker for sonarcloud --- .github/workflows/sonarcloud.yml | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index fad8aa8..1f1717c 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -28,27 +28,21 @@ jobs: needs: - condition-check if: ${{ needs.condition-check.outputs.ok == 'true' }} - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest steps: - name: Git checkout uses: actions/checkout@v2 with: submodules: 'recursive' - - name: Setup build wrapper - run: | - wget -q https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip - unzip build-wrapper-linux-x86.zip - - name: Setup Sonar Scanner - run: | - wget -q https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.2.0.1873-linux.zip - unzip sonar-scanner-cli-4.2.0.1873-linux.zip - - name: Setup compiler - run: ./tools/setup_linux_compiler.sh clang5 - name: Build with wrapper - run: ./build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw_output python3 make.py -compiler clang5 -config Release -cpu x64 -build + uses: docker://ghcr.io/nfrechette/toolchain-amd64-linux-sonarcloud:v1 + with: + args: '../build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw_output python3 make.py -compiler clang5 -config Release -cpu x64 -build' - name: Run Sonar Scanner and upload to Sonarcloud env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: https://sonarcloud.io - run: ./sonar-scanner-4.2.0.1873-linux/bin/sonar-scanner + uses: docker://ghcr.io/nfrechette/toolchain-amd64-linux-sonarcloud:v1 + with: + args: './sonar-scanner-4.7.0.2747-linux/bin/sonar-scanner' From 28cc60caac1218cfd196a0271423ad61d1daa0d1 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 23 May 2022 13:51:32 -0400 Subject: [PATCH 187/285] chore: use absolute paths and clang14 --- .github/workflows/sonarcloud.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 1f1717c..7ae7484 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -37,7 +37,7 @@ jobs: - name: Build with wrapper uses: docker://ghcr.io/nfrechette/toolchain-amd64-linux-sonarcloud:v1 with: - args: '../build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw_output python3 make.py -compiler clang5 -config Release -cpu x64 -build' + args: '/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw_output python3 make.py -compiler clang14 -config Release -cpu x64 -build' - name: Run Sonar Scanner and upload to Sonarcloud env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} @@ -45,4 +45,4 @@ jobs: SONAR_HOST_URL: https://sonarcloud.io uses: docker://ghcr.io/nfrechette/toolchain-amd64-linux-sonarcloud:v1 with: - args: './sonar-scanner-4.7.0.2747-linux/bin/sonar-scanner' + args: '/sonar-scanner-4.7.0.2747-linux/bin/sonar-scanner' From d095dc5c8ae19f9813d6e2764331beda595f2bb1 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 23 May 2022 14:07:03 -0400 Subject: [PATCH 188/285] chore: use v2 sonarcloud image --- .github/workflows/sonarcloud.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 7ae7484..dbd896f 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -35,7 +35,7 @@ jobs: with: submodules: 'recursive' - name: Build with wrapper - uses: docker://ghcr.io/nfrechette/toolchain-amd64-linux-sonarcloud:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-linux-sonarcloud:v2 with: args: '/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw_output python3 make.py -compiler clang14 -config Release -cpu x64 -build' - name: Run Sonar Scanner and upload to Sonarcloud @@ -43,6 +43,6 @@ jobs: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: https://sonarcloud.io - uses: docker://ghcr.io/nfrechette/toolchain-amd64-linux-sonarcloud:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-linux-sonarcloud:v2 with: args: '/sonar-scanner-4.7.0.2747-linux/bin/sonar-scanner' From 410d261d688cf76dcc7bc9ba70bd0ed24f8ceeac Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 12 Jun 2022 10:55:26 -0400 Subject: [PATCH 189/285] fix(ci): disable sonarcloud cache Not used and it warns every time --- sonar-project.properties | 1 + 1 file changed, 1 insertion(+) diff --git a/sonar-project.properties b/sonar-project.properties index fdd36b4..8d5839d 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -8,3 +8,4 @@ sonar.sources=includes,tests/sources,tests/main_generic sonar.cfamily.build-wrapper-output=bw_output sonar.cfamily.threads=2 +sonar.cfamily.cache.enabled=false From fd9851639662f21271ff959366802796afbf4c8e Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 12 Jun 2022 16:29:27 -0400 Subject: [PATCH 190/285] chore(ci): use ubuntu-latest for sonarcloud check job --- .github/workflows/sonarcloud.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index dbd896f..f69ae9d 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -14,7 +14,7 @@ on: jobs: condition-check: - runs-on: ubuntu-18.04 + runs-on: ubuntu-latest outputs: ok: ${{ steps.check-secrets.outputs.ok }} steps: From 586f548fcfe9275d9f9f23eb279432b840f69a4f Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 3 Jul 2022 17:57:51 -0400 Subject: [PATCH 191/285] fix: force macro expansion in version namespace identifier --- includes/sjson/version.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/includes/sjson/version.h b/includes/sjson/version.h index f60dadd..3797a7a 100644 --- a/includes/sjson/version.h +++ b/includes/sjson/version.h @@ -49,8 +49,12 @@ #endif #endif -// Name of the namespace, e.g. v08 -#define SJSON_CPP_IMPL_VERSION_NAMESPACE_NAME v ## SJSON_CPP_VERSION_MAJOR ## SJSON_CPP_VERSION_MINOR +// Force macro expansion to concatenate namespace identifier +#define SJSON_CPP_IMPL_VERSION_CONCAT_IMPL(prefix, major, minor, patch) prefix ## major ## minor ## patch +#define SJSON_CPP_IMPL_VERSION_CONCAT(prefix, major, minor, patch) SJSON_CPP_IMPL_VERSION_CONCAT_IMPL(prefix, major, minor, patch) + +// Name of the namespace, e.g. v082 +#define SJSON_CPP_IMPL_VERSION_NAMESPACE_NAME SJSON_CPP_IMPL_VERSION_CONCAT(v, SJSON_CPP_VERSION_MAJOR, SJSON_CPP_VERSION_MINOR, SJSON_CPP_VERSION_PATCH) // Because this is being introduced in a patch release, as caution, it is disabled // by default. It does break ABI if host runtimes forward declare types but that From f9e8fdd641d556f94f6552de4d74eb141e77ec50 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 3 Jul 2022 17:59:21 -0400 Subject: [PATCH 192/285] chore: update change log --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce25737..560c092 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Significant changes per release +## 0.8.3 + +* Force macro expansion in version namespace identifier + ## 0.8.2 * Add versioned namespace to allow multiple versions to coexist within a binary From 37f8eac8222055afe6491905d2f1614139e24d91 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 3 Jul 2022 20:03:54 -0400 Subject: [PATCH 193/285] chore: bump version numbers --- appveyor.yml | 2 +- includes/sjson/version.h | 2 +- sonar-project.properties | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index d4c0ff1..f215a5e 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 0.8.2.{build} +version: 0.8.99.{build} environment: PYTHON: "C:\\Python36-x64\\python.exe" diff --git a/includes/sjson/version.h b/includes/sjson/version.h index 3797a7a..ed652d2 100644 --- a/includes/sjson/version.h +++ b/includes/sjson/version.h @@ -30,7 +30,7 @@ #define SJSON_CPP_VERSION_MAJOR 0 #define SJSON_CPP_VERSION_MINOR 8 -#define SJSON_CPP_VERSION_PATCH 2 +#define SJSON_CPP_VERSION_PATCH 99 //////////////////////////////////////////////////////////////////////////////// // In order to allow multiple versions of this library to coexist side by side diff --git a/sonar-project.properties b/sonar-project.properties index 8d5839d..228bb99 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -2,7 +2,7 @@ sonar.organization=nfrechette-github sonar.projectKey=nfrechette_sjson-cpp sonar.projectName=sjson-cpp -sonar.projectVersion=0.8.2 +sonar.projectVersion=0.8.99 sonar.sources=includes,tests/sources,tests/main_generic From f88bc0f03d346c306085633a4ab4b4179d3ceeb3 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 18 Jul 2022 22:01:33 -0400 Subject: [PATCH 194/285] fix: properly forward declare Parser --- includes/sjson/fwd.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/sjson/fwd.h b/includes/sjson/fwd.h index 8a5a2d4..4f2a82c 100644 --- a/includes/sjson/fwd.h +++ b/includes/sjson/fwd.h @@ -44,7 +44,7 @@ namespace sjson // Parser struct ParserError; struct ParserState; - struct Parser; + class Parser; // Writer class StreamWriter; From c76a3c9f721bf5893d22d2260777efa32b2f5b93 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 18 Jul 2022 22:31:51 -0400 Subject: [PATCH 195/285] feat: add support for vs2022 and vs2022-clang --- make.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/make.py b/make.py index 318782f..88f4e16 100644 --- a/make.py +++ b/make.py @@ -16,7 +16,7 @@ def parse_argv(): actions.add_argument('-unit_test', action='store_true') target = parser.add_argument_group(title='Target') - target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'vs2019-clang', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'clang10', 'clang11', 'clang12', 'clang13', 'clang14', 'gcc4.8', 'gcc4.9', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'gcc10', 'gcc11', 'osx', 'ios', 'emscripten'], help='Defaults to the host system\'s default compiler') + target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'vs2019-clang', 'vs2022', 'vs2022-clang', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'clang10', 'clang11', 'clang12', 'clang13', 'clang14', 'gcc4.8', 'gcc4.9', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'gcc10', 'gcc11', 'osx', 'ios', 'emscripten'], help='Defaults to the host system\'s default compiler') target.add_argument('-config', choices=['Debug', 'Release'], type=str.capitalize) target.add_argument('-cpu', choices=['x86', 'x64', 'armv7', 'arm64', 'wasm'], help='Defaults to the host system\'s architecture') @@ -139,6 +139,8 @@ def get_generator(compiler, cpu): return 'Visual Studio 15 2017' elif compiler == 'vs2019' or compiler == 'vs2019-clang': return 'Visual Studio 16 2019' + elif compiler == 'vs2022' or compiler == 'vs2022-clang': + return 'Visual Studio 17 2022' elif compiler == 'android': # For Android, we use the default generator since we don't build with CMake return None @@ -167,7 +169,7 @@ def get_architecture(compiler, cpu): if compiler == 'vs2017': if cpu == 'arm64': return 'ARM64' - elif compiler == 'vs2019' or compiler == 'vs2019-clang': + elif compiler.startswith('vs20'): if cpu == 'x86': return 'Win32' else: @@ -288,7 +290,7 @@ def do_generate_solution(build_dir, cmake_script_dir, args): print('Using default generator') else: generator_suffix = '' - if compiler == 'vs2019-clang': + if compiler == 'vs2019-clang' or compiler == 'vs2022-clang': extra_switches.append('-T ClangCL') generator_suffix = 'Clang CL' From fe9592c42853971b0d1abcd30a6d89a0b3abceb2 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 20 Jul 2022 21:37:36 -0400 Subject: [PATCH 196/285] fix: vs cmake detection --- make.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/make.py b/make.py index 88f4e16..c79786e 100644 --- a/make.py +++ b/make.py @@ -169,7 +169,14 @@ def get_architecture(compiler, cpu): if compiler == 'vs2017': if cpu == 'arm64': return 'ARM64' - elif compiler.startswith('vs20'): + + is_modern_vs = False + if compiler == 'vs2019' or compiler == 'vs2019-clang': + is_modern_vs = True + elif compiler == 'vs2022' or compiler == 'vs2022-clang': + is_modern_vs = True + + if is_modern_vs: if cpu == 'x86': return 'Win32' else: From 0b25c3c5910cf23fd2b7fc2f43ed0abd326d18f6 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 20 Jul 2022 21:37:55 -0400 Subject: [PATCH 197/285] docs: update supported VS versions --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index f0429db..71c0afe 100644 --- a/README.md +++ b/README.md @@ -37,8 +37,8 @@ Unicode formats other than UTF-8 aren't supported. ## Supported platforms * Windows VS2015 x86 and x64 -* Windows (VS2017, VS2019) x86, x64, and ARM64 -* Windows VS2019 with clang9 x86 and x64 +* Windows (VS2017 to VS2022) x86, x64, and ARM64 +* Windows (VS2017 to VS2022) with clang x86 and x64 * Linux (gcc 5 to 11) x86 and x64 * Linux (clang 4 to 14) x86 and x64 * OS X (Xcode 10.3) x86 and x64 @@ -123,4 +123,4 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d -This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! \ No newline at end of file +This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! From 41fc6b662d46ef4735423875290f83d1689c8b8b Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 20 Jul 2022 22:55:53 -0400 Subject: [PATCH 198/285] chore(ci): add vs2019 github action push build --- .github/workflows/build_push.yml | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 07c00c2..3623ac1 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -121,3 +121,39 @@ jobs: uses: docker://ghcr.io/nfrechette/toolchain-amd64-linux-emscripten:v1 with: args: 'python3 make.py -ci -compiler emscripten -config release -unit_test' + + vs2019: + runs-on: windows-2019 + steps: + - name: Git checkout + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: Building (debug-x64) + run: python3 make.py -ci -compiler vs2019 -config Debug -cpu x64 -build + - name: Running unit tests (debug-x64) + run: python3 make.py -ci -compiler vs2019 -config Debug -cpu x64 -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building (release-x64) + run: python3 make.py -ci -compiler vs2019 -config Release -cpu x64 -build + - name: Running unit tests (release-x64) + run: python3 make.py -ci -compiler vs2019 -config Release -cpu x64 -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building (debug-arm64) + run: python3 make.py -ci -compiler vs2019 -config Debug -cpu arm64 -build + - name: Clean + run: python3 make.py -clean_only + - name: Building (release-arm64) + run: python3 make.py -ci -compiler vs2019 -config Release -cpu arm64 -build + - name: Building (debug-x64) with Clang + run: python3 make.py -ci -compiler vs2019-clang -config Debug -cpu x64 -build + - name: Running unit tests (debug-x64) with Clang + run: python3 make.py -ci -compiler vs2019-clang -config Debug -cpu x64 -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building (release-x64) with Clang + run: python3 make.py -ci -compiler vs2019-clang -config Release -cpu x64 -build + - name: Running unit tests (release-x64) with Clang + run: python3 make.py -ci -compiler vs2019-clang -config Release -cpu x64 -unit_test From de9660eed3299a4b80aa15a32ece649ea6d652cd Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 20 Jul 2022 23:00:05 -0400 Subject: [PATCH 199/285] chore(ci): add missing clean --- .github/workflows/build_push.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 3623ac1..27b0e89 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -147,6 +147,8 @@ jobs: run: python3 make.py -clean_only - name: Building (release-arm64) run: python3 make.py -ci -compiler vs2019 -config Release -cpu arm64 -build + - name: Clean + run: python3 make.py -clean_only - name: Building (debug-x64) with Clang run: python3 make.py -ci -compiler vs2019-clang -config Debug -cpu x64 -build - name: Running unit tests (debug-x64) with Clang From a8a0b43c7fb56dbe0f10b83bc5aab92ea3ac6a1b Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 20 Jul 2022 23:05:57 -0400 Subject: [PATCH 200/285] chore(ci): add vs2022 github action on push --- .github/workflows/build_push.yml | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 27b0e89..e9f2499 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -159,3 +159,41 @@ jobs: run: python3 make.py -ci -compiler vs2019-clang -config Release -cpu x64 -build - name: Running unit tests (release-x64) with Clang run: python3 make.py -ci -compiler vs2019-clang -config Release -cpu x64 -unit_test + + vs2022: + runs-on: windows-2022 + steps: + - name: Git checkout + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: Building (debug-x64) + run: python3 make.py -ci -compiler vs2022 -config Debug -cpu x64 -build + - name: Running unit tests (debug-x64) + run: python3 make.py -ci -compiler vs2022 -config Debug -cpu x64 -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building (release-x64) + run: python3 make.py -ci -compiler vs2022 -config Release -cpu x64 -build + - name: Running unit tests (release-x64) + run: python3 make.py -ci -compiler vs2022 -config Release -cpu x64 -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building (debug-arm64) + run: python3 make.py -ci -compiler vs2022 -config Debug -cpu arm64 -build + - name: Clean + run: python3 make.py -clean_only + - name: Building (release-arm64) + run: python3 make.py -ci -compiler vs2022 -config Release -cpu arm64 -build + - name: Clean + run: python3 make.py -clean_only + - name: Building (debug-x64) with Clang + run: python3 make.py -ci -compiler vs2022-clang -config Debug -cpu x64 -build + - name: Running unit tests (debug-x64) with Clang + run: python3 make.py -ci -compiler vs2022-clang -config Debug -cpu x64 -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building (release-x64) with Clang + run: python3 make.py -ci -compiler vs2022-clang -config Release -cpu x64 -build + - name: Running unit tests (release-x64) with Clang + run: python3 make.py -ci -compiler vs2022-clang -config Release -cpu x64 -unit_test From c75939750f1c0a11a2f024bc5b2ca85525802d32 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 20 Jul 2022 23:11:02 -0400 Subject: [PATCH 201/285] fix: add vs2022 arm64 support --- make.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/make.py b/make.py index c79786e..df2ddb2 100644 --- a/make.py +++ b/make.py @@ -89,7 +89,7 @@ def parse_argv(): is_arm_supported = False # Cross compilation - if args.compiler in ['vs2017', 'vs2019', 'ios', 'android']: + if args.compiler in ['vs2017', 'vs2019', 'vs2022', 'ios', 'android']: is_arm_supported = True # Native compilation From 9fe07c1558d9ed1180f00df979dfbb7cef717d15 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 20 Jul 2022 23:14:59 -0400 Subject: [PATCH 202/285] chore(ci): add vs2019 and vs2022 github action on pull request --- .github/workflows/build_pull_request.yml | 76 ++++++++++++++++++++++++ 1 file changed, 76 insertions(+) diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml index e27db31..22e59ea 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build_pull_request.yml @@ -280,3 +280,79 @@ jobs: uses: docker://ghcr.io/nfrechette/toolchain-amd64-linux-emscripten:v1 with: args: 'python3 make.py -ci -compiler emscripten -config release -unit_test' + + vs2019: + runs-on: windows-2019 + steps: + - name: Git checkout + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: Building (debug-x64) + run: python3 make.py -ci -compiler vs2019 -config Debug -cpu x64 -build + - name: Running unit tests (debug-x64) + run: python3 make.py -ci -compiler vs2019 -config Debug -cpu x64 -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building (release-x64) + run: python3 make.py -ci -compiler vs2019 -config Release -cpu x64 -build + - name: Running unit tests (release-x64) + run: python3 make.py -ci -compiler vs2019 -config Release -cpu x64 -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building (debug-arm64) + run: python3 make.py -ci -compiler vs2019 -config Debug -cpu arm64 -build + - name: Clean + run: python3 make.py -clean_only + - name: Building (release-arm64) + run: python3 make.py -ci -compiler vs2019 -config Release -cpu arm64 -build + - name: Clean + run: python3 make.py -clean_only + - name: Building (debug-x64) with Clang + run: python3 make.py -ci -compiler vs2019-clang -config Debug -cpu x64 -build + - name: Running unit tests (debug-x64) with Clang + run: python3 make.py -ci -compiler vs2019-clang -config Debug -cpu x64 -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building (release-x64) with Clang + run: python3 make.py -ci -compiler vs2019-clang -config Release -cpu x64 -build + - name: Running unit tests (release-x64) with Clang + run: python3 make.py -ci -compiler vs2019-clang -config Release -cpu x64 -unit_test + + vs2022: + runs-on: windows-2022 + steps: + - name: Git checkout + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: Building (debug-x64) + run: python3 make.py -ci -compiler vs2022 -config Debug -cpu x64 -build + - name: Running unit tests (debug-x64) + run: python3 make.py -ci -compiler vs2022 -config Debug -cpu x64 -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building (release-x64) + run: python3 make.py -ci -compiler vs2022 -config Release -cpu x64 -build + - name: Running unit tests (release-x64) + run: python3 make.py -ci -compiler vs2022 -config Release -cpu x64 -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building (debug-arm64) + run: python3 make.py -ci -compiler vs2022 -config Debug -cpu arm64 -build + - name: Clean + run: python3 make.py -clean_only + - name: Building (release-arm64) + run: python3 make.py -ci -compiler vs2022 -config Release -cpu arm64 -build + - name: Clean + run: python3 make.py -clean_only + - name: Building (debug-x64) with Clang + run: python3 make.py -ci -compiler vs2022-clang -config Debug -cpu x64 -build + - name: Running unit tests (debug-x64) with Clang + run: python3 make.py -ci -compiler vs2022-clang -config Debug -cpu x64 -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building (release-x64) with Clang + run: python3 make.py -ci -compiler vs2022-clang -config Release -cpu x64 -build + - name: Running unit tests (release-x64) with Clang + run: python3 make.py -ci -compiler vs2022-clang -config Release -cpu x64 -unit_test From ee4f43469da19f4e4b8caf0d8c3b8ea508d943e8 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 20 Jul 2022 23:15:48 -0400 Subject: [PATCH 203/285] chore(ci): remove vs2019 github action on push --- .github/workflows/build_push.yml | 38 -------------------------------- 1 file changed, 38 deletions(-) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index e9f2499..273327b 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -122,44 +122,6 @@ jobs: with: args: 'python3 make.py -ci -compiler emscripten -config release -unit_test' - vs2019: - runs-on: windows-2019 - steps: - - name: Git checkout - uses: actions/checkout@v2 - with: - submodules: 'recursive' - - name: Building (debug-x64) - run: python3 make.py -ci -compiler vs2019 -config Debug -cpu x64 -build - - name: Running unit tests (debug-x64) - run: python3 make.py -ci -compiler vs2019 -config Debug -cpu x64 -unit_test - - name: Clean - run: python3 make.py -clean_only - - name: Building (release-x64) - run: python3 make.py -ci -compiler vs2019 -config Release -cpu x64 -build - - name: Running unit tests (release-x64) - run: python3 make.py -ci -compiler vs2019 -config Release -cpu x64 -unit_test - - name: Clean - run: python3 make.py -clean_only - - name: Building (debug-arm64) - run: python3 make.py -ci -compiler vs2019 -config Debug -cpu arm64 -build - - name: Clean - run: python3 make.py -clean_only - - name: Building (release-arm64) - run: python3 make.py -ci -compiler vs2019 -config Release -cpu arm64 -build - - name: Clean - run: python3 make.py -clean_only - - name: Building (debug-x64) with Clang - run: python3 make.py -ci -compiler vs2019-clang -config Debug -cpu x64 -build - - name: Running unit tests (debug-x64) with Clang - run: python3 make.py -ci -compiler vs2019-clang -config Debug -cpu x64 -unit_test - - name: Clean - run: python3 make.py -clean_only - - name: Building (release-x64) with Clang - run: python3 make.py -ci -compiler vs2019-clang -config Release -cpu x64 -build - - name: Running unit tests (release-x64) with Clang - run: python3 make.py -ci -compiler vs2019-clang -config Release -cpu x64 -unit_test - vs2022: runs-on: windows-2022 steps: From cf215419df3ea2bfaaadd2ee3d22fe82038c064f Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 20 Jul 2022 23:17:02 -0400 Subject: [PATCH 204/285] chore(ci): remove vs2019 from appveyor config --- appveyor.yml | 7 ------- 1 file changed, 7 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index f215a5e..bd0f442 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -9,7 +9,6 @@ environment: image: - Visual Studio 2015 - Visual Studio 2017 - - Visual Studio 2019 configuration: - Debug @@ -28,12 +27,6 @@ matrix: toolchain: clang - image: Visual Studio 2017 toolchain: clang - - image: Visual Studio 2019 - platform: arm64 - toolchain: clang - - image: Previous Visual Studio 2019 - platform: arm64 - toolchain: clang init: From f06cf9c10a18d5d1ed31ebb76306a47593763266 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 1 Aug 2022 13:15:46 -0400 Subject: [PATCH 205/285] chore(ci): add msvc static analysis workflow --- .github/workflows/msvc-analysis.yml | 52 +++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 .github/workflows/msvc-analysis.yml diff --git a/.github/workflows/msvc-analysis.yml b/.github/workflows/msvc-analysis.yml new file mode 100644 index 0000000..fc4c8eb --- /dev/null +++ b/.github/workflows/msvc-analysis.yml @@ -0,0 +1,52 @@ +name: msvc analysis + +on: + pull_request: + branches: + - '**' + paths-ignore: + - '**/*.md' + +jobs: + # We use the presence of the sonar token to detect if the PR comes from a fork + condition-check: + runs-on: ubuntu-latest + outputs: + ok: ${{ steps.check-secrets.outputs.ok }} + steps: + - name: Secret guard + id: check-secrets + run: | + if [ ! -z "${{ secrets.SONAR_TOKEN }}" ]; then + echo "::set-output name=ok::true" + fi + vs2022: + needs: + - condition-check + runs-on: windows-2022 + steps: + - name: Git checkout + uses: actions/checkout@v2 + with: + submodules: 'recursive' + - name: Generate solution (release-x64) + run: python3 make.py -ci -compiler vs2022 -config Release -cpu x64 + - name: Run MSVC Code Analysis + uses: microsoft/msvc-code-analysis-action@v0.1.0 + id: run-analysis + with: + cmakeBuildDirectory: ${{ github.workspace }}/build + buildConfiguration: Release + ruleset: NativeRecommendedRules.ruleset + ignoredPaths: ${{ github.workspace }}/external + - name: Upload SARIF to GitHub + # Can only upload SARIF if we don't come from a fork + if: ${{ needs.condition-check.outputs.ok == 'true' }} + uses: github/codeql-action/upload-sarif@v1 + with: + sarif_file: ${{ steps.run-analysis.outputs.sarif }} + - name: Upload SARIF as an Artifact + uses: actions/upload-artifact@v2 + with: + name: sarif-file + path: ${{ steps.run-analysis.outputs.sarif }} From eb959299f03122f714c240ffe399912c9b65695a Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 1 Aug 2022 22:10:54 -0400 Subject: [PATCH 206/285] chore(tools): mark root cmake project as C++ This allows CMake to detect the compiler when the file API is used. This is used by the MSVC static analysis GitHub Action workflow. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d214e2..dbdfa37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required (VERSION 3.2) -project(sjson-cpp NONE) +project(sjson-cpp CXX) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake") From 2c0212fbddded87d2f2f3d2bdb38317e441dfe30 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 1 Aug 2022 22:26:39 -0400 Subject: [PATCH 207/285] fix: reduce vsnprintf buffer size --- includes/sjson/error.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/sjson/error.h b/includes/sjson/error.h index aae9211..8c48673 100644 --- a/includes/sjson/error.h +++ b/includes/sjson/error.h @@ -123,7 +123,7 @@ (void)line; (void)file; - constexpr int buffer_size = 64 * 1024; + constexpr int buffer_size = 1 * 1024; char buffer[buffer_size]; va_list args; From 8fce02fc9d0573231f1eae04d08d338a75c5ec02 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 4 Mar 2023 08:35:58 -0500 Subject: [PATCH 208/285] chore(ci): update github actions to latest and fix set-output --- .github/workflows/msvc-analysis.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/msvc-analysis.yml b/.github/workflows/msvc-analysis.yml index fc4c8eb..8a8d829 100644 --- a/.github/workflows/msvc-analysis.yml +++ b/.github/workflows/msvc-analysis.yml @@ -18,7 +18,7 @@ jobs: id: check-secrets run: | if [ ! -z "${{ secrets.SONAR_TOKEN }}" ]; then - echo "::set-output name=ok::true" + echo "ok=true" >> $GITHUB_OUTPUT fi vs2022: needs: @@ -26,13 +26,13 @@ jobs: runs-on: windows-2022 steps: - name: Git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: 'recursive' - name: Generate solution (release-x64) run: python3 make.py -ci -compiler vs2022 -config Release -cpu x64 - name: Run MSVC Code Analysis - uses: microsoft/msvc-code-analysis-action@v0.1.0 + uses: microsoft/msvc-code-analysis-action@v0.1.1 id: run-analysis with: cmakeBuildDirectory: ${{ github.workspace }}/build @@ -42,7 +42,7 @@ jobs: - name: Upload SARIF to GitHub # Can only upload SARIF if we don't come from a fork if: ${{ needs.condition-check.outputs.ok == 'true' }} - uses: github/codeql-action/upload-sarif@v1 + uses: github/codeql-action/upload-sarif@v2 with: sarif_file: ${{ steps.run-analysis.outputs.sarif }} - name: Upload SARIF as an Artifact From 5a70744455993cb89745969f34d3b9d570519147 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 4 Mar 2023 08:52:29 -0500 Subject: [PATCH 209/285] chore(ci): update github action to latest and avoid set-output --- .github/workflows/sonarcloud.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index f69ae9d..4a200f5 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -22,7 +22,7 @@ jobs: id: check-secrets run: | if [ ! -z "${{ secrets.SONAR_TOKEN }}" ]; then - echo "::set-output name=ok::true" + echo "ok=true" >> $GITHUB_OUTPUT fi sonarcloud: needs: @@ -31,7 +31,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: 'recursive' - name: Build with wrapper From 77d86ca27d630e3ef2562f8e8f35567c4e56ef0b Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 4 Mar 2023 08:53:38 -0500 Subject: [PATCH 210/285] chore(ci): update github action to latest --- .github/workflows/build_push.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 273327b..2dc1af7 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -15,7 +15,7 @@ jobs: compiler: [gcc11, clang14] steps: - name: Git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: 'recursive' - name: Building (debug-x86) @@ -70,7 +70,7 @@ jobs: compiler: [xcode13] steps: - name: Git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: 'recursive' - name: Setup ${{ matrix.compiler }} compiler @@ -98,7 +98,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: 'recursive' - name: Building (debug) @@ -126,7 +126,7 @@ jobs: runs-on: windows-2022 steps: - name: Git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: 'recursive' - name: Building (debug-x64) From 2f9b383822ce79df2a42cb230e058b4a5848bc34 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 4 Mar 2023 09:00:51 -0500 Subject: [PATCH 211/285] chore(ci): update github action to latest --- .github/workflows/build_pull_request.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml index 22e59ea..159b9bc 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build_pull_request.yml @@ -15,7 +15,7 @@ jobs: compiler: [clang4] steps: - name: Git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: 'recursive' - name: Building (debug-x86) @@ -70,7 +70,7 @@ jobs: compiler: [gcc5, gcc6, gcc7, gcc8, clang5, clang6, clang7, clang8, clang9, clang10] steps: - name: Git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: 'recursive' - name: Building (debug-x86) @@ -125,7 +125,7 @@ jobs: compiler: [gcc9, gcc10, gcc11, clang11, clang12, clang13, clang14] steps: - name: Git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: 'recursive' - name: Building (debug-x86) @@ -180,7 +180,7 @@ jobs: compiler: [xcode10, xcode11] steps: - name: Git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: 'recursive' - name: Setup ${{ matrix.compiler }} compiler @@ -229,7 +229,7 @@ jobs: compiler: [xcode12, xcode13] steps: - name: Git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: 'recursive' - name: Setup ${{ matrix.compiler }} compiler @@ -257,7 +257,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: 'recursive' - name: Building (debug) @@ -285,7 +285,7 @@ jobs: runs-on: windows-2019 steps: - name: Git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: 'recursive' - name: Building (debug-x64) @@ -323,7 +323,7 @@ jobs: runs-on: windows-2022 steps: - name: Git checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 with: submodules: 'recursive' - name: Building (debug-x64) From f46969be9a8c7b8d0dcc6c08b73f4020f23a6ee4 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 22 Apr 2023 14:32:52 -0400 Subject: [PATCH 212/285] chore: add support for clang 15 and gcc 12 and 13 --- README.md | 4 ++-- make.py | 11 ++++++++++- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 71c0afe..d1d826d 100644 --- a/README.md +++ b/README.md @@ -39,8 +39,8 @@ Unicode formats other than UTF-8 aren't supported. * Windows VS2015 x86 and x64 * Windows (VS2017 to VS2022) x86, x64, and ARM64 * Windows (VS2017 to VS2022) with clang x86 and x64 -* Linux (gcc 5 to 11) x86 and x64 -* Linux (clang 4 to 14) x86 and x64 +* Linux (gcc 5 to 13) x86 and x64 +* Linux (clang 4 to 15) x86 and x64 * OS X (Xcode 10.3) x86 and x64 * OS X (Xcode 11.7, 12.5, 13.2) x64 and ARM64 * Android (NDK 21) ARMv7-A and ARM64 diff --git a/make.py b/make.py index df2ddb2..f2f565c 100644 --- a/make.py +++ b/make.py @@ -16,7 +16,7 @@ def parse_argv(): actions.add_argument('-unit_test', action='store_true') target = parser.add_argument_group(title='Target') - target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'vs2019-clang', 'vs2022', 'vs2022-clang', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'clang10', 'clang11', 'clang12', 'clang13', 'clang14', 'gcc4.8', 'gcc4.9', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'gcc10', 'gcc11', 'osx', 'ios', 'emscripten'], help='Defaults to the host system\'s default compiler') + target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'vs2019-clang', 'vs2022', 'vs2022-clang', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'clang10', 'clang11', 'clang12', 'clang13', 'clang14', 'clang15', 'gcc4.8', 'gcc4.9', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'gcc10', 'gcc11', 'gcc12', 'gcc13', 'osx', 'ios', 'emscripten'], help='Defaults to the host system\'s default compiler') target.add_argument('-config', choices=['Debug', 'Release'], type=str.capitalize) target.add_argument('-cpu', choices=['x86', 'x64', 'armv7', 'arm64', 'wasm'], help='Defaults to the host system\'s architecture') @@ -229,6 +229,9 @@ def set_compiler_env(compiler, args): elif compiler == 'clang14': os.environ['CC'] = 'clang-14' os.environ['CXX'] = 'clang++-14' + elif compiler == 'clang15': + os.environ['CC'] = 'clang-15' + os.environ['CXX'] = 'clang++-15' elif compiler == 'gcc4.8': os.environ['CC'] = 'gcc-4.8' os.environ['CXX'] = 'g++-4.8' @@ -256,6 +259,12 @@ def set_compiler_env(compiler, args): elif compiler == 'gcc11': os.environ['CC'] = 'gcc-11' os.environ['CXX'] = 'g++-11' + elif compiler == 'gcc12': + os.environ['CC'] = 'gcc-12' + os.environ['CXX'] = 'g++-12' + elif compiler == 'gcc13': + os.environ['CC'] = 'gcc-13' + os.environ['CXX'] = 'g++-13' elif compiler == 'emscripten': # Nothing to do for Emscripten return From 9717585e7758b8c43341af47126b2d1d66c620cc Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 22 Apr 2023 14:40:04 -0400 Subject: [PATCH 213/285] chore: update push workflow to gcc12 and clang15 --- .github/workflows/build_push.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 2dc1af7..87a9bed 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -12,54 +12,54 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - compiler: [gcc11, clang14] + compiler: [gcc13, clang15] steps: - name: Git checkout uses: actions/checkout@v3 with: submodules: 'recursive' - name: Building (debug-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -build' - name: Running unit tests (debug-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -unit_test' - name: Clean - uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 with: args: 'python3 make.py -clean_only' - name: Building (debug-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -build' - name: Running unit tests (debug-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -unit_test' - name: Clean - uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 with: args: 'python3 make.py -clean_only' - name: Building (release-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -build' - name: Running unit tests (release-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -unit_test' - name: Clean - uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 with: args: 'python3 make.py -clean_only' - name: Building (release-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -build' - name: Running unit tests (release-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test' From 2f08c2d2e37c8adb62e1df2dc7e9c642fd35e453 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 22 Apr 2023 14:43:41 -0400 Subject: [PATCH 214/285] chore: add gcc 12, 13 and clang 15 to pull request workflow --- .github/workflows/build_pull_request.yml | 55 ++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml index 159b9bc..5665908 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build_pull_request.yml @@ -173,6 +173,61 @@ jobs: with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test' + linux-lunar: + runs-on: ubuntu-latest + strategy: + matrix: + compiler: [gcc12, gcc13, clang15] + steps: + - name: Git checkout + uses: actions/checkout@v3 + with: + submodules: 'recursive' + - name: Building (debug-x86) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -build' + - name: Running unit tests (debug-x86) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -unit_test' + - name: Clean + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + with: + args: 'python3 make.py -clean_only' + - name: Building (debug-x64) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -build' + - name: Running unit tests (debug-x64) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -unit_test' + - name: Clean + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + with: + args: 'python3 make.py -clean_only' + - name: Building (release-x86) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -build' + - name: Running unit tests (release-x86) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -unit_test' + - name: Clean + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + with: + args: 'python3 make.py -clean_only' + - name: Building (release-x64) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -build' + - name: Running unit tests (release-x64) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test' + osx-10: runs-on: macos-10.15 strategy: From b370c9358280c0c2b066c7cfe8c6defca7050328 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 22 Apr 2023 20:47:10 -0400 Subject: [PATCH 215/285] chore: add xcode14 support for CI --- tools/setup_osx_compiler.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tools/setup_osx_compiler.sh b/tools/setup_osx_compiler.sh index dd98a3c..53aabaa 100755 --- a/tools/setup_osx_compiler.sh +++ b/tools/setup_osx_compiler.sh @@ -3,6 +3,14 @@ # Extract our command line arguments COMPILER=$1 +# See Github hosted runners: +# macos-12: https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md +# xcode 13.1, 12.2.1, 13.3.1, 13.4.1, 14.1, 14.2 +# maxos-11: https://github.com/actions/runner-images/blob/main/images/macos/macos-11-Readme.md +# xcode 11.7, 12.4, 12.5.1, 13.0, 13.1, 13.2.1 +# maxos-10.15: https://github.com/actions/runner-images/blob/main/images/macos/macos-10.15-Readme.md +# xcode 10.3, 11.2.1, 11.3.1, 11.4.1, 11.5, 11.6, 11.7, 12, 12.1, 12.1.1, 12.2, 12.3, 12.4 + # Convert our compiler string into our XCode path # Paths must match Github Action virtual images if [[ $COMPILER == xcode10 ]]; then @@ -13,6 +21,8 @@ elif [[ $COMPILER == xcode12 ]]; then XCODE_PATH="/Applications/Xcode_12.5.1.app" elif [[ $COMPILER == xcode13 ]]; then XCODE_PATH="/Applications/Xcode_13.2.1.app" +elif [[ $COMPILER == xcode14 ]]; then + XCODE_PATH="/Applications/Xcode_14.2.app" fi # Select our XCode version From 1e488d6717c7a0bb16117c365ea0d9e87ecbf33d Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 22 Apr 2023 20:48:19 -0400 Subject: [PATCH 216/285] chore: update push workflow to xcode 14 --- .github/workflows/build_push.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 87a9bed..43b5924 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -64,10 +64,10 @@ jobs: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test' osx-11: - runs-on: macos-11 + runs-on: macos-12 strategy: matrix: - compiler: [xcode13] + compiler: [xcode14] steps: - name: Git checkout uses: actions/checkout@v3 From c606d2e0e0c32f2f3adeb1cb70983ae6cbb9ec20 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 22 Apr 2023 20:49:46 -0400 Subject: [PATCH 217/285] chore: add xcode 14 to pull request workflow --- .github/workflows/build_pull_request.yml | 31 ++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml index 5665908..b343a09 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build_pull_request.yml @@ -307,6 +307,37 @@ jobs: run: python3 make.py -clean_only - name: Building for iOS (release-arm64) run: python3 make.py -ci -compiler ios -config Release -build + + osx-12: + runs-on: macos-12 + strategy: + matrix: + compiler: [xcode14] + steps: + - name: Git checkout + uses: actions/checkout@v3 + with: + submodules: 'recursive' + - name: Setup ${{ matrix.compiler }} compiler + run: ./tools/setup_osx_compiler.sh ${{ matrix.compiler }} + - name: Building (debug-x64) + run: python3 make.py -ci -compiler osx -config Debug -cpu x64 -build + - name: Running unit tests (debug-x64) + run: python3 make.py -ci -compiler osx -config Debug -cpu x64 -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building (release-x64) + run: python3 make.py -ci -compiler osx -config Release -cpu x64 -build + - name: Running unit tests (release-x64) + run: python3 make.py -ci -compiler osx -config Release -cpu x64 -unit_test + - name: Clean + run: python3 make.py -clean_only + - name: Building for iOS (debug-arm64) + run: python3 make.py -ci -compiler ios -config Debug -build + - name: Clean + run: python3 make.py -clean_only + - name: Building for iOS (release-arm64) + run: python3 make.py -ci -compiler ios -config Release -build emscripten: runs-on: ubuntu-latest From 6f1c3cea116b8a70a09ac2f067fe5853a58bfb5a Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 22 Apr 2023 20:53:02 -0400 Subject: [PATCH 218/285] docs: update readme with xcode 14 version --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d1d826d..b9accf3 100644 --- a/README.md +++ b/README.md @@ -42,9 +42,9 @@ Unicode formats other than UTF-8 aren't supported. * Linux (gcc 5 to 13) x86 and x64 * Linux (clang 4 to 15) x86 and x64 * OS X (Xcode 10.3) x86 and x64 -* OS X (Xcode 11.7, 12.5, 13.2) x64 and ARM64 +* OS X (Xcode 11.7, 12.5, 13.2, 14.2) x64 and ARM64 * Android (NDK 21) ARMv7-A and ARM64 -* iOS (Xcode 10.3, 11.7, 12.5, 13.2) ARM64 +* iOS (Xcode 10.3, 11.7, 12.5, 13.2, 14.2) ARM64 * Emscripten (1.39.11) WASM The above supported platform list is only what is tested every release but if it compiles, it should run just fine. From e7887cc3e4882611ef05e4c06490a00cd1fdd408 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 22 Apr 2023 21:22:56 -0400 Subject: [PATCH 219/285] chore: update osx job label --- .github/workflows/build_push.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 43b5924..8fcd1bf 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -63,7 +63,7 @@ jobs: with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test' - osx-11: + osx-12: runs-on: macos-12 strategy: matrix: From a18dbaa0f75f7d56f30a6c1dde84ae895d1620ba Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 23 Apr 2023 11:02:40 -0400 Subject: [PATCH 220/285] chore(tools): expose C++ version We still default to C++11 but now we can test other versions. --- make.py | 5 ++++- tests/main_android/app/build.gradle.in | 1 + tests/main_android/app/src/main/cpp/CMakeLists.txt | 2 -- tests/main_emscripten/CMakeLists.txt | 2 -- tests/main_generic/CMakeLists.txt | 2 -- tests/main_ios/CMakeLists.txt | 2 +- 6 files changed, 6 insertions(+), 8 deletions(-) diff --git a/make.py b/make.py index f2f565c..db71c49 100644 --- a/make.py +++ b/make.py @@ -19,6 +19,7 @@ def parse_argv(): target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'vs2019-clang', 'vs2022', 'vs2022-clang', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'clang10', 'clang11', 'clang12', 'clang13', 'clang14', 'clang15', 'gcc4.8', 'gcc4.9', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'gcc10', 'gcc11', 'gcc12', 'gcc13', 'osx', 'ios', 'emscripten'], help='Defaults to the host system\'s default compiler') target.add_argument('-config', choices=['Debug', 'Release'], type=str.capitalize) target.add_argument('-cpu', choices=['x86', 'x64', 'armv7', 'arm64', 'wasm'], help='Defaults to the host system\'s architecture') + target.add_argument('-cpp_version', choices=['11', '14', '17', '20'], help='Defaults to C++11') misc = parser.add_argument_group(title='Miscellaneous') misc.add_argument('-num_threads', help='No. to use while compiling') @@ -32,7 +33,7 @@ def parse_argv(): if not num_threads or num_threads == 0: num_threads = 4 - parser.set_defaults(build=False, clean=False, clean_only=False, unit_test=False, compiler=None, config='Release', cpu=None, num_threads=num_threads, tests_matching='') + parser.set_defaults(build=False, clean=False, clean_only=False, unit_test=False, compiler=None, config='Release', cpu=None, cpp_version='11', num_threads=num_threads, tests_matching='') args = parser.parse_args() @@ -283,6 +284,7 @@ def do_generate_solution(build_dir, cmake_script_dir, args): extra_switches = ['--no-warn-unused-cli'] extra_switches.append('-DCPU_INSTRUCTION_SET:STRING={}'.format(cpu)) + extra_switches.append('-DCMAKE_CXX_STANDARD:STRING={}'.format(args.cpp_version)) if not platform.system() == 'Windows': extra_switches.append('-DCMAKE_BUILD_TYPE={}'.format(config.upper())) @@ -417,6 +419,7 @@ def do_tests(build_dir, args): print('Using cpu: {}'.format(args.cpu)) if args.compiler: print('Using compiler: {}'.format(args.compiler)) + print('Using C++-{}'.format(args.cpp_version)) print('Using {} threads'.format(args.num_threads)) # Make sure 'make' runs with all available cores diff --git a/tests/main_android/app/build.gradle.in b/tests/main_android/app/build.gradle.in index ca59f4f..13aba89 100644 --- a/tests/main_android/app/build.gradle.in +++ b/tests/main_android/app/build.gradle.in @@ -11,6 +11,7 @@ android { testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" externalNativeBuild { cmake { + arguments '-DCMAKE_CXX_STANDARD=@CMAKE_CXX_STANDARD@' } } ndk { diff --git a/tests/main_android/app/src/main/cpp/CMakeLists.txt b/tests/main_android/app/src/main/cpp/CMakeLists.txt index 552d9d3..5b1d085 100644 --- a/tests/main_android/app/src/main/cpp/CMakeLists.txt +++ b/tests/main_android/app/src/main/cpp/CMakeLists.txt @@ -1,8 +1,6 @@ cmake_minimum_required(VERSION 3.2) project(sjson-cpp_unit_tests CXX) -set(CMAKE_CXX_STANDARD 11) - # Project root is \tests\main_android set(PROJECT_ROOT_DIR "${PROJECT_SOURCE_DIR}/../../../..") diff --git a/tests/main_emscripten/CMakeLists.txt b/tests/main_emscripten/CMakeLists.txt index 424b7d3..c4ae660 100644 --- a/tests/main_emscripten/CMakeLists.txt +++ b/tests/main_emscripten/CMakeLists.txt @@ -1,8 +1,6 @@ cmake_minimum_required (VERSION 3.2) project(sjson-cpp_unit_tests CXX) -set(CMAKE_CXX_STANDARD 11) - include_directories("${PROJECT_SOURCE_DIR}/../../includes") include_directories("${PROJECT_SOURCE_DIR}/../../external/catch2/single_include") diff --git a/tests/main_generic/CMakeLists.txt b/tests/main_generic/CMakeLists.txt index 4c66857..7802ee7 100644 --- a/tests/main_generic/CMakeLists.txt +++ b/tests/main_generic/CMakeLists.txt @@ -1,8 +1,6 @@ cmake_minimum_required (VERSION 3.2) project(sjson-cpp_unit_tests CXX) -set(CMAKE_CXX_STANDARD 11) - include_directories("${PROJECT_SOURCE_DIR}/../../includes") include_directories("${PROJECT_SOURCE_DIR}/../../external/catch2/single_include") diff --git a/tests/main_ios/CMakeLists.txt b/tests/main_ios/CMakeLists.txt index 3e323cd..4057d72 100644 --- a/tests/main_ios/CMakeLists.txt +++ b/tests/main_ios/CMakeLists.txt @@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 3.2) project(sjson-cpp_unit_tests) # iOS cmake toolchain does not support CMAKE_CXX_STANDARD -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") +set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++${CMAKE_CXX_STANDARD}") # Force enable debug symbols set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g") From 0d8dff9957189561e8f70d79582461b907208ed3 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 23 Apr 2023 11:22:58 -0400 Subject: [PATCH 221/285] chore(ci): add C++ version test workflow --- .github/workflows/test_cpp_versions.yml | 54 +++++++++++++++++++++++++ 1 file changed, 54 insertions(+) create mode 100644 .github/workflows/test_cpp_versions.yml diff --git a/.github/workflows/test_cpp_versions.yml b/.github/workflows/test_cpp_versions.yml new file mode 100644 index 0000000..e48259e --- /dev/null +++ b/.github/workflows/test_cpp_versions.yml @@ -0,0 +1,54 @@ +name: test cpp versions + +on: + pull_request: + branches: + - '**' + paths-ignore: + - '**/*.md' + +jobs: + linux: + runs-on: ubuntu-latest + strategy: + matrix: + compiler: [gcc13, clang15] + cpp_version: [14, 17, 20] + steps: + - name: Git checkout + uses: actions/checkout@v3 + with: + submodules: 'recursive' + - name: Building (release-x86) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -cpp_version ${{ matrix.cpp_version }} -build' + - name: Clean + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + with: + args: 'python3 make.py -clean_only' + - name: Building (release-x64) + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + with: + args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -cpp_version ${{ matrix.cpp_version }} -build' + + vs2022: + runs-on: windows-2022 + strategy: + matrix: + cpp_version: [14, 17, 20] + steps: + - name: Git checkout + uses: actions/checkout@v3 + with: + submodules: 'recursive' + - name: Building (release-x86) + run: python3 make.py -ci -compiler vs2022 -config Release -cpu x86 -cpp_version ${{ matrix.cpp_version }} -build + - name: Clean + run: python3 make.py -clean_only + - name: Building (release-x64) + run: python3 make.py -ci -compiler vs2022 -config Release -cpu x64 -cpp_version ${{ matrix.cpp_version }} -build + - name: Clean + run: python3 make.py -clean_only + - name: Building (release-arm64) + run: python3 make.py -ci -compiler vs2022 -config Release -cpu arm64 -cpp_version ${{ matrix.cpp_version }} -build From 164d959e995a7a7a4ea0b168d4d805cd48fa5d02 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 7 May 2023 09:29:33 -0400 Subject: [PATCH 222/285] chore: remove macos-10.15 CI builds 10.15 is no longer supported --- .github/workflows/build_pull_request.yml | 49 ------------------------ 1 file changed, 49 deletions(-) diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml index b343a09..8ec622b 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build_pull_request.yml @@ -228,55 +228,6 @@ jobs: with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test' - osx-10: - runs-on: macos-10.15 - strategy: - matrix: - compiler: [xcode10, xcode11] - steps: - - name: Git checkout - uses: actions/checkout@v3 - with: - submodules: 'recursive' - - name: Setup ${{ matrix.compiler }} compiler - run: ./tools/setup_osx_compiler.sh ${{ matrix.compiler }} - - name: Building (debug-x86) - if: ${{ matrix.compiler == 'xcode10' }} - run: python3 make.py -ci -compiler osx -config Debug -cpu x86 -build - - name: Running unit tests (debug-x86) - if: ${{ matrix.compiler == 'xcode10' }} - run: python3 make.py -ci -compiler osx -config Debug -cpu x86 -unit_test - - name: Clean - if: ${{ matrix.compiler == 'xcode10' }} - run: python3 make.py -clean_only - - name: Building (debug-x64) - run: python3 make.py -ci -compiler osx -config Debug -cpu x64 -build - - name: Running unit tests (debug-x64) - run: python3 make.py -ci -compiler osx -config Debug -cpu x64 -unit_test - - name: Clean - run: python3 make.py -clean_only - - name: Building (release-x86) - if: ${{ matrix.compiler == 'xcode10' }} - run: python3 make.py -ci -compiler osx -config Release -cpu x86 -build - - name: Running unit tests (release-x86) - if: ${{ matrix.compiler == 'xcode10' }} - run: python3 make.py -ci -compiler osx -config Release -cpu x86 -unit_test - - name: Clean - if: ${{ matrix.compiler == 'xcode10' }} - run: python3 make.py -clean_only - - name: Building (release-x64) - run: python3 make.py -ci -compiler osx -config Release -cpu x64 -build - - name: Running unit tests (release-x64) - run: python3 make.py -ci -compiler osx -config Release -cpu x64 -unit_test - - name: Clean - run: python3 make.py -clean_only - - name: Building for iOS (debug-arm64) - run: python3 make.py -ci -compiler ios -config Debug -build - - name: Clean - run: python3 make.py -clean_only - - name: Building for iOS (release-arm64) - run: python3 make.py -ci -compiler ios -config Release -build - osx-11: runs-on: macos-11 strategy: From 6b0622911460149b61045d054407c6a5c2c6ffc2 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 7 May 2023 09:30:42 -0400 Subject: [PATCH 223/285] docs: remove macos-10.15 XCode versions They still work fine, but no longer tested by CI --- README.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/README.md b/README.md index b9accf3..a3bfa13 100644 --- a/README.md +++ b/README.md @@ -41,8 +41,7 @@ Unicode formats other than UTF-8 aren't supported. * Windows (VS2017 to VS2022) with clang x86 and x64 * Linux (gcc 5 to 13) x86 and x64 * Linux (clang 4 to 15) x86 and x64 -* OS X (Xcode 10.3) x86 and x64 -* OS X (Xcode 11.7, 12.5, 13.2, 14.2) x64 and ARM64 +* OS X (XCode 12.5, 13.2, 14.2) x64 and ARM64 * Android (NDK 21) ARMv7-A and ARM64 * iOS (Xcode 10.3, 11.7, 12.5, 13.2, 14.2) ARM64 * Emscripten (1.39.11) WASM From 4ddc3561e0fd5a21ef10e9673bc07aea322864f8 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 18 Jul 2023 18:04:40 -0400 Subject: [PATCH 224/285] feat: add support for MSYS2 --- README.md | 1 + make.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index a3bfa13..38b13b5 100644 --- a/README.md +++ b/README.md @@ -45,6 +45,7 @@ Unicode formats other than UTF-8 aren't supported. * Android (NDK 21) ARMv7-A and ARM64 * iOS (Xcode 10.3, 11.7, 12.5, 13.2, 14.2) ARM64 * Emscripten (1.39.11) WASM +* MSYS2 x64 The above supported platform list is only what is tested every release but if it compiles, it should run just fine. diff --git a/make.py b/make.py index db71c49..dd912ff 100644 --- a/make.py +++ b/make.py @@ -335,7 +335,12 @@ def do_build(args): if args.compiler == 'android': cmake_cmd += ' --config {}'.format(config) else: - cmake_cmd += ' --config {} --target INSTALL'.format(config) + if os.path.sep == '\\': + # Native Windows + cmake_cmd += ' --config {} --target INSTALL'.format(config) + else: + # MSYS2 or Cygwin + cmake_cmd += ' --config {} --target install'.format(config) elif platform.system() == 'Darwin': if args.compiler == 'ios': cmake_cmd += ' --config {}'.format(config) From 2929bf4587fc4bcbe75d227f24b127748095eb3a Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 30 Jul 2023 11:32:32 -0400 Subject: [PATCH 225/285] fix: properly handle cmake config with msys2 --- make.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/make.py b/make.py index dd912ff..be0ee07 100644 --- a/make.py +++ b/make.py @@ -286,7 +286,14 @@ def do_generate_solution(build_dir, cmake_script_dir, args): extra_switches.append('-DCPU_INSTRUCTION_SET:STRING={}'.format(cpu)) extra_switches.append('-DCMAKE_CXX_STANDARD:STRING={}'.format(args.cpp_version)) - if not platform.system() == 'Windows': + if platform.system() == 'Windows': + if os.path.sep == '\\': + # Native Windows + extra_switches + else: + # MSYS2 or Cygwin + extra_switches.append('-DCMAKE_BUILD_TYPE={}'.format(config.upper())) + else: extra_switches.append('-DCMAKE_BUILD_TYPE={}'.format(config.upper())) if platform.system() == 'Darwin' and compiler == 'ios' and args.ci: From 10d232e718081d06fa16c376ef0ab86a3b27f0e3 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 11 Sep 2023 22:04:04 -0400 Subject: [PATCH 226/285] feat: add wrapper header for catch2.h We need to disable some warnings when /Wall is used --- tests/main_generic/CMakeLists.txt | 1 + tests/main_generic/main.cpp | 2 +- tests/sources/catch2.impl.h | 48 ++++++++++++++++++++++++++++++ tests/sources/test_parser.cpp | 2 +- tests/sources/test_string_view.cpp | 2 +- tests/sources/test_writer.cpp | 2 +- 6 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 tests/sources/catch2.impl.h diff --git a/tests/main_generic/CMakeLists.txt b/tests/main_generic/CMakeLists.txt index 7802ee7..6b69dc4 100644 --- a/tests/main_generic/CMakeLists.txt +++ b/tests/main_generic/CMakeLists.txt @@ -3,6 +3,7 @@ project(sjson-cpp_unit_tests CXX) include_directories("${PROJECT_SOURCE_DIR}/../../includes") include_directories("${PROJECT_SOURCE_DIR}/../../external/catch2/single_include") +include_directories("${PROJECT_SOURCE_DIR}/../sources") # Grab all of our test source files file(GLOB_RECURSE ALL_TEST_SOURCE_FILES LIST_DIRECTORIES false diff --git a/tests/main_generic/main.cpp b/tests/main_generic/main.cpp index 990a85f..7aa5be0 100644 --- a/tests/main_generic/main.cpp +++ b/tests/main_generic/main.cpp @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////////////////// #define CATCH_CONFIG_RUNNER -#include +#include "catch2.impl.h" #ifdef _WIN32 #include diff --git a/tests/sources/catch2.impl.h b/tests/sources/catch2.impl.h new file mode 100644 index 0000000..0b523b6 --- /dev/null +++ b/tests/sources/catch2.impl.h @@ -0,0 +1,48 @@ +//////////////////////////////////////////////////////////////////////////////// +// The MIT License (MIT) +// +// Copyright (c) 2023 Nicholas Frechette, Cody Jones, and sjson-cpp contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +//////////////////////////////////////////////////////////////////////////////// + +// We disable various informational warnings with using /Wall with MSVC caused by Catch2 + +#if defined(_MSC_VER) && !defined(__clang__) + #pragma warning(push) + #pragma warning(disable : 4365) // Signed/unsigned mismatch + #pragma warning(disable : 4388) // Signed/unsigned comparison + #pragma warning(disable : 4583) // Destructor is not implicitly called + #pragma warning(disable : 4623) // Default constructor implicitly deleted + #pragma warning(disable : 4625) // Copy constructor implicitly deleted + #pragma warning(disable : 4626) // Copy assignment operator implicitly deleted + #pragma warning(disable : 4868) // May not enforce left to right order in initializer + #pragma warning(disable : 5026) // Move constructor implicitly deleted + #pragma warning(disable : 5027) // Move assignment operator implicitly deleted + #pragma warning(disable : 5039) // Pointer to potentially throwing function passed to extern C + #pragma warning(disable : 5204) // Class has virtual functions but no virtual destructor + #pragma warning(disable : 5219) // Implicit conversion, possible loss of data + #pragma warning(disable : 5267) // Implicit copy constructor deprecated due to user destructor +#endif + +#include + +#if defined(_MSC_VER) && !defined(__clang__) + #pragma warning(pop) +#endif diff --git a/tests/sources/test_parser.cpp b/tests/sources/test_parser.cpp index 7b28684..ff8ba32 100644 --- a/tests/sources/test_parser.cpp +++ b/tests/sources/test_parser.cpp @@ -22,7 +22,7 @@ // SOFTWARE. //////////////////////////////////////////////////////////////////////////////// -#include +#include "catch2.impl.h" #include diff --git a/tests/sources/test_string_view.cpp b/tests/sources/test_string_view.cpp index 9346320..f400025 100644 --- a/tests/sources/test_string_view.cpp +++ b/tests/sources/test_string_view.cpp @@ -22,7 +22,7 @@ // SOFTWARE. //////////////////////////////////////////////////////////////////////////////// -#include +#include "catch2.impl.h" #include diff --git a/tests/sources/test_writer.cpp b/tests/sources/test_writer.cpp index 936a0ab..87a5d2f 100644 --- a/tests/sources/test_writer.cpp +++ b/tests/sources/test_writer.cpp @@ -22,7 +22,7 @@ // SOFTWARE. //////////////////////////////////////////////////////////////////////////////// -#include +#include "catch2.impl.h" #include From 79d61af123bffe716fd85be5383a93c3fd433d9d Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 11 Sep 2023 22:05:27 -0400 Subject: [PATCH 227/285] fix: explicitly delete implicitly deleted functions --- includes/sjson/error.h | 2 ++ tests/sources/test_writer.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/includes/sjson/error.h b/includes/sjson/error.h index 8c48673..4cba6cd 100644 --- a/includes/sjson/error.h +++ b/includes/sjson/error.h @@ -112,6 +112,8 @@ class runtime_assert final : public std::runtime_error { + runtime_assert() = delete; // Default constructor not needed + using std::runtime_error::runtime_error; // Inherit constructors }; diff --git a/tests/sources/test_writer.cpp b/tests/sources/test_writer.cpp index 87a5d2f..dca01e1 100644 --- a/tests/sources/test_writer.cpp +++ b/tests/sources/test_writer.cpp @@ -35,6 +35,8 @@ class StringStreamWriter final : public StreamWriter { public: StringStreamWriter() = default; + StringStreamWriter(const StringStreamWriter&) = delete; + StringStreamWriter& operator=(const StringStreamWriter&) = delete; virtual void write(const void* buffer, size_t buffer_size) override { From 33d57a351254c31a2f5c33e88bc5b9cae81a2710 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 11 Sep 2023 22:06:12 -0400 Subject: [PATCH 228/285] fix: use correct integral types and static_cast --- includes/sjson/error.h | 2 +- includes/sjson/writer.h | 48 +++++++++++++++++------------------ tests/sources/test_writer.cpp | 2 +- 3 files changed, 26 insertions(+), 26 deletions(-) diff --git a/includes/sjson/error.h b/includes/sjson/error.h index 4cba6cd..3cf9d36 100644 --- a/includes/sjson/error.h +++ b/includes/sjson/error.h @@ -136,7 +136,7 @@ va_end(args); if (count >= 0 && count < buffer_size) - throw runtime_assert(std::string(&buffer[0], count)); + throw runtime_assert(std::string(&buffer[0], static_cast(count))); else throw runtime_assert("Failed to format assert message!\n"); } diff --git a/includes/sjson/writer.h b/includes/sjson/writer.h index bd1badc..df0c4e4 100644 --- a/includes/sjson/writer.h +++ b/includes/sjson/writer.h @@ -267,9 +267,9 @@ namespace sjson m_stream_writer.write(" = "); char buffer[256]; - size_t length = snprintf(buffer, sizeof(buffer), "%s%s", value ? "true" : "false", k_line_terminator); + int length = snprintf(buffer, sizeof(buffer), "%s%s", value ? "true" : "false", k_line_terminator); SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to insert SJSON value: [%s = %s]", key, value); - m_stream_writer.write(buffer, length); + m_stream_writer.write(buffer, static_cast(length)); } inline void ObjectWriter::insert(const char* key, double value) @@ -300,9 +300,9 @@ namespace sjson else { char buffer[256]; - size_t length = snprintf(buffer, sizeof(buffer), "%.17g%s", value, k_line_terminator); + int length = snprintf(buffer, sizeof(buffer), "%.17g%s", value, k_line_terminator); SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to insert SJSON value: [%s = %.17g]", key, value); - m_stream_writer.write(buffer, length); + m_stream_writer.write(buffer, static_cast(length)); } } @@ -317,9 +317,9 @@ namespace sjson m_stream_writer.write(" = "); char buffer[256]; - size_t length = snprintf(buffer, sizeof(buffer), "%" PRId64 "%s", value, k_line_terminator); + int length = snprintf(buffer, sizeof(buffer), "%" PRId64 "%s", value, k_line_terminator); SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to insert SJSON value: [%s = %lld]", key, value); - m_stream_writer.write(buffer, length); + m_stream_writer.write(buffer, static_cast(length)); } inline void ObjectWriter::insert_unsigned_integer(const char* key, uint64_t value) @@ -333,9 +333,9 @@ namespace sjson m_stream_writer.write(" = "); char buffer[256]; - size_t length = snprintf(buffer, sizeof(buffer), "%" PRIu64 "%s", value, k_line_terminator); + int length = snprintf(buffer, sizeof(buffer), "%" PRIu64 "%s", value, k_line_terminator); SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to insert SJSON value: [%s = %llu]", key, value); - m_stream_writer.write(buffer, length); + m_stream_writer.write(buffer, static_cast(length)); } template::type* requirement> @@ -462,9 +462,9 @@ namespace sjson SJSON_CPP_ASSERT(!m_is_locked, "Cannot assign a value when locked"); char buffer[256]; - size_t length = snprintf(buffer, sizeof(buffer), "%s%s", value ? "true" : "false", k_line_terminator); + int length = snprintf(buffer, sizeof(buffer), "%s%s", value ? "true" : "false", k_line_terminator); SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to assign SJSON value: %s", value); - m_object_writer->m_stream_writer.write(buffer, length); + m_object_writer->m_stream_writer.write(buffer, static_cast(length)); m_is_empty = false; } @@ -492,9 +492,9 @@ namespace sjson else { char buffer[256]; - size_t length = snprintf(buffer, sizeof(buffer), "%.17g%s", value, k_line_terminator); + int length = snprintf(buffer, sizeof(buffer), "%.17g%s", value, k_line_terminator); SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to assign SJSON value: %.17g", value); - m_object_writer->m_stream_writer.write(buffer, length); + m_object_writer->m_stream_writer.write(buffer, static_cast(length)); } m_is_empty = false; @@ -557,9 +557,9 @@ namespace sjson SJSON_CPP_ASSERT(!m_is_locked, "Cannot assign a value when locked"); char buffer[256]; - size_t length = snprintf(buffer, sizeof(buffer), "%" PRId64 "%s", value, k_line_terminator); + int length = snprintf(buffer, sizeof(buffer), "%" PRId64 "%s", value, k_line_terminator); SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to assign SJSON value: %lld", value); - m_object_writer->m_stream_writer.write(buffer, length); + m_object_writer->m_stream_writer.write(buffer, static_cast(length)); m_is_empty = false; } @@ -570,9 +570,9 @@ namespace sjson SJSON_CPP_ASSERT(!m_is_locked, "Cannot assign a value when locked"); char buffer[256]; - size_t length = snprintf(buffer, sizeof(buffer), "%" PRIu64 "%s", value, k_line_terminator); + int length = snprintf(buffer, sizeof(buffer), "%" PRIu64 "%s", value, k_line_terminator); SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to assign SJSON value: %llu", value); - m_object_writer->m_stream_writer.write(buffer, length); + m_object_writer->m_stream_writer.write(buffer, static_cast(length)); m_is_empty = false; } @@ -614,9 +614,9 @@ namespace sjson write_indentation(); char buffer[256]; - size_t length = snprintf(buffer, sizeof(buffer), "%s", value ? "true" : "false"); + int length = snprintf(buffer, sizeof(buffer), "%s", value ? "true" : "false"); SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to push SJSON value: %s", value); - m_stream_writer.write(buffer, length); + m_stream_writer.write(buffer, static_cast(length)); m_is_empty = false; m_is_newline = false; } @@ -647,9 +647,9 @@ namespace sjson else { char buffer[256]; - size_t length = snprintf(buffer, sizeof(buffer), "%.17g", value); + int length = snprintf(buffer, sizeof(buffer), "%.17g", value); SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to push SJSON value: %.17g", value); - m_stream_writer.write(buffer, length); + m_stream_writer.write(buffer, static_cast(length)); } m_is_empty = false; @@ -667,9 +667,9 @@ namespace sjson write_indentation(); char buffer[256]; - size_t length = snprintf(buffer, sizeof(buffer), "%" PRId64, value); + int length = snprintf(buffer, sizeof(buffer), "%" PRId64, value); SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to push SJSON value: %lld", value); - m_stream_writer.write(buffer, length); + m_stream_writer.write(buffer, static_cast(length)); m_is_empty = false; m_is_newline = false; } @@ -685,9 +685,9 @@ namespace sjson write_indentation(); char buffer[256]; - size_t length = snprintf(buffer, sizeof(buffer), "%" PRIu64, value); + int length = snprintf(buffer, sizeof(buffer), "%" PRIu64, value); SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to push SJSON value: %llu", value); - m_stream_writer.write(buffer, length); + m_stream_writer.write(buffer, static_cast(length)); m_is_empty = false; m_is_newline = false; } diff --git a/tests/sources/test_writer.cpp b/tests/sources/test_writer.cpp index dca01e1..49bab9b 100644 --- a/tests/sources/test_writer.cpp +++ b/tests/sources/test_writer.cpp @@ -40,7 +40,7 @@ class StringStreamWriter final : public StreamWriter virtual void write(const void* buffer, size_t buffer_size) override { - m_buffer.sputn(reinterpret_cast(buffer), buffer_size); + m_buffer.sputn(reinterpret_cast(buffer), static_cast(buffer_size)); } std::string str() const { return m_buffer.str(); } From cb0b58f10cc7e6c3920024e5bfe63a4273965676 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 11 Sep 2023 22:06:32 -0400 Subject: [PATCH 229/285] fix: use uint32_t for error code to match enum --- includes/sjson/parser.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/sjson/parser.h b/includes/sjson/parser.h index 60cdca5..4ebf372 100644 --- a/includes/sjson/parser.h +++ b/includes/sjson/parser.h @@ -402,7 +402,7 @@ namespace sjson bool read_opening_bracket() { return read_symbol('[', ParserError::OpeningBracketExpected); } bool read_closing_bracket() { return read_symbol(']', ParserError::ClosingBracketExpected); } - bool read_symbol(char expected, int32_t reason_if_other_found) + bool read_symbol(char expected, uint32_t reason_if_other_found) { if (!skip_comments_and_whitespace_fail_if_eof()) return false; @@ -1005,7 +1005,7 @@ namespace sjson return true; } - void set_error(int32_t error) + void set_error(uint32_t error) { m_state.error.error = error; m_state.error.line = m_state.line; From b14333973e1cd8f0b2551717775402c156735b3d Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 11 Sep 2023 22:07:02 -0400 Subject: [PATCH 230/285] fix: explicitly add missing virtual destructor Also explicitly add implicitly deleted functions --- includes/sjson/parser_error.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/includes/sjson/parser_error.h b/includes/sjson/parser_error.h index f0de3f1..51dee4e 100644 --- a/includes/sjson/parser_error.h +++ b/includes/sjson/parser_error.h @@ -63,6 +63,12 @@ namespace sjson uint32_t line = 0; uint32_t column = 0; + ParserError() = default; + ParserError(const ParserError&) = default; + ParserError& operator=(const ParserError&) = default; + + virtual ~ParserError() = default; + virtual const char* get_description() const { switch (error) From 5ee9158ce3824c84a3f367652e3121313aa23a15 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 11 Sep 2023 22:07:23 -0400 Subject: [PATCH 231/285] feat: enable /Wall with MSVC --- cmake/CMakeCompiler.cmake | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/cmake/CMakeCompiler.cmake b/cmake/CMakeCompiler.cmake index fae4e93..8a87b01 100644 --- a/cmake/CMakeCompiler.cmake +++ b/cmake/CMakeCompiler.cmake @@ -4,11 +4,17 @@ macro(setup_default_compiler_flags _project_name) if(MSVC) # Replace some default compiler switches and add new ones STRING(REPLACE "/GR" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Disable RTTI - STRING(REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Bump warnings to W4 + STRING(REPLACE "/W3" "/Wall" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Enable all warnings target_compile_options(${_project_name} PRIVATE /Zi) # Add debug info target_compile_options(${_project_name} PRIVATE /Oi) # Generate intrinsic functions target_compile_options(${_project_name} PRIVATE /WX) # Treat warnings as errors - target_compile_options(${_project_name} PRIVATE /MP) # Enable parallel compilation + target_compile_options(${_project_name} PRIVATE /MP) # Enable parallel compilation + + # Disable various warnings that are harmless + target_compile_options(${_project_name} PRIVATE /wd4514) # Unreferenced inline function removed + target_compile_options(${_project_name} PRIVATE /wd4820) # Padding added after data member + target_compile_options(${_project_name} PRIVATE /wd4710) # Function not inlined + target_compile_options(${_project_name} PRIVATE /wd5045) # Spectre mitigation for memory load if(MSVC_VERSION GREATER 1900) # VS2017 and above From f493faea34c2db25b722ab91ad10f9e8734d5d74 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 11 Sep 2023 22:09:38 -0400 Subject: [PATCH 232/285] fix: disable inlining informational warning --- cmake/CMakeCompiler.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/CMakeCompiler.cmake b/cmake/CMakeCompiler.cmake index 8a87b01..5721bf4 100644 --- a/cmake/CMakeCompiler.cmake +++ b/cmake/CMakeCompiler.cmake @@ -14,6 +14,7 @@ macro(setup_default_compiler_flags _project_name) target_compile_options(${_project_name} PRIVATE /wd4514) # Unreferenced inline function removed target_compile_options(${_project_name} PRIVATE /wd4820) # Padding added after data member target_compile_options(${_project_name} PRIVATE /wd4710) # Function not inlined + target_compile_options(${_project_name} PRIVATE /wd4711) # Function selected for automatic inlining target_compile_options(${_project_name} PRIVATE /wd5045) # Spectre mitigation for memory load if(MSVC_VERSION GREATER 1900) From 89a16afb022dc36dee0db007523203169316503a Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 11 Sep 2023 22:12:38 -0400 Subject: [PATCH 233/285] fix: disable x86 float informational warning --- cmake/CMakeCompiler.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/CMakeCompiler.cmake b/cmake/CMakeCompiler.cmake index 5721bf4..b51ad5c 100644 --- a/cmake/CMakeCompiler.cmake +++ b/cmake/CMakeCompiler.cmake @@ -15,6 +15,7 @@ macro(setup_default_compiler_flags _project_name) target_compile_options(${_project_name} PRIVATE /wd4820) # Padding added after data member target_compile_options(${_project_name} PRIVATE /wd4710) # Function not inlined target_compile_options(${_project_name} PRIVATE /wd4711) # Function selected for automatic inlining + target_compile_options(${_project_name} PRIVATE /wd4738) # Storing 32-bit float in memory leads to rounding (x86) target_compile_options(${_project_name} PRIVATE /wd5045) # Spectre mitigation for memory load if(MSVC_VERSION GREATER 1900) From 23ecdc8c5c02760f7e9fcb1ef6eee75409dd25db Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 11 Sep 2023 22:23:52 -0400 Subject: [PATCH 234/285] fix: disable warning about unknown warnings --- cmake/CMakeCompiler.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/CMakeCompiler.cmake b/cmake/CMakeCompiler.cmake index b51ad5c..a0671cc 100644 --- a/cmake/CMakeCompiler.cmake +++ b/cmake/CMakeCompiler.cmake @@ -12,6 +12,7 @@ macro(setup_default_compiler_flags _project_name) # Disable various warnings that are harmless target_compile_options(${_project_name} PRIVATE /wd4514) # Unreferenced inline function removed + target_compile_options(${_project_name} PRIVATE /wd4619) # No warning with specified number target_compile_options(${_project_name} PRIVATE /wd4820) # Padding added after data member target_compile_options(${_project_name} PRIVATE /wd4710) # Function not inlined target_compile_options(${_project_name} PRIVATE /wd4711) # Function selected for automatic inlining From ff447113a1cd8818a54a16206a2449adbcf505ae Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 11 Sep 2023 22:24:06 -0400 Subject: [PATCH 235/285] fix: explicitly cast to avoid warning --- includes/sjson/writer.h | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/includes/sjson/writer.h b/includes/sjson/writer.h index df0c4e4..bfc18b9 100644 --- a/includes/sjson/writer.h +++ b/includes/sjson/writer.h @@ -268,7 +268,7 @@ namespace sjson char buffer[256]; int length = snprintf(buffer, sizeof(buffer), "%s%s", value ? "true" : "false", k_line_terminator); - SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to insert SJSON value: [%s = %s]", key, value); + SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to insert SJSON value: [%s = %s]", key, value); m_stream_writer.write(buffer, static_cast(length)); } @@ -301,7 +301,7 @@ namespace sjson { char buffer[256]; int length = snprintf(buffer, sizeof(buffer), "%.17g%s", value, k_line_terminator); - SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to insert SJSON value: [%s = %.17g]", key, value); + SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to insert SJSON value: [%s = %.17g]", key, value); m_stream_writer.write(buffer, static_cast(length)); } } @@ -318,7 +318,7 @@ namespace sjson char buffer[256]; int length = snprintf(buffer, sizeof(buffer), "%" PRId64 "%s", value, k_line_terminator); - SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to insert SJSON value: [%s = %lld]", key, value); + SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to insert SJSON value: [%s = %lld]", key, value); m_stream_writer.write(buffer, static_cast(length)); } @@ -334,7 +334,7 @@ namespace sjson char buffer[256]; int length = snprintf(buffer, sizeof(buffer), "%" PRIu64 "%s", value, k_line_terminator); - SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to insert SJSON value: [%s = %llu]", key, value); + SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to insert SJSON value: [%s = %llu]", key, value); m_stream_writer.write(buffer, static_cast(length)); } @@ -463,7 +463,7 @@ namespace sjson char buffer[256]; int length = snprintf(buffer, sizeof(buffer), "%s%s", value ? "true" : "false", k_line_terminator); - SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to assign SJSON value: %s", value); + SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to assign SJSON value: %s", value); m_object_writer->m_stream_writer.write(buffer, static_cast(length)); m_is_empty = false; } @@ -493,7 +493,7 @@ namespace sjson { char buffer[256]; int length = snprintf(buffer, sizeof(buffer), "%.17g%s", value, k_line_terminator); - SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to assign SJSON value: %.17g", value); + SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to assign SJSON value: %.17g", value); m_object_writer->m_stream_writer.write(buffer, static_cast(length)); } @@ -558,7 +558,7 @@ namespace sjson char buffer[256]; int length = snprintf(buffer, sizeof(buffer), "%" PRId64 "%s", value, k_line_terminator); - SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to assign SJSON value: %lld", value); + SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to assign SJSON value: %lld", value); m_object_writer->m_stream_writer.write(buffer, static_cast(length)); m_is_empty = false; } @@ -571,7 +571,7 @@ namespace sjson char buffer[256]; int length = snprintf(buffer, sizeof(buffer), "%" PRIu64 "%s", value, k_line_terminator); - SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to assign SJSON value: %llu", value); + SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to assign SJSON value: %llu", value); m_object_writer->m_stream_writer.write(buffer, static_cast(length)); m_is_empty = false; } @@ -615,7 +615,7 @@ namespace sjson char buffer[256]; int length = snprintf(buffer, sizeof(buffer), "%s", value ? "true" : "false"); - SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to push SJSON value: %s", value); + SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to push SJSON value: %s", value); m_stream_writer.write(buffer, static_cast(length)); m_is_empty = false; m_is_newline = false; @@ -648,7 +648,7 @@ namespace sjson { char buffer[256]; int length = snprintf(buffer, sizeof(buffer), "%.17g", value); - SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to push SJSON value: %.17g", value); + SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to push SJSON value: %.17g", value); m_stream_writer.write(buffer, static_cast(length)); } @@ -668,7 +668,7 @@ namespace sjson char buffer[256]; int length = snprintf(buffer, sizeof(buffer), "%" PRId64, value); - SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to push SJSON value: %lld", value); + SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to push SJSON value: %lld", value); m_stream_writer.write(buffer, static_cast(length)); m_is_empty = false; m_is_newline = false; @@ -686,7 +686,7 @@ namespace sjson char buffer[256]; int length = snprintf(buffer, sizeof(buffer), "%" PRIu64, value); - SJSON_CPP_ASSERT(length > 0 && length < sizeof(buffer), "Failed to push SJSON value: %llu", value); + SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to push SJSON value: %llu", value); m_stream_writer.write(buffer, static_cast(length)); m_is_empty = false; m_is_newline = false; From bd5fe588559f0001d1362ee5a760120d5b736ac9 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 11 Sep 2023 22:33:29 -0400 Subject: [PATCH 236/285] fix: avoid warning about C++98 compatibility --- cmake/CMakeCompiler.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/CMakeCompiler.cmake b/cmake/CMakeCompiler.cmake index a0671cc..7b8032b 100644 --- a/cmake/CMakeCompiler.cmake +++ b/cmake/CMakeCompiler.cmake @@ -40,6 +40,9 @@ macro(setup_default_compiler_flags _project_name) target_compile_options(${_project_name} PRIVATE -Wshadow) # Enable shadowing warnings target_compile_options(${_project_name} PRIVATE -Werror) # Treat warnings as errors + # Disable various warnings that are harmless + target_compile_options(${_project_name} PRIVATE -Wno-c++98-compat) # No need to support C++98 + target_compile_options(${_project_name} PRIVATE -g) # Enable debug symbols endif() endmacro() From 85af75a52ba80315524eecd789eda2dd84714693 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 12 Sep 2023 21:44:33 -0400 Subject: [PATCH 237/285] fix: stick with /W4 for msvc clang It is too pedantic for now Disable C++98 warnings for msvc clang Disable float comparison for msvc clang --- cmake/CMakeCompiler.cmake | 17 +++++++++++++---- tests/main_generic/CMakeLists.txt | 4 ++++ 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/cmake/CMakeCompiler.cmake b/cmake/CMakeCompiler.cmake index 7b8032b..6ad6ab0 100644 --- a/cmake/CMakeCompiler.cmake +++ b/cmake/CMakeCompiler.cmake @@ -4,12 +4,21 @@ macro(setup_default_compiler_flags _project_name) if(MSVC) # Replace some default compiler switches and add new ones STRING(REPLACE "/GR" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Disable RTTI - STRING(REPLACE "/W3" "/Wall" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Enable all warnings + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + STRING(REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Enable level 4 warnings + else() + STRING(REPLACE "/W3" "/Wall" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Enable all warnings + endif() target_compile_options(${_project_name} PRIVATE /Zi) # Add debug info target_compile_options(${_project_name} PRIVATE /Oi) # Generate intrinsic functions target_compile_options(${_project_name} PRIVATE /WX) # Treat warnings as errors target_compile_options(${_project_name} PRIVATE /MP) # Enable parallel compilation + if(MSVC_VERSION GREATER 1900) + # VS2017 and above + target_compile_options(${_project_name} PRIVATE /permissive-) + endif() + # Disable various warnings that are harmless target_compile_options(${_project_name} PRIVATE /wd4514) # Unreferenced inline function removed target_compile_options(${_project_name} PRIVATE /wd4619) # No warning with specified number @@ -19,9 +28,9 @@ macro(setup_default_compiler_flags _project_name) target_compile_options(${_project_name} PRIVATE /wd4738) # Storing 32-bit float in memory leads to rounding (x86) target_compile_options(${_project_name} PRIVATE /wd5045) # Spectre mitigation for memory load - if(MSVC_VERSION GREATER 1900) - # VS2017 and above - target_compile_options(${_project_name} PRIVATE /permissive-) + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + target_compile_options(${_project_name} PRIVATE -Wno-c++98-compat) # No need to support C++98 + target_compile_options(${_project_name} PRIVATE -Wno-c++98-compat-pedantic) # No need to support C++98 endif() # Add linker flags diff --git a/tests/main_generic/CMakeLists.txt b/tests/main_generic/CMakeLists.txt index 6b69dc4..248ca16 100644 --- a/tests/main_generic/CMakeLists.txt +++ b/tests/main_generic/CMakeLists.txt @@ -32,6 +32,10 @@ if(MSVC) # Exceptions are not enabled by default for ARM targets, enable them target_compile_options(${PROJECT_NAME} PRIVATE /EHsc) endif() + + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + target_compile_options(${PROJECT_NAME} PRIVATE -Wno-float-equal) # Float comparison + endif() endif() # Throw on failure to allow us to catch them and recover From de3ca96309d1f4c7f1f27e72795ce63dd8113795 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 12 Sep 2023 22:02:50 -0400 Subject: [PATCH 238/285] fix: stick to /W4 with vs2017 and earlier --- cmake/CMakeCompiler.cmake | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/cmake/CMakeCompiler.cmake b/cmake/CMakeCompiler.cmake index 6ad6ab0..b72c7ec 100644 --- a/cmake/CMakeCompiler.cmake +++ b/cmake/CMakeCompiler.cmake @@ -5,9 +5,14 @@ macro(setup_default_compiler_flags _project_name) # Replace some default compiler switches and add new ones STRING(REPLACE "/GR" "" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Disable RTTI if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - STRING(REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Enable level 4 warnings + STRING(REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Enable level 4 warnings else() - STRING(REPLACE "/W3" "/Wall" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Enable all warnings + if(MSVC_VERSION GREATER 1920) + # VS2019 and above + STRING(REPLACE "/W3" "/Wall" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Enable all warnings + else() + STRING(REPLACE "/W3" "/W4" CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Enable level 4 warnings + endif() endif() target_compile_options(${_project_name} PRIVATE /Zi) # Add debug info target_compile_options(${_project_name} PRIVATE /Oi) # Generate intrinsic functions From 0f9319d303c71990b68d7b962f066f88f06fac07 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 26 Sep 2023 21:44:16 -0400 Subject: [PATCH 239/285] fix: add missing path and catch2 shim include --- tests/main_android/app/src/main/cpp/CMakeLists.txt | 1 + tests/main_android/app/src/main/cpp/main.cpp | 2 +- tests/main_emscripten/CMakeLists.txt | 1 + tests/main_emscripten/main.cpp | 2 +- tests/main_ios/CMakeLists.txt | 1 + tests/main_ios/main.cpp | 2 +- 6 files changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/main_android/app/src/main/cpp/CMakeLists.txt b/tests/main_android/app/src/main/cpp/CMakeLists.txt index 5b1d085..879c79e 100644 --- a/tests/main_android/app/src/main/cpp/CMakeLists.txt +++ b/tests/main_android/app/src/main/cpp/CMakeLists.txt @@ -6,6 +6,7 @@ set(PROJECT_ROOT_DIR "${PROJECT_SOURCE_DIR}/../../../..") include_directories("${PROJECT_ROOT_DIR}/../../includes") include_directories("${PROJECT_ROOT_DIR}/../../external/catch2/single_include") +include_directories("${PROJECT_ROOT_DIR}/../sources") # Grab all of our test source files file(GLOB_RECURSE ALL_TEST_SOURCE_FILES LIST_DIRECTORIES false diff --git a/tests/main_android/app/src/main/cpp/main.cpp b/tests/main_android/app/src/main/cpp/main.cpp index d19f914..b38e7cc 100644 --- a/tests/main_android/app/src/main/cpp/main.cpp +++ b/tests/main_android/app/src/main/cpp/main.cpp @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////////////////// #define CATCH_CONFIG_RUNNER -#include +#include "catch2.impl.h" #include diff --git a/tests/main_emscripten/CMakeLists.txt b/tests/main_emscripten/CMakeLists.txt index c4ae660..907c2e8 100644 --- a/tests/main_emscripten/CMakeLists.txt +++ b/tests/main_emscripten/CMakeLists.txt @@ -3,6 +3,7 @@ project(sjson-cpp_unit_tests CXX) include_directories("${PROJECT_SOURCE_DIR}/../../includes") include_directories("${PROJECT_SOURCE_DIR}/../../external/catch2/single_include") +include_directories("${PROJECT_SOURCE_DIR}/../sources") # Grab all of our test source files file(GLOB_RECURSE ALL_TEST_SOURCE_FILES LIST_DIRECTORIES false diff --git a/tests/main_emscripten/main.cpp b/tests/main_emscripten/main.cpp index 7295628..b952cf7 100644 --- a/tests/main_emscripten/main.cpp +++ b/tests/main_emscripten/main.cpp @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////////////////// #define CATCH_CONFIG_RUNNER -#include +#include "catch2.impl.h" int main(int argc, char* argv[]) { diff --git a/tests/main_ios/CMakeLists.txt b/tests/main_ios/CMakeLists.txt index 4057d72..397e556 100644 --- a/tests/main_ios/CMakeLists.txt +++ b/tests/main_ios/CMakeLists.txt @@ -17,6 +17,7 @@ set(MACOSX_BUNDLE_BUNDLE_NAME "sjson-cpp-unit-tests") include_directories("${PROJECT_SOURCE_DIR}/../../includes") include_directories("${PROJECT_SOURCE_DIR}/../../external/catch2/single_include") +include_directories("${PROJECT_SOURCE_DIR}/../sources") # Grab all of our test source files file(GLOB_RECURSE ALL_TEST_SOURCE_FILES LIST_DIRECTORIES false diff --git a/tests/main_ios/main.cpp b/tests/main_ios/main.cpp index e2341ac..0a4c876 100644 --- a/tests/main_ios/main.cpp +++ b/tests/main_ios/main.cpp @@ -23,7 +23,7 @@ //////////////////////////////////////////////////////////////////////////////// #define CATCH_CONFIG_RUNNER -#include +#include "catch2.impl.h" int main(int argc, char* argv[]) { From 4aa6fe56a27097a8212f670e667185ae27df420a Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 26 Sep 2023 21:44:45 -0400 Subject: [PATCH 240/285] fix: pin android NDK version --- tests/main_android/app/build.gradle.in | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/main_android/app/build.gradle.in b/tests/main_android/app/build.gradle.in index 13aba89..ee029f8 100644 --- a/tests/main_android/app/build.gradle.in +++ b/tests/main_android/app/build.gradle.in @@ -1,6 +1,7 @@ apply plugin: 'com.android.application' android { + ndkVersion "20.1.5948944" compileSdkVersion 28 defaultConfig { applicationId "com.sjson.unit_tests" From 5359443388b8c8677fe1036ce871da1c8bbfbf98 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 2 Oct 2023 22:45:04 -0400 Subject: [PATCH 241/285] fix: selectively disable clang only warning --- cmake/CMakeCompiler.cmake | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/cmake/CMakeCompiler.cmake b/cmake/CMakeCompiler.cmake index b72c7ec..95faa15 100644 --- a/cmake/CMakeCompiler.cmake +++ b/cmake/CMakeCompiler.cmake @@ -55,7 +55,9 @@ macro(setup_default_compiler_flags _project_name) target_compile_options(${_project_name} PRIVATE -Werror) # Treat warnings as errors # Disable various warnings that are harmless - target_compile_options(${_project_name} PRIVATE -Wno-c++98-compat) # No need to support C++98 + if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + target_compile_options(${_project_name} PRIVATE -Wno-c++98-compat) # No need to support C++98 + endif() target_compile_options(${_project_name} PRIVATE -g) # Enable debug symbols endif() From da21a5d436fbfd3711d240c2844ac4f76a1b1668 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 7 Oct 2023 16:38:34 -0400 Subject: [PATCH 242/285] chore(ci): update sonarcloud image to latest --- .github/workflows/sonarcloud.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 4a200f5..6410712 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -35,14 +35,14 @@ jobs: with: submodules: 'recursive' - name: Build with wrapper - uses: docker://ghcr.io/nfrechette/toolchain-amd64-linux-sonarcloud:v2 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-linux-sonarcloud:v3 with: - args: '/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw_output python3 make.py -compiler clang14 -config Release -cpu x64 -build' + args: '/build-wrapper-linux-x86/build-wrapper-linux-x86-64 --out-dir bw_output python3 make.py -compiler clang15 -config Release -cpu x64 -build' - name: Run Sonar Scanner and upload to Sonarcloud env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} SONAR_HOST_URL: https://sonarcloud.io - uses: docker://ghcr.io/nfrechette/toolchain-amd64-linux-sonarcloud:v2 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-linux-sonarcloud:v3 with: - args: '/sonar-scanner-4.7.0.2747-linux/bin/sonar-scanner' + args: '/sonar-scanner-5.0.1.3006-linux/bin/sonar-scanner' From 9ce278b13d1390b61224ae7cd9ea0a6f4a4a757e Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 7 Oct 2023 17:24:20 -0400 Subject: [PATCH 243/285] fix: mark assert functions as noreturn --- includes/sjson/error.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/includes/sjson/error.h b/includes/sjson/error.h index 3cf9d36..2815c39 100644 --- a/includes/sjson/error.h +++ b/includes/sjson/error.h @@ -73,7 +73,7 @@ namespace error_impl { - inline void on_assert_abort(const char* expression, int line, const char* file, const char* format, ...) + [[noreturn]] inline void on_assert_abort(const char* expression, int line, const char* file, const char* format, ...) { (void)expression; (void)line; @@ -119,7 +119,7 @@ namespace error_impl { - inline void on_assert_throw(const char* expression, int line, const char* file, const char* format, ...) + [[noreturn]] inline void on_assert_throw(const char* expression, int line, const char* file, const char* format, ...) { (void)expression; (void)line; From 804f257689226cdbad159267d14aea7709f2bc19 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 7 Oct 2023 17:24:50 -0400 Subject: [PATCH 244/285] fix: properly initialize all members --- includes/sjson/parser_state.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/includes/sjson/parser_state.h b/includes/sjson/parser_state.h index 05611c1..5bc4cd8 100644 --- a/includes/sjson/parser_state.h +++ b/includes/sjson/parser_state.h @@ -37,11 +37,10 @@ namespace sjson struct ParserState { ParserState(const char* input, size_t input_length) - : offset() + : offset(0) , line(1) , column(1) , symbol(input_length > 0 ? input[0] : '\0') - , error() { } From 8504cd925f82bfad1477f3c5723a7467bea4aa1d Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 7 Oct 2023 17:25:49 -0400 Subject: [PATCH 245/285] feat: introduce a bit_cast shim --- includes/sjson/impl/bit_cast.impl.h | 59 +++++++++++++++++++++++++++++ tests/sources/test_writer.cpp | 3 +- 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 includes/sjson/impl/bit_cast.impl.h diff --git a/includes/sjson/impl/bit_cast.impl.h b/includes/sjson/impl/bit_cast.impl.h new file mode 100644 index 0000000..2bae686 --- /dev/null +++ b/includes/sjson/impl/bit_cast.impl.h @@ -0,0 +1,59 @@ +#pragma once + +//////////////////////////////////////////////////////////////////////////////// +// The MIT License (MIT) +// +// Copyright (c) 2023 Nicholas Frechette, Cody Jones, and sjson-cpp contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +//////////////////////////////////////////////////////////////////////////////// + +#include "sjson/version.h" + +#if defined(__cplusplus) && __cplusplus >= 202002L + #include +#elif defined(_MSVC_LANG) && _MSVC_LANG >= 202002L + #include +#endif + +namespace sjson +{ + SJSON_CPP_IMPL_VERSION_NAMESPACE_BEGIN + + namespace sjson_impl + { + ////////////////////////////////////////////////////////////////////////// + // C++20 introduced std::bit_cast which is safer than reinterpret_cast + ////////////////////////////////////////////////////////////////////////// + + #if defined(__cplusplus) && __cplusplus >= 202002L + using std::bit_cast; + #elif defined(_MSVC_LANG) && _MSVC_LANG >= 202002L + using std::bit_cast; + #else + template + inline constexpr dest_type_t bit_cast(src_type_t input) noexcept + { + return reinterpret_cast(input); + } + #endif + } + + SJSON_CPP_IMPL_VERSION_NAMESPACE_END +} diff --git a/tests/sources/test_writer.cpp b/tests/sources/test_writer.cpp index 49bab9b..2ce35fe 100644 --- a/tests/sources/test_writer.cpp +++ b/tests/sources/test_writer.cpp @@ -25,6 +25,7 @@ #include "catch2.impl.h" #include +#include #include #include @@ -40,7 +41,7 @@ class StringStreamWriter final : public StreamWriter virtual void write(const void* buffer, size_t buffer_size) override { - m_buffer.sputn(reinterpret_cast(buffer), static_cast(buffer_size)); + m_buffer.sputn(sjson_impl::bit_cast(buffer), static_cast(buffer_size)); } std::string str() const { return m_buffer.str(); } From 16cf2debbb450f5ea4ff34b1e86ac95ac5b441e4 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 7 Oct 2023 18:07:13 -0400 Subject: [PATCH 246/285] fix: avoid using inline with constexpr --- includes/sjson/impl/bit_cast.impl.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/includes/sjson/impl/bit_cast.impl.h b/includes/sjson/impl/bit_cast.impl.h index 2bae686..d19177e 100644 --- a/includes/sjson/impl/bit_cast.impl.h +++ b/includes/sjson/impl/bit_cast.impl.h @@ -48,7 +48,7 @@ namespace sjson using std::bit_cast; #else template - inline constexpr dest_type_t bit_cast(src_type_t input) noexcept + constexpr dest_type_t bit_cast(src_type_t input) noexcept { return reinterpret_cast(input); } From ce26fd7359b92defdad1b175f8974b61c0b4bf7b Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sun, 8 Oct 2023 10:47:30 -0400 Subject: [PATCH 247/285] fix: check for nullptr before calling strlen --- tests/sources/test_parser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/sources/test_parser.cpp b/tests/sources/test_parser.cpp index ff8ba32..34ff316 100644 --- a/tests/sources/test_parser.cpp +++ b/tests/sources/test_parser.cpp @@ -30,7 +30,7 @@ using namespace sjson; static Parser parser_from_c_str(const char* c_str) { - return Parser(c_str, std::strlen(c_str)); + return Parser(c_str, c_str != nullptr ? std::strlen(c_str) : 0); } TEST_CASE("Parser Misc", "[parser]") From 7ac9dbaeec95cbbb4de31c067bda6b47e97a23d8 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Tue, 10 Oct 2023 07:44:06 -0400 Subject: [PATCH 248/285] fix(ci): remove deprecated sonarcloud property usage --- sonar-project.properties | 1 - 1 file changed, 1 deletion(-) diff --git a/sonar-project.properties b/sonar-project.properties index 228bb99..947b060 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -8,4 +8,3 @@ sonar.sources=includes,tests/sources,tests/main_generic sonar.cfamily.build-wrapper-output=bw_output sonar.cfamily.threads=2 -sonar.cfamily.cache.enabled=false From 1bef1f4f0caa1482e40db31742b9861faeaeac27 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 6 Sep 2023 21:53:24 -0400 Subject: [PATCH 249/285] fix: add a macro to specify the string format in assert macros --- includes/sjson/error.h | 15 +++++++++++++++ includes/sjson/writer.h | 12 ++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/includes/sjson/error.h b/includes/sjson/error.h index 2815c39..cb1e5e7 100644 --- a/includes/sjson/error.h +++ b/includes/sjson/error.h @@ -54,11 +54,26 @@ // #define SJSON_CPP_ON_ASSERT_CUSTOM // #define SJSON_CPP_ASSERT(expression, format, ...) checkf(expression, ANSI_TO_TCHAR(format), #__VA_ARGS__) // +// [Custom String Format Specifier] +// Note that if you use a custom function, you may need to override the SJSON_STRING_FORMAT_SPECIFIER +// to properly handle ANSI/Unicode support. The C++11 standard does not support a way to say that '%s' +// always means an ANSI string (with 'const char*' as type). MSVC does support '%hs' but other compilers +// do not. +// // No checks: // By default if no macro mentioned above is defined, all asserts will be stripped // at compile time. ////////////////////////////////////////////////////////////////////////// +// See [Custom String Format Specifier] for details +#if !defined(SJSON_STRING_FORMAT_SPECIFIER) + #if defined(_MSC_VER) && !defined(__clang__) + #define SJSON_STRING_FORMAT_SPECIFIER "%hs" + #else + #define SJSON_STRING_FORMAT_SPECIFIER "%s" + #endif +#endif + #if defined(SJSON_CPP_ON_ASSERT_ABORT) #include "sjson/version.h" diff --git a/includes/sjson/writer.h b/includes/sjson/writer.h index bfc18b9..6b36e0a 100644 --- a/includes/sjson/writer.h +++ b/includes/sjson/writer.h @@ -268,7 +268,7 @@ namespace sjson char buffer[256]; int length = snprintf(buffer, sizeof(buffer), "%s%s", value ? "true" : "false", k_line_terminator); - SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to insert SJSON value: [%s = %s]", key, value); + SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to insert SJSON value: [" SJSON_STRING_FORMAT_SPECIFIER " = " SJSON_STRING_FORMAT_SPECIFIER "]", key, value); m_stream_writer.write(buffer, static_cast(length)); } @@ -301,7 +301,7 @@ namespace sjson { char buffer[256]; int length = snprintf(buffer, sizeof(buffer), "%.17g%s", value, k_line_terminator); - SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to insert SJSON value: [%s = %.17g]", key, value); + SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to insert SJSON value: [" SJSON_STRING_FORMAT_SPECIFIER " = %.17g]", key, value); m_stream_writer.write(buffer, static_cast(length)); } } @@ -318,7 +318,7 @@ namespace sjson char buffer[256]; int length = snprintf(buffer, sizeof(buffer), "%" PRId64 "%s", value, k_line_terminator); - SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to insert SJSON value: [%s = %lld]", key, value); + SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to insert SJSON value: [" SJSON_STRING_FORMAT_SPECIFIER " = %lld]", key, value); m_stream_writer.write(buffer, static_cast(length)); } @@ -334,7 +334,7 @@ namespace sjson char buffer[256]; int length = snprintf(buffer, sizeof(buffer), "%" PRIu64 "%s", value, k_line_terminator); - SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to insert SJSON value: [%s = %llu]", key, value); + SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to insert SJSON value: [" SJSON_STRING_FORMAT_SPECIFIER " = %llu]", key, value); m_stream_writer.write(buffer, static_cast(length)); } @@ -463,7 +463,7 @@ namespace sjson char buffer[256]; int length = snprintf(buffer, sizeof(buffer), "%s%s", value ? "true" : "false", k_line_terminator); - SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to assign SJSON value: %s", value); + SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to assign SJSON value: " SJSON_STRING_FORMAT_SPECIFIER, value); m_object_writer->m_stream_writer.write(buffer, static_cast(length)); m_is_empty = false; } @@ -615,7 +615,7 @@ namespace sjson char buffer[256]; int length = snprintf(buffer, sizeof(buffer), "%s", value ? "true" : "false"); - SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to push SJSON value: %s", value); + SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to push SJSON value: " SJSON_STRING_FORMAT_SPECIFIER, value); m_stream_writer.write(buffer, static_cast(length)); m_is_empty = false; m_is_newline = false; From c3442e491f2fc1195a5709a5182cafe568e37e4a Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 6 Sep 2023 22:04:50 -0400 Subject: [PATCH 250/285] fix: always use %s in assert format string We don't know enough information to do better. For abort/throw, %s is the right one but it might not be so for custom functions. If the format string is converted to unicode with the L prefix, formatting won't work correctly with ANSI strings. There, %hs is required with MSVC. --- includes/sjson/error.h | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/includes/sjson/error.h b/includes/sjson/error.h index cb1e5e7..38f5b63 100644 --- a/includes/sjson/error.h +++ b/includes/sjson/error.h @@ -67,11 +67,7 @@ // See [Custom String Format Specifier] for details #if !defined(SJSON_STRING_FORMAT_SPECIFIER) - #if defined(_MSC_VER) && !defined(__clang__) - #define SJSON_STRING_FORMAT_SPECIFIER "%hs" - #else - #define SJSON_STRING_FORMAT_SPECIFIER "%s" - #endif + #define SJSON_STRING_FORMAT_SPECIFIER "%s" #endif #if defined(SJSON_CPP_ON_ASSERT_ABORT) From 3a84a2b51c1d2a6e5d125b87141e9b3ccb010768 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 27 Oct 2023 21:36:20 -0400 Subject: [PATCH 251/285] style: clarify macro name --- includes/sjson/error.h | 6 +++--- includes/sjson/writer.h | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/includes/sjson/error.h b/includes/sjson/error.h index 38f5b63..4d12200 100644 --- a/includes/sjson/error.h +++ b/includes/sjson/error.h @@ -55,7 +55,7 @@ // #define SJSON_CPP_ASSERT(expression, format, ...) checkf(expression, ANSI_TO_TCHAR(format), #__VA_ARGS__) // // [Custom String Format Specifier] -// Note that if you use a custom function, you may need to override the SJSON_STRING_FORMAT_SPECIFIER +// Note that if you use a custom function, you may need to override the SJSON_ASSERT_STRING_FORMAT_SPECIFIER // to properly handle ANSI/Unicode support. The C++11 standard does not support a way to say that '%s' // always means an ANSI string (with 'const char*' as type). MSVC does support '%hs' but other compilers // do not. @@ -66,8 +66,8 @@ ////////////////////////////////////////////////////////////////////////// // See [Custom String Format Specifier] for details -#if !defined(SJSON_STRING_FORMAT_SPECIFIER) - #define SJSON_STRING_FORMAT_SPECIFIER "%s" +#if !defined(SJSON_ASSERT_STRING_FORMAT_SPECIFIER) + #define SJSON_ASSERT_STRING_FORMAT_SPECIFIER "%s" #endif #if defined(SJSON_CPP_ON_ASSERT_ABORT) diff --git a/includes/sjson/writer.h b/includes/sjson/writer.h index 6b36e0a..e2b7dfc 100644 --- a/includes/sjson/writer.h +++ b/includes/sjson/writer.h @@ -268,7 +268,7 @@ namespace sjson char buffer[256]; int length = snprintf(buffer, sizeof(buffer), "%s%s", value ? "true" : "false", k_line_terminator); - SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to insert SJSON value: [" SJSON_STRING_FORMAT_SPECIFIER " = " SJSON_STRING_FORMAT_SPECIFIER "]", key, value); + SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to insert SJSON value: [" SJSON_ASSERT_STRING_FORMAT_SPECIFIER " = " SJSON_ASSERT_STRING_FORMAT_SPECIFIER "]", key, value); m_stream_writer.write(buffer, static_cast(length)); } @@ -301,7 +301,7 @@ namespace sjson { char buffer[256]; int length = snprintf(buffer, sizeof(buffer), "%.17g%s", value, k_line_terminator); - SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to insert SJSON value: [" SJSON_STRING_FORMAT_SPECIFIER " = %.17g]", key, value); + SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to insert SJSON value: [" SJSON_ASSERT_STRING_FORMAT_SPECIFIER " = %.17g]", key, value); m_stream_writer.write(buffer, static_cast(length)); } } @@ -318,7 +318,7 @@ namespace sjson char buffer[256]; int length = snprintf(buffer, sizeof(buffer), "%" PRId64 "%s", value, k_line_terminator); - SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to insert SJSON value: [" SJSON_STRING_FORMAT_SPECIFIER " = %lld]", key, value); + SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to insert SJSON value: [" SJSON_ASSERT_STRING_FORMAT_SPECIFIER " = %lld]", key, value); m_stream_writer.write(buffer, static_cast(length)); } @@ -334,7 +334,7 @@ namespace sjson char buffer[256]; int length = snprintf(buffer, sizeof(buffer), "%" PRIu64 "%s", value, k_line_terminator); - SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to insert SJSON value: [" SJSON_STRING_FORMAT_SPECIFIER " = %llu]", key, value); + SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to insert SJSON value: [" SJSON_ASSERT_STRING_FORMAT_SPECIFIER " = %llu]", key, value); m_stream_writer.write(buffer, static_cast(length)); } @@ -463,7 +463,7 @@ namespace sjson char buffer[256]; int length = snprintf(buffer, sizeof(buffer), "%s%s", value ? "true" : "false", k_line_terminator); - SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to assign SJSON value: " SJSON_STRING_FORMAT_SPECIFIER, value); + SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to assign SJSON value: " SJSON_ASSERT_STRING_FORMAT_SPECIFIER, value); m_object_writer->m_stream_writer.write(buffer, static_cast(length)); m_is_empty = false; } @@ -615,7 +615,7 @@ namespace sjson char buffer[256]; int length = snprintf(buffer, sizeof(buffer), "%s", value ? "true" : "false"); - SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to push SJSON value: " SJSON_STRING_FORMAT_SPECIFIER, value); + SJSON_CPP_ASSERT(length > 0 && length < static_cast(sizeof(buffer)), "Failed to push SJSON value: " SJSON_ASSERT_STRING_FORMAT_SPECIFIER, value); m_stream_writer.write(buffer, static_cast(length)); m_is_empty = false; m_is_newline = false; From eb310f49aeb877fc2c3f4adb27fc26ace03748f2 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 10 Nov 2023 22:20:58 -0500 Subject: [PATCH 252/285] chore: bump version numbers --- appveyor.yml | 2 +- includes/sjson/version.h | 4 ++-- sonar-project.properties | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index bd0f442..fad095f 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 0.8.99.{build} +version: 0.9.0.{build} environment: PYTHON: "C:\\Python36-x64\\python.exe" diff --git a/includes/sjson/version.h b/includes/sjson/version.h index ed652d2..89a412b 100644 --- a/includes/sjson/version.h +++ b/includes/sjson/version.h @@ -29,8 +29,8 @@ //////////////////////////////////////////////////////////////////////////////// #define SJSON_CPP_VERSION_MAJOR 0 -#define SJSON_CPP_VERSION_MINOR 8 -#define SJSON_CPP_VERSION_PATCH 99 +#define SJSON_CPP_VERSION_MINOR 9 +#define SJSON_CPP_VERSION_PATCH 0 //////////////////////////////////////////////////////////////////////////////// // In order to allow multiple versions of this library to coexist side by side diff --git a/sonar-project.properties b/sonar-project.properties index 947b060..87a948e 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -2,7 +2,7 @@ sonar.organization=nfrechette-github sonar.projectKey=nfrechette_sjson-cpp sonar.projectName=sjson-cpp -sonar.projectVersion=0.8.99 +sonar.projectVersion=0.9.0 sonar.sources=includes,tests/sources,tests/main_generic From 54b3985e8ccc5efb5f24dabf0b4b802a996366e6 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 10 Nov 2023 22:29:14 -0500 Subject: [PATCH 253/285] chore: update change log --- CHANGELOG.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 560c092..d3c02eb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,17 @@ # Significant changes per release +## 0.9.0 + +* Added support for Clang 12, 13, 14, and 15 +* Added support for GCC 11, 12, and 13 +* Added support for XCode 14 +* Added support for VS2022 +* Added support for MSYS2 +* Added support for C++14, C++17, and C++20 +* CI now uses docker where possible +* Lots of static analysis fixes and improvements +* Misc minor improvements + ## 0.8.3 * Force macro expansion in version namespace identifier From 1c78c9706ff8006d617f2abe73a3da62f75faaf7 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 22 Nov 2023 22:20:49 -0500 Subject: [PATCH 254/285] chore: bump version numbers --- appveyor.yml | 2 +- includes/sjson/version.h | 2 +- sonar-project.properties | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index fad095f..1ecd502 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -1,4 +1,4 @@ -version: 0.9.0.{build} +version: 0.9.99.{build} environment: PYTHON: "C:\\Python36-x64\\python.exe" diff --git a/includes/sjson/version.h b/includes/sjson/version.h index 89a412b..8e719ac 100644 --- a/includes/sjson/version.h +++ b/includes/sjson/version.h @@ -30,7 +30,7 @@ #define SJSON_CPP_VERSION_MAJOR 0 #define SJSON_CPP_VERSION_MINOR 9 -#define SJSON_CPP_VERSION_PATCH 0 +#define SJSON_CPP_VERSION_PATCH 99 //////////////////////////////////////////////////////////////////////////////// // In order to allow multiple versions of this library to coexist side by side diff --git a/sonar-project.properties b/sonar-project.properties index 87a948e..d0cb86d 100644 --- a/sonar-project.properties +++ b/sonar-project.properties @@ -2,7 +2,7 @@ sonar.organization=nfrechette-github sonar.projectKey=nfrechette_sjson-cpp sonar.projectName=sjson-cpp -sonar.projectVersion=0.9.0 +sonar.projectVersion=0.9.99 sonar.sources=includes,tests/sources,tests/main_generic From 784fe95e09a27a6806569effdcfbed73531ee09d Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 22 Nov 2023 22:21:13 -0500 Subject: [PATCH 255/285] chore: bump iOS deployment target version --- cmake/Toolchain-iOS.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Toolchain-iOS.cmake b/cmake/Toolchain-iOS.cmake index 4bc4c44..ffa914f 100644 --- a/cmake/Toolchain-iOS.cmake +++ b/cmake/Toolchain-iOS.cmake @@ -14,4 +14,4 @@ set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "") set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_ENTITLEMENTS "") set(CMAKE_OSX_SYSROOT iphoneos CACHE STRING "") set(CMAKE_OSX_ARCHITECTURES arm64 CACHE STRING "") -set(CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 11.0) +set(CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 17.0) From 223c516211d3dda68d685b7baec831e55b1adfbc Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 22 Nov 2023 22:21:42 -0500 Subject: [PATCH 256/285] fix: set iOS product bundle identifier --- tests/main_ios/CMakeLists.txt | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tests/main_ios/CMakeLists.txt b/tests/main_ios/CMakeLists.txt index 397e556..113caba 100644 --- a/tests/main_ios/CMakeLists.txt +++ b/tests/main_ios/CMakeLists.txt @@ -36,3 +36,6 @@ add_executable(${PROJECT_NAME} MACOSX_BUNDLE ${ALL_TEST_SOURCE_FILES} ${ALL_MAIN # Throw on failure to allow us to catch them and recover add_definitions(-DSJSON_CPP_ON_ASSERT_THROW) + +# Set XCode properties +set_property(TARGET ${PROJECT_NAME} PROPERTY XCODE_ATTRIBUTE_PRODUCT_BUNDLE_IDENTIFIER "com.sjson.cpp.unit-tests") From b78ec0545e9c53bf1d84a6fbfc04a1bb54a4acfa Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 5 Jan 2024 21:01:55 -0500 Subject: [PATCH 257/285] feat(tests): add a new project to catch missing includes --- tests/CMakeLists.txt | 1 + tests/validate_includes/CMakeLists.txt | 41 +++++++++++++++++++ tests/validate_includes/dummy.cpp | 27 ++++++++++++ tests/validate_includes/single_include.cpp.in | 25 +++++++++++ 4 files changed, 94 insertions(+) create mode 100644 tests/validate_includes/CMakeLists.txt create mode 100644 tests/validate_includes/dummy.cpp create mode 100644 tests/validate_includes/single_include.cpp.in diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 6ffef2c..de431e6 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -9,4 +9,5 @@ elseif(PLATFORM_EMSCRIPTEN) add_subdirectory("${PROJECT_SOURCE_DIR}/main_emscripten") else() add_subdirectory("${PROJECT_SOURCE_DIR}/main_generic") + add_subdirectory("${PROJECT_SOURCE_DIR}/validate_includes") endif() diff --git a/tests/validate_includes/CMakeLists.txt b/tests/validate_includes/CMakeLists.txt new file mode 100644 index 0000000..18a92cc --- /dev/null +++ b/tests/validate_includes/CMakeLists.txt @@ -0,0 +1,41 @@ +cmake_minimum_required (VERSION 3.2) +project(sjson-cpp_validate_includes CXX) + +# The goal of this project is to generate a single cpp file for every public header +# This will allow us to detect if we are missing an include file during development + +include_directories("${PROJECT_SOURCE_DIR}/../../includes") + +# Grab all of our public header files +file(GLOB ALL_PUBLIC_HEADER_FILES LIST_DIRECTORIES false + ${PROJECT_SOURCE_DIR}/../../includes/sjson/*.h) + +# Generate the single include cpp files +foreach(HEADER_FILE ${ALL_PUBLIC_HEADER_FILES}) + # Find the root include directory position + string(FIND ${HEADER_FILE} "sjson" HEADER_FILE_SJSON_CPP_POS REVERSE) + + # Strip the root of the include path + string(SUBSTRING ${HEADER_FILE} ${HEADER_FILE_SJSON_CPP_POS} -1 HEADER_INCLUDE_PATH) + + # Configure our cpp file content + set(SJSON_CPP_SINGLE_INCLUDE_NAME ${HEADER_INCLUDE_PATH}) + + # Sanitize our filename so we can generate a unique cpp file for it + string(REPLACE "/" "_" HEADER_SANITIZED_FILENAME ${HEADER_INCLUDE_PATH}) + string(REPLACE "\\" "_" HEADER_SANITIZED_FILENAME ${HEADER_SANITIZED_FILENAME}) + + # Generate our single include cpp file + configure_file(${PROJECT_SOURCE_DIR}/single_include.cpp.in single_include_${HEADER_SANITIZED_FILENAME}.cpp @ONLY) +endforeach(HEADER_FILE) + +# Grab all of our main source files +file(GLOB_RECURSE ALL_MAIN_SOURCE_FILES LIST_DIRECTORIES false + ${PROJECT_SOURCE_DIR}/*.cpp + ${PROJECT_BINARY_DIR}/*.cpp) + +create_source_groups("${ALL_MAIN_SOURCE_FILES}" ${PROJECT_SOURCE_DIR}) + +add_library(${PROJECT_NAME} STATIC ${ALL_MAIN_SOURCE_FILES}) + +setup_default_compiler_flags(${PROJECT_NAME}) diff --git a/tests/validate_includes/dummy.cpp b/tests/validate_includes/dummy.cpp new file mode 100644 index 0000000..39fe33d --- /dev/null +++ b/tests/validate_includes/dummy.cpp @@ -0,0 +1,27 @@ +//////////////////////////////////////////////////////////////////////////////// +// The MIT License (MIT) +// +// Copyright (c) 2024 Nicholas Frechette, Cody Jones, and sjson-cpp contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +//////////////////////////////////////////////////////////////////////////////// + +// We define a single symbol here to avoid a warning when we build our static library +// to validate includes +void some_function() {} diff --git a/tests/validate_includes/single_include.cpp.in b/tests/validate_includes/single_include.cpp.in new file mode 100644 index 0000000..ca90dc2 --- /dev/null +++ b/tests/validate_includes/single_include.cpp.in @@ -0,0 +1,25 @@ +//////////////////////////////////////////////////////////////////////////////// +// The MIT License (MIT) +// +// Copyright (c) 2024 Nicholas Frechette, Cody Jones, and sjson-cpp contributors +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in all +// copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +// SOFTWARE. +//////////////////////////////////////////////////////////////////////////////// + +#include <@SJSON_CPP_SINGLE_INCLUDE_NAME@> From e814e8a1da8d3ce27c8296382f705fdcc106641a Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 5 Jan 2024 21:27:22 -0500 Subject: [PATCH 258/285] fix(writer): strip assert only members and initialize members inline --- includes/sjson/writer.h | 81 ++++++++++++++++++++++++++++++++--------- 1 file changed, 63 insertions(+), 18 deletions(-) diff --git a/includes/sjson/writer.h b/includes/sjson/writer.h index e2b7dfc..8ab649a 100644 --- a/includes/sjson/writer.h +++ b/includes/sjson/writer.h @@ -78,7 +78,7 @@ namespace sjson } private: - std::FILE* m_file; + std::FILE* m_file = nullptr; }; // A lambda that does not capture anything is equivalent to a static function @@ -128,10 +128,13 @@ namespace sjson void write_indentation(); StreamWriter& m_stream_writer; - uint32_t m_indent_level; - bool m_is_empty; - bool m_is_locked; - bool m_is_newline; + uint32_t m_indent_level = 0; + bool m_is_empty = true; + bool m_is_newline = false; + +#if defined(SJSON_CPP_HAS_ASSERT_CHECKS) + bool m_is_locked = false; +#endif friend ObjectWriter; }; @@ -195,9 +198,12 @@ namespace sjson void assign_signed_integer(int64_t value); void assign_unsigned_integer(uint64_t value); - ObjectWriter* m_object_writer; - bool m_is_empty; - bool m_is_locked; + ObjectWriter* m_object_writer = nullptr; + bool m_is_empty = true; + +#if defined(SJSON_CPP_HAS_ASSERT_CHECKS) + bool m_is_locked = false; +#endif friend ObjectWriter; }; @@ -216,9 +222,12 @@ namespace sjson private: StreamWriter& m_stream_writer; - uint32_t m_indent_level; - bool m_is_locked; - bool m_has_live_value_ref; + uint32_t m_indent_level = 0; + bool m_has_live_value_ref = false; + +#if defined(SJSON_CPP_HAS_ASSERT_CHECKS) + bool m_is_locked = false; +#endif friend ArrayWriter; }; @@ -238,8 +247,6 @@ namespace sjson inline ObjectWriter::ObjectWriter(StreamWriter& stream_writer, uint32_t indent_level) : m_stream_writer(stream_writer) , m_indent_level(indent_level) - , m_is_locked(false) - , m_has_live_value_ref(false) {} inline void ObjectWriter::insert(const char* key, const char* value) @@ -349,12 +356,18 @@ namespace sjson m_stream_writer.write(key); m_stream_writer.write(" = {"); m_stream_writer.write(k_line_terminator); + +#if defined(SJSON_CPP_HAS_ASSERT_CHECKS) m_is_locked = true; +#endif ObjectWriter object_writer(m_stream_writer, m_indent_level + 1); writer_fun(object_writer); +#if defined(SJSON_CPP_HAS_ASSERT_CHECKS) m_is_locked = false; +#endif + write_indentation(); m_stream_writer.write("}"); @@ -371,7 +384,10 @@ namespace sjson m_stream_writer.write(key); m_stream_writer.write(" = [ "); + +#if defined(SJSON_CPP_HAS_ASSERT_CHECKS) m_is_locked = true; +#endif ArrayWriter array_writer(m_stream_writer, m_indent_level + 1); writer_fun(array_writer); @@ -388,7 +404,9 @@ namespace sjson m_stream_writer.write(k_line_terminator); } +#if defined(SJSON_CPP_HAS_ASSERT_CHECKS) m_is_locked = false; +#endif } inline void ObjectWriter::write_indentation() @@ -407,8 +425,6 @@ namespace sjson inline ObjectWriter::ValueRef::ValueRef(ObjectWriter& object_writer, const char* key) : m_object_writer(&object_writer) - , m_is_empty(true) - , m_is_locked(false) { SJSON_CPP_ASSERT(!object_writer.m_is_locked, "Cannot insert SJSON value in locked object"); SJSON_CPP_ASSERT(!object_writer.m_has_live_value_ref, "Cannot insert SJSON value in object when it has a live ValueRef"); @@ -417,13 +433,18 @@ namespace sjson object_writer.m_stream_writer.write(key); object_writer.m_stream_writer.write(" = "); object_writer.m_has_live_value_ref = true; + +#if defined(SJSON_CPP_HAS_ASSERT_CHECKS) object_writer.m_is_locked = true; +#endif } inline ObjectWriter::ValueRef::ValueRef(ValueRef&& other) noexcept : m_object_writer(other.m_object_writer) , m_is_empty(other.m_is_empty) +#if defined(SJSON_CPP_HAS_ASSERT_CHECKS) , m_is_locked(other.m_is_locked) +#endif { other.m_object_writer = nullptr; } @@ -438,7 +459,10 @@ namespace sjson SJSON_CPP_ASSERT(m_object_writer->m_is_locked, "Expected object writer to be locked"); m_object_writer->m_has_live_value_ref = false; + +#if defined(SJSON_CPP_HAS_ASSERT_CHECKS) m_object_writer->m_is_locked = false; +#endif } } @@ -509,12 +533,18 @@ namespace sjson m_object_writer->m_stream_writer.write("{"); m_object_writer->m_stream_writer.write(k_line_terminator); + +#if defined(SJSON_CPP_HAS_ASSERT_CHECKS) m_is_locked = true; +#endif ObjectWriter object_writer(m_object_writer->m_stream_writer, m_object_writer->m_indent_level + 1); writer_fun(object_writer); +#if defined(SJSON_CPP_HAS_ASSERT_CHECKS) m_is_locked = false; +#endif + m_object_writer->write_indentation(); m_object_writer->m_stream_writer.write("}"); m_object_writer->m_stream_writer.write(k_line_terminator); @@ -529,7 +559,10 @@ namespace sjson SJSON_CPP_ASSERT(!m_is_locked, "Cannot assign a value when locked"); m_object_writer->m_stream_writer.write("[ "); + +#if defined(SJSON_CPP_HAS_ASSERT_CHECKS) m_is_locked = true; +#endif ArrayWriter array_writer(m_object_writer->m_stream_writer, m_object_writer->m_indent_level + 1); writer_fun(array_writer); @@ -546,7 +579,10 @@ namespace sjson m_object_writer->m_stream_writer.write(k_line_terminator); } +#if defined(SJSON_CPP_HAS_ASSERT_CHECKS) m_is_locked = false; +#endif + m_is_empty = false; } @@ -581,9 +617,6 @@ namespace sjson inline ArrayWriter::ArrayWriter(StreamWriter& stream_writer, uint32_t indent_level) : m_stream_writer(stream_writer) , m_indent_level(indent_level) - , m_is_empty(true) - , m_is_locked(false) - , m_is_newline(false) {} inline void ArrayWriter::push(const char* value) @@ -708,7 +741,10 @@ namespace sjson write_indentation(); m_stream_writer.write("{"); m_stream_writer.write(k_line_terminator); + +#if defined(SJSON_CPP_HAS_ASSERT_CHECKS) m_is_locked = true; +#endif ObjectWriter object_writer(m_stream_writer, m_indent_level + 1); writer_fun(object_writer); @@ -717,7 +753,10 @@ namespace sjson m_stream_writer.write("}"); m_stream_writer.write(k_line_terminator); +#if defined(SJSON_CPP_HAS_ASSERT_CHECKS) m_is_locked = false; +#endif + m_is_empty = false; m_is_newline = true; } @@ -734,12 +773,18 @@ namespace sjson write_indentation(); m_stream_writer.write("[ "); + +#if defined(SJSON_CPP_HAS_ASSERT_CHECKS) m_is_locked = true; +#endif ArrayWriter array_writer(m_stream_writer, m_indent_level); writer_fun(array_writer); +#if defined(SJSON_CPP_HAS_ASSERT_CHECKS) m_is_locked = false; +#endif + m_stream_writer.write(" ]"); m_is_empty = false; m_is_newline = false; From ff3a65d3781015619c8dc2bc0e61323ea1e98188 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 16 Mar 2024 14:53:03 -0400 Subject: [PATCH 259/285] chore: add support for clang 16, 17, and 18 --- make.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/make.py b/make.py index be0ee07..7d9bceb 100644 --- a/make.py +++ b/make.py @@ -16,7 +16,7 @@ def parse_argv(): actions.add_argument('-unit_test', action='store_true') target = parser.add_argument_group(title='Target') - target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'vs2019-clang', 'vs2022', 'vs2022-clang', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'clang10', 'clang11', 'clang12', 'clang13', 'clang14', 'clang15', 'gcc4.8', 'gcc4.9', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'gcc10', 'gcc11', 'gcc12', 'gcc13', 'osx', 'ios', 'emscripten'], help='Defaults to the host system\'s default compiler') + target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'vs2019-clang', 'vs2022', 'vs2022-clang', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'clang10', 'clang11', 'clang12', 'clang13', 'clang14', 'clang15', 'clang16', 'clang17', 'clang18', 'gcc4.8', 'gcc4.9', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'gcc10', 'gcc11', 'gcc12', 'gcc13', 'osx', 'ios', 'emscripten'], help='Defaults to the host system\'s default compiler') target.add_argument('-config', choices=['Debug', 'Release'], type=str.capitalize) target.add_argument('-cpu', choices=['x86', 'x64', 'armv7', 'arm64', 'wasm'], help='Defaults to the host system\'s architecture') target.add_argument('-cpp_version', choices=['11', '14', '17', '20'], help='Defaults to C++11') @@ -233,6 +233,15 @@ def set_compiler_env(compiler, args): elif compiler == 'clang15': os.environ['CC'] = 'clang-15' os.environ['CXX'] = 'clang++-15' + elif compiler == 'clang16': + os.environ['CC'] = 'clang-16' + os.environ['CXX'] = 'clang++-16' + elif compiler == 'clang17': + os.environ['CC'] = 'clang-17' + os.environ['CXX'] = 'clang++-17' + elif compiler == 'clang18': + os.environ['CC'] = 'clang-18' + os.environ['CXX'] = 'clang++-18' elif compiler == 'gcc4.8': os.environ['CC'] = 'gcc-4.8' os.environ['CXX'] = 'g++-4.8' From 4102570184bab1a05e2f44eec8324422631cd36a Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 16 Mar 2024 14:56:53 -0400 Subject: [PATCH 260/285] chore: update to clang 18 --- .github/workflows/test_cpp_versions.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/test_cpp_versions.yml b/.github/workflows/test_cpp_versions.yml index e48259e..5e2d625 100644 --- a/.github/workflows/test_cpp_versions.yml +++ b/.github/workflows/test_cpp_versions.yml @@ -12,7 +12,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - compiler: [gcc13, clang15] + compiler: [gcc13, clang18] cpp_version: [14, 17, 20] steps: - name: Git checkout @@ -20,15 +20,15 @@ jobs: with: submodules: 'recursive' - name: Building (release-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v2 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -cpp_version ${{ matrix.cpp_version }} -build' - name: Clean - uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v2 with: args: 'python3 make.py -clean_only' - name: Building (release-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v2 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -cpp_version ${{ matrix.cpp_version }} -build' From c84ade154a067a9e450966ce7194e0884c79776a Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 16 Mar 2024 14:57:49 -0400 Subject: [PATCH 261/285] chore: update CI to clang 18 --- .github/workflows/build_push.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 8fcd1bf..5437577 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -12,54 +12,54 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - compiler: [gcc13, clang15] + compiler: [gcc13, clang18] steps: - name: Git checkout uses: actions/checkout@v3 with: submodules: 'recursive' - name: Building (debug-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v2 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -build' - name: Running unit tests (debug-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v2 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -unit_test' - name: Clean - uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v2 with: args: 'python3 make.py -clean_only' - name: Building (debug-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v2 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -build' - name: Running unit tests (debug-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v2 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -unit_test' - name: Clean - uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v2 with: args: 'python3 make.py -clean_only' - name: Building (release-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v2 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -build' - name: Running unit tests (release-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v2 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -unit_test' - name: Clean - uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v2 with: args: 'python3 make.py -clean_only' - name: Building (release-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v2 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -build' - name: Running unit tests (release-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v2 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test' From 6f4103a4f665baa5a0eb7fd5ed7541e1b7b7c669 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 16 Mar 2024 15:00:05 -0400 Subject: [PATCH 262/285] chore: update CI to latest lunar/clang --- .github/workflows/build_pull_request.yml | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml index 8ec622b..b5ca0e8 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build_pull_request.yml @@ -177,54 +177,54 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - compiler: [gcc12, gcc13, clang15] + compiler: [gcc12, gcc13, clang15, clang16, clang17, clang18] steps: - name: Git checkout uses: actions/checkout@v3 with: submodules: 'recursive' - name: Building (debug-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v2 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -build' - name: Running unit tests (debug-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v2 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -unit_test' - name: Clean - uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v2 with: args: 'python3 make.py -clean_only' - name: Building (debug-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v2 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -build' - name: Running unit tests (debug-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v2 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -unit_test' - name: Clean - uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v2 with: args: 'python3 make.py -clean_only' - name: Building (release-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v2 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -build' - name: Running unit tests (release-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v2 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -unit_test' - name: Clean - uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v2 with: args: 'python3 make.py -clean_only' - name: Building (release-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v2 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -build' - name: Running unit tests (release-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v1 + uses: docker://ghcr.io/nfrechette/toolchain-amd64-lunar:v2 with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test' From d1c4bcf0112ccd04a0ef03326902b076e30195dd Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 6 Jul 2024 12:11:13 -0400 Subject: [PATCH 263/285] chore(ci): update xcode version support --- tools/setup_osx_compiler.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/setup_osx_compiler.sh b/tools/setup_osx_compiler.sh index 53aabaa..18931f4 100755 --- a/tools/setup_osx_compiler.sh +++ b/tools/setup_osx_compiler.sh @@ -4,6 +4,10 @@ COMPILER=$1 # See Github hosted runners: +# macos-14: https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md +# xcode 14.3.1, 15.0.1, 15.1, 15.2, 15.3, 15.4, 16.0 +# macos-13: https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md +# xcode 14.1, 14.2, 14.3.1, 15.0.1, 15.1, 15.2 # macos-12: https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md # xcode 13.1, 12.2.1, 13.3.1, 13.4.1, 14.1, 14.2 # maxos-11: https://github.com/actions/runner-images/blob/main/images/macos/macos-11-Readme.md @@ -23,6 +27,10 @@ elif [[ $COMPILER == xcode13 ]]; then XCODE_PATH="/Applications/Xcode_13.2.1.app" elif [[ $COMPILER == xcode14 ]]; then XCODE_PATH="/Applications/Xcode_14.2.app" +elif [[ $COMPILER == xcode15 ]]; then + XCODE_PATH="/Applications/Xcode_15.2.app" +elif [[ $COMPILER == xcode16 ]]; then + XCODE_PATH="/Applications/Xcode_16.0.app" fi # Select our XCode version From 4d0026f811bfcbe1d840cc46edfd3db7198a5ebd Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 6 Jul 2024 12:12:57 -0400 Subject: [PATCH 264/285] chore(ci): update to xcode 15 with commit push --- .github/workflows/build_push.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 5437577..bfbd081 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -63,11 +63,11 @@ jobs: with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test' - osx-12: - runs-on: macos-12 + osx-14: + runs-on: macos-14 strategy: matrix: - compiler: [xcode14] + compiler: [xcode15] steps: - name: Git checkout uses: actions/checkout@v3 From 5fb697edc7503270d042dbc5c85ac1531c915391 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 6 Jul 2024 12:15:37 -0400 Subject: [PATCH 265/285] chore(ci): update xcode version for pull request push --- .github/workflows/build_pull_request.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml index b5ca0e8..2189e68 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build_pull_request.yml @@ -228,11 +228,11 @@ jobs: with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test' - osx-11: - runs-on: macos-11 + osx-12: + runs-on: macos-12 strategy: matrix: - compiler: [xcode12, xcode13] + compiler: [xcode13] steps: - name: Git checkout uses: actions/checkout@v3 @@ -259,11 +259,11 @@ jobs: - name: Building for iOS (release-arm64) run: python3 make.py -ci -compiler ios -config Release -build - osx-12: - runs-on: macos-12 + osx-14: + runs-on: macos-14 strategy: matrix: - compiler: [xcode14] + compiler: [xcode14, xcode15] steps: - name: Git checkout uses: actions/checkout@v3 From 5fa805b8f2d9d7e90a7d99696c8ffc27000bbdae Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 6 Jul 2024 12:18:06 -0400 Subject: [PATCH 266/285] chore(ci): update checkout action to v4 --- .github/workflows/sonarcloud.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/sonarcloud.yml b/.github/workflows/sonarcloud.yml index 6410712..31a3b60 100644 --- a/.github/workflows/sonarcloud.yml +++ b/.github/workflows/sonarcloud.yml @@ -31,7 +31,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: 'recursive' - name: Build with wrapper From 45c2d5314a73de30a5b56560cfed00322877a72f Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 6 Jul 2024 12:19:17 -0400 Subject: [PATCH 267/285] chore(ci): update checkout action to v4 --- .github/workflows/build_push.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index bfbd081..83e2df2 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -15,7 +15,7 @@ jobs: compiler: [gcc13, clang18] steps: - name: Git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: 'recursive' - name: Building (debug-x86) @@ -70,7 +70,7 @@ jobs: compiler: [xcode15] steps: - name: Git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: 'recursive' - name: Setup ${{ matrix.compiler }} compiler @@ -98,7 +98,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: 'recursive' - name: Building (debug) @@ -126,7 +126,7 @@ jobs: runs-on: windows-2022 steps: - name: Git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: 'recursive' - name: Building (debug-x64) From cd1ce2dccae17bf77a881dc2b9d8fc19f583f66f Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 6 Jul 2024 12:22:10 -0400 Subject: [PATCH 268/285] chore(ci): update checkout action to v4 --- .github/workflows/build_pull_request.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml index 2189e68..c83ea35 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build_pull_request.yml @@ -15,7 +15,7 @@ jobs: compiler: [clang4] steps: - name: Git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: 'recursive' - name: Building (debug-x86) @@ -70,7 +70,7 @@ jobs: compiler: [gcc5, gcc6, gcc7, gcc8, clang5, clang6, clang7, clang8, clang9, clang10] steps: - name: Git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: 'recursive' - name: Building (debug-x86) @@ -125,7 +125,7 @@ jobs: compiler: [gcc9, gcc10, gcc11, clang11, clang12, clang13, clang14] steps: - name: Git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: 'recursive' - name: Building (debug-x86) @@ -180,7 +180,7 @@ jobs: compiler: [gcc12, gcc13, clang15, clang16, clang17, clang18] steps: - name: Git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: 'recursive' - name: Building (debug-x86) @@ -235,7 +235,7 @@ jobs: compiler: [xcode13] steps: - name: Git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: 'recursive' - name: Setup ${{ matrix.compiler }} compiler @@ -266,7 +266,7 @@ jobs: compiler: [xcode14, xcode15] steps: - name: Git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: 'recursive' - name: Setup ${{ matrix.compiler }} compiler @@ -294,7 +294,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: 'recursive' - name: Building (debug) @@ -322,7 +322,7 @@ jobs: runs-on: windows-2019 steps: - name: Git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: 'recursive' - name: Building (debug-x64) @@ -360,7 +360,7 @@ jobs: runs-on: windows-2022 steps: - name: Git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: 'recursive' - name: Building (debug-x64) From 8409e652dc37a49fba4efdbda62214b2d9610d61 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 6 Jul 2024 12:25:11 -0400 Subject: [PATCH 269/285] chore(ci): switch commit push xcode to arm64 --- .github/workflows/build_push.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 83e2df2..95ed0e6 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -75,16 +75,16 @@ jobs: submodules: 'recursive' - name: Setup ${{ matrix.compiler }} compiler run: ./tools/setup_osx_compiler.sh ${{ matrix.compiler }} - - name: Building (debug-x64) - run: python3 make.py -ci -compiler osx -config Debug -cpu x64 -build - - name: Running unit tests (debug-x64) - run: python3 make.py -ci -compiler osx -config Debug -cpu x64 -unit_test + - name: Building (debug-arm64) + run: python3 make.py -ci -compiler osx -config Debug -build + - name: Running unit tests (debug-arm64) + run: python3 make.py -ci -compiler osx -config Debug -unit_test - name: Clean run: python3 make.py -clean_only - - name: Building (release-x64) - run: python3 make.py -ci -compiler osx -config Release -cpu x64 -build - - name: Running unit tests (release-x64) - run: python3 make.py -ci -compiler osx -config Release -cpu x64 -unit_test + - name: Building (release-arm64) + run: python3 make.py -ci -compiler osx -config Release -build + - name: Running unit tests (release-arm64) + run: python3 make.py -ci -compiler osx -config Release -unit_test - name: Clean run: python3 make.py -clean_only - name: Building for iOS (debug-arm64) From 347269d0cc086ec63589508faa805b8fedf82228 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 6 Jul 2024 12:26:32 -0400 Subject: [PATCH 270/285] chore(ci): update pull request push xcode to arm64 --- .github/workflows/build_pull_request.yml | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml index c83ea35..e04ffd9 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build_pull_request.yml @@ -271,16 +271,16 @@ jobs: submodules: 'recursive' - name: Setup ${{ matrix.compiler }} compiler run: ./tools/setup_osx_compiler.sh ${{ matrix.compiler }} - - name: Building (debug-x64) - run: python3 make.py -ci -compiler osx -config Debug -cpu x64 -build - - name: Running unit tests (debug-x64) - run: python3 make.py -ci -compiler osx -config Debug -cpu x64 -unit_test + - name: Building (debug-arm64) + run: python3 make.py -ci -compiler osx -config Debug -build + - name: Running unit tests (debug-arm64) + run: python3 make.py -ci -compiler osx -config Debug -unit_test - name: Clean run: python3 make.py -clean_only - - name: Building (release-x64) - run: python3 make.py -ci -compiler osx -config Release -cpu x64 -build - - name: Running unit tests (release-x64) - run: python3 make.py -ci -compiler osx -config Release -cpu x64 -unit_test + - name: Building (release-arm64) + run: python3 make.py -ci -compiler osx -config Release -build + - name: Running unit tests (release-arm64) + run: python3 make.py -ci -compiler osx -config Release -unit_test - name: Clean run: python3 make.py -clean_only - name: Building for iOS (debug-arm64) From 739a88db0a43decb327aec07fd32685b02f7b453 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Sat, 6 Jul 2024 13:50:56 -0400 Subject: [PATCH 271/285] chore(ci): update xcode 14 version --- tools/setup_osx_compiler.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/setup_osx_compiler.sh b/tools/setup_osx_compiler.sh index 18931f4..0c4cef9 100755 --- a/tools/setup_osx_compiler.sh +++ b/tools/setup_osx_compiler.sh @@ -26,7 +26,7 @@ elif [[ $COMPILER == xcode12 ]]; then elif [[ $COMPILER == xcode13 ]]; then XCODE_PATH="/Applications/Xcode_13.2.1.app" elif [[ $COMPILER == xcode14 ]]; then - XCODE_PATH="/Applications/Xcode_14.2.app" + XCODE_PATH="/Applications/Xcode_14.3.1.app" elif [[ $COMPILER == xcode15 ]]; then XCODE_PATH="/Applications/Xcode_15.2.app" elif [[ $COMPILER == xcode16 ]]; then From 138f4135fa54477ffb4d49cf878c17734a72840e Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 15 Aug 2025 20:55:33 -0400 Subject: [PATCH 272/285] fix(tools): remove unnecessary cmake_minimum_version --- cmake/CMakeCompiler.cmake | 2 -- cmake/CMakePlatforms.cmake | 2 -- cmake/CMakeUtils.cmake | 2 -- cmake/Toolchain-Android.cmake | 2 -- cmake/Toolchain-iOS.cmake | 2 -- tests/CMakeLists.txt | 1 - tests/main_android/CMakeLists.txt | 1 - tests/main_emscripten/CMakeLists.txt | 1 - tests/main_generic/CMakeLists.txt | 1 - tests/main_ios/CMakeLists.txt | 1 - tests/validate_includes/CMakeLists.txt | 1 - 11 files changed, 16 deletions(-) diff --git a/cmake/CMakeCompiler.cmake b/cmake/CMakeCompiler.cmake index 95faa15..07aec88 100644 --- a/cmake/CMakeCompiler.cmake +++ b/cmake/CMakeCompiler.cmake @@ -1,5 +1,3 @@ -cmake_minimum_required (VERSION 3.2) - macro(setup_default_compiler_flags _project_name) if(MSVC) # Replace some default compiler switches and add new ones diff --git a/cmake/CMakePlatforms.cmake b/cmake/CMakePlatforms.cmake index 8f88f16..8d5b8f2 100644 --- a/cmake/CMakePlatforms.cmake +++ b/cmake/CMakePlatforms.cmake @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 3.2) - if(PLATFORM_NAME) return() # Already set endif() diff --git a/cmake/CMakeUtils.cmake b/cmake/CMakeUtils.cmake index c18543f..52e4673 100644 --- a/cmake/CMakeUtils.cmake +++ b/cmake/CMakeUtils.cmake @@ -1,5 +1,3 @@ -cmake_minimum_required (VERSION 3.2) - # Create groups for the test source files, this creates the proper directory structure under the # Visual Studio filters macro(create_source_groups _source_files _relative_directory) diff --git a/cmake/Toolchain-Android.cmake b/cmake/Toolchain-Android.cmake index c5570d4..c91a8ea 100644 --- a/cmake/Toolchain-Android.cmake +++ b/cmake/Toolchain-Android.cmake @@ -1,5 +1,3 @@ -cmake_minimum_required(VERSION 3.2) - # For Android, we just set the platform name as we won't be using CMake to build anything. # Instead Gradle is used through CMake. diff --git a/cmake/Toolchain-iOS.cmake b/cmake/Toolchain-iOS.cmake index ffa914f..2d710d5 100644 --- a/cmake/Toolchain-iOS.cmake +++ b/cmake/Toolchain-iOS.cmake @@ -1,5 +1,3 @@ -cmake_minimum_required (VERSION 3.2) - set(CMAKE_SYSTEM_NAME Darwin) # Set here instead of CMakePlatforms.cmake since we can't distinguis otherwise diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index de431e6..6931680 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required (VERSION 3.2) project(sjson-cpp_unit_tests_root NONE) if(PLATFORM_ANDROID) diff --git a/tests/main_android/CMakeLists.txt b/tests/main_android/CMakeLists.txt index 79e24ab..8065325 100644 --- a/tests/main_android/CMakeLists.txt +++ b/tests/main_android/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required(VERSION 3.2) project(sjson-cpp_unit_tests_gradle_shim NONE) # Set our project root since our gradle files used to build live in the binary output directory diff --git a/tests/main_emscripten/CMakeLists.txt b/tests/main_emscripten/CMakeLists.txt index 907c2e8..90557c6 100644 --- a/tests/main_emscripten/CMakeLists.txt +++ b/tests/main_emscripten/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required (VERSION 3.2) project(sjson-cpp_unit_tests CXX) include_directories("${PROJECT_SOURCE_DIR}/../../includes") diff --git a/tests/main_generic/CMakeLists.txt b/tests/main_generic/CMakeLists.txt index 248ca16..0cc0c71 100644 --- a/tests/main_generic/CMakeLists.txt +++ b/tests/main_generic/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required (VERSION 3.2) project(sjson-cpp_unit_tests CXX) include_directories("${PROJECT_SOURCE_DIR}/../../includes") diff --git a/tests/main_ios/CMakeLists.txt b/tests/main_ios/CMakeLists.txt index 113caba..f191655 100644 --- a/tests/main_ios/CMakeLists.txt +++ b/tests/main_ios/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required (VERSION 3.2) project(sjson-cpp_unit_tests) # iOS cmake toolchain does not support CMAKE_CXX_STANDARD diff --git a/tests/validate_includes/CMakeLists.txt b/tests/validate_includes/CMakeLists.txt index 18a92cc..09246c1 100644 --- a/tests/validate_includes/CMakeLists.txt +++ b/tests/validate_includes/CMakeLists.txt @@ -1,4 +1,3 @@ -cmake_minimum_required (VERSION 3.2) project(sjson-cpp_validate_includes CXX) # The goal of this project is to generate a single cpp file for every public header From 254b8c6115b5af2b6681b65a998b7e5cfeee26ca Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 15 Aug 2025 20:55:48 -0400 Subject: [PATCH 273/285] fix(tools): add max cmake version --- CMakeLists.txt | 2 +- tests/main_android/app/src/main/cpp/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index dbdfa37..a12fa75 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required (VERSION 3.2) +cmake_minimum_required(VERSION 3.2...3.25) project(sjson-cpp CXX) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake") diff --git a/tests/main_android/app/src/main/cpp/CMakeLists.txt b/tests/main_android/app/src/main/cpp/CMakeLists.txt index 879c79e..c615988 100644 --- a/tests/main_android/app/src/main/cpp/CMakeLists.txt +++ b/tests/main_android/app/src/main/cpp/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.2) +cmake_minimum_required(VERSION 3.2...3.25) project(sjson-cpp_unit_tests CXX) # Project root is \tests\main_android From 0e0c5e4d20e39bb04ee427cb6a9004169cb904da Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 15 Aug 2025 21:11:08 -0400 Subject: [PATCH 274/285] fix(ci): update github action versions --- .github/workflows/msvc-analysis.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/msvc-analysis.yml b/.github/workflows/msvc-analysis.yml index 8a8d829..7743c00 100644 --- a/.github/workflows/msvc-analysis.yml +++ b/.github/workflows/msvc-analysis.yml @@ -26,7 +26,7 @@ jobs: runs-on: windows-2022 steps: - name: Git checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: submodules: 'recursive' - name: Generate solution (release-x64) @@ -42,11 +42,11 @@ jobs: - name: Upload SARIF to GitHub # Can only upload SARIF if we don't come from a fork if: ${{ needs.condition-check.outputs.ok == 'true' }} - uses: github/codeql-action/upload-sarif@v2 + uses: github/codeql-action/upload-sarif@v3 with: sarif_file: ${{ steps.run-analysis.outputs.sarif }} - name: Upload SARIF as an Artifact - uses: actions/upload-artifact@v2 + uses: actions/upload-artifact@v4 with: name: sarif-file path: ${{ steps.run-analysis.outputs.sarif }} From da067ab115748d7c3d5872faa6b5aa28d50c6e6c Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 15 Aug 2025 21:16:37 -0400 Subject: [PATCH 275/285] chore(ci): remove older toolchains Rarely useful and takes time for little gain --- .github/workflows/build_pull_request.yml | 236 +---------------------- 1 file changed, 1 insertion(+), 235 deletions(-) diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml index e04ffd9..320067a 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build_pull_request.yml @@ -8,171 +8,6 @@ on: - '**/*.md' jobs: - linux-xenial: - runs-on: ubuntu-latest - strategy: - matrix: - compiler: [clang4] - steps: - - name: Git checkout - uses: actions/checkout@v4 - with: - submodules: 'recursive' - - name: Building (debug-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-xenial:v1 - with: - args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -build' - - name: Running unit tests (debug-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-xenial:v1 - with: - args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -unit_test' - - name: Clean - uses: docker://ghcr.io/nfrechette/toolchain-amd64-xenial:v1 - with: - args: 'python3 make.py -clean_only' - - name: Building (debug-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-xenial:v1 - with: - args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -build' - - name: Running unit tests (debug-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-xenial:v1 - with: - args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -unit_test' - - name: Clean - uses: docker://ghcr.io/nfrechette/toolchain-amd64-xenial:v1 - with: - args: 'python3 make.py -clean_only' - - name: Building (release-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-xenial:v1 - with: - args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -build' - - name: Running unit tests (release-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-xenial:v1 - with: - args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -unit_test' - - name: Clean - uses: docker://ghcr.io/nfrechette/toolchain-amd64-xenial:v1 - with: - args: 'python3 make.py -clean_only' - - name: Building (release-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-xenial:v1 - with: - args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -build' - - name: Running unit tests (release-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-xenial:v1 - with: - args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test' - - linux-bionic: - runs-on: ubuntu-latest - strategy: - matrix: - compiler: [gcc5, gcc6, gcc7, gcc8, clang5, clang6, clang7, clang8, clang9, clang10] - steps: - - name: Git checkout - uses: actions/checkout@v4 - with: - submodules: 'recursive' - - name: Building (debug-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 - with: - args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -build' - - name: Running unit tests (debug-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 - with: - args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -unit_test' - - name: Clean - uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 - with: - args: 'python3 make.py -clean_only' - - name: Building (debug-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 - with: - args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -build' - - name: Running unit tests (debug-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 - with: - args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -unit_test' - - name: Clean - uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 - with: - args: 'python3 make.py -clean_only' - - name: Building (release-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 - with: - args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -build' - - name: Running unit tests (release-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 - with: - args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -unit_test' - - name: Clean - uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 - with: - args: 'python3 make.py -clean_only' - - name: Building (release-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 - with: - args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -build' - - name: Running unit tests (release-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-bionic:v1 - with: - args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test' - - linux-focal: - runs-on: ubuntu-latest - strategy: - matrix: - compiler: [gcc9, gcc10, gcc11, clang11, clang12, clang13, clang14] - steps: - - name: Git checkout - uses: actions/checkout@v4 - with: - submodules: 'recursive' - - name: Building (debug-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 - with: - args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -build' - - name: Running unit tests (debug-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 - with: - args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x86 -unit_test' - - name: Clean - uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 - with: - args: 'python3 make.py -clean_only' - - name: Building (debug-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 - with: - args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -build' - - name: Running unit tests (debug-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 - with: - args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Debug -cpu x64 -unit_test' - - name: Clean - uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 - with: - args: 'python3 make.py -clean_only' - - name: Building (release-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 - with: - args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -build' - - name: Running unit tests (release-x86) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 - with: - args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x86 -unit_test' - - name: Clean - uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 - with: - args: 'python3 make.py -clean_only' - - name: Building (release-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 - with: - args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -build' - - name: Running unit tests (release-x64) - uses: docker://ghcr.io/nfrechette/toolchain-amd64-focal:v1 - with: - args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test' - linux-lunar: runs-on: ubuntu-latest strategy: @@ -228,42 +63,11 @@ jobs: with: args: 'python3 make.py -ci -compiler ${{ matrix.compiler }} -config Release -cpu x64 -unit_test' - osx-12: - runs-on: macos-12 - strategy: - matrix: - compiler: [xcode13] - steps: - - name: Git checkout - uses: actions/checkout@v4 - with: - submodules: 'recursive' - - name: Setup ${{ matrix.compiler }} compiler - run: ./tools/setup_osx_compiler.sh ${{ matrix.compiler }} - - name: Building (debug-x64) - run: python3 make.py -ci -compiler osx -config Debug -cpu x64 -build - - name: Running unit tests (debug-x64) - run: python3 make.py -ci -compiler osx -config Debug -cpu x64 -unit_test - - name: Clean - run: python3 make.py -clean_only - - name: Building (release-x64) - run: python3 make.py -ci -compiler osx -config Release -cpu x64 -build - - name: Running unit tests (release-x64) - run: python3 make.py -ci -compiler osx -config Release -cpu x64 -unit_test - - name: Clean - run: python3 make.py -clean_only - - name: Building for iOS (debug-arm64) - run: python3 make.py -ci -compiler ios -config Debug -build - - name: Clean - run: python3 make.py -clean_only - - name: Building for iOS (release-arm64) - run: python3 make.py -ci -compiler ios -config Release -build - osx-14: runs-on: macos-14 strategy: matrix: - compiler: [xcode14, xcode15] + compiler: [xcode15] steps: - name: Git checkout uses: actions/checkout@v4 @@ -318,44 +122,6 @@ jobs: with: args: 'python3 make.py -ci -compiler emscripten -config release -unit_test' - vs2019: - runs-on: windows-2019 - steps: - - name: Git checkout - uses: actions/checkout@v4 - with: - submodules: 'recursive' - - name: Building (debug-x64) - run: python3 make.py -ci -compiler vs2019 -config Debug -cpu x64 -build - - name: Running unit tests (debug-x64) - run: python3 make.py -ci -compiler vs2019 -config Debug -cpu x64 -unit_test - - name: Clean - run: python3 make.py -clean_only - - name: Building (release-x64) - run: python3 make.py -ci -compiler vs2019 -config Release -cpu x64 -build - - name: Running unit tests (release-x64) - run: python3 make.py -ci -compiler vs2019 -config Release -cpu x64 -unit_test - - name: Clean - run: python3 make.py -clean_only - - name: Building (debug-arm64) - run: python3 make.py -ci -compiler vs2019 -config Debug -cpu arm64 -build - - name: Clean - run: python3 make.py -clean_only - - name: Building (release-arm64) - run: python3 make.py -ci -compiler vs2019 -config Release -cpu arm64 -build - - name: Clean - run: python3 make.py -clean_only - - name: Building (debug-x64) with Clang - run: python3 make.py -ci -compiler vs2019-clang -config Debug -cpu x64 -build - - name: Running unit tests (debug-x64) with Clang - run: python3 make.py -ci -compiler vs2019-clang -config Debug -cpu x64 -unit_test - - name: Clean - run: python3 make.py -clean_only - - name: Building (release-x64) with Clang - run: python3 make.py -ci -compiler vs2019-clang -config Release -cpu x64 -build - - name: Running unit tests (release-x64) with Clang - run: python3 make.py -ci -compiler vs2019-clang -config Release -cpu x64 -unit_test - vs2022: runs-on: windows-2022 steps: From 823c4fe9c6817ccebc74a482b6c67600e4295718 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 15 Aug 2025 21:17:37 -0400 Subject: [PATCH 276/285] chore(ci): update XCode versions --- tools/setup_osx_compiler.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tools/setup_osx_compiler.sh b/tools/setup_osx_compiler.sh index 0c4cef9..f611e4e 100755 --- a/tools/setup_osx_compiler.sh +++ b/tools/setup_osx_compiler.sh @@ -5,7 +5,7 @@ COMPILER=$1 # See Github hosted runners: # macos-14: https://github.com/actions/runner-images/blob/main/images/macos/macos-14-arm64-Readme.md -# xcode 14.3.1, 15.0.1, 15.1, 15.2, 15.3, 15.4, 16.0 +# xcode 15.0.1, 15.1, 15.2, 15.3, 15.4, 16.1, 16.2 # macos-13: https://github.com/actions/runner-images/blob/main/images/macos/macos-13-Readme.md # xcode 14.1, 14.2, 14.3.1, 15.0.1, 15.1, 15.2 # macos-12: https://github.com/actions/runner-images/blob/main/images/macos/macos-12-Readme.md @@ -28,9 +28,9 @@ elif [[ $COMPILER == xcode13 ]]; then elif [[ $COMPILER == xcode14 ]]; then XCODE_PATH="/Applications/Xcode_14.3.1.app" elif [[ $COMPILER == xcode15 ]]; then - XCODE_PATH="/Applications/Xcode_15.2.app" + XCODE_PATH="/Applications/Xcode_15.4.app" elif [[ $COMPILER == xcode16 ]]; then - XCODE_PATH="/Applications/Xcode_16.0.app" + XCODE_PATH="/Applications/Xcode_16.2.app" fi # Select our XCode version From fba03ca969f303bed1dc4de586130a772d721605 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 15 Aug 2025 21:18:09 -0400 Subject: [PATCH 277/285] chore(ci): add XCode 16 --- .github/workflows/build_pull_request.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml index 320067a..8a38184 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build_pull_request.yml @@ -67,7 +67,7 @@ jobs: runs-on: macos-14 strategy: matrix: - compiler: [xcode15] + compiler: [xcode15, xcode16] steps: - name: Git checkout uses: actions/checkout@v4 From 8f45cbbc55a384ee22fafeb32d9fc04fc44d39c4 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 18 Aug 2025 20:14:38 -0400 Subject: [PATCH 278/285] docs: update readme section of supported platforms --- README.md | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 38b13b5..b672692 100644 --- a/README.md +++ b/README.md @@ -36,18 +36,15 @@ Unicode formats other than UTF-8 aren't supported. ## Supported platforms -* Windows VS2015 x86 and x64 -* Windows (VS2017 to VS2022) x86, x64, and ARM64 -* Windows (VS2017 to VS2022) with clang x86 and x64 -* Linux (gcc 5 to 13) x86 and x64 -* Linux (clang 4 to 15) x86 and x64 -* OS X (XCode 12.5, 13.2, 14.2) x64 and ARM64 -* Android (NDK 21) ARMv7-A and ARM64 -* iOS (Xcode 10.3, 11.7, 12.5, 13.2, 14.2) ARM64 -* Emscripten (1.39.11) WASM -* MSYS2 x64 - -The above supported platform list is only what is tested every release but if it compiles, it should run just fine. +Continuous integration tests a variety of platforms and configurations but it generally runs as-is anywhere where C++11 (or later) is supported. CI currently tests: + +* Windows VS2022: x86, x64, ARM64 +* Linux GCC 12+: x86, x64 +* Linux Clang 15+: x86, x64 +* OS X XCode 15+: ARM64 +* Emscripten 1.39.11: WASM + +Each releases is also manually tested on iOS and Android. ## External dependencies From dfffb2c4223132f9496fcd536ef0764a0eff6053 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 18 Aug 2025 20:16:19 -0400 Subject: [PATCH 279/285] chore(ci): remove appveyor support Only used to test older toolchains, no longer needed --- README.md | 1 - appveyor.yml | 42 ------------------------------------------ 2 files changed, 43 deletions(-) delete mode 100644 appveyor.yml diff --git a/README.md b/README.md index b672692..ed7d5ea 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,5 @@ [![CLA assistant](https://cla-assistant.io/readme/badge/nfrechette/sjson-cpp)](https://cla-assistant.io/nfrechette/sjson-cpp) [![All Contributors](https://img.shields.io/github/all-contributors/nfrechette/sjson-cpp)](#contributors-) -[![Build status](https://ci.appveyor.com/api/projects/status/oynd3x3d9umjaruf/branch/develop?svg=true)](https://ci.appveyor.com/project/nfrechette/sjson-cpp) [![Build status](https://github.com/nfrechette/sjson-cpp/workflows/build/badge.svg)](https://github.com/nfrechette/sjson-cpp/actions) [![Sonar Status](https://sonarcloud.io/api/project_badges/measure?project=nfrechette_sjson-cpp&metric=alert_status)](https://sonarcloud.io/dashboard?id=nfrechette_sjson-cpp) [![GitHub (pre-)release](https://img.shields.io/github/release/nfrechette/sjson-cpp/all.svg)](https://github.com/nfrechette/sjson-cpp/releases) diff --git a/appveyor.yml b/appveyor.yml deleted file mode 100644 index 1ecd502..0000000 --- a/appveyor.yml +++ /dev/null @@ -1,42 +0,0 @@ -version: 0.9.99.{build} - -environment: - PYTHON: "C:\\Python36-x64\\python.exe" - matrix: - - toolchain: msvc - - toolchain: clang - -image: - - Visual Studio 2015 - - Visual Studio 2017 - -configuration: - - Debug - - Release - -platform: - - x86 - - x64 - - arm64 - -matrix: - exclude: - - image: Visual Studio 2015 - platform: arm64 - - image: Visual Studio 2015 - toolchain: clang - - image: Visual Studio 2017 - toolchain: clang - - -init: -# Only run latest compiler on push, run everything on pull request -- ps: if (!$env:APPVEYOR_PULL_REQUEST_NUMBER -and $env:APPVEYOR_BUILD_WORKER_IMAGE -ne "Visual Studio 2019") {Exit-AppveyorBuild} - -install: -- cmd: >- - git submodule update --init --recursive - -build_script: -- cmd: >- - .\tools\appveyor_ci.bat "%APPVEYOR_BUILD_WORKER_IMAGE%" %platform% %configuration% %toolchain% "%PYTHON%" From 771096001410882097881d565b533e6befa900a0 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 8 Sep 2025 21:39:42 -0400 Subject: [PATCH 280/285] feat: add support for ARM64EC with MSVC --- make.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/make.py b/make.py index 7d9bceb..2ef6730 100644 --- a/make.py +++ b/make.py @@ -18,7 +18,7 @@ def parse_argv(): target = parser.add_argument_group(title='Target') target.add_argument('-compiler', choices=['vs2015', 'vs2017', 'vs2019', 'vs2019-clang', 'vs2022', 'vs2022-clang', 'android', 'clang4', 'clang5', 'clang6', 'clang7', 'clang8', 'clang9', 'clang10', 'clang11', 'clang12', 'clang13', 'clang14', 'clang15', 'clang16', 'clang17', 'clang18', 'gcc4.8', 'gcc4.9', 'gcc5', 'gcc6', 'gcc7', 'gcc8', 'gcc9', 'gcc10', 'gcc11', 'gcc12', 'gcc13', 'osx', 'ios', 'emscripten'], help='Defaults to the host system\'s default compiler') target.add_argument('-config', choices=['Debug', 'Release'], type=str.capitalize) - target.add_argument('-cpu', choices=['x86', 'x64', 'armv7', 'arm64', 'wasm'], help='Defaults to the host system\'s architecture') + target.add_argument('-cpu', choices=['x86', 'x64', 'armv7', 'arm64', 'arm64ec', 'wasm'], help='Defaults to the host system\'s architecture') target.add_argument('-cpp_version', choices=['11', '14', '17', '20'], help='Defaults to C++11') misc = parser.add_argument_group(title='Miscellaneous') @@ -100,7 +100,11 @@ def parse_argv(): is_arm_supported = True if not is_arm_supported: - print('arm64 is only supported with VS2017, VS2019, OS X (M1 processors), Linux, Android, and iOS') + print('arm64 is only supported with VS2017, VS2019, VS2022, OS X (M* processors), Linux, Android, and iOS') + sys.exit(1) + elif args.cpu == 'arm64ec': + if not args.compiler in ['vs2019', 'vs2022']: + print('arm64ec is only supported with VS2019 and VS2022') sys.exit(1) elif args.cpu == 'armv7': if not args.compiler == 'android': From 17db0166b1f519d94a18a7dc70f3cf587b0ba72e Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Mon, 8 Sep 2025 21:57:48 -0400 Subject: [PATCH 281/285] docs: update supported platform list --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index ed7d5ea..f14a8f2 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Unicode formats other than UTF-8 aren't supported. Continuous integration tests a variety of platforms and configurations but it generally runs as-is anywhere where C++11 (or later) is supported. CI currently tests: -* Windows VS2022: x86, x64, ARM64 +* Windows VS2022: x86, x64, ARM64, ARM64EC * Linux GCC 12+: x86, x64 * Linux Clang 15+: x86, x64 * OS X XCode 15+: ARM64 From 2030a8f5ae436524633f45e7235d26d03c844bf2 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Wed, 10 Sep 2025 21:25:19 -0400 Subject: [PATCH 282/285] chore(ci): add arm64ec to push CI --- .github/workflows/build_push.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/build_push.yml b/.github/workflows/build_push.yml index 95ed0e6..2ff50ed 100644 --- a/.github/workflows/build_push.yml +++ b/.github/workflows/build_push.yml @@ -149,6 +149,14 @@ jobs: run: python3 make.py -ci -compiler vs2022 -config Release -cpu arm64 -build - name: Clean run: python3 make.py -clean_only + - name: Building (debug-arm64ec) + run: python3 make.py -ci -compiler vs2022 -config Debug -cpu arm64ec -build + - name: Clean + run: python3 make.py -clean_only + - name: Building (release-arm64ec) + run: python3 make.py -ci -compiler vs2022 -config Release -cpu arm64ec -build + - name: Clean + run: python3 make.py -clean_only - name: Building (debug-x64) with Clang run: python3 make.py -ci -compiler vs2022-clang -config Debug -cpu x64 -build - name: Running unit tests (debug-x64) with Clang From 9a19d1aaa6b033327d22d88a13f86d1a8779223e Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 12 Sep 2025 21:09:00 -0400 Subject: [PATCH 283/285] fix(ci): skip unit test detection when cross-compiling --- CMakeLists.txt | 1 + make.py | 8 ++++++++ tests/main_generic/CMakeLists.txt | 11 +++++++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a12fa75..093bca7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,6 +8,7 @@ include(CMakeCompiler) include(CMakePlatforms) set(CPU_INSTRUCTION_SET false CACHE STRING "CPU instruction set") +set(IS_CROSS_COMPILING false CACHE BOOL "Whether we are cross-compiling or not") if(CMAKE_CONFIGURATION_TYPES) set(CMAKE_CONFIGURATION_TYPES Debug Release) diff --git a/make.py b/make.py index 2ef6730..cb496bf 100644 --- a/make.py +++ b/make.py @@ -292,6 +292,10 @@ def do_generate_solution(build_dir, cmake_script_dir, args): cpu = args.cpu config = args.config + is_arm64_cpu = False + if platform.machine() == 'arm64' or platform.machine() == 'aarch64': + is_arm64_cpu = True + if compiler: set_compiler_env(compiler, args) @@ -299,6 +303,10 @@ def do_generate_solution(build_dir, cmake_script_dir, args): extra_switches.append('-DCPU_INSTRUCTION_SET:STRING={}'.format(cpu)) extra_switches.append('-DCMAKE_CXX_STANDARD:STRING={}'.format(args.cpp_version)) + if platform.system() == 'Windows' and not is_arm64_cpu: + if cpu == 'arm64' or cpu == 'arm64ec': + extra_switches.append('-DIS_CROSS_COMPILING:BOOL=true') + if platform.system() == 'Windows': if os.path.sep == '\\': # Native Windows diff --git a/tests/main_generic/CMakeLists.txt b/tests/main_generic/CMakeLists.txt index 0cc0c71..5000896 100644 --- a/tests/main_generic/CMakeLists.txt +++ b/tests/main_generic/CMakeLists.txt @@ -19,10 +19,13 @@ create_source_groups("${ALL_MAIN_SOURCE_FILES}" ${PROJECT_SOURCE_DIR}) add_executable(${PROJECT_NAME} ${ALL_TEST_SOURCE_FILES} ${ALL_MAIN_SOURCE_FILES}) -list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/../../external/catch2/contrib") -include(CTest) -include(Catch) -catch_discover_tests(${PROJECT_NAME}) +if(NOT IS_CROSS_COMPILING) + # Don't attempt to detect unit tests if we are cross-compiling + list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/../../external/catch2/contrib") + include(CTest) + include(Catch) + catch_discover_tests(${PROJECT_NAME}) +endif() setup_default_compiler_flags(${PROJECT_NAME}) From 34f50563ed5b5e8a475bb0d46b3b88e74d12cbe0 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 12 Sep 2025 21:12:50 -0400 Subject: [PATCH 284/285] chore(ci): add arm64ec to pull request CI --- .github/workflows/build_pull_request.yml | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/.github/workflows/build_pull_request.yml b/.github/workflows/build_pull_request.yml index 8a38184..17cf981 100644 --- a/.github/workflows/build_pull_request.yml +++ b/.github/workflows/build_pull_request.yml @@ -149,6 +149,14 @@ jobs: run: python3 make.py -ci -compiler vs2022 -config Release -cpu arm64 -build - name: Clean run: python3 make.py -clean_only + - name: Building (debug-arm64) + run: python3 make.py -ci -compiler vs2022 -config Debug -cpu arm64ec -build + - name: Clean + run: python3 make.py -clean_only + - name: Building (release-arm64) + run: python3 make.py -ci -compiler vs2022 -config Release -cpu arm64ec -build + - name: Clean + run: python3 make.py -clean_only - name: Building (debug-x64) with Clang run: python3 make.py -ci -compiler vs2022-clang -config Debug -cpu x64 -build - name: Running unit tests (debug-x64) with Clang From a9a9e6675cf3c84e9efcf400d1e553e1e487c572 Mon Sep 17 00:00:00 2001 From: Nicholas Frechette Date: Fri, 12 Sep 2025 21:53:41 -0400 Subject: [PATCH 285/285] docs: fix github action build status badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index f14a8f2..16ca01a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ [![CLA assistant](https://cla-assistant.io/readme/badge/nfrechette/sjson-cpp)](https://cla-assistant.io/nfrechette/sjson-cpp) [![All Contributors](https://img.shields.io/github/all-contributors/nfrechette/sjson-cpp)](#contributors-) -[![Build status](https://github.com/nfrechette/sjson-cpp/workflows/build/badge.svg)](https://github.com/nfrechette/sjson-cpp/actions) +[![Build status](https://github.com/nfrechette/sjson-cpp/actions/workflows/build_push.yml/badge.svg)](https://github.com/nfrechette/sjson-cpp/actions/workflows/build_push.yml) [![Sonar Status](https://sonarcloud.io/api/project_badges/measure?project=nfrechette_sjson-cpp&metric=alert_status)](https://sonarcloud.io/dashboard?id=nfrechette_sjson-cpp) [![GitHub (pre-)release](https://img.shields.io/github/release/nfrechette/sjson-cpp/all.svg)](https://github.com/nfrechette/sjson-cpp/releases) [![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/nfrechette/sjson-cpp/master/LICENSE)