NaNConstraint
NaNConstraint tests that the actual value is a double or float NaN
using System;
using System.Runtime.CompilerServices;
namespace NUnit.Framework.Constraints
{
[System.Runtime.CompilerServices.NullableContext(1)]
[System.Runtime.CompilerServices.Nullable(0)]
public class NaNConstraint : Constraint
{
public override string Description => "NaN";
public override ConstraintResult ApplyTo<[System.Runtime.CompilerServices.Nullable(2)] TActual>(TActual actual)
{
object actualValue = actual;
int isSuccess;
if (((object)actual) is double) {
double d = actual as double;
if (double.IsNaN(d)) {
isSuccess = 1;
goto IL_0057;
}
}
if (((object)actual) is float) {
float f = actual as float;
isSuccess = (float.IsNaN(f) ? 1 : 0);
} else
isSuccess = 0;
goto IL_0057;
IL_0057:
return new ConstraintResult(this, actualValue, (byte)isSuccess != 0);
}
public NaNConstraint()
: base(Array.Empty<object>())
{
}
}
}