Ejemplo n.º 1
0
 public void DllAddLast()
 {
     var list = new DlList<Int>();
     list.AddLast(new Int(2));
     Assert.AreEqual(2, list.Last.Data.Value);
     list.AddLast(new Int(1));
     Assert.AreEqual(1, list.Last.Data.Value);
 }
Ejemplo n.º 2
0
        public void DllCount()
        {
            var list = new DlList<Int>();
            list.AddLast(new Int(1));
            list.AddLast(new Int(2));
            list.AddLast(new Int(3));
            list.AddLast(new Int(4));

            var listSize = list.Count();

            Assert.IsTrue(listSize == 4);
            Assert.IsFalse(listSize == 0);
        }
Ejemplo n.º 3
0
        public void DllClear()
        {
            var list = new DlList<Int>();
            list.AddLast(new Int(1));
            list.AddLast(new Int(2));
            list.AddLast(new Int(3));
            Assert.AreEqual(3, list.Last.Data.Value);
            Assert.AreEqual(1, list.First.Data.Value);

            list.Clear();
            Assert.IsNull(list.Last);
            Assert.IsNull(list.First);
        }
Ejemplo n.º 4
0
        public void DllFind()
        {
            var list = new DlList<Int>();
            list.AddLast(new Int(1));
            list.AddLast(new Int(2));
            list.AddLast(new Int(3));
            list.AddLast(new Int(4));

            var four = new Int(4);
            var five = new Int(5);

            Assert.AreEqual(four.Value, list.Find(four).Data.Value);
            Assert.IsFalse(list.Find(five).Data.Value.Equals(five.Value));
        }
Ejemplo n.º 5
0
        public void DllContains()
        {
            var list = new DlList<Int>();
            list.AddLast(new Int(1));
            list.AddLast(new Int(2));
            list.AddLast(new Int(3));
            list.AddLast(new Int(4));

            var trueNode = new Node<Int>(new Int(4));
            var falseNode = new Node<Int>(new Int(5));

            Assert.IsTrue(list.Contains(trueNode));
            Assert.IsFalse(list.Contains(falseNode.Data));
        }