Check for index-out-of-bound in elementAt function (KT-30051)
This commit is contained in:
@@ -1460,4 +1460,14 @@ ${" "}
|
||||
assertEquals(" ABC\n \n 123", "ABC\n \n123".prependIndent(" "))
|
||||
assertEquals(" ", "".prependIndent(" "))
|
||||
}
|
||||
|
||||
@Test
|
||||
fun elementAt() {
|
||||
expect('a') { "a c".elementAt(0) }
|
||||
expect(' ') { "a c".elementAt(1) }
|
||||
expect('c') { "a c".elementAt(2) }
|
||||
|
||||
assertFailsWith<IndexOutOfBoundsException> { "".elementAt(0) }
|
||||
assertFailsWith<IndexOutOfBoundsException> { "a c".elementAt(-1) }
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user