Ejemplo n.º 1
0
        public void FindTest()
        {
            MyList <int> firstTestList  = new MyList <int>();
            MyList <int> secondTestList = new MyList <int>();

            for (int i = 0; i < 12; i += 3)
            {
                firstTestList.AddFirst(i);
                firstTestList.AddLast(i + 1);
                secondTestList.AddLast(i);
                secondTestList.AddFirst(i + 1);
            }


            for (int i = 0; i < 12; i++)
            {
                if ((i - 2) % 3 == 0)
                {
                    if (firstTestList.Find(i) != null || secondTestList.Find(i) != null)
                    {
                        Assert.Fail();
                    }
                }

                else
                if (firstTestList.Find(i) == null || secondTestList.Find(i) == null)
                {
                    Assert.Fail();
                }
            }
        }
Ejemplo n.º 2
0
 private void CreateList_Click(object sender, EventArgs e)
 {
     list.Clear();
     for (int i = 0; i < textBox1.Lines.Length; i++)
     {
         list.AddLast(Convert.ToInt32(textBox1.Lines[i]));
     }
     //textBox2.Lines = list.Printer();
 }
Ejemplo n.º 3
0
        public void AddLastTest()
        {
            MyList <int> testList = new MyList <int>();

            for (int i = 0; i <= 10; i++)
            {
                testList.AddLast(i);
                if (testList.Length() != i + 1)
                {
                    Assert.Fail();
                }
            }

            Assert.Pass();
        }
Ejemplo n.º 4
0
        public void DeleteTest()
        {
            MyList <int> testList = new MyList <int>();

            for (int i = 3; i <= 9; i += 2)
            {
                testList.AddFirst(i);
                testList.AddLast(i + 1);
            }

            for (int i = 12; i >= 7; i--)
            {
                if (i > 10 && testList.Delete(i))
                {
                    Assert.Fail();
                }

                else if (i <= 10)
                {
                    Node <int> sampleNode;
                    if (i % 2 == 1)
                    {
                        sampleNode = testList.Head;
                    }
                    else
                    {
                        sampleNode = testList.Tail;
                    }

                    if (!(testList.Length() == 8 + i - 10 && testList.Delete(i)))
                    {
                        Assert.Fail();
                    }
                }
            }
            for (int i = 3; i <= 4; i++)
            {
                Node <int> deletable = testList.Find(i);
                if (!testList.Delete(i) || testList.Length() != 3 - (i - 3))
                {
                    Assert.Fail();
                }
            }
            Assert.Pass();
        }