Skip to content
Merged
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
49 changes: 29 additions & 20 deletions exercises/triangle/src/test/java/TriangleTest.java
Original file line number Diff line number Diff line change
@@ -1,117 +1,126 @@
import org.junit.Test;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.rules.ExpectedException;

import static org.junit.Assert.assertEquals;

public class TriangleTest {

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

@Test
public void equilateralTriangleHaveEqualSides() throws Exception {
public void equilateralTriangleHaveEqualSides() throws TriangleException {
Triangle triangle = new Triangle(2, 2, 2);

assertEquals(TriangleKind.EQUILATERAL, triangle.getKind());
}

@Ignore
@Test
public void largerEquilateralTrianglesAlsoHaveEqualSides() throws Exception {
public void largerEquilateralTrianglesAlsoHaveEqualSides() throws TriangleException {
Triangle triangle = new Triangle(10, 10, 10);

assertEquals(TriangleKind.EQUILATERAL, triangle.getKind());
}

@Ignore
@Test
public void isoscelesTrianglesHaveLastTwoSidesEqual() throws Exception {
public void isoscelesTrianglesHaveLastTwoSidesEqual() throws TriangleException {
Triangle triangle = new Triangle(3, 4, 4);

assertEquals(TriangleKind.ISOSCELES, triangle.getKind());
}

@Ignore
@Test
public void isoscelesTrianglesHaveFirstAndLastSidesEqual() throws Exception {
public void isoscelesTrianglesHaveFirstAndLastSidesEqual() throws TriangleException {
Triangle triangle = new Triangle(4, 3, 4);

assertEquals(TriangleKind.ISOSCELES, triangle.getKind());
}

@Ignore
@Test
public void isoscelesTrianglesHaveTwoFirstSidesEqual() throws Exception {
public void isoscelesTrianglesHaveTwoFirstSidesEqual() throws TriangleException {
Triangle triangle = new Triangle(4, 4, 3);

assertEquals(TriangleKind.ISOSCELES, triangle.getKind());
}

@Ignore
@Test
public void isoscelesTrianglesHaveInFactExactlyTwoSidesEqual() throws Exception {
public void isoscelesTrianglesHaveInFactExactlyTwoSidesEqual() throws TriangleException {
Triangle triangle = new Triangle(10, 10, 2);

assertEquals(TriangleKind.ISOSCELES, triangle.getKind());
}

@Ignore
@Test
public void scaleneTrianglesHaveNoEqualSides() throws Exception {
public void scaleneTrianglesHaveNoEqualSides() throws TriangleException {
Triangle triangle = new Triangle(3, 4, 5);

assertEquals(TriangleKind.SCALENE, triangle.getKind());
}

@Ignore
@Test
public void scaleneTrianglesHaveNoEqualSidesAtLargerScaleEither() throws Exception {
public void scaleneTrianglesHaveNoEqualSidesAtLargerScaleEither() throws TriangleException {
Triangle triangle = new Triangle(10, 11, 12);

assertEquals(TriangleKind.SCALENE, triangle.getKind());
}

@Ignore
@Test
public void scaleneTrianglesHaveNoEqualSidesInDescendingOrderEither() throws Exception {
public void scaleneTrianglesHaveNoEqualSidesInDescendingOrderEither() throws TriangleException {
Triangle triangle = new Triangle(5, 4, 2);

assertEquals(TriangleKind.SCALENE, triangle.getKind());
}

@Ignore
@Test
public void verySmallTrianglesAreLegal() throws Exception {
public void verySmallTrianglesAreLegal() throws TriangleException {
Triangle triangle = new Triangle(0.4, 0.6, 0.3);

assertEquals(TriangleKind.SCALENE, triangle.getKind());
}

@Ignore
@Test(expected = TriangleException.class)
public void trianglesWithNoSizeAreIllegal() throws Exception {
@Test
public void trianglesWithNoSizeAreIllegal() throws TriangleException {
thrown.expect(TriangleException.class);
new Triangle(0, 0, 0);
}

@Ignore
@Test(expected = TriangleException.class)
public void trianglesWithNegativeSidesAreIllegal() throws Exception {
@Test
public void trianglesWithNegativeSidesAreIllegal() throws TriangleException {
thrown.expect(TriangleException.class);
new Triangle(3, 4, -5);
}

@Ignore
@Test(expected = TriangleException.class)
public void trianglesViolatingTriangleInequalityAreIllegal() throws Exception {
@Test
public void trianglesViolatingTriangleInequalityAreIllegal() throws TriangleException {
thrown.expect(TriangleException.class);
new Triangle(1, 1, 3);
}

@Ignore
@Test(expected = TriangleException.class)
public void trianglesViolatingTriangleInequalityAreIllegal2() throws Exception {
@Test
public void trianglesViolatingTriangleInequalityAreIllegal2() throws TriangleException {
thrown.expect(TriangleException.class);
new Triangle(2, 4, 2);
}

@Ignore
@Test(expected = TriangleException.class)
public void trianglesViolatingTriangleInequalityAreIllegal3() throws Exception {
@Test
public void trianglesViolatingTriangleInequalityAreIllegal3() throws TriangleException {
thrown.expect(TriangleException.class);
new Triangle(7, 3, 2);
}
}