Serenity Operating System
at master 30 lines 591 B view raw
1/* 2 * Copyright (c) 2020, the SerenityOS developers. 3 * 4 * SPDX-License-Identifier: BSD-2-Clause 5 */ 6 7#include <LibTest/TestCase.h> 8 9#include <AK/Array.h> 10 11static constexpr int constexpr_sum(ReadonlySpan<int> const span) 12{ 13 int sum = 0; 14 for (auto value : span) 15 sum += value; 16 17 return sum; 18} 19 20TEST_CASE(compile_time_constructible) 21{ 22 constexpr Array<int, 4> array = { 0, 1, 2, 3 }; 23 static_assert(array.size() == 4); 24} 25 26TEST_CASE(compile_time_iterable) 27{ 28 constexpr Array<int, 8> array = { 0, 1, 2, 3, 4, 5, 6, 7 }; 29 static_assert(constexpr_sum(array) == 28); 30}