[U-Boot] [PATCH 06/15] test: test printing Unicode
Heinrich Schuchardt
xypron.glpk at gmx.de
Sat Aug 11 15:28:11 UTC 2018
Test printing of Unicode strings
Signed-off-by: Heinrich Schuchardt <xypron.glpk at gmx.de>
---
test/unicode_ut.c | 37 +++++++++++++++++++++++++++++++++++++
1 file changed, 37 insertions(+)
diff --git a/test/unicode_ut.c b/test/unicode_ut.c
index 29316606c4..8e8c4d189e 100644
--- a/test/unicode_ut.c
+++ b/test/unicode_ut.c
@@ -34,6 +34,42 @@ static const char d3[] = {0xe6, 0xbd, 0x9c, 0xe6, 0xb0, 0xb4, 0xe8, 0x89,
static const char d4[] = {0xf0, 0x90, 0x92, 0x8d, 0xf0, 0x90, 0x92, 0x96,
0xf0, 0x90, 0x92, 0x87, 0x00};
+static int ut_string16(void)
+{
+#if defined(CONFIG_EFI_LOADER) && \
+ !defined(CONFIG_SPL_BUILD) && !defined(API_BUILD)
+ char buf[20];
+
+ memset(buf, 0xff, sizeof(buf));
+ sprintf(buf, "%8.6ls", c2);
+ if (buf[1] != ' ')
+ return -1;
+ if (strncmp(&buf[2], d2, 7))
+ return -1;
+ if (buf[9])
+ return -1;
+
+ memset(buf, 0xff, sizeof(buf));
+ sprintf(buf, "%8.6ls", c4);
+ if (buf[4] != ' ')
+ return -1;
+ if (strncmp(&buf[5], d4, 12))
+ return -1;
+ if (buf[17])
+ return -1;
+
+ memset(buf, 0xff, sizeof(buf));
+ sprintf(buf, "%-8.2ls", c4);
+ if (strncmp(buf, d4, 8))
+ return -1;
+ if (buf[8] != ' ')
+ return -1;
+ if (buf[14])
+ return -1;
+#endif
+ return 0;
+}
+
static int ut_utf8_get(void)
{
const char *s;
@@ -451,6 +487,7 @@ int do_ut_unicode(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
{
int ret = 0;
+ ret |= ut_string16();
ret |= ut_utf8_get();
ret |= ut_utf8_put();
ret |= ut_utf8_utf16_strlen();
--
2.18.0
More information about the U-Boot
mailing list