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

base64: in tests, test both option forms

This commit is contained in:
Nathan Ross 2016-02-15 19:06:30 -05:00
parent 1c1cf2446e
commit 2bad30b2b0

View file

@ -18,14 +18,16 @@ fn test_encode() {
#[test] #[test]
fn test_decode() { fn test_decode() {
for decode_param in vec!["-d", "--decode"] {
let (_, mut ucmd) = testing(UTIL_NAME); let (_, mut ucmd) = testing(UTIL_NAME);
let input = "aGVsbG8sIHdvcmxkIQ=="; let input = "aGVsbG8sIHdvcmxkIQ==";
let result = ucmd.arg("-d").run_piped_stdin(input.as_bytes()); let result = ucmd.arg(decode_param).run_piped_stdin(input.as_bytes());
assert_empty_stderr!(result); assert_empty_stderr!(result);
assert!(result.success); assert!(result.success);
assert_eq!(result.stdout, "hello, world!"); assert_eq!(result.stdout, "hello, world!");
} }
}
#[test] #[test]
fn test_garbage() { fn test_garbage() {
@ -40,23 +42,26 @@ fn test_garbage() {
#[test] #[test]
fn test_ignore_garbage() { fn test_ignore_garbage() {
for ignore_garbage_param in vec!["-i", "--ignore-garbage"] {
let (_, mut ucmd) = testing(UTIL_NAME); let (_, mut ucmd) = testing(UTIL_NAME);
let input = "aGVsbG8sIHdvcmxkIQ==\0"; let input = "aGVsbG8sIHdvcmxkIQ==\0";
let result = ucmd.arg("-d").arg("-i").run_piped_stdin(input.as_bytes()); let result = ucmd.arg("-d").arg(ignore_garbage_param).run_piped_stdin(input.as_bytes());
assert_empty_stderr!(result); assert_empty_stderr!(result);
assert!(result.success); assert!(result.success);
assert_eq!(result.stdout, "hello, world!"); assert_eq!(result.stdout, "hello, world!");
} }
}
#[test] #[test]
fn test_wrap() { fn test_wrap() {
for wrap_param in vec!["-w", "--wrap"] {
let (_, mut ucmd) = testing(UTIL_NAME); let (_, mut ucmd) = testing(UTIL_NAME);
let input = "The quick brown fox jumps over the lazy dog."; let input = "The quick brown fox jumps over the lazy dog.";
let result = ucmd.arg("-w").arg("20").run_piped_stdin(input.as_bytes()); let result = ucmd.arg(wrap_param).arg("20").run_piped_stdin(input.as_bytes());
assert_empty_stderr!(result); assert_empty_stderr!(result);
assert!(result.success); assert!(result.success);
assert_eq!(result.stdout, assert_eq!(result.stdout,
"VGhlIHF1aWNrIGJyb3du\nIGZveCBqdW1wcyBvdmVy\nIHRoZSBsYXp5IGRvZy4=\n"); "VGhlIHF1aWNrIGJyb3du\nIGZveCBqdW1wcyBvdmVy\nIHRoZSBsYXp5IGRvZy4=\n");
} }
}