Skip to content

ofRectangleTests: extended == / != coverage (follow-up to #8567) - #8570

Merged
danoli3 merged 1 commit into
openframeworks:masterfrom
danoli3:ofRectangle-equality-tests
Oct 4, 2026
Merged

danoli3 merged 1 commit into
openframeworks:masterfrom
danoli3:ofRectangle-equality-tests

Conversation

@danoli3

@danoli3 danoli3 commented Oct 3, 2026 •

Copy link
Copy Markdown
Member

Follow-up to #8567 (now merged: operator!= returns !(*this == rect)). Rebased on master, so this PR is just one commit extending tests/types/ofRectangleTests.

Added test coverage

Every case checks that operator!= is the negation of operator==, and where the answer is well defined, that operator== gives it:

  • each field differing on its own; identical negative floats
  • 1 ULP at different magnitudes/signs: 1, 100, 1920, -3.5, FLT_MAX; 0.1f + 0.2f vs 0.3f; 4 ULP and 0.1 vs 0.1000001 stay unequal
  • integer coordinates: 0, ±1, 7, 255, 1080, 1920, 3840, 65535, ±1e6 (vs itself and vs +1), INT_MAX, INT_MIN, and 2^24 where neighbouring ints map to the same float / 1 ULP apart
  • +0 vs -0, 0 vs denorm_min, FLT_MIN
  • non-finite values (±inf, NaN): only operator agreement is required, since ofIsFloatEqual is not meaningful there (inf - inf is NaN)
  • scale / translate / scaleFromCenter round trips
  • 200,000 seeded random pairs (exact copies, 1-3 ULP nudges, random floats in ±1e6, random ints), compared in both directions

Verification

Compiled this test main.cpp (with a thin ofxUnitTests shim) against the real ofRectangle.cpp from before #8567 and with the fix:

A larger standalone sweep (4M comparisons) showed 166,430 ==/!= contradictions before the fix and 0 with the fix. The full test project builds/runs in CI via scripts/ci/linux64/run_tests.sh.

Behaviour notes (inherited from ofIsFloatEqual, not introduced here)

  • A rectangle with an infinite field is not == to itself, so r != r is now true for it (was false); +inf == -inf is true.
  • The tolerance is eps * |a| (~1 ULP), so drift of a few ULP (e.g. 10 × translate(0.1) then -1) still compares unequal.

Add checks across float magnitudes and signs (1 ULP at 1, 100, 1920,
-3.5, FLT_MAX), integer coordinates (incl. INT_MAX/INT_MIN and 2^24
where neighbouring ints share a float), signed zero and denormals,
non-finite values, scale/translate round trips, and 200,000 seeded
random pairs compared in both directions.
@danoli3
danoli3 force-pushed the ofRectangle-equality-tests branch from 5e349c1 to ed9d6df Compare October 3, 2026 05:49
@danoli3 danoli3 changed the title ofRectangle: fix operator!= + extended equality tests (follow-up to #8567) ofRectangleTests: extended == / != coverage (follow-up to #8567) Oct 3, 2026
@danoli3
danoli3 merged commit 8088c22 into openframeworks:master Oct 4, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant