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.180 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.179 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.178 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.177 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.176 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.175 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.174 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.173 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.172 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.171 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.170 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.169 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.167 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.166 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.165 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.164 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.163 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.162 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.161 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java
trackler-2.2.1.160 tracks/java/exercises/spiral-matrix/src/test/java/SpiralMatrixBuilderTest.java