Skip to content

Commit

Permalink
test/assert_regex.bats: Test BASH_REMATCH availability
Browse files Browse the repository at this point in the history
  • Loading branch information
rico-chet committed May 28, 2022
1 parent d85966e commit 03bc04c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/assert_regex.bats
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ pattern : ^[a-z]b[c-z]+
ERR_MSG
}

@test "assert_regex() <value> <pattern>: provides results in BASH_REMATCH" {
unset -v BASH_REMATCH

assert_regex 'abcd' 'b.d'
declare -p BASH_REMATCH
[ "${BASH_REMATCH[0]}" = 'bcd' ]
}

@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'
Expand Down

0 comments on commit 03bc04c

Please sign in to comment.