How to use ushort class of io.kotest.matchers.short package

Best Kotest code snippet using io.kotest.matchers.short.ushort

KotlinMetadataAnnotationUnsignedTest.kt

Source:KotlinMetadataAnnotationUnsignedTest.kt Github

copy

Full Screen

1/*2 * ProGuardCORE -- library to process Java bytecode.3 *4 * Copyright (c) 2002-2020 Guardsquare NV5 *6 * Licensed under the Apache License, Version 2.0 (the "License");7 * you may not use this file except in compliance with the License.8 * You may obtain a copy of the License at9 *10 * http://www.apache.org/licenses/LICENSE-2.011 *12 * Unless required by applicable law or agreed to in writing, software13 * distributed under the License is distributed on an "AS IS" BASIS,14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.15 * See the License for the specific language governing permissions and16 * limitations under the License.17 */18package proguard.classfile.kotlin19import io.kotest.common.ExperimentalKotest20import io.kotest.core.spec.style.FreeSpec21import io.kotest.datatest.withData22import io.kotest.matchers.shouldBe23import io.mockk.spyk24import io.mockk.verify25import proguard.classfile.kotlin.visitor.AllKotlinAnnotationArgumentVisitor26import proguard.classfile.kotlin.visitor.AllKotlinAnnotationVisitor27import proguard.classfile.kotlin.visitor.AllTypeAliasVisitor28import proguard.classfile.kotlin.visitor.KotlinAnnotationArgumentVisitor29import testutils.ClassPoolBuilder30import testutils.KotlinSource31import testutils.ReWritingMetadataVisitor32@OptIn(ExperimentalKotest::class)33class KotlinMetadataAnnotationUnsignedTest : FreeSpec({34 withData(35 UnsignedTestValues(36 name = "Unsigned zero should be converted to signed 0",37 uByte = "0u" expect 0,38 uShort = "0u" expect 0,39 uInt = "0u" expect 0,40 uLong = "0u" expect 0L41 ),42 UnsignedTestValues(43 name = "Unsigned MAX_VALUE should be converted to signed -1",44 uByte = "UByte.MAX_VALUE" expect -1,45 uShort = "UShort.MAX_VALUE" expect -1,46 uInt = "UInt.MAX_VALUE" expect -1,47 uLong = "ULong.MAX_VALUE" expect -1L48 ),49 UnsignedTestValues(50 name = "Unsigned MIN_VALUE should be converted to signed 0",51 uByte = "UByte.MIN_VALUE" expect 0,52 uShort = "UShort.MIN_VALUE" expect 0,53 uInt = "UInt.MIN_VALUE" expect 0,54 uLong = "ULong.MIN_VALUE" expect 0L55 ),56 UnsignedTestValues(57 name = "Unsigned (MAX_VALUE - 1) should be converted to signed -2",58 uByte = "${UByte.MAX_VALUE - 1u}u" expect -2,59 uShort = "${UShort.MAX_VALUE - 1u}u" expect -2,60 uInt = "${UInt.MAX_VALUE - 1u}u" expect -2,61 uLong = "${ULong.MAX_VALUE - 1u}u" expect -2,62 ),63 UnsignedTestValues(64 name = "Unsigned (MIN_VALUE + 1) should be converted to signed 1",65 uByte = "${UByte.MIN_VALUE + 1u}u" expect 1,66 uShort = "${UShort.MIN_VALUE + 1u}u" expect 1,67 uInt = "${UInt.MIN_VALUE + 1u}u" expect 1,68 uLong = "${ULong.MIN_VALUE + 1u}u" expect 1,69 ),70 ) { (_, uByte, uShort, uInt, uLong) ->71 val (programClassPool, _) = ClassPoolBuilder.fromSource(72 KotlinSource(73 "TestUnsigned.kt",74 """75 @Target(AnnotationTarget.TYPEALIAS)76 annotation class MyTypeAliasAnnotationWithUnsigned(77 val uByte: UByte,78 val uShort: UShort,79 val uInt: UInt,80 val uLong: ULong,81 )82 @MyTypeAliasAnnotationWithUnsigned(83 uByte = ${uByte.first},84 uShort = ${uShort.first},85 uInt = ${uInt.first},86 uLong = ${uLong.first}87 )88 typealias myAliasWithUnsigned = String89 """.trimIndent()90 ),91 kotlincArguments = listOf("-Xuse-experimental=kotlin.ExperimentalUnsignedTypes")92 )93 val annotationArgVisitor = spyk<KotlinAnnotationArgumentVisitor>()94 val clazz = programClassPool.getClass("TestUnsignedKt")95 programClassPool.classesAccept(96 clazz.name,97 ReWritingMetadataVisitor(98 AllTypeAliasVisitor(99 AllKotlinAnnotationVisitor(100 AllKotlinAnnotationArgumentVisitor(annotationArgVisitor)101 )102 )103 )104 )105 verify(exactly = 1) {106 annotationArgVisitor.visitUByteArgument(107 clazz,108 ofType<KotlinAnnotatable>(),109 ofType<KotlinAnnotation>(),110 withArg { it.name shouldBe "uByte" },111 KotlinAnnotationArgument.UByteValue(uByte.second)112 )113 annotationArgVisitor.visitUShortArgument(114 clazz,115 ofType<KotlinAnnotatable>(),116 ofType<KotlinAnnotation>(),117 withArg { it.name shouldBe "uShort" },118 KotlinAnnotationArgument.UShortValue(uShort.second)119 )120 annotationArgVisitor.visitUIntArgument(121 clazz,122 ofType<KotlinAnnotatable>(),123 ofType<KotlinAnnotation>(),124 withArg { it.name shouldBe "uInt" },125 KotlinAnnotationArgument.UIntValue(uInt.second)126 )127 annotationArgVisitor.visitULongArgument(128 clazz,129 ofType<KotlinAnnotatable>(),130 ofType<KotlinAnnotation>(),131 withArg { it.name shouldBe "uLong" },132 KotlinAnnotationArgument.ULongValue(uLong.second)133 )134 }135 }136})137private data class UnsignedTestValues(138 val name: String,139 val uByte: Pair<String, Byte>,140 val uShort: Pair<String, Short>,141 val uInt: Pair<String, Int>,142 val uLong: Pair<String, Long>143) {144 override fun toString(): String = name145}146private inline infix fun <reified T : Number> String.expect(value: T) = Pair(this, value)...

Full Screen

Full Screen

ByteBufShortTest.kt

Source:ByteBufShortTest.kt Github

copy

Full Screen

1/*2 * Copyright 2018-2021 Guthix3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16package io.guthix.buffer.bytebuf17import io.guthix.buffer.*18import io.kotest.core.spec.style.StringSpec19import io.kotest.matchers.ints.shouldBeNonNegative20import io.kotest.matchers.shouldBe21import io.kotest.property.Arb22import io.kotest.property.arbitrary.*23import io.kotest.property.checkAll24import io.netty.buffer.ByteBuf25import io.netty.buffer.ByteBufAllocator26private suspend fun doShortGSTest(27 setter: ByteBuf.(Int, Int) -> ByteBuf,28 getter: ByteBuf.(Int) -> Short29) = checkAll(Arb.shortArray(collectionSizeArb, Arb.short())) { testData ->30 val buf = ByteBufAllocator.DEFAULT.buffer(testData.size * Short.SIZE_BYTES)31 try {32 testData.forEachIndexed { i, expected -> buf.setter(i * Short.SIZE_BYTES, expected.toInt()) }33 testData.forEachIndexed { i, expected ->34 val get = buf.getter(i * Short.SIZE_BYTES)35 get shouldBe expected36 }37 } finally {38 buf.release()39 }40}41private suspend fun doShortRWTest(42 writer: ByteBuf.(Int) -> ByteBuf,43 reader: ByteBuf.() -> Short44) = checkAll(Arb.shortArray(collectionSizeArb, Arb.short())) { testData ->45 val buf = ByteBufAllocator.DEFAULT.buffer(testData.size * Short.SIZE_BYTES)46 try {47 testData.forEach { expected -> buf.writer(expected.toInt()) }48 testData.forEach { expected ->49 val read = buf.reader()50 read shouldBe expected51 }52 } finally {53 buf.release()54 }55}56@ExperimentalUnsignedTypes57private suspend fun doUShortGSTest(58 setter: ByteBuf.(Int, Int) -> ByteBuf,59 getter: ByteBuf.(Int) -> Int60) = checkAll(Arb.uShortArray(collectionSizeArb, Arb.uShort())) { testData ->61 val buf = ByteBufAllocator.DEFAULT.buffer(testData.size * UShort.SIZE_BYTES)62 try {63 testData.forEachIndexed { i, expected -> buf.setter(i * UShort.SIZE_BYTES, expected.toInt()) }64 testData.forEachIndexed { i, expected ->65 val get = buf.getter(i * UShort.SIZE_BYTES)66 get.shouldBeNonNegative()67 get shouldBe expected.toInt()68 }69 } finally {70 buf.release()71 }72}73@ExperimentalUnsignedTypes74private suspend fun doUShortRWTest(75 writer: ByteBuf.(Int) -> ByteBuf,76 reader: ByteBuf.() -> Int77) = checkAll(Arb.uShortArray(collectionSizeArb, Arb.uShort())) { testData ->78 val buf = ByteBufAllocator.DEFAULT.buffer(testData.size * UShort.SIZE_BYTES)79 try {80 testData.forEach { expected -> buf.writer(expected.toInt()) }81 testData.forEach { expected ->82 val read = buf.reader()83 read.shouldBeNonNegative()84 read shouldBe expected.toInt()85 }86 } finally {87 buf.release()88 }89}90@ExperimentalUnsignedTypes91class ByteBufShortTest : StringSpec({92 "Get/Set Short add" { doShortGSTest(ByteBuf::setShortAdd, ByteBuf::getShortAdd) }93 "Read/Write Short add" { doShortRWTest(ByteBuf::writeShortAdd, ByteBuf::readShortAdd) }94 "Unsigned Get/Set Short add" { doUShortGSTest(ByteBuf::setShortAdd, ByteBuf::getUnsignedShortAdd) }95 "Unsigned Read/Write Short add" { doUShortRWTest(ByteBuf::writeShortAdd, ByteBuf::readUnsignedShortAdd) }96 "Get/Set Short LE add" { doShortGSTest(ByteBuf::setShortLEAdd, ByteBuf::getShortLEAdd) }97 "Read/Write Short LE add" { doShortRWTest(ByteBuf::writeShortLEAdd, ByteBuf::readShortLEAdd) }98 "Unsigned Get/Set Short LE add" { doUShortGSTest(ByteBuf::setShortLEAdd, ByteBuf::getUnsignedShortLEAdd) }99 "Unsigned Read/Write Short LE add" { doUShortRWTest(ByteBuf::writeShortLEAdd, ByteBuf::readUnsignedShortLEAdd) }100})...

Full Screen

Full Screen

JagMessageSerializationShortTest.kt

Source:JagMessageSerializationShortTest.kt Github

copy

Full Screen

1/*2 * Copyright 2018-2021 Guthix3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16package io.guthix.buffer17import io.kotest.core.spec.style.StringSpec18import io.kotest.matchers.shouldBe19import io.kotest.property.checkAll20import io.netty.buffer.ByteBufAllocator21import kotlinx.serialization.ExperimentalSerializationApi22import kotlinx.serialization.Serializable23@ExperimentalSerializationApi24@Serializable25private data class ShortTest(26 @JShort(JShortType.DEFAULT) val default: Short,27 @JShort(JShortType.LE) val le: Short,28 @JShort(JShortType.ADD) val add: Short,29 @JShort(JShortType.LE_ADD) val leAdd: Short30)31@ExperimentalSerializationApi32@Serializable33private data class UShortTest(34 @JShort(JShortType.DEFAULT) val default: UShort,35 @JShort(JShortType.LE) val le: UShort,36 @JShort(JShortType.ADD) val add: UShort,37 @JShort(JShortType.LE_ADD) val leAdd: UShort38)39@ExperimentalUnsignedTypes40@ExperimentalSerializationApi41class JagMessageSerializationShortTest : StringSpec({42 "Encode/Decode Test" {43 checkAll<Short, Short, Short, Short> { default, le, add, leAdd ->44 val expectedByteBuf = ByteBufAllocator.DEFAULT.jBuffer(Short.SIZE_BYTES * 4).apply {45 writeShort(default.toInt())46 writeShortLE(le.toInt())47 writeShortAdd(add.toInt())48 writeShortLEAdd(leAdd.toInt())49 }50 try {51 val expectedTest = ShortTest(default, le, add, leAdd)52 val actualByteBuf = JagMessage.encodeToByteBuf(ShortTest.serializer(), expectedTest)53 try {54 actualByteBuf shouldBe expectedByteBuf55 val actualTest = JagMessage.decodeFromByteBuf(ShortTest.serializer(), expectedByteBuf)56 actualTest shouldBe expectedTest57 } finally {58 actualByteBuf.release()59 }60 } finally {61 expectedByteBuf.release()62 }63 }64 }65 "Unsigned Encode/Decode Test" {66 checkAll<UShort, UShort, UShort, UShort> { default, le, add, leAdd ->67 val expectedByteBuf = ByteBufAllocator.DEFAULT.jBuffer(UShort.SIZE_BYTES * 4).apply {68 writeShort(default.toInt())69 writeShortLE(le.toInt())70 writeShortAdd(add.toInt())71 writeShortLEAdd(leAdd.toInt())72 }73 try {74 val expectedTest = UShortTest(default, le, add, leAdd)75 val actualByteBuf = JagMessage.encodeToByteBuf(UShortTest.serializer(), expectedTest)76 try {77 actualByteBuf shouldBe expectedByteBuf78 val actualTest = JagMessage.decodeFromByteBuf(UShortTest.serializer(), expectedByteBuf)79 actualTest shouldBe expectedTest80 } finally {81 actualByteBuf.release()82 }83 } finally {84 expectedByteBuf.release()85 }86 }87 }88})...

Full Screen

Full Screen

ByteBufShortSmart.kt

Source:ByteBufShortSmart.kt Github

copy

Full Screen

1/*2 * Copyright 2018-2021 Guthix3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16package io.guthix.buffer.bytebuf17import io.guthix.buffer.*18import io.kotest.core.spec.style.StringSpec19import io.kotest.matchers.ints.shouldBeNonNegative20import io.kotest.matchers.shouldBe21import io.kotest.property.Arb22import io.kotest.property.arbitrary.*23import io.kotest.property.checkAll24import io.netty.buffer.ByteBuf25import io.netty.buffer.ByteBufAllocator26private suspend fun doShortSmartRWTest(27 writer: ByteBuf.(Int) -> ByteBuf,28 reader: ByteBuf.() -> Short29) = checkAll(30 Arb.shortArray(collectionSizeArb, Arb.short(Smart.MIN_SHORT_VALUE.toShort(), Smart.MAX_SHORT_VALUE.toShort()))31) { testData ->32 val buf = ByteBufAllocator.DEFAULT.buffer(testData.size * Short.SIZE_BYTES)33 try {34 testData.forEach { expected -> buf.writer(expected.toInt()) }35 testData.forEach { expected ->36 val read = buf.reader()37 read shouldBe expected38 }39 } finally {40 buf.release()41 }42}43@ExperimentalUnsignedTypes44private suspend fun doUShortSmartRWTest(45 writer: ByteBuf.(Int) -> ByteBuf,46 reader: ByteBuf.() -> Short47) = checkAll(48 Arb.uShortArray(collectionSizeArb, Arb.uShort(USmart.MIN_SHORT_VALUE.toUShort(), USmart.MAX_SHORT_VALUE.toUShort()))49) { testData ->50 val buf = ByteBufAllocator.DEFAULT.buffer(testData.size * Short.SIZE_BYTES)51 try {52 testData.forEach { expected -> buf.writer(expected.toInt()) }53 testData.forEach { expected ->54 val read = buf.reader()55 read.toInt().shouldBeNonNegative()56 read shouldBe expected.toInt()57 }58 } finally {59 buf.release()60 }61}62@ExperimentalUnsignedTypes63private suspend fun doIncrShortSmartRWTest(64 writer: ByteBuf.(Int) -> ByteBuf,65 reader: ByteBuf.() -> Int66) = checkAll(Arb.intArray(collectionSizeArb, Arb.int(0, 100_000))) { testData ->67 val buf = ByteBufAllocator.DEFAULT.buffer()68 try {69 testData.forEach { expected -> buf.writer(expected) }70 testData.forEach { expected ->71 val read = buf.reader()72 read.shouldBeNonNegative()73 read shouldBe expected74 }75 } finally {76 buf.release()77 }78}79@ExperimentalUnsignedTypes80class ByteBufShortSmartTest : StringSpec({81 "Read/Write Short Smart" { doShortSmartRWTest(ByteBuf::writeShortSmart, ByteBuf::readShortSmart) }82 "Unsigned Read/Write Short Smart" {83 doUShortSmartRWTest(ByteBuf::writeUnsignedShortSmart, ByteBuf::readUnsignedShortSmart)84 }85 "Unsigned Read/Write Incr Short Smart" {86 doIncrShortSmartRWTest(ByteBuf::writeIncrShortSmart, ByteBuf::readIncrShortSmart)87 }88})...

Full Screen

Full Screen

JagMessageSerializationShortSmartTest.kt

Source:JagMessageSerializationShortSmartTest.kt Github

copy

Full Screen

1/*2 * Copyright 2018-2021 Guthix3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16package io.guthix.buffer17import io.kotest.core.spec.style.StringSpec18import io.kotest.matchers.shouldBe19import io.kotest.property.Arb20import io.kotest.property.arbitrary.short21import io.kotest.property.arbitrary.uShort22import io.kotest.property.checkAll23import io.netty.buffer.ByteBufAllocator24import kotlinx.serialization.ExperimentalSerializationApi25import kotlinx.serialization.Serializable26@ExperimentalSerializationApi27@Serializable28private data class ShortSmartTest(29 @JShortSmart val default: Short30)31@ExperimentalSerializationApi32@Serializable33private data class UShortSmartTest(34 @JShortSmart val default: UShort35)36@ExperimentalUnsignedTypes37@ExperimentalSerializationApi38class JagMessageSerializationShortSmartTest : StringSpec({39 "Encode/Decode Test" {40 checkAll(Arb.short(Smart.MIN_SHORT_VALUE.toShort(), Smart.MAX_SHORT_VALUE.toShort())) { default ->41 val expectedByteBuf = ByteBufAllocator.DEFAULT.jBuffer(Short.SIZE_BYTES).apply {42 writeShortSmart(default.toInt())43 }44 try {45 val expectedTest = ShortSmartTest(default)46 val actualByteBuf = JagMessage.encodeToByteBuf(ShortSmartTest.serializer(), expectedTest)47 try {48 actualByteBuf shouldBe expectedByteBuf49 val actualTest = JagMessage.decodeFromByteBuf(ShortSmartTest.serializer(), expectedByteBuf)50 actualTest shouldBe expectedTest51 } finally {52 actualByteBuf.release()53 }54 } finally {55 expectedByteBuf.release()56 }57 }58 }59 "Unsigned Encode/Decode Test" {60 checkAll(Arb.uShort(USmart.MIN_SHORT_VALUE.toUShort(), USmart.MAX_SHORT_VALUE.toUShort())) { default ->61 val expectedByteBuf = ByteBufAllocator.DEFAULT.jBuffer(UShort.SIZE_BYTES).apply {62 writeUShortSmart(default.toInt())63 }64 try {65 val expectedTest = UShortSmartTest(default)66 val actualByteBuf = JagMessage.encodeToByteBuf(UShortSmartTest.serializer(), expectedTest)67 try {68 actualByteBuf shouldBe expectedByteBuf69 val actualTest = JagMessage.decodeFromByteBuf(UShortSmartTest.serializer(), expectedByteBuf)70 actualTest shouldBe expectedTest71 } finally {72 actualByteBuf.release()73 }74 } finally {75 expectedByteBuf.release()76 }77 }78 }79})...

Full Screen

Full Screen

test.kt

Source:test.kt Github

copy

Full Screen

1package unsigned2import io.kotest.core.spec.style.StringSpec3import io.kotest.matchers.ints.shouldBeLessThan4import io.kotest.matchers.shouldBe5import java.math.BigInteger6/**7 * Created by elect on 15/10/16.8 */9val Int.b10 get() = toByte()11val Int.s12 get() = toShort()13val Long.b14 get() = toByte()15val Long.s16 get() = toShort()17val Long.i18 get() = toInt()19val BigInteger.L20 get() = toLong()21/**22 * BUG, 0xffffffffffffffff is outside Long range23 * https://youtrack.jetbrains.com/issue/KT-474924 */25val String.hL: Long26 get() = java.lang.Long.parseUnsignedLong(filter { it != '_' && it != '\'' }, 16)27val String.L: Long28 get() = java.lang.Long.parseUnsignedLong(filter { it != '_' && it != '\'' })29val String.bL: Long30 get() = java.lang.Long.parseUnsignedLong(filter { it != '_' && it != '\'' }, 2)31class Unsigned : StringSpec() {32 init {33 "primitive" {34 250.b udiv 50.b shouldBe 5.b35 250.b urem 200.b shouldBe 50.b36 250.b ucmp 251.b shouldBeLessThan 137 250.b ucmp 250.b shouldBe 038 0b1010_1010.b ushr 4 shouldBe 0b1010.b39 65500.s udiv 500.s shouldBe 131.s40 65500.s urem 65000.s shouldBe 500.s41 65500.s ucmp 65501.s shouldBeLessThan 142 65500.s ucmp 65500.s shouldBe 043 0b0100_1100_0011_1101.s ushr 8 shouldBe 0b100_1100.s44 4_000_000_000.i udiv 2 shouldBe 2_000_000_00045 2_750_000_000.i urem 2_000_000_000 shouldBe 750_000_00046 4_000_000_000.i ucmp 4_000_000_001.i shouldBeLessThan 147 4_000_000_000.i ucmp 4_000_000_000.i shouldBe 048 "18_000_000_000_000_000_000".L udiv 2L shouldBe "9'000'000'000'000'000'000".L49 "17'000'000'000'000'000'000".L urem "9'000'000'000'000'000'000".L shouldBe "8'000'000'000'000'000'000".L50 "18'000'000'000'000'000'000".L ucmp "18'000'000'000'000'000'001".L shouldBeLessThan 151 "18'000'000'000'000'000'001".L ucmp "18'000'000'000'000'000'001".L shouldBe 052 }53 "string format" {54 Ubyte(0xff).v.toString() shouldBe "-1"55 Ubyte(0xff).toString() shouldBe "255"56 Ushort(0xffff).v.toString() shouldBe "-1"57 Ushort(0xffff).toString() shouldBe "65535"58 Uint(0xffff_ffff).v.toString() shouldBe "-1"59 Uint(0xffff_ffff).toString() shouldBe "4294967295"60 Ulong(Ulong.MAX_VALUE).v.toString() shouldBe "-1"61 Ulong(Ulong.MAX_VALUE).toString() shouldBe "18446744073709551615"62 Ubyte.MIN.toString(16) shouldBe "0"63 Ubyte.MAX.toString(16) shouldBe "ff"64 Ushort.MIN.toString(16) shouldBe "0"65 Ushort.MAX.toString(16) shouldBe "ffff"66 Uint.MIN.toString(16) shouldBe "0"67 Uint.MAX.toString(16) shouldBe "ffffffff"68 Ulong.MIN.toString(16) shouldBe "0"69 Ulong.MAX.toString(16) shouldBe "ffffffffffffffff"70 Ubyte.MAX.toString("%08x") shouldBe "000000ff"71// (-71777214294589696L).toBinaryString() shouldBe "1111111100000000111111110000000011111111000000001111111100000000"72 }73 }74}...

Full Screen

Full Screen

ShortTest.kt

Source:ShortTest.kt Github

copy

Full Screen

1package com.sksamuel.kotest.property.arbitrary2import io.kotest.core.spec.style.FunSpec3import io.kotest.data.blocking.forAll4import io.kotest.data.row5import io.kotest.inspectors.forAll6import io.kotest.matchers.short.shouldBeBetween7import io.kotest.matchers.shouldBe8import io.kotest.property.Arb9import io.kotest.property.PropTest10import io.kotest.property.arbitrary.*11import io.kotest.property.checkAll12import io.kotest.property.checkCoverage13class ShortTest : FunSpec({14 test("<Short, Short> should give values between min and max inclusive") {15 // Test parameters include the test for negative bounds16 forAll(17 row(-10, -1),18 row(1, 3),19 row(-100, 100),20 row((Short.MAX_VALUE - 10).toShort(), Short.MAX_VALUE),21 row(Short.MIN_VALUE, (Short.MIN_VALUE + 10).toShort())22 ) { vMin, vMax ->23 val expectedValues = (vMin..vMax).map { it.toShort() }.toSet()24 val actualValues = (1..100_000).map { Arb.short(vMin, vMax).single() }.toSet()25 actualValues shouldBe expectedValues26 }27 }28 test("Arb.short edge cases should respect min and max bounds") {29 checkCoverage("run", 25.0) {30 PropTest(iterations = 1000).checkAll<Short, Short> { min, max ->31 if (min < max) {32 classify("run")33 Arb.short(min, max).edgecases().forAll {34 it.shouldBeBetween(min, max)35 }36 }37 }38 }39 }40})41class UShortTest : FunSpec({42 test("<UShort, UShort> should give values between min and max inclusive") {43 forAll(44 row(1u, 3u),45 row(0u, 100u),46 row((UShort.MAX_VALUE - 10u).toUShort(), UShort.MAX_VALUE),47 row(UShort.MIN_VALUE, (UShort.MIN_VALUE + 10u).toUShort())48 ) { vMin, vMax ->49 val expectedValues = (vMin..vMax).map { it.toUShort() }.toSet()50 val actualValues = (1..100_000).map { Arb.uShort(vMin, vMax).single() }.toSet()51 actualValues shouldBe expectedValues52 }53 }54 test("Arb.uShort edge cases should respect min and max bounds") {55 checkCoverage("run", 25.0) {56 PropTest(iterations = 1000).checkAll<UShort, UShort> { min, max ->57 if (min < max) {58 classify("run")59 Arb.uShort(min, max).edgecases().forAll {60 it.shouldBeBetween(min, max)61 }62 }63 }64 }65 }66})...

Full Screen

Full Screen

ushort.kt

Source:ushort.kt Github

copy

Full Screen

1package io.kotest.matchers.short2import io.kotest.matchers.Matcher3import io.kotest.matchers.MatcherResult4import io.kotest.matchers.shouldBe5fun UShort.shouldBeBetween(lower: UShort, upper: UShort): UShort {6 this shouldBe between(lower, upper)7 return this8}9fun between(lower: UShort, upper: UShort) = object : Matcher<UShort> {10 override fun test(value: UShort) = MatcherResult(11 value in lower..upper,12 { "$value should be between ($lower, $upper) inclusive" },13 {14 "$value should not be between ($lower, $upper) inclusive"15 })16}...

Full Screen

Full Screen

ushort

Using AI Code Generation

copy

Full Screen

1import io.kotest.matchers.short.shouldBeLessThan2import io.kotest.matchers.int.shouldBeGreaterThan3import io.kotest.matchers.long.shouldBeLessThanOrEqual4import io.kotest.matchers.float.shouldBeGreaterThanOrEqual5import io.kotest.matchers.double.shouldBeBetween6import io.kotest.matchers.string.shouldContain7import io.kotest.matchers.char.shouldBeLowerCase8import io.kotest.matchers.boolean.shouldBeTrue9import io.kotest.matchers.array.shouldContain10import io.kotest.matchers.collection.shouldContain11import io.kotest.matchers.map.shouldContain12import io.kotest.matchers.iterable.shouldContain13import io.kotest.matchers.any.shouldBeInstance14import io.kotest.matchers.function.shouldThrow15import io.kotest.matchers.result.shouldBeFailure16import io.kotest.matchers.option.shouldBeDefined17import io.kotest.matchers.try.shouldBeFailure18import io.kotest.matchers.io.shouldBeEmpty

Full Screen

Full Screen

ushort

Using AI Code Generation

copy

Full Screen

1 import io.kotest.matchers . short . shouldBeLessThan 2 import io.kotest.matchers . int . shouldBeGreaterThan 3 import io.kotest.matchers . long . shouldBeLessThan 4 import io.kotest.matchers . float . shouldBeGreaterThan 5 import io.kotest.matchers . double . shouldBeLessThan6 import io.kotest.matchers . byte . shouldNotBeLessThan 7 import io.kotest.matchers . short . shouldNotBeLessThan 8 import io.kotest.matchers . int . shouldNotBeGreaterThan 9 import io.kotest.matchers . long . shouldNotBeLessThan 10 import io.kotest.matchers . float . shouldNotBeGreaterThan 11 import io.kotest.matchers . double . shouldNotBeLessThan12 import io.kotest.matchers . byte . shouldBeLessThanOrEqualTo 13 import io.kotest.matchers . short . shouldBeLessThanOrEqualTo 14 import io.kotest.matchers . int . shouldBeGreaterThanOrEqualTo 15 import io

Full Screen

Full Screen

ushort

Using AI Code Generation

copy

Full Screen

1 import io.kotest.matchers.shouldBe2 import io.kotest.matchers.shouldNotBe3 import io.kotest.matchers.types.shouldBeSameInstanceAs4 import io.kotest.matchers.shouldBe5 import io.kotest.matchers.shouldNotBe6 import io.kotest.matchers.types.shouldBeSameInstanceAs7 import io.kotest.matchers.shouldBe8 import io.kotest.matchers.shouldNotBe9 import io.kotest.matchers.types.shouldBeSameInstanceAs10 import io.kotest.matchers.shouldBe11 import io.kotest.matchers.shouldNotBe12 import io.kotest.matchers.types.shouldBeSameInstanceAs13 import io.kotest.matchers.shouldBe14 import io.kotest.matchers.shouldNotBe15 import io.kotest.matchers.types.shouldBeSameInstanceAs16 import io.kotest.matchers.shouldBe17 import io.kotest.matchers.shouldNotBe18 import io.kotest.matchers.types.shouldBeSameInstanceAs19 import io.kotest.matchers.shouldBe20 import io.kotest.matchers.shouldNotBe21 import io.kotest.matchers.types.shouldBeSameInstanceAs22 import io.kotest.matchers.shouldBe23 import io.kotest.matchers.shouldNotBe24 import io.kotest.matchers.types.shouldBeSameInstanceAs25 import io.kotest.matchers.shouldBe26 import io.kotest.matchers.shouldNotBe27 import io.kotest.matchers.types.shouldBeSameInstanceAs28 import io

Full Screen

Full Screen

ushort

Using AI Code Generation

copy

Full Screen

1val expected : List<Int> = listOf(1,2,3)2val actual : List<Int> = listOf(1,2,3,4)3val expected : Map<String,Int> = mapOf("one" to 1,"two" to 2,"three" to 3)4val actual : Map<String,Int> = mapOf("one" to 1,"two" to 2,"three" to 3,"four" to 4)5val expected : Array<Int> = arrayOf(1,2,3)6val actual : Array<Int> = arrayOf(1,2,3,4)7val expected : Throwable = RuntimeException()8val actual : Throwable = RuntimeException()9val expected : Result<Int> = Result.success(10)10val actual : Result<Int> = Result.success(20)11val expected : Option<Int> = Option.Some(10)12val actual : Option<Int> = Option.Some(20)

Full Screen

Full Screen

ushort

Using AI Code Generation

copy

Full Screen

1 import io.kotest.matchers.shouldBe2 import io.kotest.matchers.shouldNotBe3 class ShortTest : WordSpec({4 "Short" Should {5 "have the correct value" {6 a shouldBe 1.toShort()7 }8 }9 })

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Run Kotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Most used methods in ushort

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful