From 070746c1b54793ae2ad004ad26f0e213b1c1bdfc Mon Sep 17 00:00:00 2001 From: Pascal Grange Date: Fri, 3 Mar 2023 10:45:19 +0100 Subject: [PATCH] prepare release v2.1.0 --- bash_unit | 2 +- docs/man/man1/bash_unit.1 | 53 ++++++++++++++++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 4 deletions(-) diff --git a/bash_unit b/bash_unit index a194926..503bbcb 100755 --- a/bash_unit +++ b/bash_unit @@ -16,7 +16,7 @@ # # https://github.com/pgrange/bash_unit -VERSION=v2.0.1 +VERSION=v2.1.0 ESCAPE=$(printf "\033") NOCOLOR="${ESCAPE}[0m" diff --git a/docs/man/man1/bash_unit.1 b/docs/man/man1/bash_unit.1 index 2320557..73ff925 100644 --- a/docs/man/man1/bash_unit.1 +++ b/docs/man/man1/bash_unit.1 @@ -1,13 +1,13 @@ '\" t .\" Title: bash_unit .\" Author: [see the "AUTHOR(S)" section] -.\" Generator: Asciidoctor 2.0.17 -.\" Date: 2022-09-28 +.\" Generator: Asciidoctor 2.0.18 +.\" Date: 2023-03-03 .\" Manual: \ \& .\" Source: \ \& .\" Language: English .\" -.TH "BASH_UNIT" "1" "2022-09-28" "\ \&" "\ \&" +.TH "BASH_UNIT" "1" "2023-03-03" "\ \&" "\ \&" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .ss \n[.ss] 0 @@ -102,6 +102,8 @@ Running tests in tests/test_core.sh Running test_assert_status_code_fails ... SUCCESS Running test_assert_status_code_succeeds ... SUCCESS Running test_assert_succeeds ... SUCCESS + Running test_assert_within_delta_fails ... SUCCESS + Running test_assert_within_delta_succeeds ... SUCCESS Running test_fail_fails ... SUCCESS Running test_fail_prints_failure_message ... SUCCESS Running test_fail_prints_where_is_error ... SUCCESS @@ -151,6 +153,8 @@ Running tests in tests/test_core.sh Running test_assert_status_code_fails ... SUCCESS Running test_assert_status_code_succeeds ... SUCCESS Running test_assert_succeeds ... SUCCESS + Running test_assert_within_delta_fails ... SUCCESS + Running test_assert_within_delta_succeeds ... SUCCESS Running test_fail_fails ... SUCCESS Overall result: SUCCESS .fam @@ -192,6 +196,8 @@ ok \- test_assert_shows_stdout_on_failure ok \- test_assert_status_code_fails ok \- test_assert_status_code_succeeds ok \- test_assert_succeeds +ok \- test_assert_within_delta_fails +ok \- test_assert_within_delta_succeeds ok \- test_fail_fails ok \- test_fail_prints_failure_message ok \- test_fail_prints_where_is_error @@ -604,6 +610,47 @@ doc:2:test_obvious_matching_with_assert_not_matches() .fam .fi .if n .RE +.SS "\fBassert_within_delta\fP" +.sp +.if n .RS 4 +.nf +.fam C +assert_within_delta [message] +.fam +.fi +.if n .RE +.sp +Asserts that the expected num matches the actual num up to a given max delta. +This function only support integers. +Given an expectation of 5 and a delta of 2 this would match 3, 4, 5, 6, and 7: +.sp +.if n .RS 4 +.nf +.fam C +test_matches_within_delta(){ + assert_within_delta 5 3 2 + assert_within_delta 5 4 2 + assert_within_delta 5 5 2 + assert_within_delta 5 6 2 + assert_within_delta 5 7 2 +} +test_does_not_match_within_delta(){ + assert_within_delta 5 2 2 +} +.fam +.fi +.if n .RE +.sp +.if n .RS 4 +.nf +.fam C + Running test_does_not_match_within_delta ... FAILURE + expected value [5] to match [2] with a maximum delta of [2] +doc:9:test_does_not_match_within_delta() + Running test_matches_within_delta ... SUCCESS +.fam +.fi +.if n .RE .SS "\fBassert_no_diff\fP" .sp .if n .RS 4