From 3b884966ac207107feb12a831e63083d746b06cb Mon Sep 17 00:00:00 2001 From: Marras Antoine Date: Mon, 8 Jan 2024 14:30:56 +0100 Subject: [PATCH] printf: added failing tests on alternative hex form --- tests/by-util/test_printf.rs | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/tests/by-util/test_printf.rs b/tests/by-util/test_printf.rs index 48fc1e6ac..f162df490 100644 --- a/tests/by-util/test_printf.rs +++ b/tests/by-util/test_printf.rs @@ -639,3 +639,29 @@ fn partial_char() { "printf: warning: bc: character(s) following character constant have been ignored\n", ); } + +#[test] +fn sub_alternative_lower_hex_0() { + new_ucmd!().args(&["%#x", "0"]).succeeds().stdout_only("0"); +} + +#[test] +fn sub_alternative_lower_hex() { + new_ucmd!() + .args(&["%#x", "42"]) + .succeeds() + .stdout_only("0x2a"); +} + +#[test] +fn sub_alternative_upper_hex_0() { + new_ucmd!().args(&["%#X", "0"]).succeeds().stdout_only("0"); +} + +#[test] +fn sub_alternative_upper_hex() { + new_ucmd!() + .args(&["%#X", "42"]) + .succeeds() + .stdout_only("0x2A"); +}