Beispiel #1
0
        void RemoveRange_works(int index, int count, InstructionList list, Instruction[] expected)
        {
            list.RemoveRange(index, count);
            Assert.Equal(expected.Length, list.Count);
            Assert.True(expected.Length <= list.Capacity);
            var listElems = new Instruction[list.Count];

            list.CopyTo(listElems);
            AssertEqual(expected, listElems);
        }
Beispiel #2
0
        void RemoveRange_throws_if_invalid_input()
        {
            var             instructions = GetInstructions();
            InstructionList list;

            list = new InstructionList(Array.Empty <Instruction>());
            Assert.Throws <ArgumentOutOfRangeException>(() => list.RemoveRange(GetValue(-1), GetValue(0)));
            Assert.Throws <ArgumentOutOfRangeException>(() => list.RemoveRange(GetValue(0), GetValue(1)));
            Assert.Throws <ArgumentOutOfRangeException>(() => list.RemoveRange(GetValue(1), GetValue(0)));
            Assert.Throws <ArgumentOutOfRangeException>(() => list.RemoveRange(GetValue(-1), GetValue(1)));

            list = new InstructionList(instructions);
            Assert.Throws <ArgumentOutOfRangeException>(() => list.RemoveRange(GetValue(-1), 0));
            Assert.Throws <ArgumentOutOfRangeException>(() => list.RemoveRange(GetValue(1), GetValue(list.Count)));
            Assert.Throws <ArgumentOutOfRangeException>(() => list.RemoveRange(GetValue(0), GetValue(list.Count + 1)));
            Assert.Throws <ArgumentOutOfRangeException>(() => list.RemoveRange(GetValue(int.MinValue), GetValue(0)));
            Assert.Throws <ArgumentOutOfRangeException>(() => list.RemoveRange(GetValue(0), GetValue(int.MaxValue)));
            Assert.Throws <ArgumentOutOfRangeException>(() => list.RemoveRange(GetValue(int.MaxValue), GetValue(int.MaxValue)));
            Assert.Throws <ArgumentOutOfRangeException>(() => list.RemoveRange(GetValue(int.MinValue), GetValue(int.MaxValue)));
        }