summaryrefslogtreecommitdiff
path: root/source/test/unittests
diff options
context:
space:
mode:
Diffstat (limited to 'source/test/unittests')
-rw-r--r--source/test/unittests/CMakeLists.txt6
-rw-r--r--source/test/unittests/array_ref.test.c23
-rw-r--r--source/test/unittests/string_ref.test.c17
3 files changed, 43 insertions, 3 deletions
diff --git a/source/test/unittests/CMakeLists.txt b/source/test/unittests/CMakeLists.txt
index 75b1f3f..37f7dbb 100644
--- a/source/test/unittests/CMakeLists.txt
+++ b/source/test/unittests/CMakeLists.txt
@@ -1,6 +1,6 @@
target_sources(
${KIT_TEST_SUITE}
PRIVATE
- async_function.test.c main.test.c array_ref.test.c
- input_stream.test.c lower_bound.test.c input_buffer.test.c
- dynamic_array.test.c)
+ async_function.test.c main.test.c string_ref.test.c
+ array_ref.test.c input_stream.test.c lower_bound.test.c
+ input_buffer.test.c dynamic_array.test.c)
diff --git a/source/test/unittests/array_ref.test.c b/source/test/unittests/array_ref.test.c
index d8cbcec..27b754b 100644
--- a/source/test/unittests/array_ref.test.c
+++ b/source/test/unittests/array_ref.test.c
@@ -3,6 +3,29 @@
#define KIT_TEST_FILE array_ref
#include "../../kit_test/test.h"
+TEST("array ref const wrap") {
+ int foo[] = { 1, 2, 3 };
+ AR_CONST_WRAP(ref, foo);
+
+ REQUIRE(ref.size == 3);
+ REQUIRE(ref.values[0] == 1);
+ REQUIRE(ref.values[1] == 2);
+ REQUIRE(ref.values[2] == 3);
+}
+
+TEST("array ref wrap") {
+ int foo[] = { 1, 2, 3 };
+ AR_WRAP(ref, foo);
+
+ REQUIRE(ref.size == 3);
+ REQUIRE(ref.values[0] == 1);
+ REQUIRE(ref.values[1] == 2);
+ REQUIRE(ref.values[2] == 3);
+
+ ref.values[1] = 42;
+ REQUIRE(ref.values[1] == 42);
+}
+
TEST("array ref equal") {
int foo[] = { 1, 2, 3, 4, 5, 6, 7 };
int bar[] = { 3, 4, 5 };
diff --git a/source/test/unittests/string_ref.test.c b/source/test/unittests/string_ref.test.c
new file mode 100644
index 0000000..b89459e
--- /dev/null
+++ b/source/test/unittests/string_ref.test.c
@@ -0,0 +1,17 @@
+#include "../../kit/string_ref.h"
+
+#define KIT_TEST_FILE string_ref
+#include "../../kit_test/test.h"
+
+TEST("static string wrap") {
+ SZ(ref, "foo bar");
+
+ REQUIRE(ref.size == 7);
+ REQUIRE(ref.values[0] == 'f');
+ REQUIRE(ref.values[1] == 'o');
+ REQUIRE(ref.values[2] == 'o');
+ REQUIRE(ref.values[3] == ' ');
+ REQUIRE(ref.values[4] == 'b');
+ REQUIRE(ref.values[5] == 'a');
+ REQUIRE(ref.values[6] == 'r');
+}