示例#1
0
        public void EmptyArrayShouldThrowArgumentException()
        {
            var rotations = 7;

            var array = new int[0];

            var arrayRotation = new ArrayLeftRotation();

            var rotatedArray = arrayRotation.RotateLeft(rotations, array);

            CollectionAssert.AreEqual(array, rotatedArray);
        }
示例#2
0
        public void NullArrayShouldThrowArgumentNullException()
        {
            var rotations = 7;

            int[] array = null;

            var arrayRotation = new ArrayLeftRotation();

            var rotatedArray = arrayRotation.RotateLeft(rotations, array);

            CollectionAssert.AreEqual(array, rotatedArray);
        }
示例#3
0
        public void LeftRotate_Test()
        {
            var d    = 4;
            var list = new List <int> {
                1, 2, 3, 4, 5
            };

            var actual = ArrayLeftRotation.LeftRotate(list, d);

            Assert.Equal(new List <int> {
                5, 1, 2, 3, 4
            }, actual);
        }
示例#4
0
        public void NegativeRotationsShouldThrowArgumentOutOfRangeException()
        {
            var rotations = 7;
            var array     = new int[5] {
                1, 2, 3, 4, 5
            };

            var arrayRotation = new ArrayLeftRotation();

            var rotatedArray = arrayRotation.RotateLeft(rotations, array);

            CollectionAssert.AreEqual(array, rotatedArray);
        }
示例#5
0
        public void OneRotationsShouldReturnUpdatedArray()
        {
            var rotations = 1;

            var inputArray = new int[5] {
                1, 2, 3, 4, 5
            };

            var expectedArray = new int[5] {
                2, 3, 4, 5, 1
            };

            var arrayRotation = new ArrayLeftRotation();

            var rotatedArray = arrayRotation.RotateLeft(rotations, inputArray);

            CollectionAssert.AreEqual(expectedArray, rotatedArray);
        }
示例#6
0
        public void RotationsEqualToArrayLengthShouldReturnSameArray()
        {
            var inputArray = new int[5] {
                1, 2, 3, 4, 5
            };

            var rotations = inputArray.Length;

            var expectedArray = new int[5] {
                1, 2, 3, 4, 5
            };

            var arrayRotation = new ArrayLeftRotation();

            var rotatedArray = arrayRotation.RotateLeft(rotations, inputArray);

            CollectionAssert.AreEqual(expectedArray, rotatedArray);
        }
 public void Test(int[] a, int d, int[] expected)
 {
     Assert.Equal(expected, ArrayLeftRotation.Execute(a, d));
 }