public void TestPriorityQueueClear() { GraphPriorityQueue pq = new GraphPriorityQueue(); pq.Add(new Path(new Vertex(""), 50)); Assert.IsTrue("50".Equals(pq.PrintPreorder())); pq.Add(new Path(new Vertex(""), 25)); Assert.IsTrue("25 50".Equals(pq.PrintPreorder())); pq.Add(new Path(new Vertex(""), 40)); Assert.IsTrue("25 50 40".Equals(pq.PrintPreorder())); pq.Add(new Path(new Vertex(""), 60)); Assert.IsTrue("25 50 40 60".Equals(pq.PrintPreorder())); pq.Add(new Path(new Vertex(""), 30)); Assert.IsTrue("25 30 40 60 50".Equals(pq.PrintPreorder())); pq.Clear(); pq.Add(new Path(new Vertex(""), 50)); Assert.IsTrue("50".Equals(pq.PrintPreorder())); pq.Add(new Path(new Vertex(""), 25)); Assert.IsTrue("25 50".Equals(pq.PrintPreorder())); pq.Add(new Path(new Vertex(""), 40)); Assert.IsTrue("25 50 40".Equals(pq.PrintPreorder())); pq.Add(new Path(new Vertex(""), 60)); Assert.IsTrue("25 50 40 60".Equals(pq.PrintPreorder())); pq.Add(new Path(new Vertex(""), 30)); Assert.IsTrue("25 30 40 60 50".Equals(pq.PrintPreorder())); }
public void TestPriorityQueueSize() { GraphPriorityQueue pq = new GraphPriorityQueue(); pq.Add(new Path(new Vertex(""), 50)); Assert.AreEqual(1, pq.Size()); pq.Add(new Path(new Vertex(""), 25)); Assert.AreEqual(2, pq.Size()); pq.Add(new Path(new Vertex(""), 40)); Assert.AreEqual(3, pq.Size()); pq.Add(new Path(new Vertex(""), 60)); Assert.AreEqual(4, pq.Size()); pq.Add(new Path(new Vertex(""), 30)); Assert.IsTrue("25 30 40 60 50".Equals(pq.PrintPreorder())); Assert.AreEqual(5, pq.Size()); pq.Clear(); Assert.IsTrue("".Equals(pq.PrintPreorder())); Assert.AreEqual(0, pq.Size()); }