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:
parent
18c9da349c
commit
5d74a6e002
1 changed files with 36 additions and 1 deletions
|
@ -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);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue