mirror of
https://github.com/bblanchon/ArduinoJson.git
synced 2025-07-21 06:22:23 +02:00
ResourceManager: replace allocFromPool()
with allocVariant()
This commit is contained in:
@ -10,13 +10,13 @@
|
||||
|
||||
using namespace ArduinoJson::detail;
|
||||
|
||||
TEST_CASE("new (resources) VariantSlot()") {
|
||||
TEST_CASE("ResourceManager::allocVariant()") {
|
||||
SECTION("Returns different pointer") {
|
||||
ResourceManager resources(4096);
|
||||
|
||||
VariantSlot* s1 = new (&resources) VariantSlot();
|
||||
VariantSlot* s1 = resources.allocVariant();
|
||||
REQUIRE(s1 != 0);
|
||||
VariantSlot* s2 = new (&resources) VariantSlot();
|
||||
VariantSlot* s2 = resources.allocVariant();
|
||||
REQUIRE(s2 != 0);
|
||||
|
||||
REQUIRE(s1 != s2);
|
||||
@ -25,27 +25,27 @@ TEST_CASE("new (resources) VariantSlot()") {
|
||||
SECTION("Returns aligned pointers") {
|
||||
ResourceManager resources(4096);
|
||||
|
||||
REQUIRE(isAligned(new (&resources) VariantSlot()));
|
||||
REQUIRE(isAligned(new (&resources) VariantSlot()));
|
||||
REQUIRE(isAligned(resources.allocVariant()));
|
||||
REQUIRE(isAligned(resources.allocVariant()));
|
||||
}
|
||||
|
||||
SECTION("Returns zero if capacity is 0") {
|
||||
ResourceManager resources(0);
|
||||
|
||||
REQUIRE(new (&resources) VariantSlot() == 0);
|
||||
REQUIRE(resources.allocVariant() == 0);
|
||||
}
|
||||
|
||||
SECTION("Returns zero if buffer is null") {
|
||||
ResourceManager resources(4096, FailingAllocator::instance());
|
||||
|
||||
REQUIRE(new (&resources) VariantSlot() == 0);
|
||||
REQUIRE(resources.allocVariant() == 0);
|
||||
}
|
||||
|
||||
SECTION("Returns zero if capacity is insufficient") {
|
||||
ResourceManager resources(sizeof(VariantSlot));
|
||||
|
||||
new (&resources) VariantSlot();
|
||||
resources.allocVariant();
|
||||
|
||||
REQUIRE(new (&resources) VariantSlot() == 0);
|
||||
REQUIRE(resources.allocVariant() == 0);
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user