public void TailTest() { const string data = "One Two Three One Three"; var queue = data.Split().Aggregate(HoodMelvilleQueue <string> .Empty, HoodMelvilleQueue <string> .Snoc); var tail = HoodMelvilleQueue <string> .Tail(queue); Assert.AreEqual("[2, [Two, Three], 2, [Three, One]]", DumpQueue(tail)); }
public void EmptyTest() { var queue = HoodMelvilleQueue <string> .Empty; Assert.IsTrue(HoodMelvilleQueue <string> .IsEmpty(queue)); queue = HoodMelvilleQueue <string> .Snoc(queue, "Item"); Assert.IsFalse(HoodMelvilleQueue <string> .IsEmpty(queue)); queue = HoodMelvilleQueue <string> .Tail(queue); Assert.IsTrue(HoodMelvilleQueue <string> .IsEmpty(queue)); }
public void PushPopTest() { const string data = "One Two Three One Three"; var queue = data.Split().Aggregate(HoodMelvilleQueue <string> .Empty, HoodMelvilleQueue <string> .Snoc); foreach (var expected in data.Split()) { var actual = HoodMelvilleQueue <string> .Head(queue); Assert.AreEqual(expected, actual); queue = HoodMelvilleQueue <string> .Tail(queue); } Assert.IsTrue(HoodMelvilleQueue <string> .IsEmpty(queue)); }
public void EmptyTailTest() { var queue = HoodMelvilleQueue <string> .Empty; AssertThrows <ArgumentNullException>(() => HoodMelvilleQueue <string> .Tail(queue)); }