From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master 8/8] test: self: printf: add tests for formatting wide strings
Date: Thu, 20 Mar 2025 06:16:41 +0100 [thread overview]
Message-ID: <20250320051641.1721377-9-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20250320051641.1721377-1-a.fatoum@pengutronix.de>
Let's repeat the same string tests we already have, but with wide (%ls)
strings instead of our normal ones.
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
v1 -> v2:
- new patch
---
test/self/printf.c | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/test/self/printf.c b/test/self/printf.c
index eae40ed242c1..3f35b5514705 100644
--- a/test/self/printf.c
+++ b/test/self/printf.c
@@ -179,6 +179,20 @@ test_string(void)
test(" 1234", "%10.4s", "123456");
}
+static void __init
+test_wstring(void)
+{
+ if (!IS_ENABLED(CONFIG_PRINTF_WCHAR))
+ return;
+
+ test("", "%ls%.0ls", L"", L"123");
+ test("ABCD|abc|123", "%ls|%.3ls|%.*ls", L"ABCD", L"abcdef", 3, L"123456");
+ test("1 | 2|3 | 4|5 ", "%-3ls|%3ls|%-*ls|%*ls|%*ls",
+ L"1", L"2", 3, L"3", 3, L"4", -3, L"5");
+ test("1234 ", "%-10.4ls", L"123456");
+ test(" 1234", "%10.4ls", L"123456");
+}
+
#if BITS_PER_LONG == 64
#define PTR_WIDTH 16
@@ -331,6 +345,7 @@ static void __init test_printf(void)
test_basic();
test_number();
test_string();
+ test_wstring();
test_pointer();
test_hexstr();
test_jsonpath();
--
2.39.5
next prev parent reply other threads:[~2025-03-20 5:17 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-20 5:16 [PATCH master 0/8] treewide: misc fixes Ahmad Fatoum
2025-03-20 5:16 ` [PATCH master 1/8] firmware: disable MISSING_FIRMWARE_ERROR for COMPILE_TEST builds Ahmad Fatoum
2025-03-20 5:16 ` [PATCH master 2/8] include: asm-generic/pointer.h: fix ASM_PTR definition for i386 Ahmad Fatoum
2025-03-20 5:16 ` [PATCH master 3/8] sandbox: do not enable SANDBOX_LINUX_I386 in allyesconfig Ahmad Fatoum
2025-03-20 5:16 ` [PATCH master 4/8] Documentation: devicetree: fix Sphinx warnings Ahmad Fatoum
2025-03-20 5:16 ` [PATCH master 5/8] ARM: mvebu: kwb_bbu: add missing header Ahmad Fatoum
2025-03-20 5:16 ` [PATCH master 6/8] net: phy: fix of_get_phy_mode for XLGMII and beyond Ahmad Fatoum
2025-03-20 5:16 ` [PATCH master 7/8] vsprintf: fix left indentation when formatting wide string arguments Ahmad Fatoum
2025-03-20 5:16 ` Ahmad Fatoum [this message]
2025-03-20 11:46 ` [PATCH master 0/8] treewide: misc fixes Sascha Hauer
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250320051641.1721377-9-a.fatoum@pengutronix.de \
--to=a.fatoum@pengutronix.de \
--cc=barebox@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox