diff mbox series

[U-Boot,06/15] test: test printing Unicode

Message ID 20180811152820.26817-7-xypron.glpk@gmx.de
State Superseded, archived
Delegated to: Alexander Graf
Headers show
Series efi_loader: EFI_UNICODE_COLLATION_PROTOCOL | expand

Commit Message

Heinrich Schuchardt Aug. 11, 2018, 3:28 p.m. UTC
Test printing of Unicode strings

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 test/unicode_ut.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

Comments

Alexander Graf Aug. 26, 2018, 6:06 p.m. UTC | #1
On 11.08.18 17:28, Heinrich Schuchardt wrote:
> Test printing of Unicode strings
> 
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@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

Does this check the illegal character '?' case as well?


Alex
Heinrich Schuchardt Aug. 26, 2018, 6:36 p.m. UTC | #2
On 08/26/2018 08:06 PM, Alexander Graf wrote:
> 
> 
> On 11.08.18 17:28, Heinrich Schuchardt wrote:
>> Test printing of Unicode strings
>>
>> Signed-off-by: Heinrich Schuchardt <xypron.glpk@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
> 
> Does this check the illegal character '?' case as well?

No. I can add this.

Best regards

Heinrich

> 
> 
> Alex
>
diff mbox series

Patch

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();