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

basenc: perform faster, streaming encoding

Improve the performance, both in memory and time, of the encoding
performed by the basenc (except in --z85 mode), base32, and base64
programs.

These programs now perform encoding in a buffered/streaming manner,
so encoding is not constrained by the amount of available memory.
This commit is contained in:
Andrew Liebenow 2024-09-20 14:34:18 -05:00
parent 50f99580b4
commit 846cf06272
4 changed files with 416 additions and 63 deletions

View file

@ -146,3 +146,36 @@ fn test_base64_file_not_found() {
.fails()
.stderr_only("base64: a.txt: No such file or directory\n");
}
#[test]
fn test_no_repeated_trailing_newline() {
new_ucmd!()
.args(&["--wrap", "10", "--", "-"])
.pipe_in("The quick brown fox jumps over the lazy dog.")
.succeeds()
.stdout_only(
"\
VGhlIHF1aW
NrIGJyb3du
IGZveCBqdW
1wcyBvdmVy
IHRoZSBsYX
p5IGRvZy4=
",
);
}
#[test]
fn test_wrap_default() {
new_ucmd!()
.args(&["--", "-"])
.pipe_in("The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog. The quick brown fox jumps over the lazy dog.")
.succeeds()
.stdout_only(
"\
VGhlIHF1aWNrIGJyb3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZy4gVGhlIHF1aWNrIGJy
b3duIGZveCBqdW1wcyBvdmVyIHRoZSBsYXp5IGRvZy4gVGhlIHF1aWNrIGJyb3duIGZveCBqdW1w
cyBvdmVyIHRoZSBsYXp5IGRvZy4=
",
);
}