summaryrefslogtreecommitdiff
path: root/Tests/AK/TestArray.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'Tests/AK/TestArray.cpp')
-rw-r--r--Tests/AK/TestArray.cpp30
1 files changed, 30 insertions, 0 deletions
diff --git a/Tests/AK/TestArray.cpp b/Tests/AK/TestArray.cpp
new file mode 100644
index 0000000000..440a9935ae
--- /dev/null
+++ b/Tests/AK/TestArray.cpp
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2020, the SerenityOS developers.
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#include <LibTest/TestCase.h>
+
+#include <AK/Array.h>
+
+static constexpr int constexpr_sum(const Span<const int> span)
+{
+ int sum = 0;
+ for (auto value : span)
+ sum += value;
+
+ return sum;
+}
+
+TEST_CASE(compile_time_contructible)
+{
+ constexpr Array<int, 4> array = { 0, 1, 2, 3 };
+ static_assert(array.size() == 4);
+}
+
+TEST_CASE(compile_time_iterable)
+{
+ constexpr Array<int, 8> array = { 0, 1, 2, 3, 4, 5, 6, 7 };
+ static_assert(constexpr_sum(array) == 28);
+}