mirror of
				https://github.com/eledio-devices/thirdparty-ArduinoJson.git
				synced 2025-10-31 16:14:11 +01:00 
			
		
		
		
	Clang-format: set DerivePointerAlignment to false
				
					
				
			This commit is contained in:
		| @@ -22,7 +22,7 @@ TEST_CASE("MemoryPool::clear()") { | ||||
|   } | ||||
|  | ||||
|   SECTION("Discards allocated strings") { | ||||
|     pool.saveString(adaptString(const_cast<char *>("123456789"))); | ||||
|     pool.saveString(adaptString(const_cast<char*>("123456789"))); | ||||
|     REQUIRE(pool.size() == 10); | ||||
|  | ||||
|     pool.clear(); | ||||
|   | ||||
| @@ -8,11 +8,11 @@ | ||||
|  | ||||
| using namespace ARDUINOJSON_NAMESPACE; | ||||
|  | ||||
| static const char *saveString(MemoryPool &pool, const char *s) { | ||||
|   return pool.saveString(adaptString(const_cast<char *>(s))); | ||||
| static const char* saveString(MemoryPool& pool, const char* s) { | ||||
|   return pool.saveString(adaptString(const_cast<char*>(s))); | ||||
| } | ||||
|  | ||||
| static const char *saveString(MemoryPool &pool, const char *s, size_t n) { | ||||
| static const char* saveString(MemoryPool& pool, const char* s, size_t n) { | ||||
|   return pool.saveString(adaptString(s, n)); | ||||
| } | ||||
|  | ||||
| @@ -21,36 +21,36 @@ TEST_CASE("MemoryPool::saveString()") { | ||||
|   MemoryPool pool(buffer, 32); | ||||
|  | ||||
|   SECTION("Duplicates different strings") { | ||||
|     const char *a = saveString(pool, "hello"); | ||||
|     const char *b = saveString(pool, "world"); | ||||
|     const char* a = saveString(pool, "hello"); | ||||
|     const char* b = saveString(pool, "world"); | ||||
|     REQUIRE(a != b); | ||||
|     REQUIRE(pool.size() == 6 + 6); | ||||
|   } | ||||
|  | ||||
|   SECTION("Deduplicates identical strings") { | ||||
|     const char *a = saveString(pool, "hello"); | ||||
|     const char *b = saveString(pool, "hello"); | ||||
|     const char* a = saveString(pool, "hello"); | ||||
|     const char* b = saveString(pool, "hello"); | ||||
|     REQUIRE(a == b); | ||||
|     REQUIRE(pool.size() == 6); | ||||
|   } | ||||
|  | ||||
|   SECTION("Deduplicates identical strings that contain NUL") { | ||||
|     const char *a = saveString(pool, "hello\0world", 11); | ||||
|     const char *b = saveString(pool, "hello\0world", 11); | ||||
|     const char* a = saveString(pool, "hello\0world", 11); | ||||
|     const char* b = saveString(pool, "hello\0world", 11); | ||||
|     REQUIRE(a == b); | ||||
|     REQUIRE(pool.size() == 12); | ||||
|   } | ||||
|  | ||||
|   SECTION("Reuse part of a string if it ends with NUL") { | ||||
|     const char *a = saveString(pool, "hello\0world", 11); | ||||
|     const char *b = saveString(pool, "hello"); | ||||
|     const char* a = saveString(pool, "hello\0world", 11); | ||||
|     const char* b = saveString(pool, "hello"); | ||||
|     REQUIRE(a == b); | ||||
|     REQUIRE(pool.size() == 12); | ||||
|   } | ||||
|  | ||||
|   SECTION("Don't stop on first NUL") { | ||||
|     const char *a = saveString(pool, "hello"); | ||||
|     const char *b = saveString(pool, "hello\0world", 11); | ||||
|     const char* a = saveString(pool, "hello"); | ||||
|     const char* b = saveString(pool, "hello\0world", 11); | ||||
|     REQUIRE(a != b); | ||||
|     REQUIRE(pool.size() == 18); | ||||
|   } | ||||
| @@ -58,16 +58,16 @@ TEST_CASE("MemoryPool::saveString()") { | ||||
|   SECTION("Returns NULL when full") { | ||||
|     REQUIRE(pool.capacity() == 32); | ||||
|  | ||||
|     const void *p1 = saveString(pool, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); | ||||
|     const void* p1 = saveString(pool, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); | ||||
|     REQUIRE(p1 != 0); | ||||
|     REQUIRE(pool.size() == 32); | ||||
|  | ||||
|     const void *p2 = saveString(pool, "b"); | ||||
|     const void* p2 = saveString(pool, "b"); | ||||
|     REQUIRE(p2 == 0); | ||||
|   } | ||||
|  | ||||
|   SECTION("Returns NULL when pool is too small") { | ||||
|     const void *p = saveString(pool, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); | ||||
|     const void* p = saveString(pool, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); | ||||
|     REQUIRE(0 == p); | ||||
|   } | ||||
|  | ||||
| @@ -82,15 +82,15 @@ TEST_CASE("MemoryPool::saveString()") { | ||||
|   } | ||||
|  | ||||
|   SECTION("Returns same address after clear()") { | ||||
|     const void *a = saveString(pool, "hello"); | ||||
|     const void* a = saveString(pool, "hello"); | ||||
|     pool.clear(); | ||||
|     const void *b = saveString(pool, "world"); | ||||
|     const void* b = saveString(pool, "world"); | ||||
|  | ||||
|     REQUIRE(a == b); | ||||
|   } | ||||
|  | ||||
|   SECTION("Can use full capacity when fresh") { | ||||
|     const void *a = saveString(pool, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); | ||||
|     const void* a = saveString(pool, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); | ||||
|  | ||||
|     REQUIRE(a != 0); | ||||
|   } | ||||
| @@ -99,7 +99,7 @@ TEST_CASE("MemoryPool::saveString()") { | ||||
|     saveString(pool, "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"); | ||||
|     pool.clear(); | ||||
|  | ||||
|     const void *a = saveString(pool, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); | ||||
|     const void* a = saveString(pool, "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb"); | ||||
|  | ||||
|     REQUIRE(a != 0); | ||||
|   } | ||||
|   | ||||
		Reference in New Issue
	
	Block a user