Skip to content

Commit 19c2315

Browse files
committed
printf: add tests for different octal lengths
1 parent e377d2b commit 19c2315

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/by-util/test_printf.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,21 @@ fn escaped_octal_and_newline() {
6969
.stdout_only("\x1F7\n");
7070
}
7171

72+
#[test]
73+
fn variable_sized_octal() {
74+
for x in ["|\\5|", "|\\05|", "|\\005|"] {
75+
new_ucmd!()
76+
.arg(x)
77+
.succeeds()
78+
.stdout_only_bytes([b'|', 5u8, b'|']);
79+
}
80+
81+
new_ucmd!()
82+
.arg("|\\0005|")
83+
.succeeds()
84+
.stdout_only_bytes([b'|', 0, b'5', b'|']);
85+
}
86+
7287
#[test]
7388
fn escaped_unicode_four_digit() {
7489
new_ucmd!().args(&["\\u0125"]).succeeds().stdout_only("ĥ");
@@ -148,6 +163,21 @@ fn sub_b_string_handle_escapes() {
148163
.stdout_only("hello \tworld");
149164
}
150165

166+
#[test]
167+
fn sub_b_string_variable_size_unicode() {
168+
for x in ["\\5|", "\\05|", "\\005|", "\\0005|"] {
169+
new_ucmd!()
170+
.args(&["|%b", x])
171+
.succeeds()
172+
.stdout_only_bytes([b'|', 5u8, b'|']);
173+
}
174+
175+
new_ucmd!()
176+
.args(&["|%b", "\\00005|"])
177+
.succeeds()
178+
.stdout_only_bytes([b'|', 0, b'5', b'|']);
179+
}
180+
151181
#[test]
152182
fn sub_b_string_validate_field_params() {
153183
new_ucmd!()

0 commit comments

Comments
 (0)