Skip to content

NumericAssertions does not handle NaN correctly #1690

@jnyrup

Description

@jnyrup

Description

NumericAssertions uses CompareTo to decide if a subject is e.g. smaller than the expected.
That is technically mixing different concepts, as CompareTo only decides the relative ordering between two items, i.e. how they should be sorted.
What NumericAssertions should be doing when "comparing" is arithmetic comparisons that corresponds to using operators like <, == and so on.

Complete minimal example reproducing the issue

double.NaN.Should().BeLessThan(0);

Expected behavior:

Should fail, as comparing NaN to anything using <, <=, ==, >= or > returns false.

Actual behavior:

The test passes.

Versions

  • Which version of Fluent Assertions are you using?
    • 6.1.0 (master)

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions