Split unit test into several executables

This commit is contained in:
Benoit Blanchon
2017-04-10 15:36:59 +02:00
parent ac89d91db5
commit 71edcaf20f
13 changed files with 192 additions and 57 deletions

View File

@ -10,10 +10,6 @@ project(ArduinoJson)
enable_testing() 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}) if(${COVERAGE})
set(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage") set(CMAKE_CXX_FLAGS "-g -O0 -fprofile-arcs -ftest-coverage")
endif() endif()

View File

@ -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

View File

@ -7,11 +7,6 @@
include(gtest.cmake) include(gtest.cmake)
file(GLOB_RECURSE TESTS_FILES
*.hpp
*.cpp
)
if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)") if(CMAKE_CXX_COMPILER_ID MATCHES "(GNU|Clang)")
add_compile_options( add_compile_options(
-fno-exceptions -fno-exceptions
@ -68,8 +63,15 @@ if(MSVC)
) )
endif() endif()
add_executable(ArduinoJsonTests ${TESTS_FILES}) include_directories(${CMAKE_CURRENT_LIST_DIR}/../include)
target_include_directories(ArduinoJsonTests PRIVATE ${CMAKE_CURRENT_LIST_DIR}/../include)
target_link_libraries(ArduinoJsonTests gtest)
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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

View File

@ -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)

19
test/Misc/CMakeLists.txt Normal file
View File

@ -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)

View File

@ -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)

View File

@ -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)