public void appendTest() { SinglyLink <string> singly = new SinglyLink <string>(); singly.Head = new Node <string>("B"); singly.append("D"); singly.append("E"); List <string> result = new List <string>() { "B", "D", "E" }; 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); }