SOURCE program code:
Package junit01;
public class Triangle {
Public String s (int a,int b,int c) {
if (A + b <= c| | B + C <= a| | A + c <= b| | A*b*c <= 0) return ("not triangle");
else if (a==b && b==c) return ("equilateral triangle");
else if ((a==b && b!=c) | | (b==c && c!=a) | | (A==c && c!=b)) Return ("isosceles triangle");
else return ("General triangle");
}
}
Test code:
Package junit01;
Import static org.junit.assert.*;
Import Org.junit.Assert;
Import Org.junit.Before;
Import Org.junit.Test;
public class TriangleTest2 {
Private triangle t;
@Before
public void SetUp () throws Exception {
t = new triangle ();
}
@Test
public void TestS () {
Assert.assertequals ("Cannot judge whether it is a triangle", "not a triangle", T.S (5,5,11));
Assert.assertequals ("Cannot judge whether it is equilateral triangle", "equilateral triangle", T.S (6,6,6));
Assert.assertequals ("Cannot judge whether it is isosceles triangle", "isosceles triangle", T.S (2,2,3));
Assert.assertequals ("Cannot judge whether it is a general triangle", "General Triangle", T.S (3,4,5));
}
}
On-Machine experiment