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

base32/base64: handle two corner cases

* no padding
* --wrap 0

+ remove property_tests.rs, we don't need such tests as the
code is already tests by test_base* (+ it is too dependant
on the code structure)

Should make base64.pl pass
This commit is contained in:
Sylvestre Ledru 2024-12-04 22:02:57 +01:00
parent d9ccbcdf18
commit 93dfc933bd
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]