public void PushTest() { ItemQueue q = new ItemQueue(); // push the capacity. for (int i = 0; i < 1000; i++) { q.Push(new Item(i)); } Assert.AreEqual(1000, q.Count); for (int v = 0; v < 1000; v++) { Assert.AreEqual(v, q.Pop().Value); } Assert.AreEqual(0, q.Count); // push the capacity. for (int i = 0; i < 1000; i++) { q.Push(new Item(999 - i)); } Assert.AreEqual(1000, q.Count); for (int v = 0; v < 1000; v++) { Assert.AreEqual(v, q.Pop().Value); } Assert.AreEqual(0, q.Count); ItemQueue r = CreateReversedQueue(new int[] { }); // push the capacity. for (int i = 0; i < 1000; i++) { r.Push(new Item(i)); } Assert.AreEqual(1000, r.Count); for (int v = 999; v >= 0; v--) { Assert.AreEqual(v, r.Pop().Value); } Assert.AreEqual(0, r.Count); }
///// <summary> /////A test for Down /////</summary> //public void DownTestHelper<T>() // where T : IComparable<T> //{ // PriorityQueue_Accessor<T> target = new PriorityQueue_Accessor<T>(); // TODO: Initialize to an appropriate value // int i = 0; // TODO: Initialize to an appropriate value // int n = 0; // TODO: Initialize to an appropriate value // target.Down(i, n); // Assert.Inconclusive("A method that does not return a value cannot be verified."); //} //[TestMethod()] //[DeploymentItem("TaskExtensions.dll")] //public void DownTest() //{ // Assert.Inconclusive("No appropriate type parameter is found to satisfies the type constraint(s) of T. " + // "Please call DownTestHelper<T>() with appropriate type parameters."); //} ///// <summary> /////A test for Heapify /////</summary> //public void HeapifyTestHelper<T>() // where T : IComparable<T> //{ // PriorityQueue_Accessor<T> target = new PriorityQueue_Accessor<T>(); // TODO: Initialize to an appropriate value // target.Heapify(); // Assert.Inconclusive("A method that does not return a value cannot be verified."); //} //[TestMethod()] //[DeploymentItem("TaskExtensions.dll")] //public void HeapifyTest() //{ // Assert.Inconclusive("No appropriate type parameter is found to satisfies the type constraint(s) of T. " + // "Please call HeapifyTestHelper<T>() with appropriate type parameters."); //} ///// <summary> /////A test for Less /////</summary> //public void LessTestHelper<T>() // where T : IComparable<T> //{ // PriorityQueue_Accessor<T> target = new PriorityQueue_Accessor<T>(); // TODO: Initialize to an appropriate value // int i = 0; // TODO: Initialize to an appropriate value // int j = 0; // TODO: Initialize to an appropriate value // bool expected = false; // TODO: Initialize to an appropriate value // bool actual; // actual = target.Less(i, j); // Assert.AreEqual(expected, actual); // Assert.Inconclusive("Verify the correctness of this test method."); //} //[TestMethod()] //[DeploymentItem("TaskExtensions.dll")] //public void LessTest() //{ // Assert.Inconclusive("No appropriate type parameter is found to satisfies the type constraint(s) of T. " + // "Please call LessTestHelper<T>() with appropriate type parameters."); //} ///// <summary> /////A test for MaybeGrow /////</summary> //public void MaybeGrowTestHelper<T>() // where T : IComparable<T> //{ // PriorityQueue_Accessor<T> target = new PriorityQueue_Accessor<T>(); // TODO: Initialize to an appropriate value // int minCap = 0; // TODO: Initialize to an appropriate value // target.MaybeGrow(minCap); // Assert.Inconclusive("A method that does not return a value cannot be verified."); //} //[TestMethod()] //[DeploymentItem("TaskExtensions.dll")] //public void MaybeGrowTest() //{ // Assert.Inconclusive("No appropriate type parameter is found to satisfies the type constraint(s) of T. " + // "Please call MaybeGrowTestHelper<T>() with appropriate type parameters."); //} public void AddItems(ItemQueue q, int[] values) { foreach (int value in values) { q.Push(new Item(value)); } }
public void CountTest() { ItemQueue q = CreateQueue(new int[] { 4, 2, 3, 1 }); Assert.AreEqual(4, q.Count); q.Pop(); Assert.AreEqual(3, q.Count); q.Push(new Item(12)); Assert.AreEqual(4, q.Count); ItemQueue e = new ItemQueue(); Assert.AreEqual(0, e.Count); e.Pop(); Assert.AreEqual(0, e.Count); }