コード例 #1
0
        public void MyDLListItemTest_SetException1()
        {
            int[]          mas  = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            MyDLList <int> list = new MyDLList <int>(mas);

            list[10] = 100;
        }
コード例 #2
0
        public void MyDLListCtorReferenceTest()
        {
            MyDLList <string> listA = new MyDLList <string>();

            Assert.IsNotNull(listA);
            Assert.AreEqual(0, listA.Count);
            Assert.IsFalse(listA.IsReadOnly);
        }
コード例 #3
0
        public void MyDLListCtorValueTest()
        {
            MyDLList <int> list = new MyDLList <int>();

            Assert.IsNotNull(list);
            Assert.AreEqual(0, list.Count);
            Assert.IsFalse(list.IsReadOnly);
        }
コード例 #4
0
        public void MyDLListClearTest()
        {
            int[]          mas  = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            MyDLList <int> list = new MyDLList <int>(mas);

            Assert.AreEqual(10, list.Count);
            list.Clear();
            Assert.AreEqual(0, list.Count);
        }
コード例 #5
0
        public void MyDLListItemTest_Get()
        {
            int[]          mas  = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            MyDLList <int> list = new MyDLList <int>(mas);

            for (int i = 0; i < mas.Length; ++i)
            {
                Assert.AreEqual(mas[i], list[i]);
            }
        }
コード例 #6
0
        public void MyDLListEnumeratorTest()
        {
            int[]          mas   = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            MyDLList <int> list  = new MyDLList <int>(mas);
            int            index = 0;

            foreach (int x in list)
            {
                Assert.AreEqual(mas[index++], x);
            }
        }
コード例 #7
0
        public void MyDLListItemTest_Set()
        {
            int[]          mas  = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            MyDLList <int> list = new MyDLList <int>(mas);

            list[0] = 101;
            list[5] = 106;
            list[9] = 110;
            Assert.AreEqual(101, list[0]);
            Assert.AreEqual(106, list[5]);
            Assert.AreEqual(110, list[9]);
        }
コード例 #8
0
        public void MyDLListTest()
        {
            MyDLList <int> list = new MyDLList <int>();

            Assert.AreEqual(0, list.Count);
            list.Add(100);
            Assert.AreEqual(1, list.Count);
            for (int i = 0; i < 10000; ++i)
            {
                list.Add(i);
            }
            Assert.AreEqual(10001, list.Count);
        }
コード例 #9
0
        public void MyDLListRemoveAtTest()
        {
            int[]          mas  = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            MyDLList <int> list = new MyDLList <int>(mas);

            list.RemoveAt(0);
            Assert.AreEqual(9, list.Count);
            Assert.AreEqual(2, list[0]);

            list.RemoveAt(8);
            Assert.AreEqual(8, list.Count);
            Assert.AreEqual(9, list[7]);
        }
コード例 #10
0
        public void MyDLListIndexOfTest()
        {
            int[]          mas  = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            MyDLList <int> list = new MyDLList <int>(mas);

            Assert.AreEqual(0, list.IndexOf(1));
            Assert.AreEqual(9, list.IndexOf(10));
            Assert.AreEqual(4, list.IndexOf(5));
            Assert.AreEqual(-1, list.IndexOf(0));
            Assert.AreEqual(-1, list.IndexOf(100));
            Assert.AreEqual(-1, list.IndexOf(Int32.MaxValue));
            Assert.AreEqual(-1, list.IndexOf(Int32.MinValue));
        }
コード例 #11
0
        public void MyDLListCopyToTest()
        {
            int[]          mas  = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            MyDLList <int> list = new MyDLList <int>(mas);

            int [] arr = new int[list.Count];
            list.CopyTo(arr, 0);

            for (int i = 0; i < mas.Length; ++i)
            {
                Assert.AreEqual(mas[i], arr[i]);
            }
        }
コード例 #12
0
        public void MyDLListContainsTest()
        {
            int[]          mas  = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            MyDLList <int> list = new MyDLList <int>(mas);

            Assert.IsTrue(list.Contains(1));
            Assert.IsTrue(list.Contains(6));
            Assert.IsTrue(list.Contains(10));

            Assert.IsFalse(list.Contains(-1));
            Assert.IsFalse(list.Contains(25));
            Assert.IsFalse(list.Contains(Int32.MaxValue));
            Assert.IsFalse(list.Contains(Int32.MinValue));
        }
コード例 #13
0
        public void MyDLListInsertTest()
        {
            int[]          mas  = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            MyDLList <int> list = new MyDLList <int>(mas);

            list.Insert(0, 100);
            Assert.AreEqual(11, list.Count);
            Assert.AreEqual(100, list[0]);
            Assert.AreEqual(1, list[1]);

            list.Insert(10, 1000);
            Assert.AreEqual(12, list.Count);
            Assert.AreEqual(1000, list[10]);
            Assert.AreEqual(10, list[11]);
        }
コード例 #14
0
        public void MyDLListRemoveTest()
        {
            int[]          mas  = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
            MyDLList <int> list = new MyDLList <int>(mas);

            list.Remove(0);
            Assert.AreEqual(10, list.Count);

            list.Remove(10);
            Assert.AreEqual(9, list.Count);
            Assert.AreEqual(9, list[8]);

            list.Remove(1);
            Assert.AreEqual(8, list.Count);
            Assert.AreEqual(2, list[0]);

            list.Remove(5);
            Assert.AreEqual(7, list.Count);
            Assert.AreEqual(6, list[3]);
        }
コード例 #15
0
        public void MyDLListItemTest_GetException2()
        {
            MyDLList <int> list = new MyDLList <int>();

            Assert.AreEqual(10, list[-1]);
        }
コード例 #16
0
        public void MyDLListItemTest_SetException3()
        {
            MyDLList <int> list = new MyDLList <int>();

            list[-1] = 100;
        }