Upload
joseph-owens
View
223
Download
0
Embed Size (px)
Citation preview
Exercise Variation of the Weinberg-Myers
Triangle Problem
Philippe [email protected]
http://users.polytech.unice.fr/~charman/
Last update: 04-16-2013
Different types of triangles
– invalid doesn’t exist – point reduced to a point – segment reduced to a line segment– equilateral all sides have the same length– isosceles 2 sides have the same length– right rectangle rectangled triangle– scalene none of above types
Fonction triangle
TriangleType triangle(double x,
` double y,
double z) {
// returns the triangle type according
// to the values of the 3 sides x, y and z
return TriangleType;
}
First step: Writing the test suite
• Work in pair: 2 testers• Tester A writes the tests for testing the triangle function• Tester B reviews the test suite• Example of the test suite:
void allTests () {test( triangle(0, 0, 0), point);test( triangle(1, 1, 1), equilateral);test( triangle(3, 4, 5), rectangle); etc.
}void test(TriangleType computedType,
TriangleType expectedType) {if (computedType == expectedType)
NbSuccess++;else
NbFails++;}
Second step:Writing the triangle function
• Works in pair: 2 developers
• Tester B becomes Developer A
• Tester A becomes Developer B
• Dev A writes the triangle functio
• Dev B reviews the written code
Third step: executing the test suite
•Display the number of failures
•How many failures after the very first execution
•How many test case have been written?