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);
            });
        }
Exemple #2
0
        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));
        }
Exemple #3
0
        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));
        }
Exemple #4
0
        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));
        }
Exemple #5
0
        public void EmptyTailTest()
        {
            var queue = PhysicistsQueue <string> .Empty;

            AssertThrows <ArgumentNullException>(() => PhysicistsQueue <string> .Tail(queue));
        }