public void NaNValuesComparedBitwise() { var map1 = new MapField <string, double> { { "x", SampleNaNs.Regular }, { "y", SampleNaNs.SignallingFlipped } }; var map2 = new MapField <string, double> { { "x", SampleNaNs.Regular }, { "y", SampleNaNs.PayloadFlipped } }; var map3 = new MapField <string, double> { { "x", SampleNaNs.Regular }, { "y", SampleNaNs.SignallingFlipped } }; EqualityTester.AssertInequality(map1, map2); EqualityTester.AssertEquality(map1, map3); Assert.True(map1.Values.Contains(SampleNaNs.SignallingFlipped)); Assert.False(map2.Values.Contains(SampleNaNs.SignallingFlipped)); }
public void EqualityHandlesNullValues() { var map1 = new MapField <string, ForeignMessage>(); map1.Add("a", new ForeignMessage { C = 10 }); map1.Add("b", null); var map2 = new MapField <string, ForeignMessage>(); map2.Add("a", new ForeignMessage { C = 10 }); map2.Add("b", null); EqualityTester.AssertEquality(map1, map2); // Check the null value isn't ignored entirely... Assert.IsTrue(map1.Remove("b")); EqualityTester.AssertInequality(map1, map2); map1.Add("b", new ForeignMessage()); EqualityTester.AssertInequality(map1, map2); map1["b"] = null; EqualityTester.AssertEquality(map1, map2); }
public void Equality_Simple() { var map = new MapField <string, string>(); EqualityTester.AssertEquality(map, map); EqualityTester.AssertInequality(map, null); Assert.IsFalse(map.Equals(new object())); }
public void EqualityIsOrderInsensitive() { var map1 = new MapField <string, string>(); map1.Add("a", "v1"); map1.Add("b", "v2"); var map2 = new MapField <string, string>(); map2.Add("b", "v2"); map2.Add("a", "v1"); EqualityTester.AssertEquality(map1, map2); }
public void NaNComparisons() { var message1 = new TestWellKnownTypes { DoubleField = SampleNaNs.Regular }; var message2 = new TestWellKnownTypes { DoubleField = SampleNaNs.PayloadFlipped }; var message3 = new TestWellKnownTypes { DoubleField = SampleNaNs.Regular }; EqualityTester.AssertInequality(message1, message2); EqualityTester.AssertEquality(message1, message3); }
public void EqualityIsOrderInsensitive() { var map1 = new MapField <string, string> { { "a", "v1" }, { "b", "v2" } }; var map2 = new MapField <string, string> { { "b", "v2" }, { "a", "v1" } }; EqualityTester.AssertEquality(map1, map2); }
public void NaNValuesComparedBitwise() { var list1 = new RepeatedField <double> { SampleNaNs.Regular, SampleNaNs.SignallingFlipped }; var list2 = new RepeatedField <double> { SampleNaNs.Regular, SampleNaNs.PayloadFlipped }; var list3 = new RepeatedField <double> { SampleNaNs.Regular, SampleNaNs.SignallingFlipped }; EqualityTester.AssertInequality(list1, list2); EqualityTester.AssertEquality(list1, list3); Assert.True(list1.Contains(SampleNaNs.SignallingFlipped)); Assert.False(list2.Contains(SampleNaNs.SignallingFlipped)); }
public void NaNValuesComparedBitwise() { var list1 = new RepeatedField <double> { SampleNaNs.Regular, SampleNaNs.SignallingFlipped }; var list2 = new RepeatedField <double> { SampleNaNs.Regular, SampleNaNs.PayloadFlipped }; var list3 = new RepeatedField <double> { SampleNaNs.Regular, SampleNaNs.SignallingFlipped }; // All SampleNaNs have the same hashcode under certain targets (e.g. netcoreapp2.1) EqualityTester.AssertInequality(list1, list2, checkHashcode: false); EqualityTester.AssertEquality(list1, list3); Assert.True(list1.Contains(SampleNaNs.SignallingFlipped)); Assert.False(list2.Contains(SampleNaNs.SignallingFlipped)); }