Skip to content

Commit

Permalink
test/assert_regex.bats: Test multi-line failure output
Browse files Browse the repository at this point in the history
  • Loading branch information
rico-chet committed May 26, 2022
1 parent f4caa5b commit 70b16fd
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions test/assert_regex.bats
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,20 @@ ERR_MSG
assert_test_pass
}

@test "assert_regex() <value> <pattern>: outputs multi-line <value> nicely when it fails" {
run assert_regex $'bcd\n123' '^[a-z]b[c-z]+'
assert_test_fail <<'ERR_MSG'
-- value does not match regular expression --
value (2 lines):
bcd
123
pattern (1 lines):
^[a-z]b[c-z]+
--
ERR_MSG
}

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

0 comments on commit 70b16fd

Please sign in to comment.