Exemplo n.º 1
0
        public void TestA()
        {
            var list = new ListSorted <int>();

            assertSeqEquals(list);
            list.Add(20);
            assertSeqEquals(list, 20);
            list.Add(25);
            assertSeqEquals(list, 20, 25);
            list.Add(15);
            assertSeqEquals(list, 15, 20, 25);
            list.Add(20);
            assertSeqEquals(list, 15, 20, 20, 25);

            list = new ListSorted <int>(new ReverseComparerInt());
            list.Add(20); list.Add(25); list.Add(15); list.Add(20);
            assertSeqEquals(list, 25, 20, 20, 15);

            list = new ListSorted <int>(20, new ReverseComparerInt());
            list.Add(20); list.Add(25); list.Add(15); list.Add(20);
            assertSeqEquals(list, 25, 20, 20, 15);

            try
            {
                ((IList <int>)list).Insert(0, 8);
                Assert.Fail();
            }
            catch { }
            try
            {
                list[0] = 5;
                Assert.Fail();
            }
            catch { }
        }
Exemplo n.º 2
0
        public void TestB()
        {
            var list = new ListSorted <TestThingy>(20);

            list.Add(A); list.Add(B); list.Add(C); list.Add(D); list.Add(E);
            assertSeqEquals(list, A, B, C, D, E);
            assertSeqNotEquals(list, A, C, B, D, E);
        }
Exemplo n.º 3
0
        public void TestC()
        {
            var list = new ListSorted <TestThingy>();

            list.Add(E); list.Add(B); list.Add(D); list.Add(C); list.Add(A);
            assertSeqEquals(list, A, B, D, C, E);
            Assert.AreEqual(0, list.IndexOf(A));
            Assert.AreEqual(1, list.IndexOf(B));
            Assert.AreEqual(1, list.IndexOf(C));
            Assert.AreEqual(1, list.IndexOf(D));
            Assert.AreEqual(4, list.IndexOf(E));
            Assert.AreEqual(0, list.LastIndexOf(A));
            Assert.AreEqual(3, list.LastIndexOf(B));
            Assert.AreEqual(3, list.LastIndexOf(C));
            Assert.AreEqual(3, list.LastIndexOf(D));
            Assert.AreEqual(4, list.LastIndexOf(E));
            list.RemoveAt(2);
            assertSeqEquals(list, A, B, C, E);
        }
Exemplo n.º 4
0
        public void TestG()
        {
            var list = new ListSorted <TestThingy>();

            list.Add(C);
            list.AddRange(new[] { E, D, B, A });
            assertSeqEquals(list, A, C, D, B, E);

            TestThingy[] arr = new TestThingy[6];
            list.CopyTo(arr, 1);
            Assert.IsNull(arr[0]);
            Assert.AreSame(arr[1], A);
            Assert.AreSame(arr[2], C);
            Assert.AreSame(arr[3], D);
            Assert.AreSame(arr[4], B);
            Assert.AreSame(arr[5], E);
        }