public void LookupTest() { const string data = "How now, brown cow?"; var list = data.Split().Aggregate(BinaryRandomAccessList <string> .Empty, (current, word) => BinaryRandomAccessList <string> .Cons(word, current)); Assert.AreEqual("now,", BinaryRandomAccessList <string> .Lookup(2, 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(BinaryRandomAccessList <string> .Empty, (current, word) => BinaryRandomAccessList <string> .Cons(word, current)); Assert.AreEqual("sweet.", BinaryRandomAccessList <string> .Lookup(0, list)); Assert.AreEqual("What's", BinaryRandomAccessList <string> .Lookup(17, list)); }
public void IsEmptyTest() { var list = BinaryRandomAccessList <string> .Empty; Assert.IsTrue(BinaryRandomAccessList <string> .IsEmpty(list)); list = BinaryRandomAccessList <string> .Cons("A", list); Assert.IsFalse(BinaryRandomAccessList <string> .IsEmpty(list)); }
public void HeadTest() { const string data = "How now, brown cow?"; var list = data.Split().Aggregate(BinaryRandomAccessList <string> .Empty, (current, word) => BinaryRandomAccessList <string> .Cons(word, current)); Assert.AreEqual("cow?", BinaryRandomAccessList <string> .Head(list)); list = BinaryRandomAccessList <string> .Update(0, "dog?", list); Assert.AreEqual("dog?", BinaryRandomAccessList <string> .Head(list)); }
public void EmptyTailTest() { var list = BinaryRandomAccessList <string> .Empty; AssertThrows <ArgumentNullException>(() => BinaryRandomAccessList <string> .Tail(list)); }