public static void main(String[] args) { int[][] input = new int[4][4]; input[0][0] = 1; input[0][1] = 2; input[0][2] = 3; input[0][3] = 4; input[1][0] = 5; input[1][1] = 6; input[1][2] = 7; input[1][3] = 8; input[2][0] = 9; input[2][1] = 10; input[2][2] = 11; input[2][3] = 12; input[3][0] = 13; input[3][1] = 14; input[3][2] = 15; input[3][3] = 16; RotateImage r = new RotateImage(); r.rotate(input); r.printArr(input); }
///////////////////////// Test ////////////////////////// public static void test(RotateImage r, int[][] m) { System.out.println("-------- Before ---------"); ListPrinter.print2DArray(m); System.out.println("-------- After ---------"); r.rotate(m); ListPrinter.print2DArray(m); System.out.println(); }
public void testMethod3() { int[][] matrix = { {1, 2, 3, 4, 5}, {6, 7, 8, 9, 10}, {11, 12, 13, 14, 15}, {16, 17, 18, 19, 20}, {21, 22, 23, 24, 25} }; testCase.rotate(matrix); int[][] expected = { {21, 16, 11, 6, 1}, {22, 17, 12, 7, 2}, {23, 18, 13, 8, 3}, {24, 19, 14, 9, 4}, {25, 20, 15, 10, 5} }; Assert.assertArrayEquals(expected, matrix); }
public void testMethod5() { int[][] matrix = {{1}}; testCase.rotate(matrix); int[][] expected = {{1}}; Assert.assertArrayEquals(expected, matrix); }
public void testMethod4() { int[][] matrix = {{1, 2}, {3, 4}}; testCase.rotate(matrix); int[][] expected = {{3, 1}, {4, 2}}; Assert.assertArrayEquals(expected, matrix); }
public void testMethod2() { int[][] matrix = {{1, 2, 3, 4}, {5, 6, 7, 8}, {9, 10, 11, 12}, {13, 14, 15, 16}}; testCase.rotate(matrix); int[][] expected = {{13, 9, 5, 1}, {14, 10, 6, 2}, {15, 11, 7, 3}, {16, 12, 8, 4}}; Assert.assertArrayEquals(expected, matrix); }
public void testMethod1() { int[][] matrix = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; testCase.rotate(matrix); int[][] expected = {{7, 4, 1}, {8, 5, 2}, {9, 6, 3}}; Assert.assertArrayEquals(expected, matrix); }