From: "Robert C. Martin" Date: 2001-12-11T13:23:07+09:00 Subject: [ruby-talk:28177] Re: John Roth dolt ( Re: A challenge to proponents of Unit Testing. ) On 10 Dec 2001 09:35:08 -0800, rbinder@rbsc.com (Bob Binder) wrote: >Robert C. Martin wrote in message news:... >> On Sat, 08 Dec 2001 00:35:43 -0600, Robert C. Martin > objectmentor . com> wrote: >> >> >On 7 Dec 2001 02:04:08 -0800, stephen.hill@motorola.com (Steve Hill) >> >wrote: >> > >> >>What tests would you write for a function that takes 3 numbers (the >> >>side lengths of a triangle) , and returns whether the triangle is >> >>equilateral, scalene or isoceles. >> > >> >Set sides; // data structure allows no duplicates. >> >sides.add(a); >> >sides.add(b); >> >sides.add(c); >> >return sides.length(); // 1 = equilateral, 2=isoceles, 3=scalene. >> ^^^^^^^^^--oops. >> > >> >What am I missing? > >In this example, wouldn't using an int set for the sides prevent >representing any triangle with two or more equal lengths -- I think a >bag would do the job. Assuming that your set would reject identical >values, any test suite which did not include tests like 3,3,4 or 3,3,3 >would miss that bug. The intent was to return a 1 for equilateral, 2 for isoceles, and 3 for scalene. Representing the triangle was not part of the job. Robert C. Martin | "Uncle Bob" | Software Consultants Object Mentor Inc. | rmartin@objectmentor.com | We'll help you get PO Box 5757 | Tel: (800) 338-6716 | your projects done. 565 Lakeview Pkwy | Fax: (847) 573-1658 | www.objectmentor.com Suite 135 | | www.XProgramming.com Vernon Hills, IL, | Training and Mentoring | www.junit.org 60061 | OO, XP, Java, C++, Python| "One of the great commandments of science is: 'Mistrust arguments from authority.'" -- Carl Sagan