Exemplo n.º 1
0
        private void ValidateResult(int[,] expected, int[,] input)
        {
            var inputCopy = MatrixHelpers.CreateTwoDimensionalMatrix(input.GetLength(0), input.GetLength(1), input.Cast <int>().ToArray());

            Question_1_8.PropogateZeros(input);
            TestHelpers.AssertMatricesEqual(expected, input);
            Question_1_8.PropogateZerosInPlace(inputCopy);
            TestHelpers.AssertMatricesEqual(expected, inputCopy);
        }
Exemplo n.º 2
0
        public void ZeroMatrixTest_3x3()
        {
            int[,] testMatrix = new int[3, 3]
            {
                { 1, 0, 1 },
                { 1, 1, 1 },
                { 0, 1, 1 }
            };
            int[,] expectedMatrix = new int[3, 3]
            {
                { 0, 0, 0 },
                { 0, 0, 1 },
                { 0, 0, 0 }
            };

            // Question_1_8.ZeroMatrix(testMatrix);
            Question_1_8.ZeroMatrixMemoryImproved(testMatrix);
            TestHelper.AssertMatricesAreEqual(expectedMatrix, testMatrix);
        }
Exemplo n.º 3
0
 public void Question_1_8_InvalidCases()
 {
     TestHelpers.AssertExceptionThrown(() => Question_1_8.PropogateZeros(null), typeof(ArgumentNullException));
     TestHelpers.AssertExceptionThrown(() => Question_1_8.PropogateZerosInPlace(null), typeof(ArgumentNullException));
 }