lots of exercises in java... from https://github.com/exercism/java

SpiralMatrixBuilderTest.java 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. import org.junit.Before;
  2. import org.junit.Ignore;
  3. import org.junit.Test;
  4. import static org.junit.Assert.assertArrayEquals;
  5. /*
  6. * version: 1.0.0
  7. */
  8. public class SpiralMatrixBuilderTest {
  9. private SpiralMatrixBuilder spiralMatrixBuilder;
  10. @Before
  11. public void setUp() {
  12. spiralMatrixBuilder = new SpiralMatrixBuilder();
  13. }
  14. @Test
  15. public void testEmptySpiral() {
  16. int[][] expected = {};
  17. assertArrayEquals(expected, spiralMatrixBuilder.buildMatrixOfSize(0));
  18. }
  19. @Ignore("Remove to run test")
  20. @Test
  21. public void testTrivialSpiral() {
  22. int[][] expected = {
  23. {1}
  24. };
  25. assertArrayEquals(expected, spiralMatrixBuilder.buildMatrixOfSize(1));
  26. }
  27. @Ignore("Remove to run test")
  28. @Test
  29. public void testSpiralOfSize2() {
  30. int[][] expected = {
  31. {1, 2},
  32. {4, 3}
  33. };
  34. assertArrayEquals(expected, spiralMatrixBuilder.buildMatrixOfSize(2));
  35. }
  36. @Ignore("Remove to run test")
  37. @Test
  38. public void testSpiralOfSize3() {
  39. int[][] expected = {
  40. {1, 2, 3},
  41. {8, 9, 4},
  42. {7, 6, 5}
  43. };
  44. assertArrayEquals(expected, spiralMatrixBuilder.buildMatrixOfSize(3));
  45. }
  46. @Ignore("Remove to run test")
  47. @Test
  48. public void testSpiralOfSize4() {
  49. int[][] expected = {
  50. { 1, 2, 3, 4},
  51. {12, 13, 14, 5},
  52. {11, 16, 15, 6},
  53. {10, 9, 8, 7}
  54. };
  55. assertArrayEquals(expected, spiralMatrixBuilder.buildMatrixOfSize(4));
  56. }
  57. @Ignore("Remove to run test")
  58. @Test
  59. public void testSpiralOfSize5() {
  60. int[][] expected = {
  61. { 1, 2, 3, 4, 5},
  62. {16, 17, 18, 19, 6},
  63. {15, 24, 25, 20, 7},
  64. {14, 23, 22, 21, 8},
  65. {13, 12, 11, 10, 9}
  66. };
  67. assertArrayEquals(expected, spiralMatrixBuilder.buildMatrixOfSize(5));
  68. }
  69. }