|
1 | 1 | '\" t |
2 | 2 | .\" Title: bash_unit |
3 | 3 | .\" Author: [see the "AUTHOR(S)" section] |
4 | | -.\" Generator: Asciidoctor 2.0.17 |
5 | | -.\" Date: 2022-09-28 |
| 4 | +.\" Generator: Asciidoctor 2.0.18 |
| 5 | +.\" Date: 2023-03-03 |
6 | 6 | .\" Manual: \ \& |
7 | 7 | .\" Source: \ \& |
8 | 8 | .\" Language: English |
9 | 9 | .\" |
10 | | -.TH "BASH_UNIT" "1" "2022-09-28" "\ \&" "\ \&" |
| 10 | +.TH "BASH_UNIT" "1" "2023-03-03" "\ \&" "\ \&" |
11 | 11 | .ie \n(.g .ds Aq \(aq |
12 | 12 | .el .ds Aq ' |
13 | 13 | .ss \n[.ss] 0 |
@@ -102,6 +102,8 @@ Running tests in tests/test_core.sh |
102 | 102 | Running test_assert_status_code_fails ... SUCCESS |
103 | 103 | Running test_assert_status_code_succeeds ... SUCCESS |
104 | 104 | Running test_assert_succeeds ... SUCCESS |
| 105 | + Running test_assert_within_delta_fails ... SUCCESS |
| 106 | + Running test_assert_within_delta_succeeds ... SUCCESS |
105 | 107 | Running test_fail_fails ... SUCCESS |
106 | 108 | Running test_fail_prints_failure_message ... SUCCESS |
107 | 109 | Running test_fail_prints_where_is_error ... SUCCESS |
@@ -151,6 +153,8 @@ Running tests in tests/test_core.sh |
151 | 153 | Running test_assert_status_code_fails ... SUCCESS |
152 | 154 | Running test_assert_status_code_succeeds ... SUCCESS |
153 | 155 | Running test_assert_succeeds ... SUCCESS |
| 156 | + Running test_assert_within_delta_fails ... SUCCESS |
| 157 | + Running test_assert_within_delta_succeeds ... SUCCESS |
154 | 158 | Running test_fail_fails ... SUCCESS |
155 | 159 | Overall result: SUCCESS |
156 | 160 | .fam |
@@ -192,6 +196,8 @@ ok \- test_assert_shows_stdout_on_failure |
192 | 196 | ok \- test_assert_status_code_fails |
193 | 197 | ok \- test_assert_status_code_succeeds |
194 | 198 | ok \- test_assert_succeeds |
| 199 | +ok \- test_assert_within_delta_fails |
| 200 | +ok \- test_assert_within_delta_succeeds |
195 | 201 | ok \- test_fail_fails |
196 | 202 | ok \- test_fail_prints_failure_message |
197 | 203 | ok \- test_fail_prints_where_is_error |
@@ -604,6 +610,47 @@ doc:2:test_obvious_matching_with_assert_not_matches() |
604 | 610 | .fam |
605 | 611 | .fi |
606 | 612 | .if n .RE |
| 613 | +.SS "\fBassert_within_delta\fP" |
| 614 | +.sp |
| 615 | +.if n .RS 4 |
| 616 | +.nf |
| 617 | +.fam C |
| 618 | +assert_within_delta <expected num> <actual num> <max delta> [message] |
| 619 | +.fam |
| 620 | +.fi |
| 621 | +.if n .RE |
| 622 | +.sp |
| 623 | +Asserts that the expected num matches the actual num up to a given max delta. |
| 624 | +This function only support integers. |
| 625 | +Given an expectation of 5 and a delta of 2 this would match 3, 4, 5, 6, and 7: |
| 626 | +.sp |
| 627 | +.if n .RS 4 |
| 628 | +.nf |
| 629 | +.fam C |
| 630 | +test_matches_within_delta(){ |
| 631 | + assert_within_delta 5 3 2 |
| 632 | + assert_within_delta 5 4 2 |
| 633 | + assert_within_delta 5 5 2 |
| 634 | + assert_within_delta 5 6 2 |
| 635 | + assert_within_delta 5 7 2 |
| 636 | +} |
| 637 | +test_does_not_match_within_delta(){ |
| 638 | + assert_within_delta 5 2 2 |
| 639 | +} |
| 640 | +.fam |
| 641 | +.fi |
| 642 | +.if n .RE |
| 643 | +.sp |
| 644 | +.if n .RS 4 |
| 645 | +.nf |
| 646 | +.fam C |
| 647 | + Running test_does_not_match_within_delta ... FAILURE |
| 648 | + expected value [5] to match [2] with a maximum delta of [2] |
| 649 | +doc:9:test_does_not_match_within_delta() |
| 650 | + Running test_matches_within_delta ... SUCCESS |
| 651 | +.fam |
| 652 | +.fi |
| 653 | +.if n .RE |
607 | 654 | .SS "\fBassert_no_diff\fP" |
608 | 655 | .sp |
609 | 656 | .if n .RS 4 |
|
0 commit comments