mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
basenc: Test basic functionality
It's good that all encodings already work. Let's make sure they cannot regress!
This commit is contained in:
parent
5a2e0c700e
commit
c6f75c98b7
1 changed files with 142 additions and 0 deletions
|
@ -2,6 +2,8 @@
|
|||
//
|
||||
// For the full copyright and license information, please view the LICENSE
|
||||
// file that was distributed with this source code.
|
||||
|
||||
//spell-checker: ignore (encodings) lsbf msbf
|
||||
use crate::common::util::TestScenario;
|
||||
|
||||
#[test]
|
||||
|
@ -31,3 +33,143 @@ fn test_invalid_input() {
|
|||
.fails()
|
||||
.stderr_only(error_message);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_base64() {
|
||||
new_ucmd!()
|
||||
.arg("--base64")
|
||||
.pipe_in("to>be?")
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_only("dG8+YmU/\n"); // spell-checker:disable-line
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_base64_decode() {
|
||||
new_ucmd!()
|
||||
.args(&["--base64", "-d"])
|
||||
.pipe_in("dG8+YmU/") // spell-checker:disable-line
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_only("to>be?");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_base64url() {
|
||||
new_ucmd!()
|
||||
.arg("--base64url")
|
||||
.pipe_in("to>be?")
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_only("dG8-YmU_\n"); // spell-checker:disable-line
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_base64url_decode() {
|
||||
new_ucmd!()
|
||||
.args(&["--base64url", "-d"])
|
||||
.pipe_in("dG8-YmU_") // spell-checker:disable-line
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_only("to>be?");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_base32() {
|
||||
new_ucmd!()
|
||||
.arg("--base32")
|
||||
.pipe_in("nice>base?")
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_only("NZUWGZJ6MJQXGZJ7\n"); // spell-checker:disable-line
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_base32_decode() {
|
||||
new_ucmd!()
|
||||
.args(&["--base32", "-d"])
|
||||
.pipe_in("NZUWGZJ6MJQXGZJ7") // spell-checker:disable-line
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_only("nice>base?");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_base32hex() {
|
||||
new_ucmd!()
|
||||
.arg("--base32hex")
|
||||
.pipe_in("nice>base?")
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_only("DPKM6P9UC9GN6P9V\n"); // spell-checker:disable-line
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_base32hex_decode() {
|
||||
new_ucmd!()
|
||||
.args(&["--base32hex", "-d"])
|
||||
.pipe_in("DPKM6P9UC9GN6P9V") // spell-checker:disable-line
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_only("nice>base?");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_base16() {
|
||||
new_ucmd!()
|
||||
.arg("--base16")
|
||||
.pipe_in("Hello, World!")
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_only("48656C6C6F2C20576F726C6421\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_base16_decode() {
|
||||
new_ucmd!()
|
||||
.args(&["--base16", "-d"])
|
||||
.pipe_in("48656C6C6F2C20576F726C6421")
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_only("Hello, World!");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_base2msbf() {
|
||||
new_ucmd!()
|
||||
.arg("--base2msbf")
|
||||
.pipe_in("msbf")
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_only("01101101011100110110001001100110\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_base2msbf_decode() {
|
||||
new_ucmd!()
|
||||
.args(&["--base2msbf", "-d"])
|
||||
.pipe_in("01101101011100110110001001100110")
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_only("msbf");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_base2lsbf() {
|
||||
new_ucmd!()
|
||||
.arg("--base2lsbf")
|
||||
.pipe_in("lsbf")
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_only("00110110110011100100011001100110\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_base2lsbf_decode() {
|
||||
new_ucmd!()
|
||||
.args(&["--base2lsbf", "-d"])
|
||||
.pipe_in("00110110110011100100011001100110")
|
||||
.succeeds()
|
||||
.no_stderr()
|
||||
.stdout_only("lsbf");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue