Skip to content

Commit 898e6e3

Browse files
committed
docs: documented assert_matches and assert_not_matches
1 parent f746f0c commit 898e6e3

File tree

1 file changed

+62
-0
lines changed

1 file changed

+62
-0
lines changed

README.adoc

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,14 @@ Running tests in tests/test_core.sh
9393
Running test_assert_fails ... SUCCESS
9494
Running test_assert_fails_fails ... SUCCESS
9595
Running test_assert_fails_succeeds ... SUCCESS
96+
Running test_assert_matches_fails_when_not_matching ... SUCCESS
97+
Running test_assert_matches_succeed_when_matching ... SUCCESS
9698
Running test_assert_no_diff_fails_when_diff ... SUCCESS
9799
Running test_assert_no_diff_succeeds_when_no_diff ... SUCCESS
98100
Running test_assert_not_equals_fails_when_equal ... SUCCESS
99101
Running test_assert_not_equals_succeeds_when_not_equal ... SUCCESS
102+
Running test_assert_not_matches_fails_when_matching ... SUCCESS
103+
Running test_assert_not_matches_succeed_when_not_matching ... SUCCESS
100104
Running test_assert_shows_stderr_on_failure ... SUCCESS
101105
Running test_assert_shows_stdout_on_failure ... SUCCESS
102106
Running test_assert_status_code_fails ... SUCCESS
@@ -129,10 +133,14 @@ Running tests in tests/test_core.sh
129133
Running test_assert_fails ... SUCCESS
130134
Running test_assert_fails_fails ... SUCCESS
131135
Running test_assert_fails_succeeds ... SUCCESS
136+
Running test_assert_matches_fails_when_not_matching ... SUCCESS
137+
Running test_assert_matches_succeed_when_matching ... SUCCESS
132138
Running test_assert_no_diff_fails_when_diff ... SUCCESS
133139
Running test_assert_no_diff_succeeds_when_no_diff ... SUCCESS
134140
Running test_assert_not_equals_fails_when_equal ... SUCCESS
135141
Running test_assert_not_equals_succeeds_when_not_equal ... SUCCESS
142+
Running test_assert_not_matches_fails_when_matching ... SUCCESS
143+
Running test_assert_not_matches_succeed_when_not_matching ... SUCCESS
136144
Running test_assert_shows_stderr_on_failure ... SUCCESS
137145
Running test_assert_shows_stdout_on_failure ... SUCCESS
138146
Running test_assert_status_code_fails ... SUCCESS
@@ -156,10 +164,14 @@ ok - test_assert_equals_succeed_when_equal
156164
ok - test_assert_fails
157165
ok - test_assert_fails_fails
158166
ok - test_assert_fails_succeeds
167+
ok - test_assert_matches_fails_when_not_matching
168+
ok - test_assert_matches_succeed_when_matching
159169
ok - test_assert_no_diff_fails_when_diff
160170
ok - test_assert_no_diff_succeeds_when_no_diff
161171
ok - test_assert_not_equals_fails_when_equal
162172
ok - test_assert_not_equals_succeeds_when_not_equal
173+
ok - test_assert_not_matches_fails_when_matching
174+
ok - test_assert_not_matches_succeed_when_not_matching
163175
ok - test_assert_shows_stderr_on_failure
164176
ok - test_assert_shows_stdout_on_failure
165177
ok - test_assert_status_code_fails
@@ -411,6 +423,56 @@ doc:2:test_obvious_equality_with_assert_not_equals()
411423
Running test_obvious_inequality_with_assert_not_equals ... SUCCESS
412424
```
413425

426+
##############################
427+
=== *assert_matches*
428+
429+
assert_matches <expected-regex> <actual> [message]
430+
431+
Asserts that the string _actual_ matches the regex pattern _expected-regex_.
432+
433+
```test
434+
test_obvious_notmatching_with_assert_matches(){
435+
assert_matches "a str.*" "another string" "'another string' should not match 'a str.*'"
436+
}
437+
test_obvious_matching_with_assert_matches(){
438+
assert_matches "a[nN].t{0,1}.*r str.*" "another string"
439+
}
440+
441+
```
442+
443+
```output
444+
Running test_obvious_matching_with_assert_matches ... SUCCESS
445+
Running test_obvious_notmatching_with_assert_matches ... FAILURE
446+
'another string' should not match 'a str.*'
447+
expected regex [a str.*] to match [another string]
448+
doc:2:test_obvious_notmatching_with_assert_matches()
449+
```
450+
451+
=== *assert_not_matches*
452+
453+
assert_not_matches <unexpected-regex> <actual> [message]
454+
455+
Asserts that the string _actual_ does not match the regex pattern _unexpected-regex_.
456+
457+
```test
458+
test_obvious_matching_with_assert_not_matches(){
459+
assert_not_matches "a str.*" "a string" "'a string' should not match 'a str.*'"
460+
}
461+
test_obvious_notmatching_with_assert_not_matches(){
462+
assert_not_matches "a str.*" "another string"
463+
}
464+
465+
```
466+
467+
```output
468+
Running test_obvious_matching_with_assert_not_matches ... FAILURE
469+
'a string' should not match 'a str.*'
470+
expected regex [a str.*] should not match but matched [a string]
471+
doc:2:test_obvious_matching_with_assert_not_matches()
472+
Running test_obvious_notmatching_with_assert_not_matches ... SUCCESS
473+
```
474+
475+
##############################
414476
== *fake* function
415477

416478
fake <command> [replacement code]

0 commit comments

Comments
 (0)