public void TestAddToTail2() { DLList myDLL = new DLList(); DLLNode p = new DLLNode(1); myDLL.addToTail(p); DLLNode q = new DLLNode(2); myDLL.addToTail(q); Assert.AreEqual(q, myDLL.tail);; //check that tail value == 2 }
public void testTotal2() { DLList list = new DLList(); DLLNode node1 = new DLLNode(12); DLLNode node2 = new DLLNode(6); list.addToTail(node1); list.addToTail(node2); Assert.AreEqual(list.total(), 2); }
public void TestMethodAddToTail2() { DLLNode p = new DLLNode("1"); DLList dll = new DLList(); dll.addToTail(p); p = new DLLNode("2"); dll.addToTail(p); p = new DLLNode("3"); dll.addToTail(p); //Should be: Head = 1, head.next.str = 2, head.next.next.str = 3 Assert.AreEqual(true, (dll.head.str == "1" && dll.head.next.str == "2" && dll.head.next.next.str == "3")); }//End of TestMethodAddToTail2
public void TestMethodAddToTail3() { DLLNode p = new DLLNode("1"); DLList dll = new DLList(); dll.addToTail(p); p = new DLLNode("2"); dll.addToTail(p); p = new DLLNode("3"); dll.addToTail(p); //Should be: Tail = 3, tail.previous.str = 2, tail.previous.previous.str = 1 Assert.AreEqual(true, (dll.tail.str == "3" && dll.tail.previous.str == "2" && dll.tail.previous.previous.str == "1")); }//End of TestMethodAddToTail3
public void TestMethodAddToTail1() { DLLNode p = new DLLNode("1"); DLList dll = new DLList(); dll.addToTail(p); p = new DLLNode("2"); dll.addToTail(p); p = new DLLNode("3"); dll.addToTail(p); //Head should be 1, Tail should be 3, and tail.next and head.previous should be null Assert.AreEqual(true, (dll.head.str == "1" && dll.tail.str == "3")); Assert.AreEqual(true, (dll.head.previous == null && dll.tail.next == null)); }//End of TestMethodAddToTail1
public void TestremoveNode2() { string[] str = new string[30]; int i = 0; FileStream f = new FileStream("C:/Users/edgu1/Desktop/222525.txt", FileMode.Open, FileAccess.Read); DLList pDLL = new DLList(); string line; try { StreamReader m_streamReader = new StreamReader(f); //StreamReader read txt m_streamReader.BaseStream.Seek(0, SeekOrigin.Begin); //read from head to tail by lines while ((line = m_streamReader.ReadLine()) != null) { DLLNode d = new DLLNode(line); pDLL.addToTail(d); str[i] = line; i++; } m_streamReader.Close(); } catch (FileNotFoundException e) { Console.WriteLine("errors" + e.ToString()); } string sn = "3"; DLLNode delnode = new DLLNode(sn); DLLNode a = pDLL.removeNode(delnode); Assert.AreEqual(16, a.number); }
public void Testremovehead() { string[] str = new string[30]; int i = 0; FileStream f = new FileStream("C:/Users/edgu1/Desktop/222525.txt", FileMode.Open, FileAccess.Read); DLList pDLL = new DLList(); string line; try { StreamReader m_streamReader = new StreamReader(f); //StreamReader read txt m_streamReader.BaseStream.Seek(0, SeekOrigin.Begin); //read from head to tail by lines while ((line = m_streamReader.ReadLine()) != null) { DLLNode d = new DLLNode(line); pDLL.addToTail(d); str[i] = line; i++; } m_streamReader.Close(); } catch (FileNotFoundException e) { Console.WriteLine("errors" + e.ToString()); } pDLL.removeHead(); //////////////////////// string[] str2 = new string[20]; int j = 0; DLLNode head = pDLL.head; while (head.next != null) { str2[j] = head.str; j++; head = head.next; } Console.WriteLine(head.str); str2[j] = head.str; /// ///////////////////////////////////// bool match1 = false; for (int k = 0; k < j; k++) { if (str[k + 1] == str2[k]) { match1 = true; } else { match1 = false; break; } } Assert.AreEqual(true, match1); }
public void TestAddToTail1() { DLList myDLL = new DLList(); DLLNode p = new DLLNode(1); myDLL.addToTail(p); Assert.AreEqual(myDLL.total(), 1); }
public void testAddToTail2() { DLList list = new DLList(); DLLNode node1 = new DLLNode(12); DLLNode node2 = new DLLNode(5); DLLNode node3 = new DLLNode(6); DLLNode node4 = new DLLNode(8); DLLNode node5 = new DLLNode(1); list.addToTail(node1); list.addToTail(node2); list.addToTail(node3); list.addToTail(node4); list.addToTail(node5); Assert.AreEqual(list.total(), 5); Assert.AreEqual(node5, list.tail); }
public void testAddToTail1() { DLList list = new DLList(); DLLNode node = new DLLNode(12); list.addToTail(node); Assert.AreEqual(list.total(), 1); Assert.AreEqual(node, list.tail); }
public void TestMethodAddToTail4() { DLLNode p = new DLLNode("1"); DLList dll = new DLList(); dll.addToTail(p); //Should be: Head and Tail = 1, and both .next.str and .previous.str are null; Assert.AreEqual(true, (dll.head.str == "1" && dll.tail.str == "1")); Assert.AreEqual(true, (dll.head.next == null && dll.head.previous == null)); Assert.AreEqual(true, (dll.tail.next == null && dll.tail.previous == null)); }//End of TestMethodAddToTail4
public void TestTotal2() { DLList myDLL = new DLList(); DLLNode p = new DLLNode(1); myDLL.addToTail(p); DLLNode q = new DLLNode(2); myDLL.addToTail(q); DLLNode r = new DLLNode(3); myDLL.addToTail(r); DLLNode s = new DLLNode(4); myDLL.addToTail(s); DLLNode t = new DLLNode(-7); myDLL.addToTail(t); Assert.AreEqual(myDLL.total(), 5); }
public void testRemoveTail2() { DLList list = new DLList(); DLLNode node = new DLLNode(5); list.addToTail(node); list.removeTail(); Assert.AreEqual(list.total(), 0); Assert.AreEqual(list.tail, null); }
public void Testremovetail2() { string[] str = new string[30]; int i = 0; FileStream f = new FileStream("C:/Users/edgu1/Desktop/222525.txt", FileMode.Open, FileAccess.Read); DLList pDLL = new DLList(); string line; try { StreamReader m_streamReader = new StreamReader(f); //StreamReader read txt m_streamReader.BaseStream.Seek(0, SeekOrigin.Begin); //read from head to tail by lines while ((line = m_streamReader.ReadLine()) != null) { DLLNode d = new DLLNode(line); pDLL.addToTail(d); str[i] = line; i++; } m_streamReader.Close(); } catch (FileNotFoundException e) { Console.WriteLine("errors" + e.ToString()); } pDLL.removeTail(); //////////////////////// string[] str2 = new string[20]; int j = 0; DLLNode tail = pDLL.tail; while (tail.previous != null) { str2[j] = tail.str; j++; tail = tail.previous; } str2[j] = tail.str; /// ///////////////////////////////////// string dd = null; if (str2[0] == "6") { dd = str[j + 1]; } Assert.AreEqual("54", dd); }