I think the sentence “Strings of length 1 or less are not valid.” might be slightly misleading because it talks about the length of the string (including spaces), not the number of digits.
I just came across a solution that would treat a string like "0 "
(a zero followed by a space) as valid because that string has a length greater than 1
.
There are tests that I think apply to this but I can (kind of vaguely) understand why somebody might view "0 "
as valid. They might argue that it’s not a singled digit string or a single zero because the string contains more than that single digit, the test for the single zero with space applies to leading spaces.
Let’s change it to something like “Strings with only a single digit are not valid.” That’s a small change, it’s more explicit and harder to misunderstand.
A second option would be to add another test for "0 "
.