alternating string replace: Extended input (Long).
paddy3118 at googlemail.com
Wed Jan 9 23:03:23 CET 2008
On Jan 9, 9:39 pm, Fredrik Lundh <fred... at pythonware.com> wrote:
> Paddy wrote:
> > To see how they act against 'corner cases' and
> > an exercise for me in trying to create corner cases. (I'm in to
> > functional testing at the mo').
> sounds more like "pulling requirements out of thin air". not sure that
> helps the OP get a better understanding of Python, really.
Not really out of thin air. The OP transforming alternating
occurrences of _ so corners would include a null string; strings with
1, 2 and 3 occurrences of the character to be replaced and the char to
be replaced separated or not by other chars....
Ideally I would create a randomized interesting string generator and
try each prog against a lot of generated examples and computed
'correct' answers, but I am unsure of what should be the right answer
in some cases so the earlier posting can be used to give extra
information for the spec. to be fleshed out with.
You may be right in that the OP might see the extended input and
dismiss them because he knows that the input data is never going to be
like that - or - he may find that his input validation might well
allow some of the cases through and he needs to either improve his
input validation or define what to do with more types of input.
Your also right in that its mostly not Python specific but it helps me
think of corner cases and the interpretation of specs which is very
important in helping solve the right problem.
More information about the Python-list