Skip to content

Commit

Permalink
Fix Kotest Arb.default deprecations and remove an explicit type arg…
Browse files Browse the repository at this point in the history
…umetn and some opt-ins that are no longer needed
  • Loading branch information
ShreckYe committed Dec 4, 2024
1 parent b47943d commit 46cd9c1
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,31 @@ package com.huanshankeji.codec
import io.kotest.property.Arb
import io.kotest.property.Exhaustive
import io.kotest.property.arbitrary.byteArray
import io.kotest.property.arbitrary.default
import io.kotest.property.arbitrary.list
import io.kotest.property.checkAll
import io.kotest.property.exhaustive.of
import kotlinx.coroutines.ExperimentalCoroutinesApi
import io.kotest.property.resolution.default
import kotlinx.coroutines.test.TestResult
import kotlinx.coroutines.test.runTest
import kotlin.test.Test
import kotlin.test.assertContentEquals
import kotlin.test.assertEquals

class BasicCodecsTest {
@OptIn(ExperimentalUnsignedTypes::class, ExperimentalCoroutinesApi::class)
@OptIn(ExperimentalUnsignedTypes::class)
@Test
fun testConversionBetweenLongAndBigEndianBytes(): TestResult {
val long = 0x0123456789ABCDEFU.toLong()
val bytes = ubyteArrayOf(0x01U, 0x23U, 0x45U, 0x67U, 0x89U, 0xABU, 0xCDU, 0xEFU).asByteArray()
assertContentEquals(bytes, long.toBigEndianBytes())
assertEquals(long, bytes.bigEndianToLong())

@OptIn(ExperimentalCoroutinesApi::class)
return runTest {
checkAll<Long> {
assertEquals(it, it.toBigEndianBytes().bigEndianToLong())
assertEquals(it, it.toBigEndianBytes().asList().bigEndianToLong())
}
checkAll<ByteArray>(Arb.byteArray(Exhaustive.of(8), Arb.default())) {
checkAll(Arb.byteArray(Exhaustive.of(8), Arb.default())) {
assertContentEquals(it, it.bigEndianToLong().toBigEndianBytes())
}
checkAll<List<Byte>>(Arb.list(Arb.default(), 8..8)) {
Expand Down

0 comments on commit 46cd9c1

Please sign in to comment.