Files
kotlin-fork/backend.native/tests/external/stdlib/numbers/NumbersTest/byteMinMaxValues.kt
T
Ilya Matveev 85827b4880 tests: Copy stdlib tests from Kotlin/JVM
This patch copies Kotlin/JVM stdlib tests (libraries/stdlib/test)
excepting ones with explicit java dependencies. It also transforms
the tests to use them as box-tests.
2017-04-07 17:21:11 +07:00

32 lines
1.0 KiB
Kotlin

import kotlin.test.*
object NumbersTestConstants {
public const val byteMinSucc: Byte = (Byte.MIN_VALUE + 1).toByte()
public const val byteMaxPred: Byte = (Byte.MAX_VALUE - 1).toByte()
public const val shortMinSucc: Short = (Short.MIN_VALUE + 1).toShort()
public const val shortMaxPred: Short = (Short.MAX_VALUE - 1).toShort()
public const val intMinSucc: Int = Int.MIN_VALUE + 1
public const val intMaxPred: Int = Int.MAX_VALUE - 1
public const val longMinSucc: Long = Long.MIN_VALUE + 1L
public const val longMaxPred: Long = Long.MAX_VALUE - 1L
}
var one: Int = 1
var oneS: Short = 1
var oneB: Byte = 1
fun box() {
assertTrue(Byte.MIN_VALUE < 0)
assertTrue(Byte.MAX_VALUE > 0)
assertEquals(NumbersTestConstants.byteMinSucc, Byte.MIN_VALUE.inc())
assertEquals(NumbersTestConstants.byteMaxPred, Byte.MAX_VALUE.dec())
// overflow behavior
expect(Byte.MIN_VALUE) { (Byte.MAX_VALUE + oneB).toByte() }
expect(Byte.MAX_VALUE) { (Byte.MIN_VALUE - oneB).toByte() }
}