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.98 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.97 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.96 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.95 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.94 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.93 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.92 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.91 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.90 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.89 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.88 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.87 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.86 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.85 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.84 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.83 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.82 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.81 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.80 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.79 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java