Example #1
0
        public void TestRemoveBeforeDataPresentItemBeforeNotPresent()
        {
            int[]      intArray = { 1, 2, 3 };
            MyLL <int> ll       = new MyLL <int>(intArray);

            ll.RemoveBefore(1);
        }
Example #2
0
        public void TestRemoveAfterDataPresentItemAfterNotPresent()
        {
            int[]      intArray = { 1, 2, 3 };
            MyLL <int> ll       = new MyLL <int>(intArray);

            ll.RemoveAfter(3);
        }
Example #3
0
        public void TestAddBeforeDataNotPresent()
        {
            int[]      intArray = { 1, 2, 3 };
            MyLL <int> ll       = new MyLL <int>(intArray);

            ll.AddBefore(4, 2);
        }
Example #4
0
        public void TestDeleteIndexOutOfRangePositive()
        {
            int[]      intArray = { 1, 2, 3 };
            MyLL <int> ll       = new MyLL <int>(intArray);

            ll.DeleteIndex(3);
        }
Example #5
0
        public void TestNodeDataLinkedListValue()
        {
            MyLL <int>         llinner = new MyLL <int>(1);
            MyLL <MyLL <int> > llouter = new MyLL <MyLL <int> >(llinner);
            var actual = llouter.GetHeadData();

            Assert.IsInstanceOfType(actual, llinner.GetType());
        }
Example #6
0
        public void TestToStringOverrideEmptyList()
        {
            MyLL <int> ll     = new MyLL <int>();
            var        expect = "";
            var        actual = ll.ToString();

            Assert.AreEqual(expect, actual);
        }
Example #7
0
        public void TestPopEndNonEmptyList()
        {
            int[]      intArray = { 1, 2, 3 };
            MyLL <int> ll       = new MyLL <int>(intArray);
            var        expect   = 3;
            var        actual   = ll.PopEnd();

            Assert.AreEqual(expect, actual);
        }
Example #8
0
        public void TestGetSizeEmptyList()
        {
            // Doubles as test of Empty Constructor
            MyLL <int> ll     = new MyLL <int>();
            var        expect = (int)0;
            var        actual = ll.GetSize();

            Assert.AreEqual(expect, actual);
        }
Example #9
0
        public void TestToStringOverride()
        {
            int[]      intArray = { 1, 2, 3 };
            MyLL <int> ll       = new MyLL <int>(intArray);
            var        expect   = "1, 2, 3";
            var        actual   = ll.ToString();

            Assert.AreEqual(expect, actual);
        }
Example #10
0
        public void TestAddAtEndToEmptyList()
        {
            MyLL <int> ll     = new MyLL <int>();
            var        expect = "1";

            ll.AddAtEnd(1);
            var actual = ll.ToString();

            Assert.AreEqual(expect, actual);
        }
Example #11
0
        public void TestGetSizeMultipleNodeList()
        {
            // Doubles as test of Multiple Data Constructor
            int[]      intArray = { 1, 2, 3 };
            MyLL <int> ll       = new MyLL <int>(intArray);
            var        expect   = (int)3;
            var        actual   = ll.GetSize();

            Assert.AreEqual(expect, actual);
        }
Example #12
0
        public void TestAddAtFrontToNonEmptyList()
        {
            MyLL <int> ll     = new MyLL <int>(1);
            var        expect = "2, 1";

            ll.AddAtFront(2);
            var actual = ll.ToString();

            Assert.AreEqual(expect, actual);
        }
Example #13
0
        public void TestAddBeforeDataPresent()
        {
            int[]      intArray = { 1, 2, 3 };
            MyLL <int> ll       = new MyLL <int>(intArray);

            ll.AddBefore(2, 4);
            var expect = "1, 4, 2, 3";
            var actual = ll.ToString();

            Assert.AreEqual(expect, actual);
        }
Example #14
0
        public void TestAppendEmptyToEmpty()
        {
            MyLL <int> lla = new MyLL <int>();
            MyLL <int> llb = new MyLL <int>();

            lla.Append(llb);
            var expect = 0;
            var actual = lla.GetSize();

            Assert.AreEqual(expect, actual);
        }
Example #15
0
        public void TestGetSizeOneNodeList()
        {
            // Doubles as test of Single Data Constructor
            MyLL <int> ll     = new MyLL <int>(3);
            var        expect = (int)1;
            var        actual = ll.GetSize();

            Assert.AreEqual(expect, actual);
            // CAUTION: Head and Tail of 1 node list should be the same node, not just equivalent value
            Assert.AreEqual(ll.GetHeadData(), ll.GetTailData());
        }
Example #16
0
        public void TestRemoveBeforeDataPresentItemBeforePresentFirstItem()
        {
            int[]      intArray = { 1, 2, 3 };
            MyLL <int> ll       = new MyLL <int>(intArray);

            ll.RemoveBefore(2);
            var expect = "2, 3";
            var actual = ll.ToString();

            Assert.AreEqual(expect, actual);
        }
Example #17
0
        public void TestAppendNonEmptyToEmpty()
        {
            MyLL <int> lla = new MyLL <int>(1);
            MyLL <int> llb = new MyLL <int>();

            lla.Append(llb);
            var expect = "1";
            var actual = lla.ToString();

            Assert.AreEqual(expect, actual);
        }
Example #18
0
        public void TestRemoveAfterDataPresentItemAfterPresentLastItem()
        {
            int[]      intArray = { 1, 2, 3 };
            MyLL <int> ll       = new MyLL <int>(intArray);

            ll.RemoveAfter(2);
            var expect = "1, 2";
            var actual = ll.ToString();

            Assert.AreEqual(expect, actual);
        }
Example #19
0
        public void TestDeleteIndexPresent()
        {
            int[]      intArray = { 1, 2, 3 };
            MyLL <int> ll       = new MyLL <int>(intArray);

            ll.DeleteIndex(1);
            var expect = "1, 3";
            var actual = ll.ToString();

            Assert.AreEqual(expect, actual);
        }
Example #20
0
        public void TestAppendNonEmptyToNonEmpty()
        {
            int[]      intsA = { 1, 2 };
            int[]      intsB = { 3, 4 };
            MyLL <int> lla   = new MyLL <int>(intsA);
            MyLL <int> llb   = new MyLL <int>(intsB);

            lla.Append(llb);
            var expect = "1, 2, 3, 4";
            var actual = lla.ToString();

            Assert.AreEqual(expect, actual);
        }
Example #21
0
 public void TestGetTailDataNullValue()
 {
     MyLL <string> ll     = new MyLL <string>();
     var           errata = ll.GetTailData();
 }
Example #22
0
 public void TestPopEndEmptyList()
 {
     MyLL <int> ll     = new MyLL <int>();
     var        errata = ll.PopEnd();
 }