mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
tests/printf: Fix char_as_byte test, add char and string padding tests
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user