mirror of
https://github.com/beefytech/Beef.git
synced 2025-07-04 23:36:00 +02:00
Fixes NaN comparisons
This commit is contained in:
parent
7c0293620a
commit
55298ee884
8 changed files with 256 additions and 38 deletions
|
@ -51,6 +51,66 @@ namespace Tests
|
|||
FloatParseErrTest("6e+");
|
||||
}
|
||||
|
||||
[Test]
|
||||
public static void TestCmp()
|
||||
{
|
||||
float fNeg = -1;
|
||||
float fNan = float.NaN;
|
||||
|
||||
if (fNeg < 0)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
Test.FatalError();
|
||||
}
|
||||
if (fNeg > 0)
|
||||
Test.FatalError();
|
||||
|
||||
if (fNan < 0)
|
||||
Test.FatalError();
|
||||
if (fNan <= 0)
|
||||
Test.FatalError();
|
||||
if (fNan > 0)
|
||||
Test.FatalError();
|
||||
if (fNan >= 0)
|
||||
Test.FatalError();
|
||||
if (fNan == 0)
|
||||
Test.FatalError();
|
||||
if (fNan != 0)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Test.FatalError();
|
||||
}
|
||||
|
||||
if (fNan == fNan)
|
||||
Test.FatalError();
|
||||
|
||||
if (fNan != fNan)
|
||||
{
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
Test.FatalError();
|
||||
}
|
||||
|
||||
bool b0 = fNan < 0;
|
||||
bool b1 = fNan > 0;
|
||||
bool b2 = fNan == fNan;
|
||||
bool b3 = fNan != fNan;
|
||||
bool b4 = fNan != 0;
|
||||
|
||||
Test.Assert(!b0);
|
||||
Test.Assert(!b1);
|
||||
Test.Assert(!b2);
|
||||
Test.Assert(b3);
|
||||
Test.Assert(b4);
|
||||
}
|
||||
|
||||
public static void MinMaxTest<T>(T expectedMinValue, T expectedMaxValue)
|
||||
where T : IMinMaxValue<T>
|
||||
where int : operator T <=> T
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue