Skip to content

feat(assert): add assert_within_delta#750

Merged
Chemaclass merged 1 commit into
mainfrom
feat/744-assert-within-delta
Jul 9, 2026
Merged

feat(assert): add assert_within_delta#750
Chemaclass merged 1 commit into
mainfrom
feat/744-assert-within-delta

Conversation

@Chemaclass

Copy link
Copy Markdown
Member

Summary

Adds assert_within_delta <expected> <actual> <delta> — asserts a numeric value is within a tolerance: |actual - expected| <= delta.

  • Supports floating-point values via bashunit::math::calculate (bc, awk fallback).
  • Handles negative differences (absolute value).
  • Rejects non-numeric input with a clear failure.
assert_within_delta "3.14159" "3.14" "0.01"   # pass
assert_within_delta "100" "105" "3"           # fail (diff 5 > 3)

Tests

  • test_successful_assert_within_delta
  • test_successful_assert_within_delta_with_a_negative_difference
  • test_successful_assert_within_delta_when_equal
  • test_unsuccessful_assert_within_delta
  • test_unsuccessful_assert_within_delta_with_a_non_numeric_value

make sa + make lint pass; full unit suite green under Bash 3.2 --strict --parallel --simple; bashunit doc snapshot regenerated.

Docs: docs/assertions.md. CHANGELOG updated under Unreleased → Added.

Closes #744

Assert a numeric value is within +/- delta of an expected value
(|actual - expected| <= delta). Supports floats via bashunit::math::calculate
(bc/awk) and rejects non-numeric input. Includes the regenerated doc snapshot
and CHANGELOG entry.

Closes #744
@Chemaclass Chemaclass added the enhancement New feature or request label Jul 9, 2026
@Chemaclass Chemaclass self-assigned this Jul 9, 2026
@Chemaclass Chemaclass merged commit 658eef7 into main Jul 9, 2026
31 checks passed
@Chemaclass Chemaclass deleted the feat/744-assert-within-delta branch July 9, 2026 19:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(assert): assert_within_delta for approximate numeric equality

1 participant