Example #1
0
        public void ConsHeadTailTest()
        {
            const string data  = "One Two Three One Three";
            var          queue = data.Split().Aggregate(RealTimeDeque <string> .Empty, (queue1, s) => RealTimeDeque <string> .Cons(s, queue1));

            foreach (var expected in data.Split().Reverse())
            {
                var actual = RealTimeDeque <string> .Head(queue);

                Assert.AreEqual(expected, actual);
                queue = RealTimeDeque <string> .Tail(queue);
            }

            Assert.IsTrue(RealTimeDeque <string> .IsEmpty(queue));
        }
Example #2
0
        public void SnocLastInitTest()
        {
            const string data  = "One Two Three One Three";
            var          queue = data.Split().Aggregate(RealTimeDeque <string> .Empty, RealTimeDeque <string> .Snoc);

            var dat = data.Split().Reverse();

            foreach (var expected in dat)
            {
                var actual = RealTimeDeque <string> .Last(queue);

                Assert.AreEqual(expected, actual);
                queue = RealTimeDeque <string> .Init(queue);
            }

            Assert.IsTrue(RealTimeDeque <string> .IsEmpty(queue));
        }
Example #3
0
        public void EmptyTest()
        {
            var queue = RealTimeDeque <string> .Empty;

            Assert.IsTrue(RealTimeDeque <string> .IsEmpty(queue));

            queue = RealTimeDeque <string> .Cons("Head", queue);

            Assert.IsFalse(RealTimeDeque <string> .IsEmpty(queue));
            queue = RealTimeDeque <string> .Tail(queue);

            Assert.IsTrue(RealTimeDeque <string> .IsEmpty(queue));

            queue = RealTimeDeque <string> .Snoc(queue, "Tail");

            Assert.IsFalse(RealTimeDeque <string> .IsEmpty(queue));
            queue = RealTimeDeque <string> .Init(queue);

            Assert.IsTrue(RealTimeDeque <string> .IsEmpty(queue));
        }