Skip to content

pascals-triangle: update to v1.0.0 tests #424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions exercises/pascals-triangle/src/example/java/PascalsTriangle.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class PascalsTriangleGenerator {

int[][] generateTriangle(int rows) {
if (rows < 0) {
throw new IllegalArgumentException("Rows can't be negative!");
}

int[][] triangle = new int[rows][];

for (int i = 0; i < rows; i++) {
triangle[i] = new int[i + 1];
triangle[i][0] = 1;
for (int j = 1; j < i; j++) {
triangle[i][j] = triangle[i - 1][j - 1] + triangle[i - 1][j];
}
triangle[i][i] = 1;
}
return triangle;
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import org.junit.Before;
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;

/*
* version: 1.0.0
*/
public class PascalsTriangleGeneratorTest {

private PascalsTriangleGenerator pascalsTriangleGenerator;

@Before
public void setUp() {
pascalsTriangleGenerator = new PascalsTriangleGenerator();
}

@Rule
public ExpectedException thrown = ExpectedException.none();

@Test
public void testTriangleWithZeroRows() {
int[][] expectedOutput = new int[][]{};

assertArrayEquals(expectedOutput, pascalsTriangleGenerator.generateTriangle(0));
}

@Ignore
@Test
public void testTriangleWithOneRow() {
int[][] expectedOutput = new int[][]{
{1}
};

assertArrayEquals(expectedOutput, pascalsTriangleGenerator.generateTriangle(1));
}

@Ignore
@Test
public void testTriangleWithTwoRows() {
int[][] expectedOutput = new int[][]{
{1},
{1, 1}
};

assertArrayEquals(expectedOutput, pascalsTriangleGenerator.generateTriangle(2));
}

@Ignore
@Test
public void testTriangleWithThreeRows() {
int[][] expectedOutput = new int[][]{
{1},
{1, 1},
{1, 2, 1}
};

assertArrayEquals(expectedOutput, pascalsTriangleGenerator.generateTriangle(3));
}

@Ignore
@Test
public void testTriangleWithFourRows() {
int[][] expectedOutput = new int[][]{
{1},
{1, 1},
{1, 2, 1},
{1, 3, 3, 1}
};

assertArrayEquals(expectedOutput, pascalsTriangleGenerator.generateTriangle(4));
}

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

}
85 changes: 0 additions & 85 deletions exercises/pascals-triangle/src/test/java/PascalsTriangleTest.java

This file was deleted.