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

printf: pad octal numbers with zeros on the left

This commit is contained in:
Terts Diepraam 2024-02-07 12:38:25 +01:00 committed by Daniel Hofstetter
parent d4ee5ebc85
commit 4dae902429
2 changed files with 33 additions and 3 deletions

View file

@ -680,3 +680,31 @@ fn char_as_byte() {
fn no_infinite_loop() {
new_ucmd!().args(&["a", "b"]).succeeds().stdout_only("a");
}
#[test]
fn pad_octal_with_prefix() {
new_ucmd!()
.args(&[">%#15.6o<", "0"])
.succeeds()
.stdout_only("> 000000<");
new_ucmd!()
.args(&[">%#15.6o<", "01"])
.succeeds()
.stdout_only("> 000001<");
new_ucmd!()
.args(&[">%#15.6o<", "01234"])
.succeeds()
.stdout_only("> 001234<");
new_ucmd!()
.args(&[">%#15.6o<", "012345"])
.succeeds()
.stdout_only("> 012345<");
new_ucmd!()
.args(&[">%#15.6o<", "0123456"])
.succeeds()
.stdout_only("> 0123456<");
}