AK+Tests: Remove NoAllocationGuard

On systems other than SerenityOS this was a no-op anyways.
This commit is contained in:
Undefine 2025-08-12 20:01:28 +02:00 committed by Jelle Raaijmakers
parent 4f8a4c196f
commit 0582c01c89
Notes: github-actions[bot] 2025-11-07 10:29:46 +00:00
4 changed files with 0 additions and 98 deletions

View file

@ -8,7 +8,6 @@
#include <LibTest/TestSuite.h>
#include <AK/FixedArray.h>
#include <AK/NoAllocationGuard.h>
TEST_CASE(construct)
{
@ -55,36 +54,3 @@ TEST_CASE(move)
EXPECT_EQ(moved_to_array.size(), 6u);
EXPECT_EQ(moved_from_array.size(), 0u);
}
TEST_CASE(no_allocation)
{
FixedArray<int> array = FixedArray<int>::must_create_but_fixme_should_propagate_errors(5);
EXPECT_NO_DEATH("Assignments", [&]() {
NoAllocationGuard guard;
array[0] = 0;
array[1] = 1;
array[2] = 2;
array[4] = array[1];
array[3] = array[0] + array[2];
}());
EXPECT_NO_DEATH("Move", [&]() {
FixedArray<int> moved_from_array = FixedArray<int>::must_create_but_fixme_should_propagate_errors(6);
// We need an Optional here to ensure that the NoAllocationGuard is
// destroyed before the moved_to_array, because that would call free
Optional<FixedArray<int>> moved_to_array;
{
NoAllocationGuard guard;
moved_to_array.emplace(move(moved_from_array));
}
}());
EXPECT_NO_DEATH("Swap", [&]() {
FixedArray<int> target_for_swapping;
{
NoAllocationGuard guard;
array.swap(target_for_swapping);
}
}());
}

View file

@ -358,8 +358,6 @@ TEST_CASE(move_assign)
EXPECT_EQ(second.size(), static_cast<size_t>(0));
EXPECT_EQ(second.get(2), Optional<int>());
// 'Hashtable::operator=(Hashtable&&)' allocates temporarily an empty table,
// so we can't use NoAllocationGuard here. :(
second = move(orig);
EXPECT_EQ(orig.size(), static_cast<size_t>(0));