JSON assertions did not properly handle floats, doubles and unsigned … by dennisdoomen · Pull Request #3105 · fluentassertions/fluentassertions · GitHub
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

@github-actions

github-actions Bot commented Sep 28, 2025

Copy link
Copy Markdown

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