public void LookupNullTest()
        {
            var list = AltBinaryRandomAccessList <string> .Empty;
            var ex   = AssertThrows <ArgumentException>(() => AltBinaryRandomAccessList <string> .Lookup(0, list));

            Assert.AreEqual("must be Zero or One\r\nParameter name: ts", ex.Message);
        }
        public void LookupSingleTest()
        {
            var list = AltBinaryRandomAccessList <string> .Empty;

            list = AltBinaryRandomAccessList <string> .Cons("A", list);

            Assert.AreEqual("A", AltBinaryRandomAccessList <string> .Lookup(0, list));
        }
        public void RoseTest()
        {
            const string data = "What's in a name? That which we call a rose by any other name would smell as sweet.";
            var          list = data.Split().Aggregate(AltBinaryRandomAccessList <string> .Empty, (current, word) => AltBinaryRandomAccessList <string> .Cons(word, current));

            Assert.AreEqual("[Zero: {(sweet., as), (smell, would), (name, other), (any, by), (rose, a), (call, we), (which, That), (name?, a), (in, What's)}]", DumpTree(list));
            Assert.AreEqual("sweet.", AltBinaryRandomAccessList <string> .Lookup(0, list));
            Assert.AreEqual("What's", AltBinaryRandomAccessList <string> .Lookup(17, list));
        }
        public void FUpdateZeroOddTest()
        {
            const string data = "How now, brown cow?";
            var          list = data.Split().Aggregate(AltBinaryRandomAccessList <string> .Empty, (current, word) => AltBinaryRandomAccessList <string> .Cons(word, current));

            list = AltBinaryRandomAccessList <string> .Fupdate(value => value + "-" + value, 1, list);

            Assert.AreEqual("[Zero: {(cow?, brown-brown), (now,, How)}]", DumpTree(list));
            Assert.AreEqual("brown-brown", AltBinaryRandomAccessList <string> .Lookup(1, list));
        }
        public void FUpdateOneTest()
        {
            const string data = "How now, cow?";
            var          list = data.Split().Aggregate(AltBinaryRandomAccessList <string> .Empty, (current, word) => AltBinaryRandomAccessList <string> .Cons(word, current));

            list = AltBinaryRandomAccessList <string> .Fupdate(value => value + "-" + value, 1, list);

            Assert.AreEqual("[One: cow?, {(now,-now,, How)}]", DumpTree(list));
            Assert.AreEqual("now,-now,", AltBinaryRandomAccessList <string> .Lookup(1, list));
        }
        public void UpdateTest()
        {
            const string data = "How now, brown cow?";
            var          list = data.Split().Aggregate(AltBinaryRandomAccessList <string> .Empty, (current, word) => AltBinaryRandomAccessList <string> .Cons(word, current));

            list = AltBinaryRandomAccessList <string> .Update(1, "green", list);

            Assert.AreEqual("[Zero: {(cow?, green), (now,, How)}]", DumpTree(list));
            Assert.AreEqual("green", AltBinaryRandomAccessList <string> .Lookup(1, list));
        }
        public void LookupDoubleTest()
        {
            var list = AltBinaryRandomAccessList <string> .Empty;

            list = AltBinaryRandomAccessList <string> .Cons("A", list);

            list = AltBinaryRandomAccessList <string> .Cons("B", list);

            Assert.AreEqual("[Zero: {(B, A)}]", DumpTree(list));

            Assert.AreEqual("B", AltBinaryRandomAccessList <string> .Lookup(0, list));
        }