Your Ad Here

Sunday, March 14, 2010

Test Cases for Triangles

We have studied the properties of various triangles in school. Let us apply those properties to test a triangle today.

A triangle is made of three sides (and three angles of course). Let us assume that the vertices are A, B and C, and corresponding sides are a, b, c.



Test cases follow:

1. Enter 0, a, b. No triangle is formed.
2. Enter 1, 2, 4. No triangle is formed because for a valid triangle a+b>c, b+c>a, c+a>b.
3. Enter angles A, B, C. The sum of the angles should be 180 degrees.
4. Enter a, a, a. Valid equilateral triangle.
5. Enter a, a, b. Valid isosceles triangle.
6. Enter angles A, B, C. If any of the angles is 90 degrees and the sum is 180 degrees, it is a right angle triangle.
7. Enter angles A, B, C as 90, 90, 0. The sum of angles is 180 degrees, still the triangle cannot be formed.
8. Enter negative value for a side, e.g. -1, -1, -1. Invalid input.
9. Enter character value for one of the sides, e.g. a, 2, 2. Invalid input.

Please add more to this.

No comments:

Post a Comment