Added a test on unsigned arrays

This commit is contained in:
Igor Chevdar
2021-09-28 12:16:34 +05:00
committed by Space
parent acc1643fe4
commit e64140af08
@@ -257,44 +257,44 @@ import kotlin.test.*
} }
@Test fun forDownToWithStep() { @Test fun forDownToWithStep() {
val array = Array(10) { 0L } val array = UIntArray(10) { 0U }
val array1 = Array(3) { 0L } val array1 = UIntArray(3) { 0U }
var j = 8 var j = 8
assertFailsWith<ArrayIndexOutOfBoundsException> { assertFailsWith<ArrayIndexOutOfBoundsException> {
for (i in array.size - 1 downTo 0 step 2) { for (i in array.size - 1 downTo 0 step 2) {
array[j] = 6 array[j] = 6U
j++ j++
} }
} }
assertFailsWith<ArrayIndexOutOfBoundsException> { assertFailsWith<ArrayIndexOutOfBoundsException> {
for (i in array.size - 1 downTo 1 step 2) { for (i in array.size - 1 downTo 1 step 2) {
array[i + 1] = 6 array[i + 1] = 6U
} }
} }
assertFailsWith<ArrayIndexOutOfBoundsException> { assertFailsWith<ArrayIndexOutOfBoundsException> {
for (i in array.size - 1 downTo 1 step 2) { for (i in array.size - 1 downTo 1 step 2) {
array1[i] = 6 array1[i] = 6U
} }
} }
assertFailsWith<ArrayIndexOutOfBoundsException> { assertFailsWith<ArrayIndexOutOfBoundsException> {
for (i in (array.size / 0.2).toInt() downTo 1 step 2) { for (i in (array.size / 0.2).toInt() downTo 1 step 2) {
array[i] = 6 array[i] = 6U
} }
} }
assertFailsWith<ArrayIndexOutOfBoundsException> { assertFailsWith<ArrayIndexOutOfBoundsException> {
for (i in array.size - 1 downTo -3 step 2) { for (i in array.size - 1 downTo -3 step 2) {
array[i] = 6 array[i] = 6U
} }
} }
assertFailsWith<ArrayIndexOutOfBoundsException> { assertFailsWith<ArrayIndexOutOfBoundsException> {
for (i in array.size downTo 1 step 2) { for (i in array.size downTo 1 step 2) {
array[i] = 6 array[i] = 6U
} }
} }
} }