Sha256: 3dbdceb147d1c7c8f8667968fb15becc8d09ff1a444b41f72aeb123575e2cd6c

Contents?: true

Size: 1.94 KB

Versions: 54

Compression:

Stored size: 1.94 KB

Contents

import org.junit.Test;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.rules.ExpectedException;


import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;

public class PascalsTriangleTest {

    @Rule
    public ExpectedException thrown = ExpectedException.none();
    
    @Test
    public void testTriangleWithFourRows() {
        int[][] expectedOutput = new int[][]{
                {1},
                {1, 1},
                {1, 2, 1},
                {1, 3, 3, 1},
        };

        assertArrayEquals(expectedOutput, PascalsTriangle.computeTriangle(4));
    }

    @Ignore
    @Test
    public void testTriangleWithSixRows() {
        int[][] expectedOutput = new int[][]{
                {1},
                {1, 1},
                {1, 2, 1},
                {1, 3, 3, 1},
                {1, 4, 6, 4, 1},
                {1, 5, 10, 10, 5, 1}
        };

        assertArrayEquals(expectedOutput, PascalsTriangle.computeTriangle(6));
    }

    @Ignore
    @Test
    public void testExpectEmptyTriangle() {
        int[][] expectedOutput = new int[][]{

        };

        assertArrayEquals(expectedOutput, PascalsTriangle.computeTriangle(0));
    }

    @Ignore
    @Test
    public void testValidInput() {
        int[][] input = new int[][]{
                {1},
                {1, 1},
                {1, 2, 1},
                {1, 3, 3, 1},
                {1, 4, 6, 4, 1},
        };

        assertEquals(true, PascalsTriangle.isTriangle(input));
    }

    @Ignore
    @Test
    public void testInvalidInput() {
        int[][] input = new int[][]{
                {1},
                {1, 1},
                {1, 2, 1},
                {1, 4, 4, 1},
        };

        assertEquals(false, PascalsTriangle.isTriangle(input));
    }

    @Ignore
    @Test
    public void testValidatesNotNegativeRows() {
        thrown.expect(IllegalArgumentException.class);
        PascalsTriangle.computeTriangle(-1);
    }
}

Version data entries

54 entries across 54 versions & 1 rubygems

Version Path
trackler-2.0.8.51 tracks/java/exercises/pascals-triangle/src/test/java/PascalsTriangleTest.java
trackler-2.0.8.50 tracks/java/exercises/pascals-triangle/src/test/java/PascalsTriangleTest.java
trackler-2.0.8.49 tracks/java/exercises/pascals-triangle/src/test/java/PascalsTriangleTest.java
trackler-2.0.8.48 tracks/java/exercises/pascals-triangle/src/test/java/PascalsTriangleTest.java
trackler-2.0.8.47 tracks/java/exercises/pascals-triangle/src/test/java/PascalsTriangleTest.java
trackler-2.0.8.46 tracks/java/exercises/pascals-triangle/src/test/java/PascalsTriangleTest.java
trackler-2.0.8.45 tracks/java/exercises/pascals-triangle/src/test/java/PascalsTriangleTest.java
trackler-2.0.8.44 tracks/java/exercises/pascals-triangle/src/test/java/PascalsTriangleTest.java
trackler-2.0.8.43 tracks/java/exercises/pascals-triangle/src/test/java/PascalsTriangleTest.java
trackler-2.0.8.42 tracks/java/exercises/pascals-triangle/src/test/java/PascalsTriangleTest.java
trackler-2.0.8.41 tracks/java/exercises/pascals-triangle/src/test/java/PascalsTriangleTest.java
trackler-2.0.8.40 tracks/java/exercises/pascals-triangle/src/test/java/PascalsTriangleTest.java
trackler-2.0.8.39 tracks/java/exercises/pascals-triangle/src/test/java/PascalsTriangleTest.java
trackler-2.0.8.38 tracks/java/exercises/pascals-triangle/src/test/java/PascalsTriangleTest.java
trackler-2.0.8.37 tracks/java/exercises/pascals-triangle/src/test/java/PascalsTriangleTest.java
trackler-2.0.8.36 tracks/java/exercises/pascals-triangle/src/test/java/PascalsTriangleTest.java
trackler-2.0.8.35 tracks/java/exercises/pascals-triangle/src/test/java/PascalsTriangleTest.java
trackler-2.0.8.34 tracks/java/exercises/pascals-triangle/src/test/java/PascalsTriangleTest.java
trackler-2.0.8.33 tracks/java/exercises/pascals-triangle/src/test/java/PascalsTriangleTest.java
trackler-2.0.8.32 tracks/java/exercises/pascals-triangle/src/test/java/PascalsTriangleTest.java