Skip to content

Commit

Permalink
expr: add tests for precise error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
pawelngei committed Nov 20, 2023
1 parent b0c6efd commit 0300874
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions tests/by-util/test_expr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down

0 comments on commit 0300874

Please sign in to comment.