split unit tests
This commit is contained in:
parent
263e6af48d
commit
5541e6f6f9
8 changed files with 66 additions and 11 deletions
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -14,3 +14,5 @@ android
|
||||||
doc/xml
|
doc/xml
|
||||||
|
|
||||||
benchmarks/files/numbers/*.json
|
benchmarks/files/numbers/*.json
|
||||||
|
|
||||||
|
*.o
|
||||||
|
|
|
@ -24,7 +24,7 @@ matrix:
|
||||||
- make clean
|
- make clean
|
||||||
- touch src/json.hpp
|
- touch src/json.hpp
|
||||||
- make json_unit CXXFLAGS="-fprofile-arcs -ftest-coverage -std=c++11 -lstdc++" CXX=$COMPILER
|
- make json_unit CXXFLAGS="-fprofile-arcs -ftest-coverage -std=c++11 -lstdc++" CXX=$COMPILER
|
||||||
- ./json_unit "*"
|
- test/json_unit "*"
|
||||||
- coveralls --exclude test/src/catch.hpp --exclude test/src/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'
|
||||||
- bash <(curl -s https://codecov.io/bash)
|
- bash <(curl -s https://codecov.io/bash)
|
||||||
env: COMPILER=g++-4.9
|
env: COMPILER=g++-4.9
|
||||||
|
@ -164,9 +164,9 @@ script:
|
||||||
- uname -a
|
- uname -a
|
||||||
- $COMPILER --version
|
- $COMPILER --version
|
||||||
- make CXX=$COMPILER
|
- make CXX=$COMPILER
|
||||||
- ./json_unit "*"
|
- test/json_unit "*"
|
||||||
- if [ `which valgrind` ]; then
|
- if [ `which valgrind` ]; then
|
||||||
valgrind --error-exitcode=1 --leak-check=full ./json_unit ;
|
valgrind --error-exitcode=1 --leak-check=full test/json_unit ;
|
||||||
fi
|
fi
|
||||||
- if [ `which brew` ]; then
|
- if [ `which brew` ]; then
|
||||||
brew update ;
|
brew update ;
|
||||||
|
|
12
Makefile
12
Makefile
|
@ -12,18 +12,20 @@ clean:
|
||||||
rm -fr json_unit json_benchmarks fuzz fuzz-testing *.dSYM
|
rm -fr json_unit json_benchmarks fuzz fuzz-testing *.dSYM
|
||||||
rm -fr benchmarks/files/numbers/*.json
|
rm -fr benchmarks/files/numbers/*.json
|
||||||
$(MAKE) clean -Cdoc
|
$(MAKE) clean -Cdoc
|
||||||
|
$(MAKE) clean -Ctest
|
||||||
|
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
# unit tests
|
# unit tests
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
||||||
# additional flags
|
# build unit tests
|
||||||
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
|
json_unit:
|
||||||
|
@$(MAKE) -C test
|
||||||
|
|
||||||
# build unit tests (TODO: Does this want its own makefile?)
|
# run unit tests
|
||||||
json_unit: test/src/unit.cpp src/json.hpp test/src/catch.hpp
|
check: json_unit
|
||||||
$(CXX) -std=c++11 $(CXXFLAGS) $(FLAGS) $(CPPFLAGS) -I src -I test $< $(LDFLAGS) -o $@
|
test/json_unit "*"
|
||||||
|
|
||||||
|
|
||||||
##########################################################################
|
##########################################################################
|
||||||
|
|
|
@ -501,8 +501,7 @@ Thanks a lot for helping out!
|
||||||
To compile and run the tests, you need to execute
|
To compile and run the tests, you need to execute
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
$ make
|
$ make check
|
||||||
$ ./json_unit "*"
|
|
||||||
|
|
||||||
===============================================================================
|
===============================================================================
|
||||||
All tests passed (8905012 assertions in 32 test cases)
|
All tests passed (8905012 assertions in 32 test cases)
|
||||||
|
|
|
@ -3,6 +3,7 @@ set(JSON_UNITTEST_TARGET_NAME "json_unit")
|
||||||
add_executable(${JSON_UNITTEST_TARGET_NAME}
|
add_executable(${JSON_UNITTEST_TARGET_NAME}
|
||||||
"src/catch.hpp"
|
"src/catch.hpp"
|
||||||
"src/unit.cpp"
|
"src/unit.cpp"
|
||||||
|
"src/unit-runner.cpp"
|
||||||
)
|
)
|
||||||
|
|
||||||
set_target_properties(${JSON_UNITTEST_TARGET_NAME} PROPERTIES
|
set_target_properties(${JSON_UNITTEST_TARGET_NAME} PROPERTIES
|
||||||
|
|
21
test/Makefile
Normal file
21
test/Makefile
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
##########################################################################
|
||||||
|
# unit tests
|
||||||
|
##########################################################################
|
||||||
|
|
||||||
|
# additional flags
|
||||||
|
CXXFLAGS += -std=c++11 -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
|
||||||
|
INCDIRS = -I ../src -I .
|
||||||
|
|
||||||
|
SOURCES = src/unit-runner.cpp src/unit.cpp
|
||||||
|
OBJECTS = $(SOURCES:.cpp=.o)
|
||||||
|
|
||||||
|
all: json_unit
|
||||||
|
|
||||||
|
json_unit: $(OBJECTS) ../src/json.hpp src/catch.hpp
|
||||||
|
$(CXX) $(CXXFLAGS) $(LDFLAGS) $(OBJECTS) -o $@
|
||||||
|
|
||||||
|
%.o: %.cpp
|
||||||
|
$(CXX) $(CXXFLAGS) $(INCDIRS) -c $< -o $@
|
||||||
|
|
||||||
|
clean:
|
||||||
|
rm -fr json_unit $(OBJECTS)
|
30
test/src/unit-runner.cpp
Normal file
30
test/src/unit-runner.cpp
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
/*
|
||||||
|
__ _____ _____ _____
|
||||||
|
__| | __| | | | JSON for Modern C++ (test suite)
|
||||||
|
| | |__ | | | | | | version 2.0.2
|
||||||
|
|_____|_____|_____|_|___| https://github.com/nlohmann/json
|
||||||
|
|
||||||
|
Licensed under the MIT License <http://opensource.org/licenses/MIT>.
|
||||||
|
Copyright (c) 2013-2016 Niels Lohmann <http://nlohmann.me>.
|
||||||
|
|
||||||
|
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_MAIN
|
||||||
|
#include "catch.hpp"
|
|
@ -26,12 +26,12 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#define CATCH_CONFIG_MAIN
|
|
||||||
#include "catch.hpp"
|
#include "catch.hpp"
|
||||||
|
|
||||||
#include <array>
|
#include <array>
|
||||||
#include <deque>
|
#include <deque>
|
||||||
#include <forward_list>
|
#include <forward_list>
|
||||||
|
#include <fstream>
|
||||||
#include <list>
|
#include <list>
|
||||||
#include <map>
|
#include <map>
|
||||||
#include <set>
|
#include <set>
|
||||||
|
|
Loading…
Reference in a new issue