summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2022-12-29 14:44:04 +0100
committerHeinrich Schuchardt <heinrich.schuchardt@canonical.com>2023-01-04 13:17:42 +0100
commit07355760b1759cc4c8cee402a67f7089b6a06da9 (patch)
treee668c253bcd6e127b16710f2458e2973759cc784
parent7a9b366cd9b7c1c880fda82509054a06fbac208c (diff)
downloadu-boot-07355760b1759cc4c8cee402a67f7089b6a06da9.tar.gz
u-boot-07355760b1759cc4c8cee402a67f7089b6a06da9.tar.bz2
u-boot-07355760b1759cc4c8cee402a67f7089b6a06da9.zip
test: unit test for u16_strcasecmp()
Provide a unit test for u16_strcasecmp(). Signed-off-by: Heinrich Schuchardt <heinrich.schuchardt@canonical.com>
-rw-r--r--test/unicode_ut.c25
1 files changed, 25 insertions, 0 deletions
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);