diff --git a/CMakeLists.txt b/CMakeLists.txt index c539c832..5629573e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,10 +10,6 @@ project(ArduinoJson) enable_testing() -set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib) -set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib) -set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/bin) - if(${COVERAGE}) set(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") endif() diff --git a/scripts/run-tests.sh b/scripts/run-tests.sh deleted file mode 100755 index a41e83a8..00000000 --- a/scripts/run-tests.sh +++ /dev/null @@ -1,44 +0,0 @@ -#!/bin/bash - -FILE=../bin/ArduinoJsonTests.exe -MD5="" - -file_changed() { - [[ ! -f "$FILE" ]] && return 1 - NEW_MD5=$(md5sum $FILE) - [[ "$MD5" == "$NEW_MD5" ]] && return 1 - MD5=$NEW_MD5 - return 0 -} - -test_succeed() { - echo -en "\007"{,} -} - -test_failed() { - echo -en "\007"{,,,,,,,,,,,} -} - -run_tests() { - $FILE - case $? in - 0) - test_succeed - ;; - 1) - test_failed - ;; - esac -} - -while true -do - if file_changed - then - run_tests - else - sleep 2 - fi -done - - diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6a0ffd70..3e8a783a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -7,11 +7,6 @@ include(gtest.cmake) -file(GLOB_RECURSE TESTS_FILES - *.hpp - *.cpp -) - if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)") add_compile_options( -fno-exceptions @@ -68,8 +63,15 @@ if(MSVC) ) endif() -add_executable(ArduinoJsonTests ${TESTS_FILES}) -target_include_directories(ArduinoJsonTests PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../include) -target_link_libraries(ArduinoJsonTests gtest) +include_directories(${CMAKE_CURRENT_LIST_DIR}/../include) -add_test(ArduinoJsonTests ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ArduinoJsonTests) +add_subdirectory(DynamicJsonBuffer) +add_subdirectory(IntegrationTests) +add_subdirectory(JsonArray) +add_subdirectory(JsonBuffer) +add_subdirectory(JsonObject) +add_subdirectory(JsonVariant) +add_subdirectory(JsonWriter) +add_subdirectory(Misc) +add_subdirectory(Polyfills) +add_subdirectory(StaticJsonBuffer) \ No newline at end of file diff --git a/test/DynamicJsonBuffer/CMakeLists.txt b/test/DynamicJsonBuffer/CMakeLists.txt new file mode 100644 index 00000000..a0ea3501 --- /dev/null +++ b/test/DynamicJsonBuffer/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright Benoit Blanchon 2014-2017 +# MIT License +# +# Arduino JSON library +# https://bblanchon.github.io/ArduinoJson/ +# If you like this project, please add a star! + +add_executable(DynamicJsonBufferTests + array.cpp + basics.cpp + noMemory.cpp + object.cpp + string.cpp +) + +target_link_libraries(DynamicJsonBufferTests gtest) +add_test(DynamicJsonBuffer DynamicJsonBufferTests) diff --git a/test/IntegrationTests/CMakeLists.txt b/test/IntegrationTests/CMakeLists.txt new file mode 100644 index 00000000..21625a00 --- /dev/null +++ b/test/IntegrationTests/CMakeLists.txt @@ -0,0 +1,14 @@ +# Copyright Benoit Blanchon 2014-2017 +# MIT License +# +# Arduino JSON library +# https://bblanchon.github.io/ArduinoJson/ +# If you like this project, please add a star! + +add_executable(IntegrationTests + gbathree.cpp + parse_print.cpp +) + +target_link_libraries(IntegrationTests gtest) +add_test(IntegrationTests IntegrationTests) diff --git a/test/JsonArray/CMakeLists.txt b/test/JsonArray/CMakeLists.txt new file mode 100644 index 00000000..211ff576 --- /dev/null +++ b/test/JsonArray/CMakeLists.txt @@ -0,0 +1,23 @@ +# Copyright Benoit Blanchon 2014-2017 +# MIT License +# +# Arduino JSON library +# https://bblanchon.github.io/ArduinoJson/ +# If you like this project, please add a star! + +add_executable(JsonArrayTests + add.cpp + basics.cpp + copyFrom.cpp + copyTo.cpp + invalid.cpp + iterator.cpp + prettyPrintTo.cpp + printTo.cpp + removeAt.cpp + set.cpp + subscript.cpp +) + +target_link_libraries(JsonArrayTests gtest) +add_test(JsonArray JsonArrayTests) diff --git a/test/JsonBuffer/CMakeLists.txt b/test/JsonBuffer/CMakeLists.txt new file mode 100644 index 00000000..35953ebe --- /dev/null +++ b/test/JsonBuffer/CMakeLists.txt @@ -0,0 +1,17 @@ +# Copyright Benoit Blanchon 2014-2017 +# MIT License +# +# Arduino JSON library +# https://bblanchon.github.io/ArduinoJson/ +# If you like this project, please add a star! + +add_executable(JsonBufferTests + nested.cpp + nestingLimit.cpp + parse.cpp + parseArray.cpp + parseObject.cpp +) + +target_link_libraries(JsonBufferTests gtest) +add_test(JsonBuffer JsonBufferTests) diff --git a/test/JsonObject/CMakeLists.txt b/test/JsonObject/CMakeLists.txt new file mode 100644 index 00000000..c3d71fcc --- /dev/null +++ b/test/JsonObject/CMakeLists.txt @@ -0,0 +1,22 @@ +# Copyright Benoit Blanchon 2014-2017 +# MIT License +# +# Arduino JSON library +# https://bblanchon.github.io/ArduinoJson/ +# If you like this project, please add a star! + +add_executable(JsonObjectTests + basics.cpp + containsKey.cpp + get.cpp + invalid.cpp + iterator.cpp + prettyPrintTo.cpp + printTo.cpp + remove.cpp + set.cpp + subscript.cpp +) + +target_link_libraries(JsonObjectTests gtest) +add_test(JsonObject JsonObjectTests) diff --git a/test/JsonVariant/CMakeLists.txt b/test/JsonVariant/CMakeLists.txt new file mode 100644 index 00000000..267e05c6 --- /dev/null +++ b/test/JsonVariant/CMakeLists.txt @@ -0,0 +1,21 @@ +# Copyright Benoit Blanchon 2014-2017 +# MIT License +# +# Arduino JSON library +# https://bblanchon.github.io/ArduinoJson/ +# If you like this project, please add a star! + +add_executable(JsonVariantTests + as.cpp + compare.cpp + copy.cpp + is.cpp + printTo.cpp + set_get.cpp + subscript.cpp + success.cpp + undefined.cpp +) + +target_link_libraries(JsonVariantTests gtest) +add_test(JsonVariant JsonVariantTests) diff --git a/test/JsonWriter/CMakeLists.txt b/test/JsonWriter/CMakeLists.txt new file mode 100644 index 00000000..f3f2ad3e --- /dev/null +++ b/test/JsonWriter/CMakeLists.txt @@ -0,0 +1,14 @@ +# Copyright Benoit Blanchon 2014-2017 +# MIT License +# +# Arduino JSON library +# https://bblanchon.github.io/ArduinoJson/ +# If you like this project, please add a star! + +add_executable(JsonWriterTests + writeFloat.cpp + writeString.cpp +) + +target_link_libraries(JsonWriterTests gtest) +add_test(JsonWriter JsonWriterTests) diff --git a/test/Misc/CMakeLists.txt b/test/Misc/CMakeLists.txt new file mode 100644 index 00000000..b48729fc --- /dev/null +++ b/test/Misc/CMakeLists.txt @@ -0,0 +1,19 @@ +# Copyright Benoit Blanchon 2014-2017 +# MIT License +# +# Arduino JSON library +# https://bblanchon.github.io/ArduinoJson/ +# If you like this project, please add a star! + +add_executable(MiscTests + deprecated.cpp + std_stream.cpp + std_string.cpp + StringBuilder.cpp + TypeTraits.cpp + unsigned_char.cpp + vla.cpp +) + +target_link_libraries(MiscTests gtest) +add_test(Misc MiscTests) diff --git a/test/Polyfills/CMakeLists.txt b/test/Polyfills/CMakeLists.txt new file mode 100644 index 00000000..04a13b4e --- /dev/null +++ b/test/Polyfills/CMakeLists.txt @@ -0,0 +1,16 @@ +# Copyright Benoit Blanchon 2014-2017 +# MIT License +# +# Arduino JSON library +# https://bblanchon.github.io/ArduinoJson/ +# If you like this project, please add a star! + +add_executable(PolyfillsTests + isFloat.cpp + isInteger.cpp + parseFloat.cpp + parseInteger.cpp +) + +target_link_libraries(PolyfillsTests gtest) +add_test(Polyfills PolyfillsTests) diff --git a/test/StaticJsonBuffer/CMakeLists.txt b/test/StaticJsonBuffer/CMakeLists.txt new file mode 100644 index 00000000..68d12239 --- /dev/null +++ b/test/StaticJsonBuffer/CMakeLists.txt @@ -0,0 +1,18 @@ +# Copyright Benoit Blanchon 2014-2017 +# MIT License +# +# Arduino JSON library +# https://bblanchon.github.io/ArduinoJson/ +# If you like this project, please add a star! + +add_executable(StaticJsonBufferTests + basics.cpp + createArray.cpp + createObject.cpp + parseArray.cpp + parseObject.cpp + string.cpp +) + +target_link_libraries(StaticJsonBufferTests gtest) +add_test(StaticJsonBuffer StaticJsonBufferTests)