| 
									
										
										
										
											2021-03-29 17:14:01 +02:00
										 |  |  | // ArduinoJson - https://arduinojson.org
 | 
					
						
							| 
									
										
										
										
											2024-01-03 08:47:06 +01:00
										 |  |  | // Copyright © 2014-2024, Benoit BLANCHON
 | 
					
						
							| 
									
										
										
										
											2018-11-09 17:27:32 +01:00
										 |  |  | // MIT License
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-17 16:10:56 +02:00
										 |  |  | #include <ArduinoJson/Memory/ResourceManager.hpp>
 | 
					
						
							| 
									
										
										
										
											2023-06-17 16:24:12 +02:00
										 |  |  | #include <ArduinoJson/Memory/VariantPoolImpl.hpp>
 | 
					
						
							| 
									
										
										
										
											2020-07-21 20:15:31 +02:00
										 |  |  | #include <ArduinoJson/Strings/StringAdapters.hpp>
 | 
					
						
							| 
									
										
										
										
											2018-11-09 17:27:32 +01:00
										 |  |  | #include <catch.hpp>
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-02-14 10:04:48 +01:00
										 |  |  | using namespace ArduinoJson::detail; | 
					
						
							| 
									
										
										
										
											2018-11-09 17:27:32 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-17 16:10:56 +02:00
										 |  |  | TEST_CASE("ResourceManager::clear()") { | 
					
						
							| 
									
										
										
										
											2023-07-17 18:15:13 +02:00
										 |  |  |   ResourceManager resources; | 
					
						
							| 
									
										
										
										
											2018-11-09 17:27:32 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   SECTION("Discards allocated variants") { | 
					
						
							| 
									
										
										
										
											2023-06-14 11:57:31 +02:00
										 |  |  |     resources.allocSlot(); | 
					
						
							| 
									
										
										
										
											2018-11-09 17:27:32 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-17 16:10:56 +02:00
										 |  |  |     resources.clear(); | 
					
						
							|  |  |  |     REQUIRE(resources.size() == 0); | 
					
						
							| 
									
										
										
										
											2018-11-09 17:27:32 +01:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   SECTION("Discards allocated strings") { | 
					
						
							| 
									
										
										
										
											2023-06-17 16:10:56 +02:00
										 |  |  |     resources.saveString(adaptString("123456789")); | 
					
						
							|  |  |  |     REQUIRE(resources.size() == sizeofString(9)); | 
					
						
							| 
									
										
										
										
											2018-11-09 17:27:32 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-17 16:10:56 +02:00
										 |  |  |     resources.clear(); | 
					
						
							| 
									
										
										
										
											2018-11-09 17:27:32 +01:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2023-06-17 16:10:56 +02:00
										 |  |  |     REQUIRE(resources.size() == 0); | 
					
						
							| 
									
										
										
										
											2018-11-09 17:27:32 +01:00
										 |  |  |   } | 
					
						
							|  |  |  | } |