From 18380bea869c307c0ecf6fe4fa5801e5540bec4e Mon Sep 17 00:00:00 2001 From: dzwdz Date: Tue, 3 Aug 2021 19:01:43 +0200 Subject: kernel: implement static_strcmp() will be used to test functions operating on strings --- src/kernel/tests/util.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/kernel/tests') diff --git a/src/kernel/tests/util.c b/src/kernel/tests/util.c index 5bc8656..81c36d6 100644 --- a/src/kernel/tests/util.c +++ b/src/kernel/tests/util.c @@ -21,6 +21,19 @@ TEST(memcmp) { TEST_IF(0 < memcmp("654", "555", 3)); } +TEST(static_strcmp) { + TEST_IF(0 == static_strcmp("", "")); + TEST_IF(0 == static_strcmp("same", "same")); + + TEST_IF(0 != static_strcmp("same", "diff")); + TEST_IF(0 != static_strcmp("same!", "same")); + TEST_IF(0 != static_strcmp("same", "same!")); + + TEST_IF(0 > static_strcmp("555", "654")); + TEST_IF(0 < static_strcmp("654", "555")); +} + void tests_utils() { TEST_RUN(memcmp); + TEST_RUN(static_strcmp); } -- cgit v1.2.3