From c28cb7b76c08181487a846a8e0d5bb95db74a6d0 Mon Sep 17 00:00:00 2001 From: Alex Thiessen Date: Thu, 26 May 2022 13:57:26 +0200 Subject: [PATCH] test/assert_regex.bats: Test the error case Ensure behavior in case of invalid regular expression is well-defined. --- test/assert_regex.bats | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/assert_regex.bats b/test/assert_regex.bats index 0d8d1f3..aa3014b 100644 --- a/test/assert_regex.bats +++ b/test/assert_regex.bats @@ -22,3 +22,15 @@ pattern : ^[a-z]b[c-z]+ -- ERR_MSG } + +# Error handling +@test "assert_regex() : returns 1 and displays an error message if 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 +}