public void Add() { LinkedList list = new LinkedList(); list.Add( "1" ); Assert.AreEqual( "1", list.Head ); Assert.AreEqual( 1, list.Count ); list.Add( "2" ); Assert.AreEqual( "1", list.Head ); Assert.AreEqual( 2, list.Count ); list.Add( "3" ); Assert.AreEqual( "1", list.Head ); Assert.AreEqual( 3, list.Count ); }
public void RemoveBoundary1() { LinkedList list = new LinkedList(); list.Add( "1" ); list.Add( "2" ); list.Add( "3" ); list.Remove( "1" ); Assert.AreEqual( "2", list.Head ); Assert.AreEqual( 2, list.Count ); String[] array = (String[]) list.ToArray( typeof(String) ); Assert.AreEqual( "2,3", String.Join(",", array) ); }
public void Replace4() { LinkedList list = new LinkedList(); list.Add( "0" ); list.Add( "1" ); list.Add( "2" ); list.Add( "3" ); Assert.IsTrue( list.Replace("2", "x") ); Assert.AreEqual( 4, list.Count ); String[] array = (String[]) list.ToArray( typeof(String) ); Assert.AreEqual( "0,1,x,3", String.Join(",", array) ); }
public void Insert2bis() { LinkedList list = new LinkedList(); list.Add( "0" ); list.Add( "1" ); list.Add( "2" ); list.Add( "3" ); list.Add( "4" ); list.Add( "5" ); list.Insert(2, "x"); Assert.AreEqual( 7, list.Count ); String[] array = (String[]) list.ToArray( typeof(String) ); Assert.AreEqual( "0,1,x,2,3,4,5", String.Join(",", array) ); }
public void Replace3() { LinkedList list = new LinkedList(); list.Add( "0" ); list.Add( "1" ); Assert.IsFalse( list.Replace("11", "x") ); Assert.AreEqual( 2, list.Count ); String[] array = (String[]) list.ToArray( typeof(String) ); Assert.AreEqual( "0,1", String.Join(",", array) ); }
public void Insert2() { LinkedList list = new LinkedList(); list.Add( "1" ); list.Add( "2" ); list.Add( "3" ); list.Insert(2, "x"); Assert.AreEqual( 4, list.Count ); String[] array = (String[]) list.ToArray( typeof(String) ); Assert.AreEqual( "1,2,x,3", String.Join(",", array) ); }
public void IndexOf2() { LinkedList list = new LinkedList(); list.Add( "1" ); list.Add( "2" ); list.Add( "3" ); list.Add( "4" ); list.Add( "5" ); Assert.AreEqual( 4, list.IndexOf("5") ); Assert.AreEqual( -1, list.IndexOf("10") ); }
public void RemoveMiddle2() { LinkedList list = new LinkedList(); list.Add( "1" ); list.Add( "2" ); list.Add( "3" ); list.Add( "4" ); list.Add( "5" ); list.Remove( "3" ); Assert.AreEqual( "1", list.Head ); Assert.AreEqual( 4, list.Count ); String[] array = (String[]) list.ToArray( typeof(String) ); Assert.AreEqual( "1,2,4,5", String.Join(",", array) ); }
public void Replace3() { LinkedList list = new LinkedList(); list.Add( "0" ); list.Add( "1" ); Assert.IsFalse( list.Replace("11", "x"), "Successfully replaced 11 with x when it should have failed." ); Assert.AreEqual( 2, list.Count ); String[] array = (String[]) list.ToArray( typeof(String) ); Assert.AreEqual( "0,1", String.Join(",", array) ); }
public void Insert1_AfterReplacingHeadWithAddFirst() { LinkedList list = new LinkedList(); list.Add("2"); list.AddFirst("1"); list.Insert(1, "x"); Assert.AreEqual(3, list.Count); String[] array = (String[])list.ToArray(typeof(String)); Assert.AreEqual("1,x,2", String.Join(",", array)); }