Skip to content

Commit 070746c

Browse files
committed
prepare release v2.1.0
1 parent 0f97767 commit 070746c

File tree

2 files changed

+51
-4
lines changed

2 files changed

+51
-4
lines changed

bash_unit

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
#
1717
# https://github.com/pgrange/bash_unit
1818

19-
VERSION=v2.0.1
19+
VERSION=v2.1.0
2020

2121
ESCAPE=$(printf "\033")
2222
NOCOLOR="${ESCAPE}[0m"

docs/man/man1/bash_unit.1

+50-3
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
'\" t
22
.\" Title: bash_unit
33
.\" 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
66
.\" Manual: \ \&
77
.\" Source: \ \&
88
.\" Language: English
99
.\"
10-
.TH "BASH_UNIT" "1" "2022-09-28" "\ \&" "\ \&"
10+
.TH "BASH_UNIT" "1" "2023-03-03" "\ \&" "\ \&"
1111
.ie \n(.g .ds Aq \(aq
1212
.el .ds Aq '
1313
.ss \n[.ss] 0
@@ -102,6 +102,8 @@ Running tests in tests/test_core.sh
102102
Running test_assert_status_code_fails ... SUCCESS
103103
Running test_assert_status_code_succeeds ... SUCCESS
104104
Running test_assert_succeeds ... SUCCESS
105+
Running test_assert_within_delta_fails ... SUCCESS
106+
Running test_assert_within_delta_succeeds ... SUCCESS
105107
Running test_fail_fails ... SUCCESS
106108
Running test_fail_prints_failure_message ... SUCCESS
107109
Running test_fail_prints_where_is_error ... SUCCESS
@@ -151,6 +153,8 @@ Running tests in tests/test_core.sh
151153
Running test_assert_status_code_fails ... SUCCESS
152154
Running test_assert_status_code_succeeds ... SUCCESS
153155
Running test_assert_succeeds ... SUCCESS
156+
Running test_assert_within_delta_fails ... SUCCESS
157+
Running test_assert_within_delta_succeeds ... SUCCESS
154158
Running test_fail_fails ... SUCCESS
155159
Overall result: SUCCESS
156160
.fam
@@ -192,6 +196,8 @@ ok \- test_assert_shows_stdout_on_failure
192196
ok \- test_assert_status_code_fails
193197
ok \- test_assert_status_code_succeeds
194198
ok \- test_assert_succeeds
199+
ok \- test_assert_within_delta_fails
200+
ok \- test_assert_within_delta_succeeds
195201
ok \- test_fail_fails
196202
ok \- test_fail_prints_failure_message
197203
ok \- test_fail_prints_where_is_error
@@ -604,6 +610,47 @@ doc:2:test_obvious_matching_with_assert_not_matches()
604610
.fam
605611
.fi
606612
.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
607654
.SS "\fBassert_no_diff\fP"
608655
.sp
609656
.if n .RS 4

0 commit comments

Comments
 (0)