Skip to content

JSON assertions did not properly handle floats, doubles and unsigned … - #3105

Merged
dennisdoomen merged 1 commit into
fluentassertions:hotfix/8.7.1from
dennisdoomen:fix-numeric-detection
Oct 2, 2025
Merged

JSON assertions did not properly handle floats, doubles and unsigned …#3105
dennisdoomen merged 1 commit into
fluentassertions:hotfix/8.7.1from
dennisdoomen:fix-numeric-detection

Conversation

@dennisdoomen

@dennisdoomen dennisdoomen commented Sep 28, 2025

Copy link
Copy Markdown
Member

This PR fixes a bug in JSON assertions where the library wasn't properly handling certain numeric types during comparisons. The core issue was that the JSON conversion logic only checked for int and double values, but missed other important numeric types like unsigned integers (uint, ulong), signed long integers (), and floats (float). long

The fix adds support for these missing numeric types by extending the conversion step to handle uint, , ulong, and float values. Additionally, it introduces a new IsNumeric() helper method that properly identifies all numeric JSON values by checking for , ulong, or double types. long``long

Thanks to @jnyrup for the discovery.

@coveralls

coveralls commented Sep 28, 2025

Copy link
Copy Markdown

Pull Request Test Coverage Report for Build 18187186552

Details

  • 20 of 20 (100.0%) changed or added relevant lines in 3 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.009%) to 97.148%

Totals Coverage Status
Change from base Build 18072834336: -0.009%
Covered Lines: 12767
Relevant Lines: 12985

💛 - Coveralls

@github-actions

github-actions Bot commented Sep 28, 2025

Copy link
Copy Markdown

Qodana for .NET

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked
☁️ View the detailed Qodana report

Contact Qodana team

Contact us at qodana-support@jetbrains.com

Comment thread Src/FluentAssertions/Equivalency/Steps/JsonConversionStep.cs Outdated
Comment thread Src/FluentAssertions/Specialized/JsonNodeAssertions.cs Outdated
Comment thread Src/FluentAssertions/Equivalency/Steps/JsonConversionStep.cs Outdated
Comment thread Src/FluentAssertions/Specialized/JsonNodeAssertions.cs Outdated
Comment thread Src/FluentAssertions/Specialized/JsonValueExtensions.cs Outdated
@dennisdoomen
dennisdoomen force-pushed the fix-numeric-detection branch from 965afe7 to bf23e22 Compare October 1, 2025 19:15
@dennisdoomen
dennisdoomen requested a review from jnyrup October 1, 2025 19:15

@jnyrup jnyrup left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Just a few small int32 -> numeric value corrections

Comment thread Src/FluentAssertions/Specialized/JsonNodeAssertions.cs Outdated
Comment thread Src/FluentAssertions/Specialized/JsonNodeAssertions.cs Outdated
Comment thread Src/FluentAssertions/Specialized/JsonNodeAssertions.cs Outdated
Comment thread Src/FluentAssertions/Specialized/JsonNodeAssertions.cs Outdated
@dennisdoomen
dennisdoomen force-pushed the fix-numeric-detection branch from bf23e22 to cc443c0 Compare October 2, 2025 07:17
@dennisdoomen
dennisdoomen force-pushed the fix-numeric-detection branch from cc443c0 to 3ffeed2 Compare October 2, 2025 08:07
@dennisdoomen
dennisdoomen merged commit 3a6f807 into fluentassertions:hotfix/8.7.1 Oct 2, 2025
6 checks passed
@dennisdoomen
dennisdoomen deleted the fix-numeric-detection branch October 2, 2025 08:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants