Tests: make allocator assertions more readable

This commit is contained in:
Benoit Blanchon
2023-07-26 06:06:38 +02:00
parent 30ec507989
commit 9a11d98117
31 changed files with 1127 additions and 1287 deletions

View File

@ -31,8 +31,9 @@ TEST_CASE("ResourceManager::swap()") {
REQUIRE(a1->data() == b.getSlot(a1.id())->data());
REQUIRE(b1->data() == a.getSlot(b1.id())->data());
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool()) * 2);
REQUIRE(spy.log() == AllocatorLog{
Allocate(sizeofPool()) * 2,
});
}
SECTION("Only left using preallocated pool list") {
@ -48,12 +49,12 @@ TEST_CASE("ResourceManager::swap()") {
REQUIRE(a1->data() == b.getSlot(a1.id())->data());
REQUIRE(b1->data() == a.getSlot(b1.id())->data());
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool()) *
(ARDUINOJSON_INITIAL_POOL_COUNT + 1)
<< AllocatorLog::Allocate(sizeofPoolList(
ARDUINOJSON_INITIAL_POOL_COUNT * 2))
<< AllocatorLog::Allocate(sizeofPool()));
REQUIRE(spy.log() ==
AllocatorLog{
Allocate(sizeofPool()) * (ARDUINOJSON_INITIAL_POOL_COUNT + 1),
Allocate(sizeofPoolList(ARDUINOJSON_INITIAL_POOL_COUNT * 2)),
Allocate(sizeofPool()),
});
}
SECTION("Only right using preallocated pool list") {
@ -69,12 +70,12 @@ TEST_CASE("ResourceManager::swap()") {
REQUIRE(a1->data() == b.getSlot(a1.id())->data());
REQUIRE(b1->data() == a.getSlot(b1.id())->data());
REQUIRE(spy.log() == AllocatorLog()
<< AllocatorLog::Allocate(sizeofPool()) *
ARDUINOJSON_INITIAL_POOL_COUNT
<< AllocatorLog::Allocate(sizeofPoolList(
ARDUINOJSON_INITIAL_POOL_COUNT * 2))
<< AllocatorLog::Allocate(sizeofPool()) * 2);
REQUIRE(spy.log() ==
AllocatorLog{
Allocate(sizeofPool()) * ARDUINOJSON_INITIAL_POOL_COUNT,
Allocate(sizeofPoolList(ARDUINOJSON_INITIAL_POOL_COUNT * 2)),
Allocate(sizeofPool()) * 2,
});
}
SECTION("None is using preallocated pool list") {