mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-12 21:34:11 +02:00
Nullable fixes with !=
This commit is contained in:
parent
bf80ec8897
commit
952e3aec58
4 changed files with 32 additions and 5 deletions
|
@ -121,13 +121,13 @@ namespace System
|
||||||
|
|
||||||
public static bool operator!=<TOther>(Nullable<T> lhs, TOther rhs) where bool : operator T != TOther
|
public static bool operator!=<TOther>(Nullable<T> lhs, TOther rhs) where bool : operator T != TOther
|
||||||
{
|
{
|
||||||
if (!lhs.mHasValue) return false;
|
if (!lhs.mHasValue) return true;
|
||||||
return lhs.mValue != rhs;
|
return lhs.mValue != rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool operator!=<TOther>(TOther lhs, Nullable<T> rhs) where bool : operator TOther != T
|
public static bool operator!=<TOther>(TOther lhs, Nullable<T> rhs) where bool : operator TOther != T
|
||||||
{
|
{
|
||||||
if (!rhs.mHasValue) return false;
|
if (!rhs.mHasValue) return true;
|
||||||
return lhs != rhs;
|
return lhs != rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -113,13 +113,13 @@ namespace System
|
||||||
|
|
||||||
public static bool operator!=<TOther>(Nullable<T> lhs, TOther rhs) where bool : operator T != TOther
|
public static bool operator!=<TOther>(Nullable<T> lhs, TOther rhs) where bool : operator T != TOther
|
||||||
{
|
{
|
||||||
if (!lhs.mHasValue) return false;
|
if (!lhs.mHasValue) return true;
|
||||||
return lhs.mValue != rhs;
|
return lhs.mValue != rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool operator!=<TOther>(TOther lhs, Nullable<T> rhs) where bool : operator TOther != T
|
public static bool operator!=<TOther>(TOther lhs, Nullable<T> rhs) where bool : operator TOther != T
|
||||||
{
|
{
|
||||||
if (!rhs.mHasValue) return false;
|
if (!rhs.mHasValue) return true;
|
||||||
return lhs != rhs;
|
return lhs != rhs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -55,7 +55,7 @@ namespace Tests
|
||||||
Test.FatalError();
|
Test.FatalError();
|
||||||
|
|
||||||
Test.Assert(ca?.mCondB?.mStr == null);
|
Test.Assert(ca?.mCondB?.mStr == null);
|
||||||
Test.Assert(!(ca?.mCondB?.mStr?.Length != 0));
|
Test.Assert(ca?.mCondB?.mStr?.Length != 0);
|
||||||
Test.Assert(!(ca?.mCondB?.mStr?.Length == 0));
|
Test.Assert(!(ca?.mCondB?.mStr?.Length == 0));
|
||||||
|
|
||||||
if (let i = ca?.mCondB?.mInt)
|
if (let i = ca?.mCondB?.mInt)
|
||||||
|
|
|
@ -31,5 +31,32 @@ namespace Tests
|
||||||
Test.Assert(!intn2.TryGetValue(ref i));
|
Test.Assert(!intn2.TryGetValue(ref i));
|
||||||
Test.Assert(i == 100);
|
Test.Assert(i == 100);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Test]
|
||||||
|
public static void TestOperators()
|
||||||
|
{
|
||||||
|
int? iNull = null;
|
||||||
|
bool? bNull = null;
|
||||||
|
|
||||||
|
Test.Assert(!(iNull == 0));
|
||||||
|
Test.Assert(!(iNull <= 0));
|
||||||
|
Test.Assert(!(iNull >= 0));
|
||||||
|
|
||||||
|
Test.Assert(!(bNull == false));
|
||||||
|
Test.Assert(!(bNull == true));
|
||||||
|
Test.Assert(bNull != true);
|
||||||
|
Test.Assert(bNull != false);
|
||||||
|
|
||||||
|
iNull = 100;
|
||||||
|
bNull = false;
|
||||||
|
|
||||||
|
Test.Assert(iNull >= 50);
|
||||||
|
Test.Assert(!(iNull >= 150));
|
||||||
|
Test.Assert(iNull < 150);
|
||||||
|
Test.Assert(!(iNull < 50));
|
||||||
|
Test.Assert(iNull == 100);
|
||||||
|
Test.Assert(iNull != 99);
|
||||||
|
Test.Assert(!(iNull != 100));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue