コード例 #1
0
        public void TestDelete()
        {
            Listard <int> l = new Listard <int>();

            int[] block = new int[] { 4711, 4712, 4713, 4714, 4715 };
            l.Add(block);
            l.Delete(1, 2);
            if (l.Count != 3)
            {
                throw new Exception();
            }
            if (l[0] != 4711)
            {
                throw new Exception();
            }
            if (l[1] != 4714)
            {
                throw new Exception();
            }
            if (l[2] != 4715)
            {
                throw new Exception();
            }
            l.Delete(2, 0);
            if (l.Count != 3)
            {
                throw new Exception();
            }
            if (l[0] != 4711)
            {
                throw new Exception();
            }
            if (l[1] != 4714)
            {
                throw new Exception();
            }
            if (l[2] != 4715)
            {
                throw new Exception();
            }
            l.Delete(2, 1);
            if (l.Count != 2)
            {
                throw new Exception();
            }
            if (l[0] != 4711)
            {
                throw new Exception();
            }
            if (l[1] != 4714)
            {
                throw new Exception();
            }
            l.Delete(0);
            if (l.Count != 1)
            {
                throw new Exception();
            }
            if (l[0] != 4714)
            {
                throw new Exception();
            }

            try {
                l.Delete(-1);
                throw new Exception();
            } catch (IndexOutOfRangeException) { /* expected error */ }
            try {
                l.Delete(1);
                throw new Exception();
            } catch (IndexOutOfRangeException) { /* expected error */ }
            try {
                l.Delete(0, -1);
                throw new Exception();
            } catch (ArgumentException) { /* expected error */ }
            try {
                l.Delete(0, 2);
                throw new Exception();
            } catch (ArgumentException) { /* expected error */ }

            l.Delete(0, 1);
            if (l.Count != 0)
            {
                throw new Exception();
            }
        }
コード例 #2
0
ファイル: TestListardPosition.cs プロジェクト: j0035/Snek
        public void TestDelete()
        {
            Listard <Position> l = new Listard <Position>();

            Position[] block = new Position[] {
                new Position("47|11"), new Position("47|12"),
                new Position("48|13"), new Position("48|14"), new Position("48|15")
            };
            l.Add(block);
            l.Delete(3, 2);
            if (l.Count != 3)
            {
                throw new Exception();
            }
            if (l[0].Text != "47|11")
            {
                throw new Exception();
            }
            if (l[1].Text != "47|12")
            {
                throw new Exception();
            }
            if (l[2].Text != "48|13")
            {
                throw new Exception();
            }
            l.Delete(1, 0);
            if (l.Count != 3)
            {
                throw new Exception();
            }
            if (l[0].Text != "47|11")
            {
                throw new Exception();
            }
            if (l[1].Text != "47|12")
            {
                throw new Exception();
            }
            if (l[2].Text != "48|13")
            {
                throw new Exception();
            }
            l.Delete(1, 1);
            if (l.Count != 2)
            {
                throw new Exception();
            }
            if (l[0].Text != "47|11")
            {
                throw new Exception();
            }
            if (l[1].Text != "48|13")
            {
                throw new Exception();
            }
            l.Delete(0);
            if (l.Count != 1)
            {
                throw new Exception();
            }
            if (l[0].Text != "48|13")
            {
                throw new Exception();
            }

            try {
                l.Delete(-1);
                throw new Exception();
            } catch (IndexOutOfRangeException) { /* expected error */ }
            try {
                l.Delete(1);
                throw new Exception();
            } catch (IndexOutOfRangeException) { /* expected error */ }
            try {
                l.Delete(0, -1);
                throw new Exception();
            } catch (ArgumentException) { /* expected error */ }
            try {
                l.Delete(0, 2);
                throw new Exception();
            } catch (ArgumentException) { /* expected error */ }

            l.Delete(0, 1);
            if (l.Count != 0)
            {
                throw new Exception();
            }
        }