|
2 | 2 | .\" Title: bash_unit
|
3 | 3 | .\" Author: [see the "AUTHOR(S)" section]
|
4 | 4 | .\" Generator: Asciidoctor 2.0.16
|
5 |
| -.\" Date: 2021-11-07 |
| 5 | +.\" Date: 2022-01-01 |
6 | 6 | .\" Manual: \ \&
|
7 | 7 | .\" Source: \ \&
|
8 | 8 | .\" Language: English
|
9 | 9 | .\"
|
10 |
| -.TH "BASH_UNIT" "1" "2021-11-07" "\ \&" "\ \&" |
| 10 | +.TH "BASH_UNIT" "1" "2022-01-01" "\ \&" "\ \&" |
11 | 11 | .ie \n(.g .ds Aq \(aq
|
12 | 12 | .el .ds Aq '
|
13 | 13 | .ss \n[.ss] 0
|
@@ -89,10 +89,14 @@ Running tests in tests/test_core.sh
|
89 | 89 | Running test_assert_fails ... SUCCESS
|
90 | 90 | Running test_assert_fails_fails ... SUCCESS
|
91 | 91 | Running test_assert_fails_succeeds ... SUCCESS
|
| 92 | + Running test_assert_matches_fails_when_not_matching ... SUCCESS |
| 93 | + Running test_assert_matches_succeed_when_matching ... SUCCESS |
92 | 94 | Running test_assert_no_diff_fails_when_diff ... SUCCESS
|
93 | 95 | Running test_assert_no_diff_succeeds_when_no_diff ... SUCCESS
|
94 | 96 | Running test_assert_not_equals_fails_when_equal ... SUCCESS
|
95 | 97 | Running test_assert_not_equals_succeeds_when_not_equal ... SUCCESS
|
| 98 | + Running test_assert_not_matches_fails_when_matching ... SUCCESS |
| 99 | + Running test_assert_not_matches_succeed_when_not_matching ... SUCCESS |
96 | 100 | Running test_assert_shows_stderr_on_failure ... SUCCESS
|
97 | 101 | Running test_assert_shows_stdout_on_failure ... SUCCESS
|
98 | 102 | Running test_assert_status_code_fails ... SUCCESS
|
@@ -133,10 +137,14 @@ Running tests in tests/test_core.sh
|
133 | 137 | Running test_assert_fails ... SUCCESS
|
134 | 138 | Running test_assert_fails_fails ... SUCCESS
|
135 | 139 | Running test_assert_fails_succeeds ... SUCCESS
|
| 140 | + Running test_assert_matches_fails_when_not_matching ... SUCCESS |
| 141 | + Running test_assert_matches_succeed_when_matching ... SUCCESS |
136 | 142 | Running test_assert_no_diff_fails_when_diff ... SUCCESS
|
137 | 143 | Running test_assert_no_diff_succeeds_when_no_diff ... SUCCESS
|
138 | 144 | Running test_assert_not_equals_fails_when_equal ... SUCCESS
|
139 | 145 | Running test_assert_not_equals_succeeds_when_not_equal ... SUCCESS
|
| 146 | + Running test_assert_not_matches_fails_when_matching ... SUCCESS |
| 147 | + Running test_assert_not_matches_succeed_when_not_matching ... SUCCESS |
140 | 148 | Running test_assert_shows_stderr_on_failure ... SUCCESS
|
141 | 149 | Running test_assert_shows_stdout_on_failure ... SUCCESS
|
142 | 150 | Running test_assert_status_code_fails ... SUCCESS
|
@@ -170,10 +178,14 @@ ok \- test_assert_equals_succeed_when_equal
|
170 | 178 | ok \- test_assert_fails
|
171 | 179 | ok \- test_assert_fails_fails
|
172 | 180 | ok \- test_assert_fails_succeeds
|
| 181 | +ok \- test_assert_matches_fails_when_not_matching |
| 182 | +ok \- test_assert_matches_succeed_when_matching |
173 | 183 | ok \- test_assert_no_diff_fails_when_diff
|
174 | 184 | ok \- test_assert_no_diff_succeeds_when_no_diff
|
175 | 185 | ok \- test_assert_not_equals_fails_when_equal
|
176 | 186 | ok \- test_assert_not_equals_succeeds_when_not_equal
|
| 187 | +ok \- test_assert_not_matches_fails_when_matching |
| 188 | +ok \- test_assert_not_matches_succeed_when_not_matching |
177 | 189 | ok \- test_assert_shows_stderr_on_failure
|
178 | 190 | ok \- test_assert_shows_stdout_on_failure
|
179 | 191 | ok \- test_assert_status_code_fails
|
@@ -518,7 +530,83 @@ doc:2:test_obvious_equality_with_assert_not_equals()
|
518 | 530 | .fam
|
519 | 531 | .fi
|
520 | 532 | .if n .RE
|
521 |
| -.SH "\fBFAKE\fP FUNCTION" |
| 533 | +.sp |
| 534 | +#### |
| 535 | +=== \fBassert_matches\fP |
| 536 | +.sp |
| 537 | +.if n .RS 4 |
| 538 | +.nf |
| 539 | +.fam C |
| 540 | +assert_matches <expected\-regex> <actual> [message] |
| 541 | +.fam |
| 542 | +.fi |
| 543 | +.if n .RE |
| 544 | +.sp |
| 545 | +Asserts that the string \fIactual\fP matches the regex pattern \fIexpected\-regex\fP. |
| 546 | +.sp |
| 547 | +.if n .RS 4 |
| 548 | +.nf |
| 549 | +.fam C |
| 550 | +test_obvious_notmatching_with_assert_matches(){ |
| 551 | + assert_matches "a str.*" "another string" "\*(Aqanother string\*(Aq should not match \*(Aqa str.*\*(Aq" |
| 552 | +} |
| 553 | +test_obvious_matching_with_assert_matches(){ |
| 554 | + assert_matches "a[nN].t{0,1}.*r str.*" "another string" |
| 555 | +} |
| 556 | +.fam |
| 557 | +.fi |
| 558 | +.if n .RE |
| 559 | +.sp |
| 560 | +.if n .RS 4 |
| 561 | +.nf |
| 562 | +.fam C |
| 563 | + Running test_obvious_matching_with_assert_matches ... SUCCESS |
| 564 | + Running test_obvious_notmatching_with_assert_matches ... FAILURE |
| 565 | +\*(Aqanother string\*(Aq should not match \*(Aqa str.*\*(Aq |
| 566 | + expected regex [a str.*] to match [another string] |
| 567 | +doc:2:test_obvious_notmatching_with_assert_matches() |
| 568 | +.fam |
| 569 | +.fi |
| 570 | +.if n .RE |
| 571 | +.SS "\fBassert_not_matches\fP" |
| 572 | +.sp |
| 573 | +.if n .RS 4 |
| 574 | +.nf |
| 575 | +.fam C |
| 576 | +assert_not_matches <unexpected\-regex> <actual> [message] |
| 577 | +.fam |
| 578 | +.fi |
| 579 | +.if n .RE |
| 580 | +.sp |
| 581 | +Asserts that the string \fIactual\fP does not match the regex pattern \fIunexpected\-regex\fP. |
| 582 | +.sp |
| 583 | +.if n .RS 4 |
| 584 | +.nf |
| 585 | +.fam C |
| 586 | +test_obvious_matching_with_assert_not_matches(){ |
| 587 | + assert_not_matches "a str.*" "a string" "\*(Aqa string\*(Aq should not match \*(Aqa str.*\*(Aq" |
| 588 | +} |
| 589 | +test_obvious_notmatching_with_assert_not_matches(){ |
| 590 | + assert_not_matches "a str.*" "another string" |
| 591 | +} |
| 592 | +.fam |
| 593 | +.fi |
| 594 | +.if n .RE |
| 595 | +.sp |
| 596 | +.if n .RS 4 |
| 597 | +.nf |
| 598 | +.fam C |
| 599 | + Running test_obvious_matching_with_assert_not_matches ... FAILURE |
| 600 | +\*(Aqa string\*(Aq should not match \*(Aqa str.*\*(Aq |
| 601 | + expected regex [a str.*] should not match but matched [a string] |
| 602 | +doc:2:test_obvious_matching_with_assert_not_matches() |
| 603 | + Running test_obvious_notmatching_with_assert_not_matches ... SUCCESS |
| 604 | +.fam |
| 605 | +.fi |
| 606 | +.if n .RE |
| 607 | +.sp |
| 608 | +#### |
| 609 | +== \fBfake\fP function |
522 | 610 | .sp
|
523 | 611 | .if n .RS 4
|
524 | 612 | .nf
|
|
0 commit comments