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

Merge pull request #6906 from sylvestre/base-wrap

base32/base64: handle two corner cases
This commit is contained in:
Daniel Hofstetter 2024-12-09 13:55:15 +01:00 committed by GitHub
commit 2a9e7c937a
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 145 additions and 540 deletions

View file

@ -40,6 +40,28 @@ fn test_encode_repeat_flags_later_wrap_15() {
.stdout_only("aGVsbG8sIHdvcmx\nkIQ==\n"); // spell-checker:disable-line
}
#[test]
fn test_decode_short() {
let input = "aQ";
new_ucmd!()
.args(&["--decode"])
.pipe_in(input)
.succeeds()
.stdout_only("i");
}
#[test]
fn test_multi_lines() {
let input = ["aQ\n\n\n", "a\nQ==\n\n\n"];
for i in input {
new_ucmd!()
.args(&["--decode"])
.pipe_in(i)
.succeeds()
.stdout_only("i");
}
}
#[test]
fn test_base64_encode_file() {
new_ucmd!()
@ -105,6 +127,17 @@ fn test_wrap() {
// spell-checker:disable-next-line
.stdout_only("VGhlIHF1aWNrIGJyb3du\nIGZveCBqdW1wcyBvdmVy\nIHRoZSBsYXp5IGRvZy4=\n");
}
let input = "hello, world";
new_ucmd!()
.args(&["--wrap", "0"])
.pipe_in(input)
.succeeds()
.stdout_only("aGVsbG8sIHdvcmxk"); // spell-checker:disable-line
new_ucmd!()
.args(&["--wrap", "30"])
.pipe_in(input)
.succeeds()
.stdout_only("aGVsbG8sIHdvcmxk\n"); // spell-checker:disable-line
}
#[test]