aboutsummaryrefslogtreecommitdiff
path: root/test/unicode_ut.c
diff options
context:
space:
mode:
authorHeinrich Schuchardt <xypron.glpk@gmx.de>2021-02-27 14:08:36 +0100
committerHeinrich Schuchardt <xypron.glpk@gmx.de>2021-03-07 17:37:13 +0100
commit73bb90cabcdffcd528d1002a12779779196bf200 (patch)
tree5c4fb2a3ebecf079f4cadacc41aa9e45354e69a0 /test/unicode_ut.c
parent70616a1ed8c7fe22aa19eb674915623bd236926f (diff)
downloadu-boot-73bb90cabcdffcd528d1002a12779779196bf200.zip
u-boot-73bb90cabcdffcd528d1002a12779779196bf200.tar.gz
u-boot-73bb90cabcdffcd528d1002a12779779196bf200.tar.bz2
efi_loader: carve out utf_to_cp()
Carve out a function to translate a Unicode code point to an 8bit codepage. Provide a unit test for the new function. Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
Diffstat (limited to 'test/unicode_ut.c')
-rw-r--r--test/unicode_ut.c29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/unicode_ut.c b/test/unicode_ut.c
index 6130ef0..2cc6b5f 100644
--- a/test/unicode_ut.c
+++ b/test/unicode_ut.c
@@ -595,6 +595,35 @@ static int unicode_test_u16_strsize(struct unit_test_state *uts)
}
UNICODE_TEST(unicode_test_u16_strsize);
+static int unicode_test_utf_to_cp(struct unit_test_state *uts)
+{
+ int ret;
+ s32 c;
+
+ c = '\n';
+ ret = utf_to_cp(&c, codepage_437);
+ ut_asserteq(0, ret);
+ ut_asserteq('\n', c);
+
+ c = 'a';
+ ret = utf_to_cp(&c, codepage_437);
+ ut_asserteq(0, ret);
+ ut_asserteq('a', c);
+
+ c = 0x03c4; /* Greek small letter tau */
+ ret = utf_to_cp(&c, codepage_437);
+ ut_asserteq(0, ret);
+ ut_asserteq(0xe7, c);
+
+ c = 0x03a4; /* Greek capital letter tau */
+ ret = utf_to_cp(&c, codepage_437);
+ ut_asserteq(-ENOENT, ret);
+ ut_asserteq('?', c);
+
+ return 0;
+}
+UNICODE_TEST(unicode_test_utf_to_cp);
+
#ifdef CONFIG_EFI_LOADER
static int unicode_test_efi_create_indexed_name(struct unit_test_state *uts)
{