From 88c8451973ea4e70bbe32bef617c68b018a450ed Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Sun, 11 Jul 2021 17:16:13 +0200 Subject: AK: Bring back FixedArray Let's bring this class back, but without the confusing resize() API. A FixedArray is simply a fixed-size array of T. The size is provided at run-time, unlike Array where the size is provided at compile-time. --- Tests/AK/TestFixedArray.cpp | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 Tests/AK/TestFixedArray.cpp (limited to 'Tests/AK/TestFixedArray.cpp') diff --git a/Tests/AK/TestFixedArray.cpp b/Tests/AK/TestFixedArray.cpp new file mode 100644 index 0000000000..6b33818c62 --- /dev/null +++ b/Tests/AK/TestFixedArray.cpp @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2018-2021, Andreas Kling + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include + +#include +#include + +TEST_CASE(construct) +{ + EXPECT(FixedArray().size() == 0); +} + +TEST_CASE(ints) +{ + FixedArray ints(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); + + ints.clear(); + EXPECT_EQ(ints.size(), 0u); +} -- cgit v1.2.3