From: Heinrich Schuchardt Date: Thu, 29 Dec 2022 13:44:04 +0000 (+0100) Subject: test: unit test for u16_strcasecmp() X-Git-Url: http://git.dujemihanovic.xyz/img/static/gitweb.css?a=commitdiff_plain;h=07355760b1759cc4c8cee402a67f7089b6a06da9;p=u-boot.git test: unit test for u16_strcasecmp() Provide a unit test for u16_strcasecmp(). Signed-off-by: Heinrich Schuchardt --- diff --git a/test/unicode_ut.c b/test/unicode_ut.c index 3547aeffe7..382b796516 100644 --- a/test/unicode_ut.c +++ b/test/unicode_ut.c @@ -624,6 +624,31 @@ static int unicode_test_utf_to_upper(struct unit_test_state *uts) } UNICODE_TEST(unicode_test_utf_to_upper); +static int unicode_test_u16_strcasecmp(struct unit_test_state *uts) +{ + ut_assert(u16_strcasecmp(u"abcd", u"abcd") == 0); + ut_assert(u16_strcasecmp(u"aBcd", u"abcd") == 0); + ut_assert(u16_strcasecmp(u"abcd", u"abCd") == 0); + ut_assert(u16_strcasecmp(u"abcdE", u"abcd") > 0); + ut_assert(u16_strcasecmp(u"abcd", u"abcdE") < 0); + ut_assert(u16_strcasecmp(u"abcE", u"abcd") > 0); + ut_assert(u16_strcasecmp(u"abcd", u"abcE") < 0); + ut_assert(u16_strcasecmp(u"abcd", u"abcd") == 0); + ut_assert(u16_strcasecmp(u"abcd", u"abcd") == 0); + if (CONFIG_IS_ENABLED(EFI_UNICODE_CAPITALIZATION)) { + /* Cyrillic letters */ + ut_assert(u16_strcasecmp(u"\x043a\x043d\x0438\x0433\x0430", + u"\x041a\x041d\x0418\x0413\x0410") == 0); + ut_assert(u16_strcasecmp(u"\x043a\x043d\x0438\x0433\x0430", + u"\x041a\x041d\x0418\x0413\x0411") < 0); + ut_assert(u16_strcasecmp(u"\x043a\x043d\x0438\x0433\x0431", + u"\x041a\x041d\x0418\x0413\x0410") > 0); + } + + return 0; +} +UNICODE_TEST(unicode_test_u16_strcasecmp); + static int unicode_test_u16_strncmp(struct unit_test_state *uts) { ut_assert(u16_strncmp(u"abc", u"abc", 3) == 0);