public void AddAt() { SinglyLinkedList <int> list = new SinglyLinkedList <int>(); list.AddEnd(0); list.AddEnd(1); list.AddEnd(2); list.AddAt(3, 3); int i = 0; foreach (var num in list) { Assert.True(num == i); i++; } }
public void RemoveFirst() { SinglyLinkedList <int> list = new SinglyLinkedList <int>(); list.AddEnd(2); list.AddEnd(3); list.AddEnd(1); list.RemoveFirst(); int i = 3; foreach (var num in list) { Assert.True(num == i); i -= 2; } }
public void Clear() { SinglyLinkedList <int> list = new SinglyLinkedList <int>(); list.AddEnd(0); list.Clear(); Assert.True(list.Count == 0); }
public void AddAfter() { SinglyLinkedList <int> list = new SinglyLinkedList <int>(); list.AddEnd(0); list.AddEnd(1); list.AddEnd(2); list.AddEnd(3); list.AddAfter(new SinglyLinkedNode <int>(0, new SinglyLinkedNode <int>(1)), 4); int i = 0; /*foreach (var num in list) * { * Assert.True(num == i); * i++; * }*/ Assert.True(list[1] == 4); //Assert.True(list.Count == 5); }
public void DankMemes(int[] array, int toAdd) { var test = new SinglyLinkedList <int>(); for (int i = 0; i < array.Length; i++) { test.AddEnd(array[i]); } int length = test.Count; test.AddStart(toAdd); Assert.True(length != test.Count); }