mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-11-01 00:38:27 +01:00 
			
		
		
		
	Disabled alignment on AVR (fixes #1231)
This commit is contained in:
		| @@ -9,17 +9,19 @@ add_executable(MixedConfigurationTests | ||||
| 	cpp11.cpp | ||||
| 	decode_unicode_0.cpp | ||||
| 	decode_unicode_1.cpp | ||||
| 	enable_alignment_0.cpp | ||||
| 	enable_alignment_1.cpp | ||||
| 	enable_comments_0.cpp | ||||
| 	enable_comments_1.cpp | ||||
| 	enable_infinity_0.cpp | ||||
| 	enable_infinity_1.cpp | ||||
| 	enable_nan_0.cpp | ||||
| 	enable_nan_1.cpp | ||||
| 	enable_progmem_1.cpp | ||||
| 	use_double_0.cpp | ||||
| 	use_double_1.cpp | ||||
| 	use_long_long_0.cpp | ||||
| 	use_long_long_1.cpp | ||||
| 	enable_progmem_1.cpp | ||||
| 	enable_comments_1.cpp | ||||
| 	enable_comments_0.cpp | ||||
| ) | ||||
|  | ||||
| target_link_libraries(MixedConfigurationTests | ||||
|   | ||||
							
								
								
									
										41
									
								
								extras/tests/MixedConfiguration/enable_alignment_0.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										41
									
								
								extras/tests/MixedConfiguration/enable_alignment_0.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,41 @@ | ||||
| #define ARDUINOJSON_NAMESPACE ArduinoJson_NoAlignment | ||||
| #define ARDUINOJSON_ENABLE_ALIGNMENT 0 | ||||
| #include <ArduinoJson.h> | ||||
|  | ||||
| #include <catch.hpp> | ||||
|  | ||||
| TEST_CASE("ARDUINOJSON_ENABLE_ALIGNMENT == 0") { | ||||
|   using namespace ARDUINOJSON_NAMESPACE; | ||||
|  | ||||
|   const size_t N = sizeof(void*); | ||||
|  | ||||
|   SECTION("isAligned()") { | ||||
|     CHECK(isAligned(0) == true); | ||||
|     CHECK(isAligned(1) == true); | ||||
|     CHECK(isAligned(N) == true); | ||||
|     CHECK(isAligned(N + 1) == true); | ||||
|     CHECK(isAligned(2 * N) == true); | ||||
|     CHECK(isAligned(2 * N + 1) == true); | ||||
|   } | ||||
|  | ||||
|   SECTION("addPadding()") { | ||||
|     CHECK(addPadding(0) == 0); | ||||
|     CHECK(addPadding(1) == 1); | ||||
|     CHECK(addPadding(N) == N); | ||||
|     CHECK(addPadding(N + 1) == N + 1); | ||||
|   } | ||||
|  | ||||
|   SECTION("AddPadding<>") { | ||||
|     const size_t a = AddPadding<0>::value; | ||||
|     CHECK(a == 0); | ||||
|  | ||||
|     const size_t b = AddPadding<1>::value; | ||||
|     CHECK(b == 1); | ||||
|  | ||||
|     const size_t c = AddPadding<N>::value; | ||||
|     CHECK(c == N); | ||||
|  | ||||
|     const size_t d = AddPadding<N + 1>::value; | ||||
|     CHECK(d == N + 1); | ||||
|   } | ||||
| } | ||||
							
								
								
									
										40
									
								
								extras/tests/MixedConfiguration/enable_alignment_1.cpp
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										40
									
								
								extras/tests/MixedConfiguration/enable_alignment_1.cpp
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,40 @@ | ||||
| #define ARDUINOJSON_ENABLE_ALIGNMENT 1 | ||||
| #include <ArduinoJson.h> | ||||
|  | ||||
| #include <catch.hpp> | ||||
|  | ||||
| TEST_CASE("ARDUINOJSON_ENABLE_ALIGNMENT == 1") { | ||||
|   using namespace ARDUINOJSON_NAMESPACE; | ||||
|  | ||||
|   const size_t N = sizeof(void*); | ||||
|  | ||||
|   SECTION("isAligned()") { | ||||
|     CHECK(isAligned(0) == true); | ||||
|     CHECK(isAligned(1) == false); | ||||
|     CHECK(isAligned(N) == true); | ||||
|     CHECK(isAligned(N + 1) == false); | ||||
|     CHECK(isAligned(2 * N) == true); | ||||
|     CHECK(isAligned(2 * N + 1) == false); | ||||
|   } | ||||
|  | ||||
|   SECTION("addPadding()") { | ||||
|     CHECK(addPadding(0) == 0); | ||||
|     CHECK(addPadding(1) == N); | ||||
|     CHECK(addPadding(N) == N); | ||||
|     CHECK(addPadding(N + 1) == 2 * N); | ||||
|   } | ||||
|  | ||||
|   SECTION("AddPadding<>") { | ||||
|     const size_t a = AddPadding<0>::value; | ||||
|     CHECK(a == 0); | ||||
|  | ||||
|     const size_t b = AddPadding<1>::value; | ||||
|     CHECK(b == N); | ||||
|  | ||||
|     const size_t c = AddPadding<N>::value; | ||||
|     CHECK(c == N); | ||||
|  | ||||
|     const size_t d = AddPadding<N + 1>::value; | ||||
|     CHECK(d == 2 * N); | ||||
|   } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user