Check for index-out-of-bound in elementAt function (KT-30051)

This commit is contained in:
Abduqodiri Qurbonzoda
2019-03-07 22:10:29 +03:00
parent 584137121b
commit ba61695a45
16 changed files with 496 additions and 60 deletions
+10
View File
@@ -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) }
}
}