public void TestRetainAll() { IntList list = new IntList(); for (int j = 0; j < 1000; j++) { list.Add(j); } IntList listCopy = new IntList(list); IntList listOdd = new IntList(); IntList listEven = new IntList(); for (int j = 0; j < 1000; j++) { if (j % 2 == 0) { listEven.Add(j); } else { listOdd.Add(j); } } list.RetainAll(listOdd); //Assert.AreEqual(list, listOdd); Assert.IsTrue(list.Equals(listOdd)); list.RetainAll(listEven); Assert.IsTrue(list.IsEmpty()); listCopy.RetainAll(listEven); //Assert.AreEqual(listCopy, listEven); Assert.IsTrue(listCopy.Equals(listEven)); listCopy.RetainAll(listOdd); Assert.IsTrue(listCopy.IsEmpty()); }
public override bool Equals(object o) { if (this == o) { return(true); } if (o == null || this.GetType() != o.GetType()) { return(false); } PropertyChange that = ( PropertyChange )o; if (EntityId != that.EntityId) { return(false); } //JAVA TO C# CONVERTER WARNING: LINQ 'SequenceEqual' is not always identical to Java AbstractList 'equals': //ORIGINAL LINE: if (!added.equals(that.added)) if (!Added.SequenceEqual(that.Added)) { return(false); } //JAVA TO C# CONVERTER WARNING: LINQ 'SequenceEqual' is not always identical to Java AbstractList 'equals': //ORIGINAL LINE: if (!changed.equals(that.changed)) if (!Changed.SequenceEqual(that.Changed)) { return(false); } return(Removed.Equals(that.Removed)); }
public bool Equals(IKElement other) { return(bones.Equals(other.bones) && infoNode0Index.Equals(other.infoNode0Index) && infoNode1Index.Equals(other.infoNode1Index) && infoNode2Index.Equals(other.infoNode2Index) && infoNode3Index.Equals(other.infoNode3Index) && infoNode4Index.Equals(other.infoNode4Index) && infoNode5Index.Equals(other.infoNode5Index) && infoNode6Index.Equals(other.infoNode6Index) && infoNode7Index.Equals(other.infoNode7Index) && infoNode8Index.Equals(other.infoNode8Index) && infoNode9Index.Equals(other.infoNode9Index) && infoNodeAIndex.Equals(other.infoNodeAIndex) && poleVectorIndex.Equals(other.poleVectorIndex) && slotInfoIndex.Equals(other.slotInfoIndex) && slotOffsetIndex.Equals(other.slotOffsetIndex) && rootIndex.Equals(other.rootIndex) ); }
public void TestConstructors() { IntList list = new IntList(); Assert.IsTrue(list.IsEmpty()); list.Add(0); list.Add(1); IntList list2 = new IntList(list); //Assert.AreEqual(list, list2); Assert.IsTrue(list.Equals(list2)); IntList list3 = new IntList(2); Assert.IsTrue(list3.IsEmpty()); }
public void TestEquals() { IntList list = new IntList(); Assert.AreEqual(list, list); Assert.IsTrue(!list.Equals(null)); IntList list2 = new IntList(200); Assert.IsTrue(list.Equals(list2)); //Assert.AreEqual(list, list2); Assert.IsTrue(list2.Equals(list)); //Assert.AreEqual(list2, list); Assert.AreEqual(list.GetHashCode(), list2.GetHashCode()); list.Add(0); list.Add(1); list2.Add(1); list2.Add(0); Assert.IsTrue(!list.Equals(list2)); list2.RemoveValue(1); list2.Add(1); Assert.IsTrue(list.Equals(list2)); //Assert.AreEqual(list, list2); Assert.IsTrue(list2.Equals(list)); //Assert.AreEqual(list2, list); list2.Add(2); Assert.IsTrue(!list.Equals(list2)); Assert.IsTrue(!list2.Equals(list)); }
public void TestAddAll() { IntList list = new IntList(); for (int j = 0; j < 5; j++) { list.Add(j); } IntList list2 = new IntList(0); list2.AddAll(list); list2.AddAll(list); Assert.AreEqual(2 * list.Count, list2.Count); for (int j = 0; j < 5; j++) { Assert.AreEqual(list2.Get(j), j); Assert.AreEqual(list2.Get(j + list.Count), j); } IntList empty = new IntList(); int limit = list.Count; for (int j = 0; j < limit; j++) { Assert.IsTrue(list.AddAll(j, empty)); Assert.AreEqual(limit, list.Count); } try { list.AddAll(limit + 1, empty); Assert.Fail("should have thrown an exception"); } catch (IndexOutOfRangeException) { // as expected } // try add at beginning empty.AddAll(0, list); //Assert.AreEqual(empty, list); Assert.IsTrue(empty.Equals(list)); // try in the middle empty.AddAll(1, list); Assert.AreEqual(2 * list.Count, empty.Count); Assert.AreEqual(list.Get(0), empty.Get(0)); Assert.AreEqual(list.Get(0), empty.Get(1)); Assert.AreEqual(list.Get(1), empty.Get(2)); Assert.AreEqual(list.Get(1), empty.Get(6)); Assert.AreEqual(list.Get(2), empty.Get(3)); Assert.AreEqual(list.Get(2), empty.Get(7)); Assert.AreEqual(list.Get(3), empty.Get(4)); Assert.AreEqual(list.Get(3), empty.Get(8)); Assert.AreEqual(list.Get(4), empty.Get(5)); Assert.AreEqual(list.Get(4), empty.Get(9)); // try at the end empty.AddAll(empty.Count, list); Assert.AreEqual(3 * list.Count, empty.Count); Assert.AreEqual(list.Get(0), empty.Get(0)); Assert.AreEqual(list.Get(0), empty.Get(1)); Assert.AreEqual(list.Get(0), empty.Get(10)); Assert.AreEqual(list.Get(1), empty.Get(2)); Assert.AreEqual(list.Get(1), empty.Get(6)); Assert.AreEqual(list.Get(1), empty.Get(11)); Assert.AreEqual(list.Get(2), empty.Get(3)); Assert.AreEqual(list.Get(2), empty.Get(7)); Assert.AreEqual(list.Get(2), empty.Get(12)); Assert.AreEqual(list.Get(3), empty.Get(4)); Assert.AreEqual(list.Get(3), empty.Get(8)); Assert.AreEqual(list.Get(3), empty.Get(13)); Assert.AreEqual(list.Get(4), empty.Get(5)); Assert.AreEqual(list.Get(4), empty.Get(9)); Assert.AreEqual(list.Get(4), empty.Get(14)); }