]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
test: add unit test for u16_strnlen()
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Sun, 18 Dec 2022 05:32:14 +0000 (05:32 +0000)
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>
Tue, 20 Dec 2022 15:06:48 +0000 (16:06 +0100)
Add the missing unit test. It can be executed with:

    ut unicode u16_strnlen

Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
Reviewed-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
test/unicode_ut.c

index d104bd5997feb11f7ba4e0de47ef68fba0bbf2d9..3547aeffe79d15bfbcd4def4ecf6c29207833397 100644 (file)
@@ -67,6 +67,17 @@ static int unicode_test_u16_strlen(struct unit_test_state *uts)
 }
 UNICODE_TEST(unicode_test_u16_strlen);
 
+static int unicode_test_u16_strnlen(struct unit_test_state *uts)
+{
+       ut_asserteq(0, u16_strnlen(c1, 0));
+       ut_asserteq(4, u16_strnlen(c1, 4));
+       ut_asserteq(6, u16_strnlen(c1, 6));
+       ut_asserteq(6, u16_strnlen(c1, 7));
+
+       return 0;
+}
+UNICODE_TEST(unicode_test_u16_strnlen);
+
 static int unicode_test_u16_strdup(struct unit_test_state *uts)
 {
        u16 *copy = u16_strdup(c4);