diff options
author | Mitya Selivanov <0x7fffff@guattari.ru> | 2022-08-07 08:55:32 +0400 |
---|---|---|
committer | Mitya Selivanov <0x7fffff@guattari.ru> | 2022-08-07 08:55:32 +0400 |
commit | 05630cf10cc01a237131989248261149f03fc8ab (patch) | |
tree | afc81a3f916b7b47021515f93fe426f3e45bc670 /source/test | |
parent | 4429ed09b548518dbffce7ec77ddf5a8b09484b2 (diff) | |
download | kit-05630cf10cc01a237131989248261149f03fc8ab.zip |
static array wrap, static string wrap
Diffstat (limited to 'source/test')
-rw-r--r-- | source/test/unittests/CMakeLists.txt | 6 | ||||
-rw-r--r-- | source/test/unittests/array_ref.test.c | 23 | ||||
-rw-r--r-- | source/test/unittests/string_ref.test.c | 17 |
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'); +} |