🔨 moved third-party code into separate folder

This commit is contained in:
Niels Lohmann 2016-12-22 09:35:53 +01:00
parent 6e8791912f
commit ad241a2260
160 changed files with 27 additions and 21 deletions

2
.gitignore vendored
View File

@ -20,4 +20,4 @@ cmake-build-debug
test/test-*
test/fuzz_test/Fuzzer/.svn
.svn

View File

@ -1,7 +1,7 @@
# The unit test executable.
set(JSON_UNITTEST_TARGET_NAME "json_unit")
add_executable(${JSON_UNITTEST_TARGET_NAME}
"src/catch.hpp"
"thirdparty/catch/catch.hpp"
"src/unit.cpp"
"src/unit-algorithms.cpp"
"src/unit-allocator.cpp"
@ -44,7 +44,7 @@ set_target_properties(${JSON_UNITTEST_TARGET_NAME} PROPERTIES
COMPILE_OPTIONS "$<$<CXX_COMPILER_ID:MSVC>:/EHsc;$<$<CONFIG:Release>:/Od>>"
)
target_include_directories(${JSON_UNITTEST_TARGET_NAME} PRIVATE "src")
target_include_directories(${JSON_UNITTEST_TARGET_NAME} PRIVATE "src" "thirdparty/catch")
target_link_libraries(${JSON_UNITTEST_TARGET_NAME} ${JSON_TARGET_NAME})
add_test(NAME "${JSON_UNITTEST_TARGET_NAME}_default"

View File

@ -4,7 +4,7 @@
# additional flags
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
CPPFLAGS += -I ../src -I .
CPPFLAGS += -I ../src -I . -I thirdparty/catch
SOURCES = src/unit.cpp \
src/unit-algorithms.cpp \
@ -57,11 +57,11 @@ clean:
# single test file
##############################################################################
json_unit: $(OBJECTS) ../src/json.hpp src/catch.hpp
json_unit: $(OBJECTS) ../src/json.hpp thirdparty/catch/catch.hpp
@echo "[CXXLD] $@"
@$(CXX) $(CXXFLAGS) $(LDFLAGS) $(OBJECTS) -o $@
%.o: %.cpp ../src/json.hpp src/catch.hpp
%.o: %.cpp ../src/json.hpp thirdparty/catch/catch.hpp
@echo "[CXX] $@"
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) -c $< -o $@
@ -70,7 +70,7 @@ json_unit: $(OBJECTS) ../src/json.hpp src/catch.hpp
# individual test cases
##############################################################################
test-%: src/unit-%.cpp ../src/json.hpp src/catch.hpp
test-%: src/unit-%.cpp ../src/json.hpp thirdparty/catch/catch.hpp
@echo "[CXXLD] $@"
@$(CXX) $(CXXFLAGS) $(CPPFLAGS) $(LDFLAGS) -DCATCH_CONFIG_MAIN $< -o $@

View File

@ -18,19 +18,25 @@
using json = nlohmann::json;
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size) {
try {
std::stringstream s;
s << json::parse(data, data + size);
try {
auto j = json::parse(s.str());
std::stringstream s2;
s2 << j;
assert(s.str() == s2.str());
assert(j == json::parse(s.str()));
} catch (const std::invalid_argument&) {
assert(0);
extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
try
{
std::stringstream s;
s << json::parse(data, data + size);
try
{
auto j = json::parse(s.str());
std::stringstream s2;
s2 << j;
assert(s.str() == s2.str());
assert(j == json::parse(s.str()));
}
catch (const std::invalid_argument&)
{
assert(0);
}
}
} catch (const std::invalid_argument&) { }
return 0;
catch (const std::invalid_argument&) { }
return 0;
}

Some files were not shown because too many files have changed in this diff Show More