Skip to content

Commit

Permalink
test/assert_regex.bats: Test the error case
Browse files Browse the repository at this point in the history
Ensure behavior in case of invalid regular expression is well-defined.
  • Loading branch information
rico-chet committed May 26, 2022
1 parent cea9bff commit c28cb7b
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions test/assert_regex.bats
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,15 @@ pattern : ^[a-z]b[c-z]+
--
ERR_MSG
}

# Error handling
@test "assert_regex() <value> <pattern>: returns 1 and displays an error message if <regexp> is not a valid extended regular expression" {
run assert_output --regexp '[.*'

assert_test_fail <<'ERR_MSG'
-- ERROR: assert_regex --
Invalid extended regular expression: `[.*'
--
ERR_MSG
}

0 comments on commit c28cb7b

Please sign in to comment.