public void prependTest() { SinglyLink <string> singly = new SinglyLink <string>(); singly.Head = new Node <string>("B"); singly.prepend("D"); singly.prepend("E"); List <string> result = new List <string>() { "E", "D", "B" }; CollectionAssert.AreEqual(singly.display(), result); }
public void indexOfTest() { SinglyLink <string> singly = new SinglyLink <string>(); singly.Head = new Node <string>("B"); singly.prepend("A"); singly.append("C"); singly.append("D"); singly.append("E"); singly.append("F"); singly.append("G"); singly.append("H"); Assert.AreEqual(singly.indexOf("F"), 5); }
public void getTest() { SinglyLink <string> singly = new SinglyLink <string>(); singly.Head = new Node <string>("B"); singly.prepend("A"); singly.append("C"); singly.append("D"); singly.append("E"); singly.append("F"); singly.append("G"); singly.append("H"); Assert.AreEqual(singly.get(5), "F"); }
public void clearTest() { SinglyLink <string> singly = new SinglyLink <string>(); singly.Head = new Node <string>("B"); singly.prepend("A"); singly.append("C"); singly.append("D"); singly.append("E"); singly.append("F"); singly.append("G"); singly.append("H"); Assert.AreEqual(singly.isEmpty, false); singly.clear(); Assert.AreEqual(singly.length, 0); Assert.AreEqual(singly.isEmpty, true); }
public void removeTest() { SinglyLink <string> singly = new SinglyLink <string>(); singly.Head = new Node <string>("B"); singly.prepend("A"); singly.append("C"); singly.append("D"); singly.append("E"); singly.append("F"); singly.append("G"); singly.append("H"); singly.remove(0); singly.remove(2); singly.remove(5); List <string> result = new List <string>() { "B", "C", "E", "F", "G" }; CollectionAssert.AreEqual(singly.display(), result); }