From: Kent Beck Date: 2001-12-11T16:42:50+09:00 Subject: [ruby-talk:28183] Re: John Roth dolt ( Re: A challenge to proponents of Unit Testing. ) Tom Adams wrote in message news:793af3df.0112101027.1061721f@posting.google.com... > "Kent Beck" wrote in message news:<9v1ss3$adi$1@suaar1aa.prod.compuserve.com>... > > > (Ken's proposed 5 test case solution to Myers Triangle problem was here) > > 1. What about oddities in the source code? Like: > > if (any side ==4) { > return 1; > } > > This would cause it to fail for the test case 1,2,4 and your tests > would miss that. Don't put oddities like this in your source code. Working strictly test first, there would have to be a test that was failing before the conditional above was written. > You would need white-box testing to catch this, or you would need > more, perhaps many more, black-box tests to cover all the possible > internals of the function's code. > > 2. There is also the issue of very large integer values. At least, you > can call the function with literal integers where it will fail. Actually, > it is not possible to code the function to handle integers of unbounded > size without using some special integer representations. Anyway, a > function would pass your tests with undefined behaviour for very large > integers. And, code using the function could work on one compiler or > machine and fail on another, depending on the language, because of issues > related to integer size. Use a sensible language where integers act like integers, not like 32-bit counter with rollover. If you want to write a Java version of the function, and show what happens with 2^31, feel free to write those test cases. The earlier note that I ignored ill-formed triangles (5,5,11) is absolutely correct. I missed those test cases. I'll post the updated code and tests later. Kent