diff --git a/tests/by-util/test_printf.rs b/tests/by-util/test_printf.rs index 46340c28e..531e527bc 100644 --- a/tests/by-util/test_printf.rs +++ b/tests/by-util/test_printf.rs @@ -673,7 +673,11 @@ fn sub_alternative_upper_hex() { #[test] fn char_as_byte() { - new_ucmd!().args(&["%c", "🙃"]).succeeds().stdout_only("ð"); + new_ucmd!() + .args(&["%c", "🙃"]) + .succeeds() + .no_stderr() + .stdout_is_bytes(b"\xf0"); } #[test] @@ -736,3 +740,34 @@ fn pad_unsigned_three() { .stdout_only(expected); } } + +#[test] +fn pad_char() { + for (format, expected) in [ + ("%3c", " X"), + ("%1c", "X"), + ("%-1c", "X"), + ("%-3c", "X "), + ] { + new_ucmd!() + .args(&[format, "X"]) + .succeeds() + .stdout_only(expected); + } +} + + +#[test] +fn pad_string() { + for (format, expected) in [ + ("%8s", " bottle"), + ("%-8s", "bottle "), + ("%6s", "bottle"), + ("%-6s", "bottle"), + ] { + new_ucmd!() + .args(&[format, "bottle"]) + .succeeds() + .stdout_only(expected); + } +} \ No newline at end of file