Sha256: 55d007bb547d1a8bb18a5e54a9d9022627659b9c5409c66ab9e065a7748c5f94

Contents?: true

Size: 1.96 KB

Versions: 133

Compression:

Stored size: 1.96 KB

Contents

import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

import static org.junit.Assert.assertArrayEquals;

public class SpiralMatrixBuilderTest {

    private SpiralMatrixBuilder spiralMatrixBuilder;

    @Before
    public void setUp() {
        spiralMatrixBuilder = new SpiralMatrixBuilder();
    }

    @Test
    public void testEmptySpiral() {
        int[][] expected = {};

        assertArrayEquals(expected, spiralMatrixBuilder.buildMatrixOfSize(0));
    }

    @Ignore("Remove to run test")
    @Test
    public void testTrivialSpiral() {
        int[][] expected = {
                {1}
        };

        assertArrayEquals(expected, spiralMatrixBuilder.buildMatrixOfSize(1));
    }

    @Ignore("Remove to run test")
    @Test
    public void testSpiralOfSize2() {
        int[][] expected = {
                {1, 2},
                {4, 3}
        };

        assertArrayEquals(expected, spiralMatrixBuilder.buildMatrixOfSize(2));
    }

    @Ignore("Remove to run test")
    @Test
    public void testSpiralOfSize3() {
        int[][] expected = {
                {1, 2, 3},
                {8, 9, 4},
                {7, 6, 5}
        };

        assertArrayEquals(expected, spiralMatrixBuilder.buildMatrixOfSize(3));
    }

    @Ignore("Remove to run test")
    @Test
    public void testSpiralOfSize4() {
        int[][] expected = {
                { 1,  2,  3,  4},
                {12, 13, 14,  5},
                {11, 16, 15,  6},
                {10,  9,  8,  7}
        };

        assertArrayEquals(expected, spiralMatrixBuilder.buildMatrixOfSize(4));
    }

    @Ignore("Remove to run test")
    @Test
    public void testSpiralOfSize5() {
        int[][] expected = {
                { 1,  2,  3,  4,  5},
                {16, 17, 18, 19,  6},
                {15, 24, 25, 20,  7},
                {14, 23, 22, 21,  8},
                {13, 12, 11, 10,  9}
        };

        assertArrayEquals(expected, spiralMatrixBuilder.buildMatrixOfSize(5));
    }

}

Version data entries

133 entries across 133 versions & 1 rubygems

Version Path
trackler-2.2.1.78 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.77 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.76 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.75 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.74 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.73 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.72 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.71 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.70 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.69 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.68 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.67 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.66 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.65 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.64 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.63 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.62 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.61 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.60 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.59 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java