From 030087459dd9c8b58e8138345b5c70534a5f33b6 Mon Sep 17 00:00:00 2001 From: ALXD Date: Mon, 20 Nov 2023 14:29:06 +0100 Subject: [PATCH] expr: add tests for precise error messages --- tests/by-util/test_expr.rs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/by-util/test_expr.rs b/tests/by-util/test_expr.rs index 28cfcf0ec90..18125fe99dd 100644 --- a/tests/by-util/test_expr.rs +++ b/tests/by-util/test_expr.rs @@ -6,6 +6,14 @@ use crate::common::util::TestScenario; +#[test] +fn test_no_arguments() { + new_ucmd!() + .fails() + .code_is(2) + .stderr_only("expr: missing operand\n"); +} + #[test] fn test_simple_values() { // null or 0 => EXIT_VALUE == 1 @@ -275,6 +283,12 @@ fn test_substr() { #[test] fn test_invalid_substr() { + new_ucmd!() + .args(&["56", "substr"]) + .fails() + .code_is(2) + .stderr_only("expr: syntax error: unexpected argument 'substr'\n"); + new_ucmd!() .args(&["substr", "abc", "0", "1"]) .fails()