From 962fcd71835797eaf1c1d9884296402971db95d3 Mon Sep 17 00:00:00 2001 From: Nathan Ross Date: Mon, 15 Feb 2016 20:38:03 -0500 Subject: [PATCH] base64: tests for incorrect wrap args --- tests/base64.rs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/tests/base64.rs b/tests/base64.rs index 2e977e731..1e9482e2d 100644 --- a/tests/base64.rs +++ b/tests/base64.rs @@ -65,3 +65,30 @@ fn test_wrap() { "VGhlIHF1aWNrIGJyb3du\nIGZveCBqdW1wcyBvdmVy\nIHRoZSBsYXp5IGRvZy4=\n"); } } + +#[test] +fn test_wrap_no_arg() { + for wrap_param in vec!["-w", "--wrap"] { + let (_, mut ucmd) = testing(UTIL_NAME); + let result = ucmd.arg(wrap_param).run(); + + assert!(!result.success); + assert!(result.stdout.len() == 0); + assert_eq!(result.stderr.trim_right(), + format!("base64: error: Argument to option '{}' missing.", + if wrap_param == "-w" { "w" } else { "wrap" })); + } +} + +#[test] +fn test_wrap_bad_arg() { + for wrap_param in vec!["-w", "--wrap"] { + let (_, mut ucmd) = testing(UTIL_NAME); + let result = ucmd.arg(wrap_param).arg("b").run(); + + assert!(!result.success); + assert!(result.stdout.len() == 0); + assert_eq!(result.stderr.trim_right(), + "base64: error: Argument to option 'wrap' improperly formatted: invalid digit found in string"); + } +}