6
Exercise Variation of the Weinberg-Myers Triangle Problem Philippe CHARMAN [email protected] http://users.polytech.unice.fr/~charman/ Last update: 04- 16-2013

Exercise Variation of the Weinberg-Myers Triangle Problem Philippe CHARMAN [email protected] charman/ Last update: 04-16-2013

Embed Size (px)

Citation preview

Page 1: Exercise Variation of the Weinberg-Myers Triangle Problem Philippe CHARMAN charman@fr.ibm.com charman/ Last update: 04-16-2013

Exercise Variation of the Weinberg-Myers

Triangle Problem

Philippe [email protected]

http://users.polytech.unice.fr/~charman/

Last update: 04-16-2013

Page 2: Exercise Variation of the Weinberg-Myers Triangle Problem Philippe CHARMAN charman@fr.ibm.com 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

Page 3: Exercise Variation of the Weinberg-Myers Triangle Problem Philippe CHARMAN charman@fr.ibm.com charman/ Last update: 04-16-2013

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;

}

Page 4: Exercise Variation of the Weinberg-Myers Triangle Problem Philippe CHARMAN charman@fr.ibm.com charman/ Last update: 04-16-2013

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++;}

Page 5: Exercise Variation of the Weinberg-Myers Triangle Problem Philippe CHARMAN charman@fr.ibm.com charman/ Last update: 04-16-2013

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

Page 6: Exercise Variation of the Weinberg-Myers Triangle Problem Philippe CHARMAN charman@fr.ibm.com charman/ Last update: 04-16-2013

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?