Răsfoiți Sursa

Split unit test into several executables

Benoit Blanchon 8 ani în urmă
părinte
comite
71edcaf20f

+ 0 - 4
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()

+ 0 - 44
scripts/run-tests.sh

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

+ 11 - 9
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)

+ 17 - 0
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)

+ 14 - 0
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)

+ 23 - 0
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)

+ 17 - 0
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)

+ 22 - 0
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)

+ 21 - 0
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)

+ 14 - 0
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)

+ 19 - 0
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)

+ 16 - 0
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)

+ 18 - 0
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)