mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	Added tests for DeserializationError::f_str()
				
					
				
			This commit is contained in:
		| @@ -24,6 +24,11 @@ inline uint8_t pgm_read_byte(const void* p) { | ||||
|   return *reinterpret_cast<const uint8_t*>(convertFlashToPtr(p)); | ||||
| } | ||||
|  | ||||
| inline const void* pgm_read_ptr(const void* p) { | ||||
|   return *reinterpret_cast<const void* const*>(convertFlashToPtr(p)); | ||||
| inline void* pgm_read_ptr(const void* p) { | ||||
|   return *reinterpret_cast<void* const*>(convertFlashToPtr(p)); | ||||
| } | ||||
|  | ||||
| #define ARDUINOJSON_DEFINE_PROGMEM_ARRAY(type, name, value)        \ | ||||
|   static type const ARDUINOJSON_CONCAT2(name, _progmem)[] = value; \ | ||||
|   static type const* name = reinterpret_cast<type const*>(         \ | ||||
|       convertPtrToFlash(ARDUINOJSON_CONCAT2(name, _progmem))); | ||||
|   | ||||
| @@ -165,3 +165,22 @@ TEST_CASE("Reader<const __FlashStringHelper*>") { | ||||
|     REQUIRE(buffer[6] == 'g'); | ||||
|   } | ||||
| } | ||||
|  | ||||
| static void testStringification(DeserializationError error, | ||||
|                                 std::string expected) { | ||||
|   const __FlashStringHelper* s = error.f_str(); | ||||
|   CHECK(reinterpret_cast<const char*>(convertFlashToPtr(s)) == expected); | ||||
| } | ||||
|  | ||||
| #define TEST_STRINGIFICATION(symbol) \ | ||||
|   testStringification(DeserializationError::symbol, #symbol) | ||||
|  | ||||
| TEST_CASE("DeserializationError::f_str()") { | ||||
|   TEST_STRINGIFICATION(Ok); | ||||
|   TEST_STRINGIFICATION(EmptyInput); | ||||
|   TEST_STRINGIFICATION(IncompleteInput); | ||||
|   TEST_STRINGIFICATION(InvalidInput); | ||||
|   TEST_STRINGIFICATION(NoMemory); | ||||
|   TEST_STRINGIFICATION(NotSupported); | ||||
|   TEST_STRINGIFICATION(TooDeep); | ||||
| } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user