How to use test method of io.kotest.matchers.ints.uint class

Best Kotest code snippet using io.kotest.matchers.ints.uint.test

gtc_packing.kt

Source:gtc_packing.kt Github

copy

Full Screen

...3import glm_.vec1.Vec14import glm_.vec2.*5import glm_.vec3.Vec36import glm_.vec4.*7import io.kotest.matchers.shouldBe8import io.kotest.core.spec.style.StringSpec9import io.kotest.matchers.shouldNotBe10import unsigned.Uint11import unsigned.Ulong12import unsigned.Ushort13class gtc_packing : StringSpec() {14 init {15 "Half1x16" {16 floatArrayOf(0f, 1f, -1f, 2f, -2f, 1.9f)17 .forEach {18 val p0 = glm.packHalf1x16(it)19 val v0 = glm.unpackHalf1x16(p0)20 val p1 = glm.packHalf1x16(v0)21 val v1 = glm.unpackHalf1x16(p1)22 v0 shouldEqual v123 }24 }25 "Half4x16" {26 listOf(Vec4(1f), Vec4(0f), Vec4(2f), Vec4(0.1f), Vec4(0.5f), Vec4(-0.9f))27 .forEach {28 val p0 = glm.packHalf4x16(it)29 val v0 = glm.unpackHalf4x16(p0)30 val p1 = glm.packHalf4x16(v0)31 val v1 = glm.unpackHalf4x16(p1)32 val p2 = glm.detail.packHalf(v0)33 val v2 = glm.detail.unpackHalf(p2)34 v0 shouldEqual v135 v0 shouldEqual v236 }37 }38 "I3x10_1x2" {39 listOf(Vec4i(0), Vec4i(1), Vec4i(-1), Vec4i(2), Vec4i(-2), Vec4i(3))40 .forEach {41 val p0 = glm.packI3x10_1x2(it)42 val v0 = glm.unpackI3x10_1x2(p0)43 val p1 = glm.packI3x10_1x2(v0)44 val v1 = glm.unpackI3x10_1x2(p1)45 v0 shouldBe v146 }47 }48 "U3x10_1x2" {49 listOf(Vec4ui(0), Vec4ui(1), Vec4ui(2), Vec4ui(3), Vec4ui(4), Vec4ui(5))50 .forEach {51 val p0 = glm.packU3x10_1x2(it)52 val v0 = glm.unpackU3x10_1x2(p0)53 val p1 = glm.packU3x10_1x2(v0)54 val v1 = glm.unpackU3x10_1x2(p1)55 v0 shouldBe v156 }57 val v0 = Vec4ub(0xff, 0x77, 0x0, 0x33)58 val p0 = Uint((v0.x.i shl 24) or (v0.y.i shl 16) or (v0.z.i shl 8) or v0.w.i)59 val r0 = Uint(0xff770033) // 0x330077ff is LSB60 p0 shouldBe r061 val v1 = Vec4ui(0xff, 0x77, 0x0, 0x33)62 val p1 = glm.packU3x10_1x2(v1)63 val r1 = Uint(0x3fc77003) // 0xc001dcff is LSB64 p1 shouldBe r165 }66 "Snorm3x10_1x2" {67 listOf(Vec4(1f), Vec4(0f), Vec4(2f), Vec4(0.1f), Vec4(0.5f), Vec4(0.9f))68 .forEach {69 val p0 = glm.packSnorm3x10_1x2(it)70 val v0 = glm.unpackSnorm3x10_1x2(p0)71 val p1 = glm.packSnorm3x10_1x2(v0)72 val v1 = glm.unpackSnorm3x10_1x2(p1)73 v0.shouldEqual(v1, 0.01f)74 }75 }76 "Unorm3x10_1x2" {77 listOf(Vec4(1f), Vec4(0f), Vec4(2f), Vec4(0.1f), Vec4(0.5f), Vec4(0.9f))78 .forEach {79 val p0 = glm.packUnorm3x10_1x2(it)80 val v0 = glm.unpackUnorm3x10_1x2(p0)81 val p1 = glm.packUnorm3x10_1x2(v0)82 val v1 = glm.unpackUnorm3x10_1x2(p1)83 v0.shouldEqual(v1, 0.001f)84 }85 }86 "F2x11_1x10" {87 listOf(Vec3(1f), Vec3(0f), Vec3(2f), Vec3(0.1f), Vec3(0.5f), Vec3(0.9f))88 .forEach {89 val p0 = glm.packF2x11_1x10(it)90 val v0 = glm.unpackF2x11_1x10(p0)91 val p1 = glm.packF2x11_1x10(v0)92 val v1 = glm.unpackF2x11_1x10(p1)93 v0 shouldEqual v194 }95 }96 "F3x9_E1x5" {97 listOf(Vec3(1f), Vec3(0f), Vec3(2f), Vec3(0.1f), Vec3(0.5f), Vec3(0.9f))98 .forEach {99 val p0 = glm.packF3x9_E1x5(it)100 val v0 = glm.unpackF3x9_E1x5(p0)101 val p1 = glm.packF3x9_E1x5(v0)102 val v1 = glm.unpackF3x9_E1x5(p1)103 v0 shouldEqual v1104 }105 }106 "RGBM" {107 repeat(1024) {108 val color = Vec3(it.f)109 val rgbm = glm.packRGBM(color)110 val result = glm.unpackRGBM(rgbm)111 color.shouldEqual(result, 0.01f)112 }113 }114 "packUnorm1x16" {115 listOf(Vec1(1f), Vec1(0.5f), Vec1(0.1f), Vec1(0f))116 .forEach { A ->117 val B = glm.packUnorm1x16(A.x)118 val C = Vec1(glm.unpackUnorm1x16(B))119 A.shouldEqual(C, 1f / 65535f)120 }121 }122 "packSnorm1x16" {123 listOf(Vec1(1f), Vec1(0f), Vec1(-0.5f), Vec1(-0.1f))124 .forEach { A ->125 val B = glm.packSnorm1x16(A.x)126 val C = Vec1(glm.unpackSnorm1x16(B))127 A.shouldEqual(C, 1f / 32767f * 2f)128 }129 }130 "packUnorm2x16" {131 listOf(Vec2(1f, 0f), Vec2(0.5f, 0.7f), Vec2(0.1f, 0.2f))132 .forEach { A ->133 val B = glm.packUnorm2x16(A)134 val C = glm.unpackUnorm2x16(B)135 A.shouldEqual(C, 1f / 65535f)136 }137 }138 "packSnorm2x16" {139 listOf(Vec2(1f, 0f), Vec2(-0.5f, -0.7f), Vec2(-0.1f, 0.1f))140 .forEach { A ->141 val B = glm.packSnorm2x16(A)142 val C = glm.unpackSnorm2x16(B)143 A.shouldEqual(C, 1f / 32767f * 2f)144 }145 }146 "packUnorm4x16" {147 listOf(Vec4(1f), Vec4(0.5f), Vec4(0.1f), Vec4(0f))148 .forEach { A ->149 val B = glm.packUnorm4x16(A)150 val C = glm.unpackUnorm4x16(B)151 A.shouldEqual(C, 1f / 65535f)152 }153 }154 "packSnorm4x16" {155 listOf(Vec4(1.0f, 0.0f, -0.5f, 0.5f), Vec4(-0.3f, -0.7f, 0.3f, 0.7f), Vec4(-0.1f, 0.1f, -0.2f, 0.2f))156 .forEach { A ->157 val B = glm.packSnorm4x16(A)158 val C = glm.unpackSnorm4x16(B)159 A.shouldEqual(C, 1f / 32767f * 2f)160 }161 }162 "packUnorm1x8" {163 listOf(Vec1(1f), Vec1(0.5f), Vec1(0f))164 .forEach { A ->165 val B = glm.packUnorm1x8(A.x)166 val C = Vec1(glm.unpackUnorm1x8(B))167 A.shouldEqual(C, 1f / 255f)168 }169 }170 "packSnorm1x8" {171 listOf(Vec1(1f), Vec1(-0.7f), Vec1(-1f))172 .forEach { A ->173 val B = glm.packSnorm1x8(A.x)174 val C = Vec1(glm.unpackSnorm1x8(B))175 A.shouldEqual(C, 1f / 127f)176 }177 }178 "packUnorm2x8" {179 listOf(Vec2(1f, 0.7f), Vec2(0.5f, 0.1f))180 .forEach { A ->181 val B = glm.packUnorm2x8(A)182 val C = glm.unpackUnorm2x8(B)183 A.shouldEqual(C, 1f / 255f)184 }185 }186 "packSnorm2x8" {187 listOf(Vec2(1f, 0f), Vec2(-0.7f, -0.1f))188 .forEach { A ->189 val B = glm.packSnorm2x8(A)190 val C = glm.unpackSnorm2x8(B)191 A.shouldEqual(C, 1f / 127f)192 }193 }194 "packUnorm4x8" {195 listOf(Vec4(1f, 0.7f, 0.3f, 0f), Vec4(0.5f, 0.1f, 0.2f, 0.3f))196 .forEach { A ->197 val B = glm.packUnorm4x8(A)198 val C = glm.unpackUnorm4x8(B)199 A.shouldEqual(C, 1f / 255f)200 }201 }202 "packSnorm4x8" {203 listOf(Vec4(1f, 0f, -0.5f, -1f), Vec4(-0.7f, -0.1f, 0.1f, 0.7f))204 .forEach { A ->205 val B = glm.packSnorm4x8(A)206 val C = glm.unpackSnorm4x8(B)207 A.shouldEqual(C, 1f / 127f)208 }209 }210// "packUnorm" {211//212// listOf(Vec2(1f, 0.7f), Vec2(0.5f, 0.1f))213// .forEach { A ->214// val B = glm.packUnorm(B);215// glm::vec2 D = glm::unpackUnorm<float>(C);216// Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 255.f)) ? 0 : 1;217// assert(!Error);218// }219//220// return Error;221// }222// int test_packSnorm()223// {224// int Error = 0;225//226// std::vector<glm::vec2> A;227// A.push_back(glm::vec2( 1.0f, 0.0f));228// A.push_back(glm::vec2(-0.5f,-0.7f));229// A.push_back(glm::vec2(-0.1f, 0.1f));230//231// for(std::size_t i = 0; i < A.size(); ++i)232// {233// glm::vec2 B(A[i]);234// glm::i16vec2 C = glm::packSnorm<glm::int16>(B);235// glm::vec2 D = glm::unpackSnorm<float>(C);236// Error += glm::all(glm::epsilonEqual(B, D, 1.0f / 32767.0f * 2.0f)) ? 0 : 1;...

Full Screen

Full Screen

ContractRequirementsUnitTest.kt

Source:ContractRequirementsUnitTest.kt Github

copy

Full Screen

1package io.provenance.scope.loan.utility2import io.kotest.assertions.throwables.shouldNotThrow3import io.kotest.assertions.throwables.shouldThrow4import io.kotest.core.spec.style.WordSpec5import io.kotest.core.test.TestCaseOrder6import io.kotest.matchers.ints.shouldBeGreaterThanOrEqual7import io.kotest.matchers.ints.shouldBeInRange8import io.kotest.matchers.ints.shouldBeLessThan9import io.kotest.matchers.shouldBe10import io.kotest.matchers.string.shouldContainIgnoringCase11import io.kotest.matchers.types.shouldBeTypeOf12import io.kotest.property.Arb13import io.kotest.property.arbitrary.list14import io.kotest.property.checkAll15import io.provenance.scope.loan.test.LoanPackageArbs16import io.provenance.scope.loan.test.shouldHaveViolationCount17class ContractRequirementsUnitTest : WordSpec({18 /* Helpers */19 fun getExpectedViolationCount(enforcements: List<ContractEnforcement>) =20 enforcements.fold(21 emptyMap<ContractViolation, UInt>() to 0U22 ) { (violationMap, overallCount), (rule, violationReport) ->23 if (!rule) {24 violationMap.getOrDefault(violationReport, 0U).let { currentIndividualCount ->25 if (currentIndividualCount == 0U) {26 violationMap.plus(violationReport to 1U) to overallCount + 1U27 } else {28 violationMap.plus(violationReport to currentIndividualCount + 1U) to overallCount29 }30 }31 } else {32 violationMap to overallCount33 }34 }.second35 /* Tests */36 "validateRequirements" When {37 "accepting a list of enforcements" should {38 "accept infix syntax" {39 checkAll<Boolean, ContractViolation> { rule, violationReport ->40 (rule orError violationReport).shouldBeTypeOf<ContractEnforcement>()41 (rule orError violationReport) shouldBe ContractEnforcement(rule, violationReport)42 }43 }44 "return state violations only for failed conditions" {45 checkAll(Arb.list(LoanPackageArbs.anyContractEnforcement)) { enforcementList ->46 val expectedOverallViolationCount = getExpectedViolationCount(enforcementList)47 if (expectedOverallViolationCount > 0U) {48 shouldThrow<IllegalContractStateException> {49 validateRequirements(ContractRequirementType.LEGAL_SCOPE_STATE, *enforcementList.toTypedArray())50 }.let { exception ->51 exception.message shouldContainIgnoringCase "state was invalid" // TODO: Make better check52 }53 } else {54 shouldNotThrow<IllegalContractStateException> {55 validateRequirements(ContractRequirementType.LEGAL_SCOPE_STATE, *enforcementList.toTypedArray())56 }57 }58 }59 }60 "return input violations only for failed conditions" {61 checkAll(Arb.list(LoanPackageArbs.anyContractEnforcement)) { enforcementList ->62 val expectedOverallViolationCount = getExpectedViolationCount(enforcementList)63 if (expectedOverallViolationCount > 0U) {64 shouldThrow<ContractViolationException> {65 validateRequirements(ContractRequirementType.VALID_INPUT, *enforcementList.toTypedArray())66 }.let { exception ->67 exception shouldHaveViolationCount expectedOverallViolationCount68 }69 } else {70 shouldNotThrow<ContractViolationException> {71 validateRequirements(ContractRequirementType.VALID_INPUT, *enforcementList.toTypedArray())72 }73 }74 }75 }76 }77 "invoked with a function body" should {78 "return state violations only for failed conditions" {79 checkAll(80 Arb.list(LoanPackageArbs.anyContractEnforcement),81 Arb.list(LoanPackageArbs.anyContractEnforcement),82 ) { enforcementListA, enforcementListB ->83 val expectedOverallViolationCount = getExpectedViolationCount(enforcementListA + enforcementListB)84 if (expectedOverallViolationCount > 0U) {85 shouldThrow<IllegalContractStateException> {86 validateRequirements(ContractRequirementType.LEGAL_SCOPE_STATE) {87 5 shouldBeGreaterThanOrEqual 488 requireThat(*enforcementListA.toTypedArray())89 3 shouldBeLessThan 490 requireThat(*enforcementListB.toTypedArray())91 2 shouldBeInRange 0..992 }93 }.let { exception ->94 exception.message shouldContainIgnoringCase "state was invalid" // TODO: Make better check95 }96 } else {97 shouldNotThrow<ContractViolationException> {98 validateRequirements(ContractRequirementType.VALID_INPUT) {99 2 shouldBeInRange 0..9100 requireThat(*enforcementListB.toTypedArray())101 5 shouldBeGreaterThanOrEqual 4102 requireThat(*enforcementListA.toTypedArray())103 3 shouldBeLessThan 4104 }105 }106 }107 }108 }109 "return input violations only for failed conditions" {110 checkAll(111 Arb.list(LoanPackageArbs.anyContractEnforcement),112 Arb.list(LoanPackageArbs.anyContractEnforcement),113 ) { enforcementListA, enforcementListB ->114 val expectedOverallViolationCount = getExpectedViolationCount(enforcementListA + enforcementListB)115 if (expectedOverallViolationCount > 0U) {116 shouldThrow<ContractViolationException> {117 validateRequirements(ContractRequirementType.VALID_INPUT) {118 5 shouldBeGreaterThanOrEqual 4119 requireThat(*enforcementListB.toTypedArray())120 3 shouldBeLessThan 4121 requireThat(*enforcementListA.toTypedArray())122 2 shouldBeInRange 0..9123 }124 }.let { exception ->125 exception shouldHaveViolationCount expectedOverallViolationCount126 }127 } else {128 shouldNotThrow<ContractViolationException> {129 validateRequirements(ContractRequirementType.VALID_INPUT) {130 2 shouldBeInRange 0..9131 requireThat(*enforcementListA.toTypedArray())132 5 shouldBeGreaterThanOrEqual 4133 requireThat(*enforcementListB.toTypedArray())134 3 shouldBeLessThan 4135 }136 }137 }138 }139 }140 }141 }142}) {143 override fun testCaseOrder() = TestCaseOrder.Random144}...

Full Screen

Full Screen

ByteBufIntSmart.kt

Source:ByteBufIntSmart.kt Github

copy

Full Screen

...14 * 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.Shrinker23import io.kotest.property.arbitrary.*24import io.kotest.property.checkAll25import io.netty.buffer.ByteBuf26import io.netty.buffer.ByteBufAllocator27import kotlin.random.nextUInt28private suspend fun doIntSmartRWTest(29 writer: ByteBuf.(Int) -> ByteBuf,30 reader: ByteBuf.() -> Int31) = checkAll(Arb.intArray(collectionSizeArb, Arb.int(Smart.MIN_INT_VALUE, Smart.MAX_INT_VALUE))) { testData ->32 val buf = ByteBufAllocator.DEFAULT.buffer(testData.size * Short.SIZE_BYTES)33 try {34 testData.forEach { expected -> buf.writer(expected) }35 testData.forEach { expected ->36 val read = buf.reader()37 read shouldBe expected38 }39 } finally {40 buf.release()41 }42}43@ExperimentalUnsignedTypes44private suspend fun doUIntSmartRWTest(45 writer: ByteBuf.(Int) -> ByteBuf,46 reader: ByteBuf.() -> Int47) = checkAll(48 Arb.uIntArray(collectionSizeArb, Arb.uInt(USmart.MIN_INT_VALUE.toUInt(), USmart.MAX_INT_VALUE.toUInt()))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.shouldBeNonNegative()56 read shouldBe expected.toInt()57 }58 } finally {59 buf.release()60 }61}62fun Arb.Companion.nullableUInt(min: UInt = UInt.MIN_VALUE, max: UInt = UInt.MAX_VALUE) = nullableUInt(min..max)63fun Arb.Companion.nullableUInt(range: UIntRange = UInt.MIN_VALUE..UInt.MAX_VALUE): Arb<UInt?> {64 val edges = listOf(range.first, 1u, range.last).filter { it in range }.distinct()65 return arbitrary(edges, NullableUIntShrinker(range)) {66 if (it.random.nextFloat() < 0.40) null else it.random.nextUInt(range)67 }68}69class NullableUIntShrinker(private val range: UIntRange) : Shrinker<UInt?> {70 override fun shrink(value: UInt?): List<UInt?> = when (value) {71 null -> emptyList()72 0u -> emptyList()73 1u -> listOf(0u).filter { it in range }74 else -> {75 val a = listOf(0u, 1u, value / 3u, null, value / 2u, value * 2u / 3u)76 val b = (1u..5u).map { value - it }.reversed().filter { it > 0u }77 (a + b).distinct().filterNot { it == value }.filter { it in range }78 }79 }80}81@ExperimentalUnsignedTypes82private suspend fun doNullableUIntSmartRWTest(83 writer: ByteBuf.(Int?) -> ByteBuf,84 reader: ByteBuf.() -> Int?85) = checkAll(86 Arb.list(Arb.nullableUInt(USmart.MIN_INT_VALUE.toUInt(), USmart.MAX_INT_VALUE.toUInt()))87) { testData ->88 val buf = ByteBufAllocator.DEFAULT.buffer(testData.size * Short.SIZE_BYTES)89 try {90 testData.forEach { expected -> buf.writer(expected?.toInt()) }91 testData.forEach { expected ->92 val read = buf.reader()93 read?.shouldBeNonNegative()94 read shouldBe expected?.toInt()95 }96 } finally {97 buf.release()98 }99}100@ExperimentalUnsignedTypes101class ByteBufIntSmartTest : StringSpec({102 "Read/Write Int Smart" { doIntSmartRWTest(ByteBuf::writeIntSmart, ByteBuf::readIntSmart) }103 "Unsigned Read/Write Int Smart" {104 doUIntSmartRWTest(ByteBuf::writeUnsignedIntSmart, ByteBuf::readUnsignedIntSmart)105 }...

Full Screen

Full Screen

ByteBufMediumTest.kt

Source:ByteBufMediumTest.kt Github

copy

Full Screen

...14 * 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 doMediumGSTest(27 setter: ByteBuf.(Int, Int) -> ByteBuf,28 getter: ByteBuf.(Int) -> Int29) = checkAll(Arb.intArray(collectionSizeArb, Arb.int(Medium.MIN_VALUE, Medium.MAX_VALUE))) { testData ->30 val buf = ByteBufAllocator.DEFAULT.buffer(testData.size * Medium.SIZE_BYTES)31 try {32 testData.forEachIndexed { i, expected -> buf.setter(i * Medium.SIZE_BYTES, expected) }33 testData.forEachIndexed { i, expected ->34 val get = buf.getter(i * Medium.SIZE_BYTES)35 get shouldBe expected36 }37 } finally {38 buf.release()39 }40}41private suspend fun doMediumRWTest(42 writer: ByteBuf.(Int) -> ByteBuf,43 reader: ByteBuf.() -> Int44) = checkAll(Arb.intArray(collectionSizeArb, Arb.int(Medium.MIN_VALUE, Medium.MAX_VALUE))) { testData ->45 val buf = ByteBufAllocator.DEFAULT.buffer(testData.size * Medium.SIZE_BYTES)46 try {47 testData.forEach { expected -> buf.writer(expected) }48 testData.forEach { expected ->49 val read = buf.reader()50 read shouldBe expected51 }52 } finally {53 buf.release()54 }55}56@ExperimentalUnsignedTypes57private suspend fun doUMediumGSTest(58 setter: ByteBuf.(Int, Int) -> ByteBuf,59 getter: ByteBuf.(Int) -> Int60) = checkAll(Arb.uIntArray(collectionSizeArb, Arb.uInt(UMedium.MIN_VALUE, UMedium.MAX_VALUE))) { testData ->61 val buf = ByteBufAllocator.DEFAULT.buffer(testData.size * UMedium.SIZE_BYTES)62 try {63 testData.forEachIndexed { i, expected -> buf.setter(i * UMedium.SIZE_BYTES, expected.toInt()) }64 testData.forEachIndexed { i, expected ->65 val get = buf.getter(i * UMedium.SIZE_BYTES)66 get.shouldBeNonNegative()67 get shouldBe expected.toInt()68 }69 } finally {70 buf.release()71 }72}73@ExperimentalUnsignedTypes74private suspend fun doUMediumRWTest(75 writer: ByteBuf.(Int) -> ByteBuf,76 reader: ByteBuf.() -> Int77) = checkAll(Arb.uIntArray(collectionSizeArb, Arb.uInt(UMedium.MIN_VALUE, UMedium.MAX_VALUE))) { testData ->78 val buf = ByteBufAllocator.DEFAULT.buffer(testData.size * UMedium.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 ByteBufMediumTest : StringSpec({92 "Get/Set Medium LME" { doMediumGSTest(ByteBuf::setMediumLME, ByteBuf::getMediumLME) }93 "Read/Write Medium LME" { doMediumRWTest(ByteBuf::writeMediumLME, ByteBuf::readMediumLME) }94 "Unsigned Get/Set Medium LME" { doUMediumGSTest(ByteBuf::setMediumLME, ByteBuf::getUnsignedMediumLME) }95 "Unsigned Read/Write Medium LME" { doUMediumRWTest(ByteBuf::writeMediumLME, ByteBuf::readUnsignedMediumLME) }...

Full Screen

Full Screen

MapTest.kt

Source:MapTest.kt Github

copy

Full Screen

1import io.kotest.matchers.shouldBe2import io.kotest.property.Arb3import io.kotest.property.Exhaustive4import io.kotest.property.arbitrary.int5import io.kotest.property.checkAll6import io.kotest.property.exhaustive.ints7import io.harmor.msgpack.internal.MessageType.MAP168import io.harmor.msgpack.internal.MessageType.MAP329import io.harmor.msgpack.IntegerValue10import io.harmor.msgpack.MapValue11import io.harmor.msgpack.ByteArraySink12import io.harmor.msgpack.msgpack13import utils.MessagePackerFactory14import utils.MessageUnpackerFactory15import utils.TypedElement16import utils.with17class MapTest : AbstractMessagePackTest() {18 init {19 "Packer" should {20 "use fixmap" {...

Full Screen

Full Screen

IntTest.kt

Source:IntTest.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.ints.*7import 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 IntTest : FunSpec({14 test("<Int, Int> 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(Int.MAX_VALUE - 10, Int.MAX_VALUE),21 row(Int.MIN_VALUE, Int.MIN_VALUE + 10)22 ) { vMin, vMax ->23 val expectedValues = (vMin..vMax).toSet()24 val actualValues = (1..100_000).map { Arb.int(vMin, vMax).single() }.toSet()25 actualValues shouldBe expectedValues26 }27 }28 test("Arb.int edge cases should respect min and max bounds") {29 checkCoverage("run", 25.0) {30 PropTest(iterations = 1000).checkAll<Int, Int> { min, max ->31 if (min < max) {32 classify("run")33 Arb.int(min..max).edgecases().forAll {34 it.shouldBeBetween(min, max)35 }36 }37 }38 }39 }40 test("Arb.positiveInts should return positive ints only") {41 val numbers = Arb.positiveInt().take(1000).toSet()42 numbers.forAll { it.shouldBePositive() }43 }44 test("Arb.nonNegativeInts should return non negative ints only") {45 val numbers = Arb.nonNegativeInt().take(1000).toSet()46 numbers.forAll { it.shouldBeNonNegative() }47 }48 test("Arb.negativeInts should return negative ints only") {49 val numbers = Arb.negativeInt().take(1000).toSet()50 numbers.forAll { it.shouldBeNegative() }51 }52 test("Arb.nonPositiveInts should return non positive ints only") {53 val numbers = Arb.nonPositiveInt().take(1000).toSet()54 numbers.forAll { it.shouldBeNonPositive() }55 }56})57class UIntTest : FunSpec({58 test("<UInt, UInt> should give values between min and max inclusive") {59 forAll(60 row(1u, 3u),61 row(0u, 100u),62 row(UInt.MAX_VALUE - 10u, UInt.MAX_VALUE),63 row(UInt.MIN_VALUE, UInt.MIN_VALUE + 10u)64 ) { vMin, vMax ->65 val expectedValues = (vMin..vMax).toSet()66 val actualValues = (1..100_000).map { Arb.uInt(vMin, vMax).single() }.toSet()67 actualValues shouldBe expectedValues68 }69 }70 test("Arb.uInt edge cases should respect min and max bounds") {71 checkCoverage("run", 25.0) {72 PropTest(iterations = 1000).checkAll<UInt, UInt> { min, max ->73 if (min < max) {74 classify("run")75 Arb.uInt(min..max).edgecases().forAll {76 it.shouldBeBetween(min, max)77 }78 }79 }80 }81 }82})...

Full Screen

Full Screen

ArrayTest.kt

Source:ArrayTest.kt Github

copy

Full Screen

2import io.harmor.msgpack.ByteArraySink3import io.harmor.msgpack.internal.MessageType.ARRAY164import io.harmor.msgpack.internal.MessageType.ARRAY325import io.harmor.msgpack.msgpack6import io.kotest.matchers.shouldBe7import io.kotest.property.Arb8import io.kotest.property.Exhaustive9import io.kotest.property.arbitrary.int10import io.kotest.property.checkAll11import io.kotest.property.exhaustive.ints12import utils.MessagePackerFactory13import utils.MessageUnpackerFactory14import utils.TypedElement15class ArrayTest : AbstractMessagePackTest() {16 init {17 "Packer" should {18 "use fixarray" {19 checkAll(Exhaustive.ints(0..15)) {20 it with packer shouldBe fixarray(it)21 }22 }23 "use array16" {24 checkAll(Arb.int(16..Short.MAX_VALUE)) {25 it with packer shouldBe array16(it)...

Full Screen

Full Screen

uint.kt

Source:uint.kt Github

copy

Full Screen

1package io.kotest.matchers.ints2import io.kotest.matchers.Matcher3import io.kotest.matchers.MatcherResult4import io.kotest.matchers.shouldBe5fun UInt.shouldBeBetween(lower: UInt, upper: UInt): UInt {6 this shouldBe between(lower, upper)7 return this8}9fun between(lower: UInt, upper: UInt) = object : Matcher<UInt> {10 override fun test(value: UInt) = 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

test

Using AI Code Generation

copy

Full Screen

1uint.shouldBeLessThan(2u)2uint.shouldBeLessThan(2)3ulong.shouldBeLessThan(2UL)4ulong.shouldBeLessThan(2)5val ushort = 1.toUShort()6ushort.shouldBeLessThan(2.toUShort())7ushort.shouldBeLessThan(2)8val ubyte = 1.toUByte()9ubyte.shouldBeLessThan(2.toUByte())10ubyte.shouldBeLessThan(2)11int.shouldBeLessThan(2)12int.shouldBeLessThan(2u)13int.shouldBeLessThan(2.toUShort())14int.shouldBeLessThan(2.toUByte())15long.shouldBeLessThan(2L)16long.shouldBeLessThan(2UL)17long.shouldBeLessThan(2.toUShort())18long.shouldBeLessThan(2.toUByte())19val short = 1.toShort()20short.shouldBeLessThan(2.toShort())21short.shouldBeLessThan(2)22short.shouldBeLessThan(2u)23short.shouldBeLessThan(2.toUByte())24val byte = 1.toByte()25byte.shouldBeLessThan(2.toByte())26byte.shouldBeLessThan(2)27byte.shouldBeLessThan(2u)28byte.shouldBeLessThan(2.toUShort())29byte.shouldBeLessThan(2.toUByte())30char.shouldBeLessThan('b')31char.shouldBeLessThan(1)32char.shouldBeLessThan(1u)33char.shouldBeLessThan(1.toUShort())34char.shouldBeLessThan(1.toU

Full Screen

Full Screen

test

Using AI Code Generation

copy

Full Screen

1fun `test io.kotest.matchers.ints.uint should be greater than`() {2a should beGreaterThan(2u)3}4}5fun `test io.kotest.matchers.ints.uint should be greater than or equal`() {6a should beGreaterThanOrEqual(5u)7}8}9fun `test io.kotest.matchers.ints.uint should be less than`() {10a should beLessThan(6u)11}12}13fun `test io.kotest.matchers.ints.uint should be less than or equal`() {14a should beLessThanOrEqual(5u)15}16}17fun `test io.kotest.matchers.ints.uint should be between`() {18a should beBetween(2u, 6u)19}20}21fun `test io.kotest.matchers.ints.uint should be in range`() {22a should beInRange(2u..6u)23}24}25fun `test io.kotest.matchers.ints.uint should be in closed range`() {26a should beInClosedRange(2u..6u)27}28}29fun `test io.kotest.matchers.ints.uint should be in closed range`() {30a should beInClosedRange(2u..6u)31}32}

Full Screen

Full Screen

test

Using AI Code Generation

copy

Full Screen

1 at org.junit.Assert.fail(Assert.java:89)2 at org.junit.Assert.failNotEquals(Assert.java:835)3 at org.junit.Assert.assertTrue(Assert.java:42)4 at org.junit.Assert.assertTrue(Assert.java:53)5 at io.kotest.matchers.ints.uintTest.shouldTestGreaterThan(uintTest.kt:14)6 at org.junit.Assert.fail(Assert.java:89)7 at org.junit.Assert.failNotEquals(Assert.java:835)8 at org.junit.Assert.assertTrue(Assert.java:42)9 at org.junit.Assert.assertTrue(Assert.java:53)10 at io.kotest.matchers.ints.uintTest.shouldTestLessThan(uintTest.kt:19)11 at org.junit.Assert.fail(Assert.java:89)12 at org.junit.Assert.failNotEquals(Assert.java:835)13 at org.junit.Assert.assertEquals(Assert.java:118)14 at org.junit.Assert.assertEquals(Assert.java:144)15 at io.kotest.matchers.ints.uintTest.shouldTestEquals(uintTest.kt:9)16 at org.junit.Assert.fail(Assert.java:89)17 at org.junit.Assert.failNotEquals(Assert.java:835)18 at org.junit.Assert.assertEquals(Assert.java:118)19 at org.junit.Assert.assertEquals(Assert.java:144)20 at io.kotest.matchers.ints.uintTest.shouldTestNotEquals(uintTest.kt:

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 method in uint

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful