mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 18:28:12 +00:00
AK: Add to_array()
This is useful if you want an array with an explicit type but still want its size to be inferred.
This commit is contained in:
parent
10216e1743
commit
d84b69ace9
2 changed files with 24 additions and 0 deletions
|
@ -46,3 +46,12 @@ TEST_CASE(first_index_of)
|
|||
EXPECT(array.first_index_of(7) == 7u);
|
||||
EXPECT(!array.first_index_of(42).has_value());
|
||||
}
|
||||
|
||||
TEST_CASE(to_array)
|
||||
{
|
||||
constexpr auto array = to_array<u8>({ 0, 2, 1 });
|
||||
static_assert(array.size() == 3);
|
||||
static_assert(array[0] == 0);
|
||||
static_assert(array[1] == 2);
|
||||
static_assert(array[2] == 1);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue