What part of "return false if there are not exactly 10 characters
left after discarding dashes" fails to handle the empty string?
A test case for the empty string is is only valuable if the
empty string is NOT a special case.


On Wed, 2 Sep 2020 at 22:52, Roelof Wobben <r.wob...@home.nl> wrote:

> Op 2-9-2020 om 12:38 schreef Richard O'Keefe:
>
> There is simply no point in "taking the first nine numbers out".
> And there shouldn't BE a test for the string being empty, anywhere.
> '' '-' '---' and so on should all be handled the same way.
>
> Oh well, what stops you doing
>
>    digits := aString select: [:each | each ~= $-].
>    digits size = 10 ifFalse: [^false].
>    lastDigit := digits la ost.
>    digits := digits copyFrom: 1 to: 9.
>    ( (lastDigit = $X or: [lastDigit isDigit]) and: [
>      digits allSatisfy: #isDigit]
>    ) ifFalse: [^false].
>
> Now my code does not do this, but it is just 16 lines of code with
> nothing that it would make sense to extract.
>
>
>
> Nothing only that I could not think of this one for myself.
> If I do it the TDD way I come more on the way Im currently thinking
>
> but does this case then be covered
>
> test14_EmptyIsbn
>     | result |
>     result := isbnVerifierCalculator isValidIsbn: ''.
>     self assert: result equals: false
>
> and still I have to do the calcualation to see if it's valid.
> If I understand the code well I can use the digits variable ?
>
>
> Roelof
>
>
>

Reply via email to