Пример #1
0
        public void ShouldThrowExceptionWhenGivenIndexIsOutOfRange()
        {
            Vector <int> empty = new ArrayVector <int>();

            var actions = new Action[]
            {
                () => empty.With(0, 0),
                () => empty.With(-1, -1),
                () => { int value = empty[0]; },
                () => { int value = empty[-1]; }
            };

            foreach (var action in actions)
            {
                action.ShouldThrow <IndexOutOfRangeException>("Index was outside the bounds of the vector.");
            }
        }
Пример #2
0
        private static Vector <int> SliceDigits(int startIndexInclusive, int endIndexExclusive)
        {
            var digits = new ArrayVector <int>(0, 1, 2, 3, 4, 5, 6, 7, 8, 9);

            return(digits.Slice(startIndexInclusive, endIndexExclusive));
        }
Пример #3
0
        public void ShouldCreateSlices()
        {
            Vector <int> slice = new ArrayVector <int>(0, 1, 2, 3, 4, 5, 6).Slice(1, 6);

            slice.ShouldList(1, 2, 3, 4, 5);
        }