Tests: use a consistent naming convention for allocators

This commit is contained in:
Benoit Blanchon
2023-07-25 14:53:54 +02:00
parent 7a76da3bc7
commit 30ec507989
25 changed files with 698 additions and 698 deletions

View File

@ -8,75 +8,75 @@
#include "Allocators.hpp"
TEST_CASE("JsonDocument::overflowed()") {
TimebombAllocator allocator(10);
JsonDocument doc(&allocator);
TimebombAllocator timebomb(10);
JsonDocument doc(&timebomb);
SECTION("returns false on a fresh object") {
allocator.setCountdown(0);
timebomb.setCountdown(0);
CHECK(doc.overflowed() == false);
}
SECTION("returns true after a failed insertion") {
allocator.setCountdown(0);
timebomb.setCountdown(0);
doc.add(0);
CHECK(doc.overflowed() == true);
}
SECTION("returns false after successful insertion") {
allocator.setCountdown(2);
timebomb.setCountdown(2);
doc.add(0);
CHECK(doc.overflowed() == false);
}
SECTION("returns true after a failed string copy") {
allocator.setCountdown(0);
timebomb.setCountdown(0);
doc.add(std::string("example"));
CHECK(doc.overflowed() == true);
}
SECTION("returns false after a successful string copy") {
allocator.setCountdown(3);
timebomb.setCountdown(3);
doc.add(std::string("example"));
CHECK(doc.overflowed() == false);
}
SECTION("returns true after a failed member add") {
allocator.setCountdown(0);
timebomb.setCountdown(0);
doc["example"] = true;
CHECK(doc.overflowed() == true);
}
SECTION("returns true after a failed deserialization") {
allocator.setCountdown(0);
timebomb.setCountdown(0);
deserializeJson(doc, "[1, 2]");
CHECK(doc.overflowed() == true);
}
SECTION("returns false after a successful deserialization") {
allocator.setCountdown(3);
timebomb.setCountdown(3);
deserializeJson(doc, "[\"example\"]");
CHECK(doc.overflowed() == false);
}
SECTION("returns false after clear()") {
allocator.setCountdown(0);
timebomb.setCountdown(0);
doc.add(0);
doc.clear();
CHECK(doc.overflowed() == false);
}
SECTION("remains false after shrinkToFit()") {
allocator.setCountdown(2);
timebomb.setCountdown(2);
doc.add(0);
allocator.setCountdown(2);
timebomb.setCountdown(2);
doc.shrinkToFit();
CHECK(doc.overflowed() == false);
}
SECTION("remains true after shrinkToFit()") {
allocator.setCountdown(0);
timebomb.setCountdown(0);
doc.add(0);
allocator.setCountdown(2);
timebomb.setCountdown(2);
doc.shrinkToFit();
CHECK(doc.overflowed() == true);
}