mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-21 23:05:27 +00:00
isAlphaNumberic and isDigit improvement + tests (#6579)
if we encounter a character that does not satisfy the proc, we return immediately, without continuing to loop over the rest of the chars in the string.
This commit is contained in:
committed by
Andreas Rumpf
parent
c051244859
commit
ce04288d64
@@ -64,6 +64,25 @@ proc testDelete =
|
||||
delete(s, 0, 0)
|
||||
assert s == "1236789ABCDEFG"
|
||||
|
||||
|
||||
proc testIsAlphaNumeric =
|
||||
assert isAlphaNumeric("abcdABC1234") == true
|
||||
assert isAlphaNumeric("a") == true
|
||||
assert isAlphaNumeric("abcABC?1234") == false
|
||||
assert isAlphaNumeric("abcABC 1234") == false
|
||||
assert isAlphaNumeric(".") == false
|
||||
|
||||
testIsAlphaNumeric()
|
||||
|
||||
proc testIsDigit =
|
||||
assert isDigit("1") == true
|
||||
assert isDigit("1234") == true
|
||||
assert isDigit("abcABC?1234") == false
|
||||
assert isDigit(".") == false
|
||||
assert isDigit(":") == false
|
||||
|
||||
testIsDigit()
|
||||
|
||||
proc testFind =
|
||||
assert "0123456789ABCDEFGH".find('A') == 10
|
||||
assert "0123456789ABCDEFGH".find('A', 5) == 10
|
||||
|
||||
Reference in New Issue
Block a user