/* * 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 { UByteArray(-1) } } @Test fun ubyteArrayInit() { assertFailsWith { UByteArray(-1) { it.toUByte() } } } @Test fun ushortArray() { assertFailsWith { UShortArray(-1) } } @Test fun ushortArrayInit() { assertFailsWith { UShortArray(-1) { it.toUShort() } } } @Test fun uintArray() { assertFailsWith { UIntArray(-1) } } @Test fun uintArrayInit() { assertFailsWith { UIntArray(-1) { it.toUInt() } } } @Test fun ulongArray() { assertFailsWith { ULongArray(-1) } } @Test fun ulongArrayInit() { assertFailsWith { ULongArray(-1) { it.toULong() } } } @Test fun ubyteArrayGetOutOfBounds() { val arr = UByteArray(5) assertFailsWith { arr[arr.size] } assertFailsWith { arr[-1] } assertFailsWith { arr[Int.MAX_VALUE] } assertFailsWith { arr[Int.MIN_VALUE] } } @Test fun ushortArrayGetOutOfBounds() { val arr = UShortArray(5) assertFailsWith { arr[arr.size] } assertFailsWith { arr[-1] } assertFailsWith { arr[Int.MAX_VALUE] } assertFailsWith { arr[Int.MIN_VALUE] } } @Test fun uintArrayGetOutOfBounds() { val arr = UIntArray(5) assertFailsWith { arr[arr.size] } assertFailsWith { arr[-1] } assertFailsWith { arr[Int.MAX_VALUE] } assertFailsWith { arr[Int.MIN_VALUE] } } @Test fun ubyteArraySetOutOfBounds() { val arr = UByteArray(5) assertFailsWith { arr[arr.size] = 1U } assertFailsWith { arr[-1] = 1U } assertFailsWith { arr[Int.MAX_VALUE] = 1U } assertFailsWith { arr[Int.MIN_VALUE] = 1U } } @Test fun ushortArraySetOutOfBounds() { val arr = UShortArray(5) assertFailsWith { arr[arr.size] = 1U } assertFailsWith { arr[-1] = 1U } assertFailsWith { arr[Int.MAX_VALUE] = 1U } assertFailsWith { arr[Int.MIN_VALUE] = 1U } } @Test fun uintArraySetOutOfBounds() { val arr = UIntArray(5) assertFailsWith { arr[arr.size] = 1U } assertFailsWith { arr[-1] = 1U } assertFailsWith { arr[Int.MAX_VALUE] = 1U } assertFailsWith { arr[Int.MIN_VALUE] = 1U } } }