lots of exercises in java... from https://github.com/exercism/java

TriangleTest.java 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. import org.junit.Test;
  2. import org.junit.Ignore;
  3. import static org.junit.Assert.assertEquals;
  4. public class TriangleTest {
  5. @Test
  6. public void equilateralTriangleHaveEqualSides() throws Exception {
  7. Triangle triangle = new Triangle(2, 2, 2);
  8. assertEquals(TriangleKind.EQUILATERAL, triangle.getKind());
  9. }
  10. @Ignore
  11. @Test
  12. public void largerEquilateralTrianglesAlsoHaveEqualSides() throws Exception {
  13. Triangle triangle = new Triangle(10, 10, 10);
  14. assertEquals(TriangleKind.EQUILATERAL, triangle.getKind());
  15. }
  16. @Ignore
  17. @Test
  18. public void isoscelesTrianglesHaveLastTwoSidesEqual() throws Exception {
  19. Triangle triangle = new Triangle(3, 4, 4);
  20. assertEquals(TriangleKind.ISOSCELES, triangle.getKind());
  21. }
  22. @Ignore
  23. @Test
  24. public void isoscelesTrianglesHaveFirstAndLastSidesEqual() throws Exception {
  25. Triangle triangle = new Triangle(4, 3, 4);
  26. assertEquals(TriangleKind.ISOSCELES, triangle.getKind());
  27. }
  28. @Ignore
  29. @Test
  30. public void isoscelesTrianglesHaveTwoFirstSidesEqual() throws Exception {
  31. Triangle triangle = new Triangle(4, 4, 3);
  32. assertEquals(TriangleKind.ISOSCELES, triangle.getKind());
  33. }
  34. @Ignore
  35. @Test
  36. public void isoscelesTrianglesHaveInFactExactlyTwoSidesEqual() throws Exception {
  37. Triangle triangle = new Triangle(10, 10, 2);
  38. assertEquals(TriangleKind.ISOSCELES, triangle.getKind());
  39. }
  40. @Ignore
  41. @Test
  42. public void scaleneTrianglesHaveNoEqualSides() throws Exception {
  43. Triangle triangle = new Triangle(3, 4, 5);
  44. assertEquals(TriangleKind.SCALENE, triangle.getKind());
  45. }
  46. @Ignore
  47. @Test
  48. public void scaleneTrianglesHaveNoEqualSidesAtLargerScaleEither() throws Exception {
  49. Triangle triangle = new Triangle(10, 11, 12);
  50. assertEquals(TriangleKind.SCALENE, triangle.getKind());
  51. }
  52. @Ignore
  53. @Test
  54. public void scaleneTrianglesHaveNoEqualSidesInDescendingOrderEither() throws Exception {
  55. Triangle triangle = new Triangle(5, 4, 2);
  56. assertEquals(TriangleKind.SCALENE, triangle.getKind());
  57. }
  58. @Ignore
  59. @Test
  60. public void verySmallTrianglesAreLegal() throws Exception {
  61. Triangle triangle = new Triangle(0.4, 0.6, 0.3);
  62. assertEquals(TriangleKind.SCALENE, triangle.getKind());
  63. }
  64. @Ignore
  65. @Test(expected = TriangleException.class)
  66. public void trianglesWithNoSizeAreIllegal() throws Exception {
  67. new Triangle(0, 0, 0);
  68. }
  69. @Ignore
  70. @Test(expected = TriangleException.class)
  71. public void trianglesWithNegativeSidesAreIllegal() throws Exception {
  72. new Triangle(3, 4, -5);
  73. }
  74. @Ignore
  75. @Test(expected = TriangleException.class)
  76. public void trianglesViolatingTriangleInequalityAreIllegal() throws Exception {
  77. new Triangle(1, 1, 3);
  78. }
  79. @Ignore
  80. @Test(expected = TriangleException.class)
  81. public void trianglesViolatingTriangleInequalityAreIllegal2() throws Exception {
  82. new Triangle(2, 4, 2);
  83. }
  84. @Ignore
  85. @Test(expected = TriangleException.class)
  86. public void trianglesViolatingTriangleInequalityAreIllegal3() throws Exception {
  87. new Triangle(7, 3, 2);
  88. }
  89. }