public static void TestValueComparisonEquals() { using (Eina.Value a = new Eina.Value(Eina.ValueType.Int32)) using (Eina.Value b = new Eina.Value(Eina.ValueType.Int32)) using (Eina.Value c = new Eina.Value(Eina.ValueType.Int32)) { Test.Assert(a.Set(1)); Test.Assert(b.Set(1)); Test.Assert(c.Set(1)); Test.Assert(a.Equals(a), "A equals A"); Test.Assert(a.Equals(b) == b.Equals(a), "A equals B == B equals A"); Test.Assert(a.Equals(b) == b.Equals(c) == a.Equals(c)); Test.Assert(b.Set(0)); Test.Assert(a.Equals(b) == b.Equals(a), "A equals B == B equals A"); Test.Assert(a.Equals(null) == false, "A == null"); } }
public static void TestValueCompareList() { using (Eina.Value a = new Eina.Value(Eina.ValueType.List, Eina.ValueType.Int32)) using (Eina.Value b = new Eina.Value(Eina.ValueType.List, Eina.ValueType.Int32)) { Test.AssertEquals(a, b); Test.Assert(a.Append(0)); Test.Assert(a.Append(1)); Test.Assert(a.Append(5)); Test.Assert(a.Append(42)); Test.Assert(b.Append(0)); Test.Assert(b.Append(1)); Test.Assert(b.Append(5)); Test.Assert(b.Append(42)); Test.AssertEquals(a, b); a[0] = -1; Test.Assert(!a.Equals(b)); Test.AssertLessThan(a, b); a[0] = 10; Test.AssertGreaterThan(a, b); a[0] = 0; Test.AssertEquals(a, b); // bigger arrays are greater Test.Assert(b.Append(0)); Test.AssertLessThan(a, b); Test.Assert(a.Append(0)); Test.Assert(a.Append(0)); Test.AssertGreaterThan(a, b); // bigger arrays are greater, unless an element says other wise b[0] = 10; Test.AssertGreaterThan(b, a); } }