Skip to content

T4 follow-up: negative-int + MinValue/MaxValue edge cases#135

Merged
Chris-Wolfgang merged 1 commit into
vNextfrom
stack/t4-edge-case-coverage
Jun 3, 2026
Merged

T4 follow-up: negative-int + MinValue/MaxValue edge cases#135
Chris-Wolfgang merged 1 commit into
vNextfrom
stack/t4-edge-case-coverage

Conversation

@Chris-Wolfgang

Copy link
Copy Markdown
Owner

Summary

Follow-up to PR #134 (T4 test-quality audit). Closes the smaller
edge-case gaps the audit noted but skipped at the time — the bulk
(custom IComparable<T> + null-bound contracts) landed in #134;
this PR is purely additive coverage.

Stacked on #134

Base = stack/t4-test-quality-audit. When #134 merges, this PR's
base auto-promotes to vNext.

What this adds

1. Negative integer range Theories (10 rows)

Every existing int Theory used positive bounds (1, 10). Added a
parallel Theory with bounds (-10, 0) covering below, exact-lower,
mid, exact-upper, above for both methods. By construction these
exercise the same code path as the positive cases, but a future
refactor introducing an Abs-based shortcut or an unsigned compare
would now break loudly.

2. int.MinValue / int.MaxValue boundary Facts (4)

Four Facts covering value = int.MaxValue and value = int.MinValue
against (int.MinValue, int.MaxValue) bounds for both methods.
Confirms strict bounds reject the exact extremes (IsBetween → false)
and inclusive bounds accept them (IsInRange → true).

3. Money record documentation (comment only)

The Money fixture introduced in #134 stipulates that
CompareTo(null) returns +1 (null is the smallest value). That's a
valid convention per IComparable guidance but the choice was
hidden in the record definition. Added a comment explaining the
rationale.

Skipped from the audit notes — not worth adding

Verified

$ dotnet test ... -c Release --framework net10.0
Passed!  Failed: 0, Passed: 72, Skipped: 0, Total: 72

72 cases — 58 after #134 + 10 negative-int rows + 4 MinValue/MaxValue
Facts.

Copilot AI review requested due to automatic review settings June 1, 2026 15:44

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds incremental unit-test coverage for IsBetween (exclusive) and IsInRange (inclusive) to lock in behavior for negative integer ranges and int.MinValue/int.MaxValue, plus a clarifying comment on the Money test fixture’s CompareTo(null) convention.

Changes:

  • Add negative-bound integer [Theory] coverage for both IsBetween and IsInRange.
  • Add Facts covering int.MinValue/int.MaxValue against full-range bounds for both methods.
  • Document the Money.CompareTo(null) convention used in custom IComparable<T> tests.

Comment thread tests/Wolfgang.Extensions.IComparable.Tests.Unit/IComparableExtensionsTests.cs Outdated
@Chris-Wolfgang Chris-Wolfgang force-pushed the stack/t4-test-quality-audit branch from 4635e65 to 0b23a18 Compare June 1, 2026 15:50
@Chris-Wolfgang Chris-Wolfgang force-pushed the stack/t4-edge-case-coverage branch from 1f902dd to decd9d1 Compare June 1, 2026 15:51
@Chris-Wolfgang Chris-Wolfgang force-pushed the stack/t4-edge-case-coverage branch from decd9d1 to 68ebca7 Compare June 2, 2026 23:57
Base automatically changed from stack/t4-test-quality-audit to vNext June 3, 2026 00:05
The bulk of the T4 audit landed in #134 (custom IComparable<T> tests
+ null-bound contract tests). This follow-up closes the smaller
edge-case gaps the audit flagged but skipped at the time:

1. Negative integer range — every existing int Theory used positive
   bounds (1, 10). Added matching Theories with bounds (-10, 0) for
   both IsBetween and IsInRange covering below, exact-lower, mid,
   exact-upper, above. By construction these exercise the same code
   path as the positive cases, but a future refactor introducing an
   Abs-based shortcut or an unsigned compare would now fail.

2. int.MinValue / int.MaxValue boundaries — added four Facts covering
   value=int.MaxValue and value=int.MinValue against (MinValue,
   MaxValue) bounds for both methods. Confirms that strict bounds
   reject the exact extremes (IsBetween → false) and inclusive
   bounds accept them (IsInRange → true).

3. Money record's CompareTo(null) convention documented with a
   comment explaining the choice ('null < any value', per the
   IComparable<T> guidance).

72 tests pass on net10.0 (58 after #134 + 14 new rows / Facts here).
@Chris-Wolfgang Chris-Wolfgang force-pushed the stack/t4-edge-case-coverage branch from 68ebca7 to 5da64c9 Compare June 3, 2026 00:08
@Chris-Wolfgang Chris-Wolfgang merged commit c14617b into vNext Jun 3, 2026
@Chris-Wolfgang Chris-Wolfgang deleted the stack/t4-edge-case-coverage branch June 3, 2026 00:32
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.

2 participants