From 328cf4d91b53a92e13a2494beaeea25bf4b114ce Mon Sep 17 00:00:00 2001 From: sbentmar Date: Sat, 15 Jan 2022 11:42:48 +0100 Subject: [PATCH] numfmt: add more negative tests --- tests/by-util/test_numfmt.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/tests/by-util/test_numfmt.rs b/tests/by-util/test_numfmt.rs index 9b1b91ed7..c7dea620c 100644 --- a/tests/by-util/test_numfmt.rs +++ b/tests/by-util/test_numfmt.rs @@ -570,6 +570,25 @@ fn test_suffix_with_padding() { } #[test] -fn test_invalid_number_returns_status_2() { +fn test_invalid_stdin_number_returns_status_2() { new_ucmd!().pipe_in("hello").fails().code_is(2); } + +#[test] +fn test_invalid_stdin_number_in_middle_of_input() { + new_ucmd!().pipe_in("100\nhello\n200").fails().code_is(2); +} + +#[test] +fn test_invalid_argument_number_returns_status_2() { + new_ucmd!().args(&["hello"]).fails().code_is(2); +} + +#[test] +fn test_invalid_argument_returns_status_1() { + new_ucmd!() + .args(&["--header=hello"]) + .pipe_in("53478") + .fails() + .code_is(1); +}