Added test case with isInteger() method.

This commit is contained in:
patkorek 2020-04-10 13:27:27 +02:00
parent 76cdbd811e
commit 949881921e
1 changed files with 11 additions and 0 deletions

View File

@ -96,4 +96,15 @@ class ConvertStringToInt {
def invalidString = null
invalidString.toInteger()
}
@Test
void givenString_whenUsingIsInteger_thenCheckIfCorrectValue() {
def invalidString = "123a"
def validString = "123"
def invalidNum = invalidString?.isInteger() ? invalidString as Integer : false
def correctNum = validString?.isInteger() ? validString as Integer : false
assertEquals(false, invalidNum)
assertEquals(123, correctNum)
}
}