mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:58:11 +00:00

FixedArray always *almost* had the following allocation guarantees: There is (possibly) one allocation in the constructor and one (or more) deallocation(s) in the destructor. No other operation allocates or deallocates. With this removal of the public clear() method, which nobody except the test used anyways, those guarantees are now completely true and furthermore fixated with an explanatory comment.
26 lines
515 B
C++
26 lines
515 B
C++
/*
|
|
* Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#include <LibTest/TestSuite.h>
|
|
|
|
#include <AK/FixedArray.h>
|
|
#include <AK/String.h>
|
|
|
|
TEST_CASE(construct)
|
|
{
|
|
EXPECT(FixedArray<int>().size() == 0);
|
|
}
|
|
|
|
TEST_CASE(ints)
|
|
{
|
|
FixedArray<int> ints = FixedArray<int>::must_create_but_fixme_should_propagate_errors(3);
|
|
ints[0] = 0;
|
|
ints[1] = 1;
|
|
ints[2] = 2;
|
|
EXPECT_EQ(ints[0], 0);
|
|
EXPECT_EQ(ints[1], 1);
|
|
EXPECT_EQ(ints[2], 2);
|
|
}
|