1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 03:27:44 +00:00

tests/printf: Fix char_as_byte test, add char and string padding tests

This commit is contained in:
Dorian Péron 2024-02-29 00:43:47 +01:00
parent 18c9da349c
commit 5d74a6e002

View file

@ -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);
}
}