public void Test(string inputStr, int expected) { var input = JsonConvert.DeserializeObject <int[][]>(inputStr); var s = new Solution(); s.CountSquares(input).Should().Be(expected); }
public void CountSquaresTest() { var s = new Solution(); int[][] matrix; int expected; matrix = Create2dArray(4, 0, 1, 1, 1, 1, 1, 1, 1, 0, 1, 1, 1); expected = 15; // 10 (1), 4 (2), 1 (3) Assert.Equal(expected, s.CountSquares(matrix)); matrix = Create2dArray(3, 1, 0, 1, 1, 1, 0, 1, 1, 0); expected = 7; // 6 (1), 1 (2) Assert.Equal(expected, s.CountSquares(matrix)); // test case 21/32 matrix = Create2dArray(5, 1, 1, 0, 0, 1, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 1, 0, 1, 0, 0, 1, 0, 1); expected = 19; // 17 (1), 2 (2) Assert.Equal(expected, s.CountSquares(matrix)); }