forked from exercism/java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTriangleTest.java
More file actions
101 lines (74 loc) · 3 KB
/
Copy pathTriangleTest.java
File metadata and controls
101 lines (74 loc) · 3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class TriangleTest {
@Test
public void equilateralTriangleHaveEqualSides() throws Exception {
Triangle triangle = new Triangle(2, 2, 2);
assertEquals(TriangleKind.EQUILATERAL, triangle.getKind());
}
@Test
public void largerEquilateralTrianglesAlsoHaveEqualSides() throws Exception {
Triangle triangle = new Triangle(10, 10, 10);
assertEquals(TriangleKind.EQUILATERAL, triangle.getKind());
}
@Test
public void isoscelesTrianglesHaveLastTwoSidesEqual() throws Exception {
Triangle triangle = new Triangle(3, 4, 4);
assertEquals(TriangleKind.ISOSCELES, triangle.getKind());
}
@Test
public void isoscelesTrianglesHaveFirstAndLastSidesEqual() throws Exception {
Triangle triangle = new Triangle(4, 3, 4);
assertEquals(TriangleKind.ISOSCELES, triangle.getKind());
}
@Test
public void isoscelesTrianglesHaveTwoFirstSidesEqual() throws Exception {
Triangle triangle = new Triangle(4, 4, 3);
assertEquals(TriangleKind.ISOSCELES, triangle.getKind());
}
@Test
public void isoscelesTrianglesHaveInFactExactlyTwoSidesEqual() throws Exception {
Triangle triangle = new Triangle(10, 10, 2);
assertEquals(TriangleKind.ISOSCELES, triangle.getKind());
}
@Test
public void scaleneTrianglesHaveNoEqualSides() throws Exception {
Triangle triangle = new Triangle(3, 4, 5);
assertEquals(TriangleKind.SCALENE, triangle.getKind());
}
@Test
public void scaleneTrianglesHaveNoEqualSidesAtLargerScaleEither() throws Exception {
Triangle triangle = new Triangle(10, 11, 12);
assertEquals(TriangleKind.SCALENE, triangle.getKind());
}
@Test
public void scaleneTrianglesHaveNoEqualSidesInDescendingOrderEither() throws Exception {
Triangle triangle = new Triangle(5, 4, 2);
assertEquals(TriangleKind.SCALENE, triangle.getKind());
}
@Test
public void verySmallTrianglesAreLegal() throws Exception {
Triangle triangle = new Triangle(0.4, 0.6, 0.3);
assertEquals(TriangleKind.SCALENE, triangle.getKind());
}
@Test(expected = TriangleException.class)
public void trianglesWithNoSizeAreIllegal() throws Exception {
new Triangle(0, 0, 0);
}
@Test(expected = TriangleException.class)
public void trianglesWithNegativeSidesAreIllegal() throws Exception {
new Triangle(3, 4, -5);
}
@Test(expected = TriangleException.class)
public void trianglesViolatingTriangleInequalityAreIllegal() throws Exception {
new Triangle(1, 1, 3);
}
@Test(expected = TriangleException.class)
public void trianglesViolatingTriangleInequalityAreIllegal2() throws Exception {
new Triangle(2, 4, 2);
}
@Test(expected = TriangleException.class)
public void trianglesViolatingTriangleInequalityAreIllegal3() throws Exception {
new Triangle(7, 3, 2);
}
}