From: Mathieu Bouchard Date: 2006-01-14T13:36:16+09:00 Subject: Re: Design contracts and refactoring (was Re: mathn: ugly warnings) On Sat, 14 Jan 2006, Hugh Sasse wrote: > On Sat, 14 Jan 2006, mathew wrote: > > Consider '+'. Requirements are that it add any two things which constitute > > numbers. Trouble is, you can't even test every possible pair of floating point > > numbers, let alone the integers and rationals. Any test of N pairs that you do > > will be statistically insignificant. > You are not testing number theory, you are testing software. You are testing "implementation" in general, not software in particular. This may include "+". The method for "+" is software, even though it uses hardware. There's nothing saying that unit-tests can't (or shouldn't) test hardware. Actually it's very appropriate to write unit-tests for hardware, and very commonplace as well. > Yes, you must test the brakes. Yes you must calibrate the speedometer. > Software, except the Monte Carlo sort, is not statistical in nature. You haven't computed a lot of Monte-Carlo integrals, have you? =) http://mathworld.wolfram.com/MonteCarloIntegration.html > If one is expected to write tests for all types a generic method > will support, then it is making a rod for one's own back. There > isn't time. unit-tests don't have to be as flat as they are usually done. Try to write polymorphic tests. _ _ __ ___ _____ ________ _____________ _____________________ ... | Mathieu Bouchard - t�l:+1.514.383.3801 - http://artengine.ca/matju | Freelance Digital Arts Engineer, Montr�al QC Canada