2016-08-04 13:24:46 +08:00
|
|
|
##########################################################################
|
|
|
|
# unit tests
|
|
|
|
##########################################################################
|
|
|
|
|
|
|
|
# additional flags
|
2016-08-10 22:22:53 +08:00
|
|
|
CXXFLAGS += -std=c++11 -Wall -Wextra -pedantic -Weffc++ -Wcast-align -Wcast-qual -Wno-ctor-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 -Wno-float-equal
|
2016-12-22 16:35:53 +08:00
|
|
|
CPPFLAGS += -I ../src -I . -I thirdparty/catch
|
2016-08-04 13:24:46 +08:00
|
|
|
|
2016-08-05 03:55:47 +08:00
|
|
|
SOURCES = src/unit.cpp \
|
|
|
|
src/unit-algorithms.cpp \
|
|
|
|
src/unit-allocator.cpp \
|
|
|
|
src/unit-capacity.cpp \
|
2016-11-27 07:09:24 +08:00
|
|
|
src/unit-cbor.cpp \
|
2016-08-05 03:55:47 +08:00
|
|
|
src/unit-class_const_iterator.cpp \
|
|
|
|
src/unit-class_iterator.cpp \
|
|
|
|
src/unit-class_lexer.cpp \
|
|
|
|
src/unit-class_parser.cpp \
|
|
|
|
src/unit-comparison.cpp \
|
|
|
|
src/unit-concepts.cpp \
|
2016-08-05 04:51:08 +08:00
|
|
|
src/unit-constructor1.cpp \
|
|
|
|
src/unit-constructor2.cpp \
|
2016-08-05 03:55:47 +08:00
|
|
|
src/unit-convenience.cpp \
|
|
|
|
src/unit-conversions.cpp \
|
|
|
|
src/unit-deserialization.cpp \
|
2016-08-05 04:51:08 +08:00
|
|
|
src/unit-element_access1.cpp \
|
|
|
|
src/unit-element_access2.cpp \
|
2016-08-05 03:55:47 +08:00
|
|
|
src/unit-inspection.cpp \
|
|
|
|
src/unit-iterator_wrapper.cpp \
|
2016-08-05 04:51:08 +08:00
|
|
|
src/unit-iterators1.cpp \
|
|
|
|
src/unit-iterators2.cpp \
|
2016-08-05 03:55:47 +08:00
|
|
|
src/unit-json_patch.cpp \
|
|
|
|
src/unit-json_pointer.cpp \
|
|
|
|
src/unit-modifiers.cpp \
|
2016-11-12 00:11:13 +08:00
|
|
|
src/unit-msgpack.cpp \
|
2016-08-05 03:55:47 +08:00
|
|
|
src/unit-pointer_access.cpp \
|
|
|
|
src/unit-readme.cpp \
|
|
|
|
src/unit-reference_access.cpp \
|
|
|
|
src/unit-regression.cpp \
|
|
|
|
src/unit-serialization.cpp \
|
|
|
|
src/unit-unicode.cpp \
|
|
|
|
src/unit-testsuites.cpp
|
|
|
|
|
2016-08-04 13:24:46 +08:00
|
|
|
OBJECTS = $(SOURCES:.cpp=.o)
|
|
|
|
|
2016-11-27 23:19:26 +08:00
|
|
|
TESTCASES = $(patsubst src/unit-%.cpp,test-%,$(wildcard src/unit-*.cpp))
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# main rules
|
|
|
|
##############################################################################
|
|
|
|
|
|
|
|
all: $(TESTCASES)
|
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -fr json_unit $(OBJECTS) $(SOURCES:.cpp=.gcno) $(SOURCES:.cpp=.gcda) $(TESTCASES)
|
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# single test file
|
|
|
|
##############################################################################
|
2016-08-04 13:24:46 +08:00
|
|
|
|
2016-12-22 16:35:53 +08:00
|
|
|
json_unit: $(OBJECTS) ../src/json.hpp thirdparty/catch/catch.hpp
|
2016-08-05 03:55:47 +08:00
|
|
|
@echo "[CXXLD] $@"
|
|
|
|
@$(CXX) $(CXXFLAGS) $(LDFLAGS) $(OBJECTS) -o $@
|
2016-08-04 13:24:46 +08:00
|
|
|
|
2016-12-22 16:35:53 +08:00
|
|
|
%.o: %.cpp ../src/json.hpp thirdparty/catch/catch.hpp
|
2016-08-05 03:55:47 +08:00
|
|
|
@echo "[CXX] $@"
|
|
|
|
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@
|
2016-08-04 13:24:46 +08:00
|
|
|
|
2016-11-27 23:19:26 +08:00
|
|
|
|
|
|
|
##############################################################################
|
|
|
|
# individual test cases
|
|
|
|
##############################################################################
|
|
|
|
|
2016-12-22 16:35:53 +08:00
|
|
|
test-%: src/unit-%.cpp ../src/json.hpp thirdparty/catch/catch.hpp
|
2016-11-27 23:19:26 +08:00
|
|
|
@echo "[CXXLD] $@"
|
|
|
|
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) -DCATCH_CONFIG_MAIN $< -o $@
|
|
|
|
|
|
|
|
TEST_PATTERN = "*"
|
|
|
|
TEST_PREFIX = ""
|
|
|
|
check: $(TESTCASES)
|
2016-11-29 06:20:03 +08:00
|
|
|
@cd .. ; for testcase in $(TESTCASES); do echo "Executing $$testcase..."; $(TEST_PREFIX)test/$$testcase $(TEST_PATTERN) || exit 1; done
|