mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	Added a test with a NULL string
This commit is contained in:
		| @@ -8,6 +8,11 @@ | |||||||
|  |  | ||||||
| void StringBuilder::append(const char* s) | void StringBuilder::append(const char* s) | ||||||
| { | { | ||||||
|  |     if (!s) | ||||||
|  |     { | ||||||
|  |         return append("null");         | ||||||
|  |     } | ||||||
|  |  | ||||||
|     char* tail = buffer + length; |     char* tail = buffer + length; | ||||||
|  |  | ||||||
|     while (*s && length<capacity) |     while (*s && length<capacity) | ||||||
| @@ -20,7 +25,11 @@ void StringBuilder::append(const char* s) | |||||||
|  |  | ||||||
| void StringBuilder::appendEscaped(const char* s) | void StringBuilder::appendEscaped(const char* s) | ||||||
| { | { | ||||||
|     if (length > capacity - 3) return; |     if (length > capacity - 2) | ||||||
|  |     { | ||||||
|  |         // not enough from for quotes | ||||||
|  |         return; | ||||||
|  |     } | ||||||
|  |  | ||||||
|     buffer[length++] = '"'; |     buffer[length++] = '"'; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -28,6 +28,12 @@ namespace JsonGeneratorTests | |||||||
|             assertResultIs(""); |             assertResultIs(""); | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  |         TEST_METHOD(Null) | ||||||
|  |         { | ||||||
|  |             append(NULL); | ||||||
|  |             assertResultIs("null"); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         TEST_METHOD(OneString) |         TEST_METHOD(OneString) | ||||||
|         { |         { | ||||||
|             append("ABCD"); |             append("ABCD"); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user