public void Test1() { const string data = "One Two Three One Three"; var queue = data.Split().Aggregate(PhysicistsQueue <string> .Empty, PhysicistsQueue <string> .Snoc); dotMemory.Check(memory => { Assert.AreEqual(5, memory.GetObjects(where => where.Type.Is <List <string> .Node>()).ObjectsCount); }); foreach (var expected in data.Split()) { var head = PhysicistsQueue <string> .Head(queue); Assert.AreEqual(expected, head); queue = PhysicistsQueue <string> .Tail(queue); } dotMemory.Check(memory => { Assert.AreEqual(0, memory.GetObjects(where => where.Type.Is <PhysicistsQueue <string> .Queue>()).ObjectsCount); }); }
public void TailTest() { const string data = "One Two Three One Three"; var queue = data.Split().Aggregate(PhysicistsQueue <string> .Empty, PhysicistsQueue <string> .Snoc); var tail = PhysicistsQueue <string> .Tail(queue); Assert.AreEqual("[[Two, Three], 2, [Two, Three], 2, [Three, One]]", DumpQueue(tail, true)); }
public void EmptyTest() { var queue = PhysicistsQueue <string> .Empty; Assert.IsTrue(PhysicistsQueue <string> .IsEmpty(queue)); queue = PhysicistsQueue <string> .Snoc(queue, "Item"); Assert.IsFalse(PhysicistsQueue <string> .IsEmpty(queue)); queue = PhysicistsQueue <string> .Tail(queue); Assert.IsTrue(PhysicistsQueue <string> .IsEmpty(queue)); }
public void PushPopTest() { const string data = "One Two Three One Three"; var queue = data.Split().Aggregate(PhysicistsQueue <string> .Empty, PhysicistsQueue <string> .Snoc); foreach (var expected in data.Split()) { var head = PhysicistsQueue <string> .Head(queue); Assert.AreEqual(expected, head); queue = PhysicistsQueue <string> .Tail(queue); } Assert.IsTrue(PhysicistsQueue <string> .IsEmpty(queue)); }
public void EmptyTailTest() { var queue = PhysicistsQueue <string> .Empty; AssertThrows <ArgumentNullException>(() => PhysicistsQueue <string> .Tail(queue)); }