Skip to content

Commit

Permalink
Better handling of NaN in nullable numeric assertions
Browse files Browse the repository at this point in the history
  • Loading branch information
jnyrup committed Mar 27, 2022
1 parent 09c5821 commit 1e4d1d7
Show file tree
Hide file tree
Showing 5 changed files with 516 additions and 3 deletions.
4 changes: 2 additions & 2 deletions Src/FluentAssertions/AssertionExtensions.cs
Expand Up @@ -686,7 +686,7 @@ public static NumericAssertions<float> Should(this float actualValue)
[Pure]
public static NullableNumericAssertions<float> Should(this float? actualValue)
{
return new NullableNumericAssertions<float>(actualValue);
return new NullableFloatAssertions(actualValue);
}

/// <summary>
Expand All @@ -706,7 +706,7 @@ public static NumericAssertions<double> Should(this double actualValue)
[Pure]
public static NullableNumericAssertions<double> Should(this double? actualValue)
{
return new NullableNumericAssertions<double>(actualValue);
return new NullableDoubleAssertions(actualValue);
}

/// <summary>
Expand Down
12 changes: 12 additions & 0 deletions Src/FluentAssertions/Numeric/NullableDoubleAssertions.cs
@@ -0,0 +1,12 @@
namespace FluentAssertions.Numeric
{
internal class NullableDoubleAssertions : NullableNumericAssertions<double>
{
public NullableDoubleAssertions(double? value)
: base(value)
{
}

private protected override bool IsNaN(double value) => double.IsNaN(value);
}
}
12 changes: 12 additions & 0 deletions Src/FluentAssertions/Numeric/NullableFloatAssertions.cs
@@ -0,0 +1,12 @@
namespace FluentAssertions.Numeric
{
internal class NullableFloatAssertions : NullableNumericAssertions<float>
{
public NullableFloatAssertions(float? value)
: base(value)
{
}

private protected override bool IsNaN(float value) => float.IsNaN(value);
}
}

0 comments on commit 1e4d1d7

Please sign in to comment.