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); }
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); }
public void Question_1_8_InvalidCases() { TestHelpers.AssertExceptionThrown(() => Question_1_8.PropogateZeros(null), typeof(ArgumentNullException)); TestHelpers.AssertExceptionThrown(() => Question_1_8.PropogateZerosInPlace(null), typeof(ArgumentNullException)); }