Bengt Richter wrote:
> On Fri, 25 Mar 2005 23:54:32 -0500, Peter Hansen <peter at engcorp.com> wrote:>>Suggestion: whip up a variety of automated test cases and>>make sure you run them all whenever you make changes to>>this code...> > Goes to show you ;-/ Do we need more tests than these?
[snip loads of tests]
Hmm... if I were doing this for real, not only would the
tests actually *tell* me when there was a failure, but
I would also throw in a few more cases involving larger
strings that more closely represent the expected real
inputs (i.e. using some numbers like 3.1415 and using
some strings that have the periods as punctuation such
as in the OP's original first "test case"). That way
if, during maintenance, somebody changes the algorithm
significantly, I'll be confident that it still covers
the broader set of cases, as well as the (exhaustive?)
set you've defined, which appear at first glance to
cover all the possible combinations of x and 3 and .
that might happen...
I'd also probably be generating most of the existing
test cases automatically, just to be sure I've got
100% coverage. Are you sure you didn't leave out one?
And what about, say, ".." or ".x3."? :-)