public void HeadReturnsNullOnEmptyList() { int?expected = null; var emptyList = OkasakiList.empty <int>(); var actual = OkasakiList.head <int>(emptyList); Assert.AreEqual(expected, actual); }
public void HeadReturnsCorrectValueForSingleton() { var value = 12; var singletonList = OkasakiList.singleton(value); int?expected = value; var actual = OkasakiList.head(singletonList); Assert.AreEqual(expected, actual); }
public void HeadReturnsCorrectValueForList() { var value1 = 1; var value2 = 2; var value3 = 3; //we load up the list in reverse order, since basic cons inserts at the head var olist1 = OkasakiList.singleton(value3); var olist2 = OkasakiList.cons(value2, olist1); var olist3 = OkasakiList.cons(value1, olist2); var expected = value1; var actual = OkasakiList.head(olist3); Assert.AreEqual(expected, actual); }