From 6a98a6c964068f407e98970f886fe310eb89e8f2 Mon Sep 17 00:00:00 2001 From: Chris Kitching Date: Sun, 8 May 2016 16:30:24 +0100 Subject: [PATCH 1/7] Add CMake option to disable building the tests (Default builds) --- CMakeLists.txt | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4ae1d8bb55..05eda64724 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,8 @@ cmake_minimum_required(VERSION 3.0) # define the project project(json VERSION 2.0.0 LANGUAGES CXX) +option(BuildTests "Build the unit tests" ON) + # define project variables set(JSON_TARGET_NAME ${PROJECT_NAME}) set(JSON_UNITTEST_TARGET_NAME "json_unit") @@ -20,15 +22,19 @@ target_include_directories(${JSON_TARGET_NAME} INTERFACE $) # create and configure the unit test target -add_executable(${JSON_UNITTEST_TARGET_NAME} - "test/catch.hpp" "test/unit.cpp") -set_target_properties(${JSON_UNITTEST_TARGET_NAME} PROPERTIES - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED ON - COMPILE_DEFINITIONS "$<$:_SCL_SECURE_NO_WARNINGS>" - COMPILE_OPTIONS "$<$:/EHsc;$<$:/Od>>") -target_include_directories(${JSON_UNITTEST_TARGET_NAME} PRIVATE "test") -target_link_libraries(${JSON_UNITTEST_TARGET_NAME} ${JSON_TARGET_NAME}) +if (BuildTests) + add_executable(${JSON_UNITTEST_TARGET_NAME} + "test/catch.hpp" + "test/unit.cpp" + ) + set_target_properties(${JSON_UNITTEST_TARGET_NAME} PROPERTIES + CXX_STANDARD 11 + CXX_STANDARD_REQUIRED ON + COMPILE_DEFINITIONS "$<$:_SCL_SECURE_NO_WARNINGS>" + COMPILE_OPTIONS "$<$:/EHsc;$<$:/Od>>") + target_include_directories(${JSON_UNITTEST_TARGET_NAME} PRIVATE "test") + target_link_libraries(${JSON_UNITTEST_TARGET_NAME} ${JSON_TARGET_NAME}) +endif() # generate a config and config version file for the package include(CMakePackageConfigHelpers) From bf7b6d15c771cd9dedc1ddce2dbc9676d14d85e8 Mon Sep 17 00:00:00 2001 From: Chris Kitching Date: Wed, 11 May 2016 01:10:29 +0100 Subject: [PATCH 2/7] Unset execute bit on sample.json --- test/json_testsuite/sample.json | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100755 => 100644 test/json_testsuite/sample.json diff --git a/test/json_testsuite/sample.json b/test/json_testsuite/sample.json old mode 100755 new mode 100644 From b6becce8fb29f9f3d21dd2edc6c0f21474b619bd Mon Sep 17 00:00:00 2001 From: Chris Kitching Date: Wed, 11 May 2016 01:12:56 +0100 Subject: [PATCH 3/7] Don't use variable for the test target name I'm not sure that using a variable for target names really helps with clarity. Unlike paths, target names aren't really something you change. In a sense, targets are themselves a sort of variable, so having a variable to name a variable seems just a bit gnarly. --- CMakeLists.txt | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 05eda64724..b51f83ab70 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,7 +7,6 @@ option(BuildTests "Build the unit tests" ON) # define project variables set(JSON_TARGET_NAME ${PROJECT_NAME}) -set(JSON_UNITTEST_TARGET_NAME "json_unit") set(JSON_PACKAGE_NAME ${JSON_TARGET_NAME}) set(JSON_TARGETS_FILENAME "${JSON_PACKAGE_NAME}Targets.cmake") set(JSON_CONFIG_FILENAME "${JSON_PACKAGE_NAME}Config.cmake") @@ -23,17 +22,17 @@ target_include_directories(${JSON_TARGET_NAME} INTERFACE # create and configure the unit test target if (BuildTests) - add_executable(${JSON_UNITTEST_TARGET_NAME} + add_executable(json_unit "test/catch.hpp" "test/unit.cpp" ) - set_target_properties(${JSON_UNITTEST_TARGET_NAME} PROPERTIES + set_target_properties(json_unit PROPERTIES CXX_STANDARD 11 CXX_STANDARD_REQUIRED ON COMPILE_DEFINITIONS "$<$:_SCL_SECURE_NO_WARNINGS>" COMPILE_OPTIONS "$<$:/EHsc;$<$:/Od>>") - target_include_directories(${JSON_UNITTEST_TARGET_NAME} PRIVATE "test") - target_link_libraries(${JSON_UNITTEST_TARGET_NAME} ${JSON_TARGET_NAME}) + target_include_directories(json_unit PRIVATE "test") + target_link_libraries(json_unit ${JSON_TARGET_NAME}) endif() # generate a config and config version file for the package From 4e6aacda3625a0212edef4b8eb7e3bbdb8989775 Mon Sep 17 00:00:00 2001 From: Chris Kitching Date: Wed, 11 May 2016 01:14:56 +0100 Subject: [PATCH 4/7] Use definitely-unique target/project name There exist lots of json libraries, and project/target names must be globally unique. If someone integrated with this library in a particularly stupid way, using a generic name like "json" might cause a problem. --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b51f83ab70..caa4a0ee47 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.0) # define the project -project(json VERSION 2.0.0 LANGUAGES CXX) +project(nlohmann_json VERSION 2.0.0 LANGUAGES CXX) option(BuildTests "Build the unit tests" ON) From af76508fe773dba22047d4bc6a31464a00afbb58 Mon Sep 17 00:00:00 2001 From: Chris Kitching Date: Wed, 11 May 2016 01:25:54 +0100 Subject: [PATCH 5/7] Introduce structure to the test/ directory This introduces a clear separation between test data and test binaries. Test data is moved into test/data, and the test binaries move into test/src. A new CMake script specific to building the tests is introduced in /test to slightly clean up the toplevel one. As well as tidying things up, this makes the next step trivial... --- .github/CONTRIBUTING.md | 2 +- .github/PULL_REQUEST_TEMPLATE.md | 2 +- .travis.yml | 2 +- CMakeLists.txt | 12 +- Makefile | 10 +- README.md | 2 +- test/CMakeLists.txt | 15 ++ test/{ => data}/json.org/1.json | 0 test/{ => data}/json.org/2.json | 0 test/{ => data}/json.org/3.json | 0 test/{ => data}/json.org/4.json | 0 test/{ => data}/json.org/5.json | 0 .../json_nlohmann_tests/all_unicode.json | 0 test/{ => data}/json_nlohmann_tests/bom.json | 0 .../json_roundtrip/roundtrip01.json | 0 .../json_roundtrip/roundtrip02.json | 0 .../json_roundtrip/roundtrip03.json | 0 .../json_roundtrip/roundtrip04.json | 0 .../json_roundtrip/roundtrip05.json | 0 .../json_roundtrip/roundtrip06.json | 0 .../json_roundtrip/roundtrip07.json | 0 .../json_roundtrip/roundtrip08.json | 0 .../json_roundtrip/roundtrip09.json | 0 .../json_roundtrip/roundtrip10.json | 0 .../json_roundtrip/roundtrip11.json | 0 .../json_roundtrip/roundtrip12.json | 0 .../json_roundtrip/roundtrip13.json | 0 .../json_roundtrip/roundtrip14.json | 0 .../json_roundtrip/roundtrip15.json | 0 .../json_roundtrip/roundtrip16.json | 0 .../json_roundtrip/roundtrip17.json | 0 .../json_roundtrip/roundtrip18.json | 0 .../json_roundtrip/roundtrip19.json | 0 .../json_roundtrip/roundtrip20.json | 0 .../json_roundtrip/roundtrip21.json | 0 .../json_roundtrip/roundtrip22.json | 0 .../json_roundtrip/roundtrip23.json | 0 .../json_roundtrip/roundtrip24.json | 0 .../json_roundtrip/roundtrip25.json | 0 .../json_roundtrip/roundtrip26.json | 0 .../json_roundtrip/roundtrip27.json | 0 .../json_roundtrip/roundtrip28.json | 0 .../json_roundtrip/roundtrip29.json | 0 .../json_roundtrip/roundtrip30.json | 0 .../json_roundtrip/roundtrip31.json | 0 .../json_roundtrip/roundtrip32.json | 0 test/{ => data}/json_tests/fail1.json | 0 test/{ => data}/json_tests/fail10.json | 0 test/{ => data}/json_tests/fail11.json | 0 test/{ => data}/json_tests/fail12.json | 0 test/{ => data}/json_tests/fail13.json | 0 test/{ => data}/json_tests/fail14.json | 0 test/{ => data}/json_tests/fail15.json | 0 test/{ => data}/json_tests/fail16.json | 0 test/{ => data}/json_tests/fail17.json | 0 test/{ => data}/json_tests/fail18.json | 0 test/{ => data}/json_tests/fail19.json | 0 test/{ => data}/json_tests/fail2.json | 0 test/{ => data}/json_tests/fail20.json | 0 test/{ => data}/json_tests/fail21.json | 0 test/{ => data}/json_tests/fail22.json | 0 test/{ => data}/json_tests/fail23.json | 0 test/{ => data}/json_tests/fail24.json | 0 test/{ => data}/json_tests/fail25.json | 0 test/{ => data}/json_tests/fail26.json | 0 test/{ => data}/json_tests/fail27.json | 0 test/{ => data}/json_tests/fail28.json | 0 test/{ => data}/json_tests/fail29.json | 0 test/{ => data}/json_tests/fail3.json | 0 test/{ => data}/json_tests/fail30.json | 0 test/{ => data}/json_tests/fail31.json | 0 test/{ => data}/json_tests/fail32.json | 0 test/{ => data}/json_tests/fail33.json | 0 test/{ => data}/json_tests/fail4.json | 0 test/{ => data}/json_tests/fail5.json | 0 test/{ => data}/json_tests/fail6.json | 0 test/{ => data}/json_tests/fail7.json | 0 test/{ => data}/json_tests/fail8.json | 0 test/{ => data}/json_tests/fail9.json | 0 test/{ => data}/json_tests/pass1.json | 0 test/{ => data}/json_tests/pass2.json | 0 test/{ => data}/json_tests/pass3.json | 0 test/{ => data}/json_testsuite/README.md | 0 test/{ => data}/json_testsuite/sample.json | 0 test/{ => src}/catch.hpp | 0 test/{ => src}/fuzz.cpp | 0 test/{ => src}/unit.cpp | 156 +++++++++--------- 87 files changed, 103 insertions(+), 98 deletions(-) create mode 100644 test/CMakeLists.txt rename test/{ => data}/json.org/1.json (100%) rename test/{ => data}/json.org/2.json (100%) rename test/{ => data}/json.org/3.json (100%) rename test/{ => data}/json.org/4.json (100%) rename test/{ => data}/json.org/5.json (100%) rename test/{ => data}/json_nlohmann_tests/all_unicode.json (100%) rename test/{ => data}/json_nlohmann_tests/bom.json (100%) rename test/{ => data}/json_roundtrip/roundtrip01.json (100%) rename test/{ => data}/json_roundtrip/roundtrip02.json (100%) rename test/{ => data}/json_roundtrip/roundtrip03.json (100%) rename test/{ => data}/json_roundtrip/roundtrip04.json (100%) rename test/{ => data}/json_roundtrip/roundtrip05.json (100%) rename test/{ => data}/json_roundtrip/roundtrip06.json (100%) rename test/{ => data}/json_roundtrip/roundtrip07.json (100%) rename test/{ => data}/json_roundtrip/roundtrip08.json (100%) rename test/{ => data}/json_roundtrip/roundtrip09.json (100%) rename test/{ => data}/json_roundtrip/roundtrip10.json (100%) rename test/{ => data}/json_roundtrip/roundtrip11.json (100%) rename test/{ => data}/json_roundtrip/roundtrip12.json (100%) rename test/{ => data}/json_roundtrip/roundtrip13.json (100%) rename test/{ => data}/json_roundtrip/roundtrip14.json (100%) rename test/{ => data}/json_roundtrip/roundtrip15.json (100%) rename test/{ => data}/json_roundtrip/roundtrip16.json (100%) rename test/{ => data}/json_roundtrip/roundtrip17.json (100%) rename test/{ => data}/json_roundtrip/roundtrip18.json (100%) rename test/{ => data}/json_roundtrip/roundtrip19.json (100%) rename test/{ => data}/json_roundtrip/roundtrip20.json (100%) rename test/{ => data}/json_roundtrip/roundtrip21.json (100%) rename test/{ => data}/json_roundtrip/roundtrip22.json (100%) rename test/{ => data}/json_roundtrip/roundtrip23.json (100%) rename test/{ => data}/json_roundtrip/roundtrip24.json (100%) rename test/{ => data}/json_roundtrip/roundtrip25.json (100%) rename test/{ => data}/json_roundtrip/roundtrip26.json (100%) rename test/{ => data}/json_roundtrip/roundtrip27.json (100%) rename test/{ => data}/json_roundtrip/roundtrip28.json (100%) rename test/{ => data}/json_roundtrip/roundtrip29.json (100%) rename test/{ => data}/json_roundtrip/roundtrip30.json (100%) rename test/{ => data}/json_roundtrip/roundtrip31.json (100%) rename test/{ => data}/json_roundtrip/roundtrip32.json (100%) rename test/{ => data}/json_tests/fail1.json (100%) rename test/{ => data}/json_tests/fail10.json (100%) rename test/{ => data}/json_tests/fail11.json (100%) rename test/{ => data}/json_tests/fail12.json (100%) rename test/{ => data}/json_tests/fail13.json (100%) rename test/{ => data}/json_tests/fail14.json (100%) rename test/{ => data}/json_tests/fail15.json (100%) rename test/{ => data}/json_tests/fail16.json (100%) rename test/{ => data}/json_tests/fail17.json (100%) rename test/{ => data}/json_tests/fail18.json (100%) rename test/{ => data}/json_tests/fail19.json (100%) rename test/{ => data}/json_tests/fail2.json (100%) rename test/{ => data}/json_tests/fail20.json (100%) rename test/{ => data}/json_tests/fail21.json (100%) rename test/{ => data}/json_tests/fail22.json (100%) rename test/{ => data}/json_tests/fail23.json (100%) rename test/{ => data}/json_tests/fail24.json (100%) rename test/{ => data}/json_tests/fail25.json (100%) rename test/{ => data}/json_tests/fail26.json (100%) rename test/{ => data}/json_tests/fail27.json (100%) rename test/{ => data}/json_tests/fail28.json (100%) rename test/{ => data}/json_tests/fail29.json (100%) rename test/{ => data}/json_tests/fail3.json (100%) rename test/{ => data}/json_tests/fail30.json (100%) rename test/{ => data}/json_tests/fail31.json (100%) rename test/{ => data}/json_tests/fail32.json (100%) rename test/{ => data}/json_tests/fail33.json (100%) rename test/{ => data}/json_tests/fail4.json (100%) rename test/{ => data}/json_tests/fail5.json (100%) rename test/{ => data}/json_tests/fail6.json (100%) rename test/{ => data}/json_tests/fail7.json (100%) rename test/{ => data}/json_tests/fail8.json (100%) rename test/{ => data}/json_tests/fail9.json (100%) rename test/{ => data}/json_tests/pass1.json (100%) rename test/{ => data}/json_tests/pass2.json (100%) rename test/{ => data}/json_tests/pass3.json (100%) rename test/{ => data}/json_testsuite/README.md (100%) rename test/{ => data}/json_testsuite/sample.json (100%) rename test/{ => src}/catch.hpp (100%) rename test/{ => src}/fuzz.cpp (100%) rename test/{ => src}/unit.cpp (99%) diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md index ea57e65055..eba242872c 100644 --- a/.github/CONTRIBUTING.md +++ b/.github/CONTRIBUTING.md @@ -35,7 +35,7 @@ There are currently two files which need to be edited: To run [`re2c`](http://re2c.org) and generate/overwrite file `src/json.hpp` with your changes in file `src/json.hpp.re2c`. -2. [`test/unit.cpp`](https://github.com/nlohmann/json/blob/master/test/unit.cpp) - This contains the [Catch](https://github.com/philsquared/Catch) unit tests which currently cover [100 %](https://coveralls.io/github/nlohmann/json) of the library's code. +2. [`test/src/unit.cpp`](https://github.com/nlohmann/json/blob/master/test/unit.cpp) - This contains the [Catch](https://github.com/philsquared/Catch) unit tests which currently cover [100 %](https://coveralls.io/github/nlohmann/json) of the library's code. If you add or change a feature, please also add a unit test to this file. The unit tests can be compiled with diff --git a/.github/PULL_REQUEST_TEMPLATE.md b/.github/PULL_REQUEST_TEMPLATE.md index 27920581cd..49d1665952 100644 --- a/.github/PULL_REQUEST_TEMPLATE.md +++ b/.github/PULL_REQUEST_TEMPLATE.md @@ -14,7 +14,7 @@ There are currently two files which need to be edited: To run [`re2c`](http://re2c.org) and generate/overwrite file `src/json.hpp` with your changes in file `src/json.hpp.re2c`. -2. [`test/unit.cpp`](https://github.com/nlohmann/json/blob/master/test/unit.cpp) - This contains the [Catch](https://github.com/philsquared/Catch) unit tests which currently cover [100 %](https://coveralls.io/github/nlohmann/json) of the library's code. +2. [`test/src/unit.cpp`](https://github.com/nlohmann/json/blob/master/test/unit.cpp) - This contains the [Catch](https://github.com/philsquared/Catch) unit tests which currently cover [100 %](https://coveralls.io/github/nlohmann/json) of the library's code. If you add or change a feature, please also add a unit test to this file. The unit tests can be compiled with diff --git a/.travis.yml b/.travis.yml index d1748dff57..1ada0084c7 100644 --- a/.travis.yml +++ b/.travis.yml @@ -19,7 +19,7 @@ matrix: - touch src/json.hpp - make json_unit CXXFLAGS="-fprofile-arcs -ftest-coverage -std=c++11 -lstdc++" CXX=$COMPILER - ./json_unit "*" - - coveralls --exclude test/catch.hpp --exclude test/unit.cpp --include src/json.hpp --gcov-options '\-lp' --gcov 'gcov-4.9' + - coveralls --exclude test/src/catch.hpp --exclude test/src/unit.cpp --include src/json.hpp --gcov-options '\-lp' --gcov 'gcov-4.9' env: COMPILER=g++-4.9 - os: linux diff --git a/CMakeLists.txt b/CMakeLists.txt index caa4a0ee47..18e9c651fa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,17 +22,7 @@ target_include_directories(${JSON_TARGET_NAME} INTERFACE # create and configure the unit test target if (BuildTests) - add_executable(json_unit - "test/catch.hpp" - "test/unit.cpp" - ) - set_target_properties(json_unit PROPERTIES - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED ON - COMPILE_DEFINITIONS "$<$:_SCL_SECURE_NO_WARNINGS>" - COMPILE_OPTIONS "$<$:/EHsc;$<$:/Od>>") - target_include_directories(json_unit PRIVATE "test") - target_link_libraries(json_unit ${JSON_TARGET_NAME}) + add_subdirectory(test) endif() # generate a config and config version file for the package diff --git a/Makefile b/Makefile index d0a80379ca..6fdc06b9df 100644 --- a/Makefile +++ b/Makefile @@ -19,8 +19,8 @@ clean: # additional flags FLAGS = -Wall -Wextra -pedantic -Weffc++ -Wcast-align -Wcast-qual -Wctor-dtor-privacy -Wdisabled-optimization -Wformat=2 -Winit-self -Wmissing-declarations -Wmissing-include-dirs -Wold-style-cast -Woverloaded-virtual -Wredundant-decls -Wshadow -Wsign-conversion -Wsign-promo -Wstrict-overflow=5 -Wswitch -Wundef -Wno-unused -Wnon-virtual-dtor -Wreorder -Wdeprecated -Wfloat-equal -# build unit tests -json_unit: test/unit.cpp src/json.hpp test/catch.hpp +# build unit tests (TODO: Does this want its own makefile?) +json_unit: test/src/unit.cpp src/json.hpp test/src/catch.hpp $(CXX) -std=c++11 $(CXXFLAGS) $(FLAGS) $(CPPFLAGS) -I src -I test $< $(LDFLAGS) -o $@ @@ -43,11 +43,11 @@ fuzz_testing: mkdir -p fuzz-testing fuzz-testing/testcases fuzz-testing/out $(MAKE) fuzz CXX=afl-clang++ mv fuzz fuzz-testing - find test/json_tests -size -5k -name *json | xargs -I{} cp "{}" fuzz-testing/testcases + find test/data/json_tests -size -5k -name *json | xargs -I{} cp "{}" fuzz-testing/testcases @echo "Execute: afl-fuzz -i fuzz-testing/testcases -o fuzz-testing/out fuzz-testing/fuzz" # the fuzzer binary -fuzz: test/fuzz.cpp src/json.hpp +fuzz: test/src/fuzz.cpp src/json.hpp $(CXX) -std=c++11 $(CXXFLAGS) $(FLAGS) $(CPPFLAGS) -I src $< $(LDFLAGS) -o $@ @@ -75,7 +75,7 @@ pretty: --indent-col1-comments --pad-oper --pad-header --align-pointer=type \ --align-reference=type --add-brackets --convert-tabs --close-templates \ --lineend=linux --preserve-date --suffix=none --formatted \ - src/json.hpp src/json.hpp.re2c test/unit.cpp test/fuzz.cpp benchmarks/benchmarks.cpp doc/examples/*.cpp + src/json.hpp src/json.hpp.re2c test/src/unit.cpp test/src/fuzz.cpp benchmarks/benchmarks.cpp doc/examples/*.cpp ########################################################################## diff --git a/README.md b/README.md index c9f3a713a6..46ede2495d 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ There are myriads of [JSON](http://json.org) libraries out there, and each may e - **Trivial integration**. Our whole code consists of a single header file `json.hpp`. That's it. No library, no subproject, no dependencies, no complex build system. The class is written in vanilla C++11. All in all, everything should require no adjustment of your compiler flags or project settings. -- **Serious testing**. Our class is heavily [unit-tested](https://github.com/nlohmann/json/blob/master/test/unit.cpp) and covers [100%](https://coveralls.io/r/nlohmann/json) of the code, including all exceptional behavior. Furthermore, we checked with [Valgrind](http://valgrind.org) that there are no memory leaks. +- **Serious testing**. Our class is heavily [unit-tested](https://github.com/nlohmann/json/blob/master/test/src/unit.cpp) and covers [100%](https://coveralls.io/r/nlohmann/json) of the code, including all exceptional behavior. Furthermore, we checked with [Valgrind](http://valgrind.org) that there are no memory leaks. Other aspects were not so important to us: diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100644 index 0000000000..0039fd84cb --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,15 @@ +# The unit test executable. +add_executable(json_unit + "src/catch.hpp" + "src/unit.cpp" +) + +set_target_properties(json_unit PROPERTIES + CXX_STANDARD 11 + CXX_STANDARD_REQUIRED ON + COMPILE_DEFINITIONS "$<$:_SCL_SECURE_NO_WARNINGS>" + COMPILE_OPTIONS "$<$:/EHsc;$<$:/Od>>" +) + +target_include_directories(json_unit PRIVATE "src") +target_link_libraries(json_unit ${JSON_TARGET_NAME}) diff --git a/test/json.org/1.json b/test/data/json.org/1.json similarity index 100% rename from test/json.org/1.json rename to test/data/json.org/1.json diff --git a/test/json.org/2.json b/test/data/json.org/2.json similarity index 100% rename from test/json.org/2.json rename to test/data/json.org/2.json diff --git a/test/json.org/3.json b/test/data/json.org/3.json similarity index 100% rename from test/json.org/3.json rename to test/data/json.org/3.json diff --git a/test/json.org/4.json b/test/data/json.org/4.json similarity index 100% rename from test/json.org/4.json rename to test/data/json.org/4.json diff --git a/test/json.org/5.json b/test/data/json.org/5.json similarity index 100% rename from test/json.org/5.json rename to test/data/json.org/5.json diff --git a/test/json_nlohmann_tests/all_unicode.json b/test/data/json_nlohmann_tests/all_unicode.json similarity index 100% rename from test/json_nlohmann_tests/all_unicode.json rename to test/data/json_nlohmann_tests/all_unicode.json diff --git a/test/json_nlohmann_tests/bom.json b/test/data/json_nlohmann_tests/bom.json similarity index 100% rename from test/json_nlohmann_tests/bom.json rename to test/data/json_nlohmann_tests/bom.json diff --git a/test/json_roundtrip/roundtrip01.json b/test/data/json_roundtrip/roundtrip01.json similarity index 100% rename from test/json_roundtrip/roundtrip01.json rename to test/data/json_roundtrip/roundtrip01.json diff --git a/test/json_roundtrip/roundtrip02.json b/test/data/json_roundtrip/roundtrip02.json similarity index 100% rename from test/json_roundtrip/roundtrip02.json rename to test/data/json_roundtrip/roundtrip02.json diff --git a/test/json_roundtrip/roundtrip03.json b/test/data/json_roundtrip/roundtrip03.json similarity index 100% rename from test/json_roundtrip/roundtrip03.json rename to test/data/json_roundtrip/roundtrip03.json diff --git a/test/json_roundtrip/roundtrip04.json b/test/data/json_roundtrip/roundtrip04.json similarity index 100% rename from test/json_roundtrip/roundtrip04.json rename to test/data/json_roundtrip/roundtrip04.json diff --git a/test/json_roundtrip/roundtrip05.json b/test/data/json_roundtrip/roundtrip05.json similarity index 100% rename from test/json_roundtrip/roundtrip05.json rename to test/data/json_roundtrip/roundtrip05.json diff --git a/test/json_roundtrip/roundtrip06.json b/test/data/json_roundtrip/roundtrip06.json similarity index 100% rename from test/json_roundtrip/roundtrip06.json rename to test/data/json_roundtrip/roundtrip06.json diff --git a/test/json_roundtrip/roundtrip07.json b/test/data/json_roundtrip/roundtrip07.json similarity index 100% rename from test/json_roundtrip/roundtrip07.json rename to test/data/json_roundtrip/roundtrip07.json diff --git a/test/json_roundtrip/roundtrip08.json b/test/data/json_roundtrip/roundtrip08.json similarity index 100% rename from test/json_roundtrip/roundtrip08.json rename to test/data/json_roundtrip/roundtrip08.json diff --git a/test/json_roundtrip/roundtrip09.json b/test/data/json_roundtrip/roundtrip09.json similarity index 100% rename from test/json_roundtrip/roundtrip09.json rename to test/data/json_roundtrip/roundtrip09.json diff --git a/test/json_roundtrip/roundtrip10.json b/test/data/json_roundtrip/roundtrip10.json similarity index 100% rename from test/json_roundtrip/roundtrip10.json rename to test/data/json_roundtrip/roundtrip10.json diff --git a/test/json_roundtrip/roundtrip11.json b/test/data/json_roundtrip/roundtrip11.json similarity index 100% rename from test/json_roundtrip/roundtrip11.json rename to test/data/json_roundtrip/roundtrip11.json diff --git a/test/json_roundtrip/roundtrip12.json b/test/data/json_roundtrip/roundtrip12.json similarity index 100% rename from test/json_roundtrip/roundtrip12.json rename to test/data/json_roundtrip/roundtrip12.json diff --git a/test/json_roundtrip/roundtrip13.json b/test/data/json_roundtrip/roundtrip13.json similarity index 100% rename from test/json_roundtrip/roundtrip13.json rename to test/data/json_roundtrip/roundtrip13.json diff --git a/test/json_roundtrip/roundtrip14.json b/test/data/json_roundtrip/roundtrip14.json similarity index 100% rename from test/json_roundtrip/roundtrip14.json rename to test/data/json_roundtrip/roundtrip14.json diff --git a/test/json_roundtrip/roundtrip15.json b/test/data/json_roundtrip/roundtrip15.json similarity index 100% rename from test/json_roundtrip/roundtrip15.json rename to test/data/json_roundtrip/roundtrip15.json diff --git a/test/json_roundtrip/roundtrip16.json b/test/data/json_roundtrip/roundtrip16.json similarity index 100% rename from test/json_roundtrip/roundtrip16.json rename to test/data/json_roundtrip/roundtrip16.json diff --git a/test/json_roundtrip/roundtrip17.json b/test/data/json_roundtrip/roundtrip17.json similarity index 100% rename from test/json_roundtrip/roundtrip17.json rename to test/data/json_roundtrip/roundtrip17.json diff --git a/test/json_roundtrip/roundtrip18.json b/test/data/json_roundtrip/roundtrip18.json similarity index 100% rename from test/json_roundtrip/roundtrip18.json rename to test/data/json_roundtrip/roundtrip18.json diff --git a/test/json_roundtrip/roundtrip19.json b/test/data/json_roundtrip/roundtrip19.json similarity index 100% rename from test/json_roundtrip/roundtrip19.json rename to test/data/json_roundtrip/roundtrip19.json diff --git a/test/json_roundtrip/roundtrip20.json b/test/data/json_roundtrip/roundtrip20.json similarity index 100% rename from test/json_roundtrip/roundtrip20.json rename to test/data/json_roundtrip/roundtrip20.json diff --git a/test/json_roundtrip/roundtrip21.json b/test/data/json_roundtrip/roundtrip21.json similarity index 100% rename from test/json_roundtrip/roundtrip21.json rename to test/data/json_roundtrip/roundtrip21.json diff --git a/test/json_roundtrip/roundtrip22.json b/test/data/json_roundtrip/roundtrip22.json similarity index 100% rename from test/json_roundtrip/roundtrip22.json rename to test/data/json_roundtrip/roundtrip22.json diff --git a/test/json_roundtrip/roundtrip23.json b/test/data/json_roundtrip/roundtrip23.json similarity index 100% rename from test/json_roundtrip/roundtrip23.json rename to test/data/json_roundtrip/roundtrip23.json diff --git a/test/json_roundtrip/roundtrip24.json b/test/data/json_roundtrip/roundtrip24.json similarity index 100% rename from test/json_roundtrip/roundtrip24.json rename to test/data/json_roundtrip/roundtrip24.json diff --git a/test/json_roundtrip/roundtrip25.json b/test/data/json_roundtrip/roundtrip25.json similarity index 100% rename from test/json_roundtrip/roundtrip25.json rename to test/data/json_roundtrip/roundtrip25.json diff --git a/test/json_roundtrip/roundtrip26.json b/test/data/json_roundtrip/roundtrip26.json similarity index 100% rename from test/json_roundtrip/roundtrip26.json rename to test/data/json_roundtrip/roundtrip26.json diff --git a/test/json_roundtrip/roundtrip27.json b/test/data/json_roundtrip/roundtrip27.json similarity index 100% rename from test/json_roundtrip/roundtrip27.json rename to test/data/json_roundtrip/roundtrip27.json diff --git a/test/json_roundtrip/roundtrip28.json b/test/data/json_roundtrip/roundtrip28.json similarity index 100% rename from test/json_roundtrip/roundtrip28.json rename to test/data/json_roundtrip/roundtrip28.json diff --git a/test/json_roundtrip/roundtrip29.json b/test/data/json_roundtrip/roundtrip29.json similarity index 100% rename from test/json_roundtrip/roundtrip29.json rename to test/data/json_roundtrip/roundtrip29.json diff --git a/test/json_roundtrip/roundtrip30.json b/test/data/json_roundtrip/roundtrip30.json similarity index 100% rename from test/json_roundtrip/roundtrip30.json rename to test/data/json_roundtrip/roundtrip30.json diff --git a/test/json_roundtrip/roundtrip31.json b/test/data/json_roundtrip/roundtrip31.json similarity index 100% rename from test/json_roundtrip/roundtrip31.json rename to test/data/json_roundtrip/roundtrip31.json diff --git a/test/json_roundtrip/roundtrip32.json b/test/data/json_roundtrip/roundtrip32.json similarity index 100% rename from test/json_roundtrip/roundtrip32.json rename to test/data/json_roundtrip/roundtrip32.json diff --git a/test/json_tests/fail1.json b/test/data/json_tests/fail1.json similarity index 100% rename from test/json_tests/fail1.json rename to test/data/json_tests/fail1.json diff --git a/test/json_tests/fail10.json b/test/data/json_tests/fail10.json similarity index 100% rename from test/json_tests/fail10.json rename to test/data/json_tests/fail10.json diff --git a/test/json_tests/fail11.json b/test/data/json_tests/fail11.json similarity index 100% rename from test/json_tests/fail11.json rename to test/data/json_tests/fail11.json diff --git a/test/json_tests/fail12.json b/test/data/json_tests/fail12.json similarity index 100% rename from test/json_tests/fail12.json rename to test/data/json_tests/fail12.json diff --git a/test/json_tests/fail13.json b/test/data/json_tests/fail13.json similarity index 100% rename from test/json_tests/fail13.json rename to test/data/json_tests/fail13.json diff --git a/test/json_tests/fail14.json b/test/data/json_tests/fail14.json similarity index 100% rename from test/json_tests/fail14.json rename to test/data/json_tests/fail14.json diff --git a/test/json_tests/fail15.json b/test/data/json_tests/fail15.json similarity index 100% rename from test/json_tests/fail15.json rename to test/data/json_tests/fail15.json diff --git a/test/json_tests/fail16.json b/test/data/json_tests/fail16.json similarity index 100% rename from test/json_tests/fail16.json rename to test/data/json_tests/fail16.json diff --git a/test/json_tests/fail17.json b/test/data/json_tests/fail17.json similarity index 100% rename from test/json_tests/fail17.json rename to test/data/json_tests/fail17.json diff --git a/test/json_tests/fail18.json b/test/data/json_tests/fail18.json similarity index 100% rename from test/json_tests/fail18.json rename to test/data/json_tests/fail18.json diff --git a/test/json_tests/fail19.json b/test/data/json_tests/fail19.json similarity index 100% rename from test/json_tests/fail19.json rename to test/data/json_tests/fail19.json diff --git a/test/json_tests/fail2.json b/test/data/json_tests/fail2.json similarity index 100% rename from test/json_tests/fail2.json rename to test/data/json_tests/fail2.json diff --git a/test/json_tests/fail20.json b/test/data/json_tests/fail20.json similarity index 100% rename from test/json_tests/fail20.json rename to test/data/json_tests/fail20.json diff --git a/test/json_tests/fail21.json b/test/data/json_tests/fail21.json similarity index 100% rename from test/json_tests/fail21.json rename to test/data/json_tests/fail21.json diff --git a/test/json_tests/fail22.json b/test/data/json_tests/fail22.json similarity index 100% rename from test/json_tests/fail22.json rename to test/data/json_tests/fail22.json diff --git a/test/json_tests/fail23.json b/test/data/json_tests/fail23.json similarity index 100% rename from test/json_tests/fail23.json rename to test/data/json_tests/fail23.json diff --git a/test/json_tests/fail24.json b/test/data/json_tests/fail24.json similarity index 100% rename from test/json_tests/fail24.json rename to test/data/json_tests/fail24.json diff --git a/test/json_tests/fail25.json b/test/data/json_tests/fail25.json similarity index 100% rename from test/json_tests/fail25.json rename to test/data/json_tests/fail25.json diff --git a/test/json_tests/fail26.json b/test/data/json_tests/fail26.json similarity index 100% rename from test/json_tests/fail26.json rename to test/data/json_tests/fail26.json diff --git a/test/json_tests/fail27.json b/test/data/json_tests/fail27.json similarity index 100% rename from test/json_tests/fail27.json rename to test/data/json_tests/fail27.json diff --git a/test/json_tests/fail28.json b/test/data/json_tests/fail28.json similarity index 100% rename from test/json_tests/fail28.json rename to test/data/json_tests/fail28.json diff --git a/test/json_tests/fail29.json b/test/data/json_tests/fail29.json similarity index 100% rename from test/json_tests/fail29.json rename to test/data/json_tests/fail29.json diff --git a/test/json_tests/fail3.json b/test/data/json_tests/fail3.json similarity index 100% rename from test/json_tests/fail3.json rename to test/data/json_tests/fail3.json diff --git a/test/json_tests/fail30.json b/test/data/json_tests/fail30.json similarity index 100% rename from test/json_tests/fail30.json rename to test/data/json_tests/fail30.json diff --git a/test/json_tests/fail31.json b/test/data/json_tests/fail31.json similarity index 100% rename from test/json_tests/fail31.json rename to test/data/json_tests/fail31.json diff --git a/test/json_tests/fail32.json b/test/data/json_tests/fail32.json similarity index 100% rename from test/json_tests/fail32.json rename to test/data/json_tests/fail32.json diff --git a/test/json_tests/fail33.json b/test/data/json_tests/fail33.json similarity index 100% rename from test/json_tests/fail33.json rename to test/data/json_tests/fail33.json diff --git a/test/json_tests/fail4.json b/test/data/json_tests/fail4.json similarity index 100% rename from test/json_tests/fail4.json rename to test/data/json_tests/fail4.json diff --git a/test/json_tests/fail5.json b/test/data/json_tests/fail5.json similarity index 100% rename from test/json_tests/fail5.json rename to test/data/json_tests/fail5.json diff --git a/test/json_tests/fail6.json b/test/data/json_tests/fail6.json similarity index 100% rename from test/json_tests/fail6.json rename to test/data/json_tests/fail6.json diff --git a/test/json_tests/fail7.json b/test/data/json_tests/fail7.json similarity index 100% rename from test/json_tests/fail7.json rename to test/data/json_tests/fail7.json diff --git a/test/json_tests/fail8.json b/test/data/json_tests/fail8.json similarity index 100% rename from test/json_tests/fail8.json rename to test/data/json_tests/fail8.json diff --git a/test/json_tests/fail9.json b/test/data/json_tests/fail9.json similarity index 100% rename from test/json_tests/fail9.json rename to test/data/json_tests/fail9.json diff --git a/test/json_tests/pass1.json b/test/data/json_tests/pass1.json similarity index 100% rename from test/json_tests/pass1.json rename to test/data/json_tests/pass1.json diff --git a/test/json_tests/pass2.json b/test/data/json_tests/pass2.json similarity index 100% rename from test/json_tests/pass2.json rename to test/data/json_tests/pass2.json diff --git a/test/json_tests/pass3.json b/test/data/json_tests/pass3.json similarity index 100% rename from test/json_tests/pass3.json rename to test/data/json_tests/pass3.json diff --git a/test/json_testsuite/README.md b/test/data/json_testsuite/README.md similarity index 100% rename from test/json_testsuite/README.md rename to test/data/json_testsuite/README.md diff --git a/test/json_testsuite/sample.json b/test/data/json_testsuite/sample.json similarity index 100% rename from test/json_testsuite/sample.json rename to test/data/json_testsuite/sample.json diff --git a/test/catch.hpp b/test/src/catch.hpp similarity index 100% rename from test/catch.hpp rename to test/src/catch.hpp diff --git a/test/fuzz.cpp b/test/src/fuzz.cpp similarity index 100% rename from test/fuzz.cpp rename to test/src/fuzz.cpp diff --git a/test/unit.cpp b/test/src/unit.cpp similarity index 99% rename from test/unit.cpp rename to test/src/unit.cpp index e42430c35e..0a2bdd104e 100644 --- a/test/unit.cpp +++ b/test/src/unit.cpp @@ -1314,7 +1314,7 @@ TEST_CASE("constructors") SECTION("std::ifstream") { - std::ifstream f("test/json_tests/pass1.json"); + std::ifstream f("test/data/json_tests/pass1.json"); json j(f); } } @@ -11652,39 +11652,39 @@ TEST_CASE("compliance tests from json.org") { for (auto filename : { - //"test/json_tests/fail1.json", - "test/json_tests/fail2.json", - "test/json_tests/fail3.json", - "test/json_tests/fail4.json", - "test/json_tests/fail5.json", - "test/json_tests/fail6.json", - "test/json_tests/fail7.json", - "test/json_tests/fail8.json", - "test/json_tests/fail9.json", - "test/json_tests/fail10.json", - "test/json_tests/fail11.json", - "test/json_tests/fail12.json", - "test/json_tests/fail13.json", - "test/json_tests/fail14.json", - "test/json_tests/fail15.json", - "test/json_tests/fail16.json", - "test/json_tests/fail17.json", - //"test/json_tests/fail18.json", - "test/json_tests/fail19.json", - "test/json_tests/fail20.json", - "test/json_tests/fail21.json", - "test/json_tests/fail22.json", - "test/json_tests/fail23.json", - "test/json_tests/fail24.json", - "test/json_tests/fail25.json", - "test/json_tests/fail26.json", - "test/json_tests/fail27.json", - "test/json_tests/fail28.json", - "test/json_tests/fail29.json", - "test/json_tests/fail30.json", - "test/json_tests/fail31.json", - "test/json_tests/fail32.json", - "test/json_tests/fail33.json" + //"test/data/json_tests/fail1.json", + "test/data/json_tests/fail2.json", + "test/data/json_tests/fail3.json", + "test/data/json_tests/fail4.json", + "test/data/json_tests/fail5.json", + "test/data/json_tests/fail6.json", + "test/data/json_tests/fail7.json", + "test/data/json_tests/fail8.json", + "test/data/json_tests/fail9.json", + "test/data/json_tests/fail10.json", + "test/data/json_tests/fail11.json", + "test/data/json_tests/fail12.json", + "test/data/json_tests/fail13.json", + "test/data/json_tests/fail14.json", + "test/data/json_tests/fail15.json", + "test/data/json_tests/fail16.json", + "test/data/json_tests/fail17.json", + //"test/data/json_tests/fail18.json", + "test/data/json_tests/fail19.json", + "test/data/json_tests/fail20.json", + "test/data/json_tests/fail21.json", + "test/data/json_tests/fail22.json", + "test/data/json_tests/fail23.json", + "test/data/json_tests/fail24.json", + "test/data/json_tests/fail25.json", + "test/data/json_tests/fail26.json", + "test/data/json_tests/fail27.json", + "test/data/json_tests/fail28.json", + "test/data/json_tests/fail29.json", + "test/data/json_tests/fail30.json", + "test/data/json_tests/fail31.json", + "test/data/json_tests/fail32.json", + "test/data/json_tests/fail33.json" }) { CAPTURE(filename); @@ -11698,9 +11698,9 @@ TEST_CASE("compliance tests from json.org") { for (auto filename : { - "test/json_tests/pass1.json", - "test/json_tests/pass2.json", - "test/json_tests/pass3.json" + "test/data/json_tests/pass1.json", + "test/data/json_tests/pass2.json", + "test/data/json_tests/pass3.json" }) { CAPTURE(filename); @@ -11873,42 +11873,42 @@ TEST_CASE("compliance tests from nativejson-benchmark") SECTION("roundtrip") { - // test cases are from https://github.com/miloyip/nativejson-benchmark/tree/master/data/roundtrip + // test cases are from https://github.com/miloyip/nativejson-benchmark/tree/master/test/data/roundtrip for (auto filename : { - "test/json_roundtrip/roundtrip01.json", - "test/json_roundtrip/roundtrip02.json", - "test/json_roundtrip/roundtrip03.json", - "test/json_roundtrip/roundtrip04.json", - "test/json_roundtrip/roundtrip05.json", - "test/json_roundtrip/roundtrip06.json", - "test/json_roundtrip/roundtrip07.json", - "test/json_roundtrip/roundtrip08.json", - "test/json_roundtrip/roundtrip09.json", - "test/json_roundtrip/roundtrip10.json", - "test/json_roundtrip/roundtrip11.json", - "test/json_roundtrip/roundtrip12.json", - "test/json_roundtrip/roundtrip13.json", - "test/json_roundtrip/roundtrip14.json", - "test/json_roundtrip/roundtrip15.json", - "test/json_roundtrip/roundtrip16.json", - "test/json_roundtrip/roundtrip17.json", - "test/json_roundtrip/roundtrip18.json", - "test/json_roundtrip/roundtrip19.json", - "test/json_roundtrip/roundtrip20.json", - "test/json_roundtrip/roundtrip21.json", - "test/json_roundtrip/roundtrip22.json", - "test/json_roundtrip/roundtrip23.json", - "test/json_roundtrip/roundtrip24.json", - "test/json_roundtrip/roundtrip25.json", - "test/json_roundtrip/roundtrip26.json", - "test/json_roundtrip/roundtrip27.json", - "test/json_roundtrip/roundtrip28.json", - "test/json_roundtrip/roundtrip29.json", - "test/json_roundtrip/roundtrip30.json", - "test/json_roundtrip/roundtrip31.json", - "test/json_roundtrip/roundtrip32.json" + "test/data/json_roundtrip/roundtrip01.json", + "test/data/json_roundtrip/roundtrip02.json", + "test/data/json_roundtrip/roundtrip03.json", + "test/data/json_roundtrip/roundtrip04.json", + "test/data/json_roundtrip/roundtrip05.json", + "test/data/json_roundtrip/roundtrip06.json", + "test/data/json_roundtrip/roundtrip07.json", + "test/data/json_roundtrip/roundtrip08.json", + "test/data/json_roundtrip/roundtrip09.json", + "test/data/json_roundtrip/roundtrip10.json", + "test/data/json_roundtrip/roundtrip11.json", + "test/data/json_roundtrip/roundtrip12.json", + "test/data/json_roundtrip/roundtrip13.json", + "test/data/json_roundtrip/roundtrip14.json", + "test/data/json_roundtrip/roundtrip15.json", + "test/data/json_roundtrip/roundtrip16.json", + "test/data/json_roundtrip/roundtrip17.json", + "test/data/json_roundtrip/roundtrip18.json", + "test/data/json_roundtrip/roundtrip19.json", + "test/data/json_roundtrip/roundtrip20.json", + "test/data/json_roundtrip/roundtrip21.json", + "test/data/json_roundtrip/roundtrip22.json", + "test/data/json_roundtrip/roundtrip23.json", + "test/data/json_roundtrip/roundtrip24.json", + "test/data/json_roundtrip/roundtrip25.json", + "test/data/json_roundtrip/roundtrip26.json", + "test/data/json_roundtrip/roundtrip27.json", + "test/data/json_roundtrip/roundtrip28.json", + "test/data/json_roundtrip/roundtrip29.json", + "test/data/json_roundtrip/roundtrip30.json", + "test/data/json_roundtrip/roundtrip31.json", + "test/data/json_roundtrip/roundtrip32.json" }) { CAPTURE(filename); @@ -11928,7 +11928,7 @@ TEST_CASE("test suite from json-test-suite") { // read a file with all unicode characters stored as single-character // strings in a JSON array - std::ifstream f("test/json_testsuite/sample.json"); + std::ifstream f("test/data/json_testsuite/sample.json"); json j; CHECK_NOTHROW(j << f); @@ -11943,35 +11943,35 @@ TEST_CASE("json.org examples") SECTION("1.json") { - std::ifstream f("test/json.org/1.json"); + std::ifstream f("test/data/json.org/1.json"); json j; CHECK_NOTHROW(j << f); } SECTION("2.json") { - std::ifstream f("test/json.org/2.json"); + std::ifstream f("test/data/json.org/2.json"); json j; CHECK_NOTHROW(j << f); } SECTION("3.json") { - std::ifstream f("test/json.org/3.json"); + std::ifstream f("test/data/json.org/3.json"); json j; CHECK_NOTHROW(j << f); } SECTION("4.json") { - std::ifstream f("test/json.org/4.json"); + std::ifstream f("test/data/json.org/4.json"); json j; CHECK_NOTHROW(j << f); } SECTION("5.json") { - std::ifstream f("test/json.org/5.json"); + std::ifstream f("test/data/json.org/5.json"); json j; CHECK_NOTHROW(j << f); } @@ -12105,7 +12105,7 @@ TEST_CASE("Unicode", "[hide]") { // read a file with all unicode characters stored as single-character // strings in a JSON array - std::ifstream f("test/json_nlohmann_tests/all_unicode.json"); + std::ifstream f("test/data/json_nlohmann_tests/all_unicode.json"); json j; CHECK_NOTHROW(j << f); @@ -12146,7 +12146,7 @@ TEST_CASE("Unicode", "[hide]") SECTION("ignore byte-order-mark") { // read a file with a UTF-8 BOM - std::ifstream f("test/json_nlohmann_tests/bom.json"); + std::ifstream f("test/data/json_nlohmann_tests/bom.json"); json j; CHECK_NOTHROW(j << f); } From 527a69bb64d2d03e385b02cfec72130e70f9b37f Mon Sep 17 00:00:00 2001 From: Chris Kitching Date: Wed, 11 May 2016 01:38:52 +0100 Subject: [PATCH 6/7] Install the test binary and test data. Fixes #241 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The resulting install tree, when tests are enabled, looks like this: ``` . ├── cmake │   ├── nlohmann_jsonConfig.cmake │   ├── nlohmann_jsonConfigVersion.cmake │   └── nlohmann_jsonTargets.cmake ├── include │   └── nlohmann │   └── json.hpp └── test ├── bin │   └── json_unit └── data ├── json_nlohmann_tests │   ├── all_unicode.json │   └── bom.json ├── json.org │   ├── 1.json │   ├── ... ├── json_roundtrip │   ├── roundtrip01.json │   ├── roundtrip02.json │   └── ... ├── json_tests │   ├── fail10.json │   └── ... └── json_testsuite └── sample.json ``` It has the property that you can invoke the test binary from the root of the install tree and the tests work correctly (you no longer depend on the test binary being run inside the source tree). If tests are disabled, the entire `test/` subtree is omitted. Notice how that yields exactly what you want for using this library in other projects. I do not believe I need to update travis due to this change, as the evil Makefile continues to do in-tree builds. I expect I'll find out soon enough. --- test/CMakeLists.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0039fd84cb..b63e5a3944 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -11,5 +11,11 @@ set_target_properties(json_unit PROPERTIES COMPILE_OPTIONS "$<$:/EHsc;$<$:/Od>>" ) +# Install the test binary. +install(TARGETS json_unit RUNTIME DESTINATION test/bin) + +# Copy the test data to the install tree. +install(DIRECTORY data/ DESTINATION test/data) + target_include_directories(json_unit PRIVATE "src") target_link_libraries(json_unit ${JSON_TARGET_NAME}) From 0e2f0c4edce364ced6cd32d8fe72d5b4d9f0ef45 Mon Sep 17 00:00:00 2001 From: Chris Kitching Date: Wed, 11 May 2016 02:06:33 +0100 Subject: [PATCH 7/7] Repair appveyor... Horrifyingly It's sort of gnarly that it's still doing in-tree builds, but I really, _really_ don't want to get any more friendly with CMake's Visual Studio generator to work out how to make it stop doing it. In-tree builds still work, after all, and the goal of this work is to make out-of-tree builds work as well. Notional horrors like this will have to wait ;) --- appveyor.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/appveyor.yml b/appveyor.yml index aaf9c5f1a2..63902ced40 100644 --- a/appveyor.yml +++ b/appveyor.yml @@ -7,5 +7,5 @@ build_script: - cmake . -G "Visual Studio 14 2015" - cmake --build . --config Release test_script: -- Release\json_unit.exe -- Release\json_unit.exe "*" +- test\Release\json_unit.exe +- test\Release\json_unit.exe "*"