Skip to content

Commit

Permalink
Merge pull request #1867 from jnyrup/NaN_for_nullables
Browse files Browse the repository at this point in the history
Better handling of NaN in nullable numeric assertions
  • Loading branch information
jnyrup committed Mar 28, 2022
2 parents 62f6fde + a0f8165 commit 83d2851
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 83d2851

Please sign in to comment.