public void Test_CompareTo() { MyDeque <int> deq = new MyDeque <int>(); deq.EnqueueLast(1); deq.EnqueueLast(2); deq.EnqueueLast(3); deq.EnqueueLast(4); MyDeque <int> deq2 = new MyDeque <int>(); deq2.EnqueueFirst(2); deq2.EnqueueFirst(2); Assert.AreEqual(deq.CompareTo(deq2), 1); deq2.EnqueueFirst(2); deq2.EnqueueFirst(2); Assert.AreEqual(deq.CompareTo(deq2), 0); deq2.EnqueueFirst(2); deq2.EnqueueFirst(2); Assert.AreEqual(deq.CompareTo(deq2), -1); }
public void Test_PeekLast() { MyDeque <int> deq = new MyDeque <int>(); deq.EnqueueLast(1); deq.EnqueueLast(2); deq.EnqueueLast(3); deq.EnqueueLast(4); Assert.AreEqual(deq.PeekLast(), 4); }
public void Test_EnqueueLast() { MyDeque <int> deq = new MyDeque <int>(); deq.EnqueueLast(1); deq.EnqueueLast(2); deq.EnqueueLast(3); deq.EnqueueLast(4); Assert.AreEqual(deq.Count, 4); Assert.AreNotEqual(deq.PeekFirst(), deq.PeekLast()); }
public void Test_Clone() { MyDeque <int> deq1 = new MyDeque <int>(); MyDeque <int> deq2 = new MyDeque <int>(); deq1.EnqueueLast(1); deq1.EnqueueLast(2); deq1.EnqueueLast(3); deq1.EnqueueLast(4); deq2 = (MyDeque <int>)deq1.Clone(); Assert.AreEqual(deq1.Count, deq2.Count); Assert.AreEqual(deq1.PeekLast(), deq2.PeekLast()); }
public void Test_DequeueLast() { MyDeque <int> deq = new MyDeque <int>(); deq.EnqueueLast(1); deq.EnqueueLast(2); deq.EnqueueLast(3); deq.EnqueueLast(4); int expected = deq.PeekLast(); int count1 = deq.Count; int actual = deq.DequeueLast(); int count2 = deq.Count; Assert.AreEqual(actual, expected); Assert.AreNotEqual(count1, count2); }
public void Test_GetEnumerator() { MyDeque <int> deq = new MyDeque <int>(); deq.EnqueueLast(1); deq.EnqueueLast(2); deq.EnqueueLast(3); deq.EnqueueLast(4); int[] numbers = new int[deq.Count]; foreach (int i in deq) { for (int n = 0; n < numbers.Length; n++) { numbers[n] = i; } } Assert.AreEqual(deq.PeekLast(), numbers[deq.Count - 1]); }