public void Equals_ObjectTest() { CompactInt ci = new CompactInt(100); object sObj = "CompactInt!"; object nl = null; Assert.False(ci.Equals(sObj)); Assert.False(ci.Equals(nl)); }
public void Comparison_EqualTest() { CompactInt first = new CompactInt(1); CompactInt second = new CompactInt(1); Assert.False(first > second); Assert.True(first >= second); Assert.False(second < first); Assert.True(second <= first); Assert.True(first == second); Assert.False(first != second); Assert.Equal(0, first.CompareTo(second)); Assert.Equal(0, first.CompareTo((object)second)); Assert.True(first.Equals(second)); Assert.True(first.Equals((object)second)); }
public void ComparisonOperator_SameTypeTest(CompactInt ci1, CompactInt ci2, ValueCompareResult expected) { Assert.Equal(expected.Bigger, ci1 > ci2); Assert.Equal(expected.BiggerEqual, ci1 >= ci2); Assert.Equal(expected.Smaller, ci1 < ci2); Assert.Equal(expected.SmallerEqual, ci1 <= ci2); Assert.Equal(expected.Equal, ci1 == ci2); Assert.Equal(!expected.Equal, ci1 != ci2); Assert.Equal(expected.Equal, ci1.Equals(ci2)); Assert.Equal(expected.Equal, ci1.Equals((object)ci2)); Assert.Equal(expected.Compare, ci1.CompareTo(ci2)); Assert.Equal(expected.Compare, ci1.CompareTo((object)ci2)); }
public void ComparisonTest() { CompactInt big = new CompactInt(1); CompactInt small = new CompactInt(0); Assert.True(big > small); Assert.True(big >= small); Assert.True(small < big); Assert.True(small <= big); Assert.False(big == small); Assert.True(big != small); Assert.Equal(1, big.CompareTo(small)); Assert.Equal(1, big.CompareTo((object)small)); Assert.Equal(-1, small.CompareTo(big)); Assert.Equal(-1, small.CompareTo((object)big)); Assert.False(big.Equals(small)); Assert.False(big.Equals((object)small)); }