Skip to content

Commit

Permalink
test/assert_regex.bats: Test value boundary matches
Browse files Browse the repository at this point in the history
  • Loading branch information
rico-chet committed May 26, 2022
1 parent 0bd1628 commit 73f9021
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions test/assert_regex.bats
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,44 @@ ERR_MSG
assert_test_pass
}

@test "assert_regex() <value> <pattern>: line breaks do not match '^' and '$'" {
run assert_regex $'one\ntwo' 'one$'
assert_test_fail <<'ERR_MSG'
-- value does not match regular expression --
value (2 lines):
one
two
pattern (1 lines):
one$
--
ERR_MSG

run assert_regex $'one\ntwo' '^two'
assert_test_fail <<'ERR_MSG'
-- value does not match regular expression --
value (2 lines):
one
two
pattern (1 lines):
^two
--
ERR_MSG

run assert_regex $'one\ntwo\n' 'two$'
assert_test_fail <<'ERR_MSG'
-- value does not match regular expression --
value (2 lines):
one
two
pattern (1 lines):
two$
--
ERR_MSG
}

@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 73f9021

Please sign in to comment.