package Examples; import org.junit.* ; import Examples.Triangle; import static org.junit.Assert.* ; public class TestTriangle { Triangle equilateral() { return new Triangle(1,1,1) ; } Triangle isoceles() { return new Triangle(1,2,1) ; } Triangle scalene() { return new Triangle(1,2,3) ; } @Test public void test() { assertTrue(equilateral().isEquilateral()) ; assertTrue(equilateral().isIsoleces()) ; assertFalse(equilateral().isScalene()) ; assertFalse(isoceles().isEquilateral()) ; assertTrue(isoceles().isIsoleces()) ; assertFalse(isoceles().isScalene()) ; assertFalse(scalene().isEquilateral()) ; assertFalse(scalene().isIsoleces()) ; assertTrue(scalene().isScalene()) ; } @Test public void illegalTriangle() { try { new Triangle(0,1,1) ; assertTrue(false) ; } catch(IllegalArgumentException e) { } try { new Triangle(1,0,1) ; assertTrue(false) ; } catch(IllegalArgumentException e) { } try { new Triangle(1,1,0) ; assertTrue(false) ; } catch(IllegalArgumentException e) { } } }