[K/N] Migrate runtime/collections tests to new testing infra ^KT-61259
This commit is contained in:
committed by
Space Team
parent
10a6d8fd2c
commit
b3e13fb2c2
@@ -0,0 +1,139 @@
|
||||
/*
|
||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package test.collections
|
||||
|
||||
import kotlin.test.*
|
||||
|
||||
// Native-specific part of stdlib/test/collections/UnsignedArraysTest.kt
|
||||
class UnsignedArraysNativeTest {
|
||||
@Test fun ubyteArray() {
|
||||
assertFailsWith<IllegalArgumentException> { UByteArray(-1) }
|
||||
}
|
||||
|
||||
@Test fun ubyteArrayInit() {
|
||||
assertFailsWith<IllegalArgumentException> { UByteArray(-1) { it.toUByte() } }
|
||||
}
|
||||
|
||||
@Test fun ushortArray() {
|
||||
assertFailsWith<IllegalArgumentException> { UShortArray(-1) }
|
||||
}
|
||||
|
||||
@Test fun ushortArrayInit() {
|
||||
assertFailsWith<IllegalArgumentException> { UShortArray(-1) { it.toUShort() } }
|
||||
}
|
||||
|
||||
@Test fun uintArray() {
|
||||
assertFailsWith<IllegalArgumentException> { UIntArray(-1) }
|
||||
}
|
||||
|
||||
@Test fun uintArrayInit() {
|
||||
assertFailsWith<IllegalArgumentException> { UIntArray(-1) { it.toUInt() } }
|
||||
}
|
||||
|
||||
@Test fun ulongArray() {
|
||||
assertFailsWith<IllegalArgumentException> { ULongArray(-1) }
|
||||
}
|
||||
|
||||
@Test fun ulongArrayInit() {
|
||||
assertFailsWith<IllegalArgumentException> { ULongArray(-1) { it.toULong() } }
|
||||
}
|
||||
|
||||
@Test fun ubyteArrayGetOutOfBounds() {
|
||||
val arr = UByteArray(5)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
arr[arr.size]
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
arr[-1]
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
arr[Int.MAX_VALUE]
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
arr[Int.MIN_VALUE]
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun ushortArrayGetOutOfBounds() {
|
||||
val arr = UShortArray(5)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
arr[arr.size]
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
arr[-1]
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
arr[Int.MAX_VALUE]
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
arr[Int.MIN_VALUE]
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun uintArrayGetOutOfBounds() {
|
||||
val arr = UIntArray(5)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
arr[arr.size]
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
arr[-1]
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
arr[Int.MAX_VALUE]
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
arr[Int.MIN_VALUE]
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun ubyteArraySetOutOfBounds() {
|
||||
val arr = UByteArray(5)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
arr[arr.size] = 1U
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
arr[-1] = 1U
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
arr[Int.MAX_VALUE] = 1U
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
arr[Int.MIN_VALUE] = 1U
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun ushortArraySetOutOfBounds() {
|
||||
val arr = UShortArray(5)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
arr[arr.size] = 1U
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
arr[-1] = 1U
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
arr[Int.MAX_VALUE] = 1U
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
arr[Int.MIN_VALUE] = 1U
|
||||
}
|
||||
}
|
||||
|
||||
@Test fun uintArraySetOutOfBounds() {
|
||||
val arr = UIntArray(5)
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
arr[arr.size] = 1U
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
arr[-1] = 1U
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
arr[Int.MAX_VALUE] = 1U
|
||||
}
|
||||
assertFailsWith<IndexOutOfBoundsException> {
|
||||
arr[Int.MIN_VALUE] = 1U
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user