How to use Arb.next method of io.kotest.property.arbitrary.next class

Best Kotest code snippet using io.kotest.property.arbitrary.next.Arb.next

GenHelper.kt

Source:GenHelper.kt Github

copy

Full Screen

1/*2 * Copyright (c) 2020 sparetimedevs and respective authors and developers.3 *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 com.sparetimedevs.pofpaf.test.generator17import arrow.core.Either18import arrow.core.left19import arrow.core.right20import com.microsoft.azure.functions.HttpMethod21import com.sparetimedevs.pofpaf.test.implementation.general.log.Level22import io.kotest.property.Arb23import io.kotest.property.Exhaustive24import io.kotest.property.arbitrary.bool25import io.kotest.property.arbitrary.byte26import io.kotest.property.arbitrary.choice27import io.kotest.property.arbitrary.create28import io.kotest.property.arbitrary.double29import io.kotest.property.arbitrary.element30import io.kotest.property.arbitrary.file31import io.kotest.property.arbitrary.float32import io.kotest.property.arbitrary.int33import io.kotest.property.arbitrary.localDate34import io.kotest.property.arbitrary.localDateTime35import io.kotest.property.arbitrary.localTime36import io.kotest.property.arbitrary.long37import io.kotest.property.arbitrary.map38import io.kotest.property.arbitrary.next39import io.kotest.property.arbitrary.period40import io.kotest.property.arbitrary.short41import io.kotest.property.arbitrary.string42import io.kotest.property.arbitrary.uuid43import io.kotest.property.exhaustive.exhaustive44import java.net.URI45fun Arb.Companion.suspendFunThatReturnsEitherAnyOrAnyOrThrows(): Arb<suspend () -> Either<Any, Any>> =46 choice(47 suspendFunThatReturnsAnyRight(),48 suspendFunThatReturnsAnyLeft(),49 suspendFunThatThrows()50 )51fun Arb.Companion.suspendFunThatReturnsEitherAnyOrUnitOrThrows(): Arb<suspend () -> Either<Any, Unit>> =52 choice(53 suspendFunThatReturnsUnitRight() as Arb<suspend () -> Either<Any, Unit>>,54 suspendFunThatReturnsAnyLeft() as Arb<suspend () -> Either<Any, Unit>>,55 suspendFunThatThrows() as Arb<suspend () -> Either<Any, Unit>>56 )57fun Arb.Companion.suspendFunThatReturnsUnitRight(): Arb<suspend () -> Either<Any, Unit>> =58 unit().map { suspend { it.right() } }59fun Arb.Companion.suspendFunThatReturnsAnyRight(): Arb<suspend () -> Either<Any, Any>> =60 any().map { suspend { it.right() } }61fun Arb.Companion.suspendFunThatReturnsAnyLeft(): Arb<suspend () -> Either<Any, Any>> =62 any().map { suspend { it.left() } }63fun Arb.Companion.suspendFunThatThrows(): Arb<suspend () -> Either<Any, Any>> =64 throwable().map { suspend { throw it } } as Arb<suspend () -> Either<Any, Any>>65fun Arb.Companion.suspendFunThatThrowsFatalThrowable(): Arb<suspend () -> Either<Any, Any>> =66 fatalThrowable().map { suspend { throw it } } as Arb<suspend () -> Either<Any, Any>>67fun Arb.Companion.throwable(): Arb<Throwable> =68 element(69 Exception(),70 RuntimeException(),71 IllegalArgumentException(),72 IllegalStateException(),73 IndexOutOfBoundsException(),74 UnsupportedOperationException(),75 ArithmeticException(),76 NumberFormatException(),77 NullPointerException(),78 ClassCastException(),79 AssertionError(),80 NoSuchElementException(),81 ConcurrentModificationException()82 )83fun Arb.Companion.fatalThrowable(): Arb<Throwable> =84 element(85 MyVirtualMachineError(),86 ThreadDeath(),87 InterruptedException(),88 LinkageError()89 )90class MyVirtualMachineError : VirtualMachineError()91fun Arb.Companion.any(): Arb<Any> =92 choice(93 string() as Arb<Any>,94 int() as Arb<Any>,95 short() as Arb<Any>,96 long() as Arb<Any>,97 float() as Arb<Any>,98 double() as Arb<Any>,99 bool() as Arb<Any>,100 byte() as Arb<Any>,101 uuid() as Arb<Any>,102 file() as Arb<Any>,103 localDate() as Arb<Any>,104 localTime() as Arb<Any>,105 localDateTime() as Arb<Any>,106 period() as Arb<Any>,107 throwable() as Arb<Any>,108 fatalThrowable() as Arb<Any>,109 mapOfStringAndStringGenerator() as Arb<Any>,110 uri() as Arb<Any>,111 httpMethod() as Arb<Any>,112 unit() as Arb<Any>113 )114fun Arb.Companion.unit(): Arb<Unit> =115 create { Unit }116fun Arb.Companion.mapOfStringAndStringGenerator(): Arb<Map<String, String>> =117 element(118 listOf(119 emptyMap(),120 mapOf(121 string().next() to string().next()122 ),123 mapOf(124 string().next() to string().next(),125 string().next() to string().next()126 ),127 mapOf(128 string().next() to string().next(),129 string().next() to string().next(),130 string().next() to string().next()131 ),132 mapOf(133 string().next() to string().next(),134 string().next() to string().next(),135 string().next() to string().next(),136 string().next() to string().next(),137 string().next() to string().next(),138 string().next() to string().next()139 ),140 mapOf(141 string().next() to string().next(),142 string().next() to string().next(),143 string().next() to string().next(),144 string().next() to string().next(),145 string().next() to string().next(),146 string().next() to string().next(),147 string().next() to string().next(),148 string().next() to string().next(),149 string().next() to string().next(),150 string().next() to string().next(),151 string().next() to string().next(),152 string().next() to string().next()153 ),154 mapOf(155 string().next() to string().next(),156 string().next() to string().next(),157 string().next() to string().next(),158 string().next() to string().next(),159 string().next() to string().next(),160 string().next() to string().next(),161 string().next() to string().next(),162 string().next() to string().next(),163 string().next() to string().next(),164 string().next() to string().next(),165 string().next() to string().next(),166 string().next() to string().next(),167 string().next() to string().next(),168 string().next() to string().next(),169 string().next() to string().next(),170 string().next() to string().next(),171 string().next() to string().next(),172 string().next() to string().next(),173 string().next() to string().next(),174 string().next() to string().next(),175 string().next() to string().next(),176 string().next() to string().next(),177 string().next() to string().next(),178 string().next() to string().next()179 )180 )181 )182fun Arb.Companion.uri(): Arb<URI> =183 element(184 listOf(185 URI.create("https://sparetimedevs.com"),186 URI.create("https://www.sparetimedevs.com"),187 URI.create("https://something.sparetimedevs.com"),188 URI.create("https://something.sparetimedevs.com/another/thing"),189 URI.create("https://something.sparetimedevs.com/another/thing?query=param")190 )191 )192fun Arb.Companion.httpMethod(): Arb<HttpMethod> =193 element(194 listOf(195 HttpMethod.GET,196 HttpMethod.HEAD,197 HttpMethod.POST,198 HttpMethod.PUT,199 HttpMethod.DELETE,200 HttpMethod.CONNECT,201 HttpMethod.OPTIONS,202 HttpMethod.TRACE203 )204 )205fun Exhaustive.Companion.logLevel(): Exhaustive<Level> =206 listOf(207 Level.INFO,208 Level.DEBUG,209 Level.WARN,210 Level.ERROR211 ).exhaustive()212fun Arb.Companion.stringOrNull(): Arb<String?> =213 choice(214 string() as Arb<String?>,215 create { null } as Arb<String?>216 )...

Full Screen

Full Screen

RoomsKtTest.kt

Source:RoomsKtTest.kt Github

copy

Full Screen

1package com.tylerkindy.betrayal.db2import com.tylerkindy.betrayal.Direction3import io.kotest.assertions.throwables.shouldThrow4import io.kotest.core.spec.style.DescribeSpec5import io.kotest.matchers.collections.shouldBeEmpty6import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder7import io.kotest.matchers.should8import io.kotest.matchers.shouldBe9import io.kotest.property.Arb10import io.kotest.property.Exhaustive11import io.kotest.property.arbitrary.ShortShrinker12import io.kotest.property.arbitrary.arbitrary13import io.kotest.property.arbitrary.enum14import io.kotest.property.arbitrary.set15import io.kotest.property.checkAll16import io.kotest.property.exhaustive.ints17import io.kotest.property.exhaustive.map18import io.kotest.property.forAll19import org.jetbrains.exposed.sql.insert20import org.jetbrains.exposed.sql.select21import org.jetbrains.exposed.sql.selectAll22import org.jetbrains.exposed.sql.transactions.transaction23import kotlin.random.nextInt24val directionSets = Arb.set(Arb.enum<Direction>(), 0..Direction.values().size)25val rotations = Exhaustive.ints(0..3).map { it.toShort() }26val invalidRotationValues = (Short.MIN_VALUE..Short.MAX_VALUE) - (0..3)27val invalidRotations = arbitrary(listOf(Short.MIN_VALUE, -1, 4, Short.MAX_VALUE), ShortShrinker) {28 it.random.nextInt(invalidRotationValues.indices).let { i -> invalidRotationValues[i] }.toShort()29}30class RoomsKtTest : DescribeSpec({31 useDatabase()32 describe("returnRoomToStack") {33 it("returns to empty stack") {34 transaction {35 val gameId = "ABCDEF"36 val stackId =37 RoomStacks.insert {38 it[this.gameId] = gameId39 it[curIndex] = null40 it[flipped] = false41 } get RoomStacks.id42 val roomId =43 Rooms.insert {44 it[this.gameId] = gameId45 it[roomDefId] = 1446 it[gridX] = 047 it[gridY] = 048 it[rotation] = 049 } get Rooms.id50 returnRoomToStack(gameId, roomId)51 Rooms.selectAll().shouldBeEmpty()52 val stackRows = RoomStacks.select { RoomStacks.id eq stackId }53 stackRows.count().shouldBe(1)54 stackRows.first().should {55 it[RoomStacks.curIndex].shouldBe(0)56 }57 RoomStackContents.select { RoomStackContents.stackId eq stackId }58 .first().should {59 it[RoomStackContents.index].shouldBe(0)60 it[RoomStackContents.roomDefId].shouldBe(14)61 }62 }63 }64 it("returns to non-empty stack") {65 transaction {66 val gameId = "ABCDEF"67 val stackId = RoomStacks.insert {68 it[this.gameId] = gameId69 it[curIndex] = 1770 it[flipped] = false71 } get RoomStacks.id72 RoomStackContents.insert {73 it[this.stackId] = stackId74 it[index] = 2575 it[roomDefId] = 976 }77 RoomStackContents.insert {78 it[this.stackId] = stackId79 it[index] = 1780 it[roomDefId] = 1381 }82 RoomStackContents.insert {83 it[this.stackId] = stackId84 it[index] = 385 it[roomDefId] = 2386 }87 val roomId = Rooms.insert {88 it[this.gameId] = gameId89 it[roomDefId] = 1490 it[gridX] = 091 it[gridY] = 092 it[rotation] = 093 } get Rooms.id94 returnRoomToStack(gameId, roomId)95 Rooms.selectAll().shouldBeEmpty()96 RoomStackContents.selectAll()97 .map { it[RoomStackContents.index] }98 .shouldContainExactlyInAnyOrder(0, 1, 2, 3)99 }100 }101 }102 describe("rotateDoors") {103 it("maintains number of directions") {104 forAll(directionSets, rotations) { dirs, rotation ->105 rotateDoors(dirs, rotation).size == dirs.size106 }107 }108 it("throws for invalid rotations") {109 checkAll(directionSets, invalidRotations) { dirs, rotation ->110 shouldThrow<IllegalArgumentException> { rotateDoors(dirs, rotation) }111 }112 }113 it("returns the same directions with no rotation") {114 forAll(directionSets) { dirs ->115 rotateDoors(dirs, 0) == dirs116 }117 }118 it("always returns all directions") {119 val allDirections = Direction.values().toSet()120 forAll(rotations) { rotation ->121 rotateDoors(allDirections, rotation) == allDirections122 }123 }124 it("rotates doors") {125 rotateDoors(126 setOf(Direction.NORTH, Direction.WEST),127 3128 ) shouldBe setOf(Direction.NORTH, Direction.EAST)129 }130 }131})...

Full Screen

Full Screen

BatchMigrationGenerator.kt

Source:BatchMigrationGenerator.kt Github

copy

Full Screen

1package liquibase.ext.generators2import io.kotest.property.Arb3import io.kotest.property.Exhaustive4import io.kotest.property.RandomSource5import io.kotest.property.arbitrary.arbitrary6import io.kotest.property.arbitrary.filter7import io.kotest.property.arbitrary.filterNot8import io.kotest.property.arbitrary.int9import io.kotest.property.arbitrary.list10import io.kotest.property.arbitrary.long11import io.kotest.property.arbitrary.map12import io.kotest.property.arbitrary.next13import io.kotest.property.arbitrary.orNull14import io.kotest.property.exhaustive.azstring15import io.kotest.property.exhaustive.exhaustive16import io.kotest.property.exhaustive.merge17import liquibase.ext.changes.BatchMigrationChange18import java.sql.RowIdLifetime19object BatchMigrationGenerator {20 val identifierGen = { min: Int -> Exhaustive.azstring(min..16).toArb() }21 val rowIdLifeTimeInvalidGenerator = listOf(22 RowIdLifetime.ROWID_UNSUPPORTED,23 RowIdLifetime.ROWID_VALID_OTHER,24 RowIdLifetime.ROWID_VALID_SESSION,25 RowIdLifetime.ROWID_VALID_TRANSACTION26 ).exhaustive()27 val rowIdLifeTimeGenerator = listOf(28 RowIdLifetime.ROWID_VALID_FOREVER,29 ).exhaustive().merge(rowIdLifeTimeInvalidGenerator)30 val validMigrationGenerator = arbitrary { rs: RandomSource ->31 val change = BatchMigrationChange()32 val colCount = Arb.int(1, 5).next(rs)33 val colGen = fixedColumnListNoDupsGenerator(colCount, colCount)34 change.tableName = identifierGen(1).next(rs)35 change.chunkSize = Arb.long(1L, 10000L).next(rs)36 val from = colGen.next(rs)37 val fromSet = from.toSet()38 change.fromColumns = from.toColumnList()39 // Make sure we do not have overlapping or crossing columns between from and to40 val to = colGen.filterNot { l -> fromSet.any { it in l.toSet() } }.next(rs)41 change.toColumns = to.toColumnList()42 change43 }44 val validMigrationWithSleepsGenerator = arbitrary { rs: RandomSource ->45 val mig = validMigrationGenerator.next(rs)46 mig.sleepTime = Arb.long(0L, 10000L).orNull().next(rs)47 mig48 }49 val sampleMigrationGenerator = arbitrary { rs: RandomSource ->50 val change = BatchMigrationChange()51 change.tableName = identifierGen(1).orNull().next(rs)52 change.chunkSize = Arb.long(-100L, 10000L).orNull().next(rs)53 val upperBound = Arb.int(0, 5).next(rs)54 val minBound = Arb.int(0, 5).filter { it <= upperBound }.next(rs)55 change.fromColumns = fixedColumnStringSequenceGenerator(minBound, upperBound).orNull().next(rs)56 change.toColumns = fixedColumnStringSequenceGenerator(minBound, upperBound).orNull().next(rs)57 change.sleepTime = Arb.long(-100L, 10000L).orNull().next(rs)58 change59 }60 val invalidMigrationGenerator = sampleMigrationGenerator.filter { c: BatchMigrationChange ->61 val simplePredicate = c.fromColumns.isNullOrEmpty() ||62 c.toColumns.isNullOrEmpty() || (c.chunkSize ?: -1L) <= 0L || c.sleepTime?.let { it < 0L } ?: false63 if (simplePredicate) return@filter true64 else {65 val from = c.fromColumns!!.split(",")66 val to = c.toColumns!!.split(",").toSet()67 // check whether from and to columns are equal somewhere or crossing68 // check whether any to column is in primary keys69 from.size != to.size || from.any { it in to }70 }71 }72 private fun List<String>.toColumnList(): String = joinToString(separator = ",") { it }73 private val fixedColumnListGenerator = { lowerBound: Int, inclusiveUpperBound: Int ->74 Arb.list(identifierGen(1), IntRange(lowerBound, inclusiveUpperBound))75 }76 private val fixedColumnListNoDupsGenerator = { lowerBound: Int, inclusiveUpperBound: Int ->77 fixedColumnListGenerator(lowerBound, inclusiveUpperBound).filterNot { l ->78 l.toSet().size != l.size79 }80 }81 private val fixedColumnStringSequenceGenerator = { lowerBound: Int, inclusiveUpperBound: Int ->82 fixedColumnListGenerator(lowerBound, inclusiveUpperBound).map { l -> l.joinToString(",") { it } }83 }84}...

Full Screen

Full Screen

CoroutineTransactionalApplicationTests.kt

Source:CoroutineTransactionalApplicationTests.kt Github

copy

Full Screen

1package br.com.demo.coroutine_transactional2import br.com.demo.coroutine_transactional.domain.book.BookService3import br.com.demo.coroutine_transactional.domain.book.model.AuthorDefinition4import br.com.demo.coroutine_transactional.domain.book.model.BookDefinition5import br.com.demo.coroutine_transactional.persistence.PersistenceConfiguration6import br.com.demo.coroutine_transactional.persistence.repository.JPAAuthorRepository7import br.com.demo.coroutine_transactional.persistence.repository.JPABookRepository8import io.kotest.assertions.throwables.shouldThrowAny9import io.kotest.core.spec.style.StringSpec10import io.kotest.extensions.spring.SpringExtension11import io.kotest.matchers.booleans.shouldBeFalse12import io.kotest.matchers.booleans.shouldBeTrue13import io.kotest.property.Arb14import io.kotest.property.arbitrary.arbitrary15import io.kotest.property.arbitrary.bool16import io.kotest.property.arbitrary.next17import io.kotest.property.arbitrary.string18import io.kotest.property.arbitrary.uuid19import io.kotest.property.checkAll20import org.springframework.beans.factory.annotation.Autowired21import org.springframework.test.context.ContextConfiguration22@ContextConfiguration(classes = [PersistenceConfiguration::class])23class CoroutineTransactionalApplicationTests : StringSpec() {24 @Autowired25 lateinit var bookService: BookService26 @Autowired27 lateinit var jpaAuthorRepository: JPAAuthorRepository28 @Autowired29 lateinit var jpaBookRepository: JPABookRepository30 override fun extensions() = listOf(SpringExtension)31 init {32 "validate @Transactional commit/rollback behaviour when using coroutine" {33 val bookGenerator = arbitrary { rs ->34 BookDefinition(35 id = Arb.uuid().next(rs).toString(),36 isbn = Arb.string().next(rs),37 title = Arb.string().next(rs),38 author = AuthorDefinition(39 id = Arb.uuid().next(rs).toString(),40 name = Arb.uuid().next(rs).toString(),41 )42 )43 }44 checkAll(bookGenerator, Arb.bool()) { book, shouldThrows ->45 if (shouldThrows) {46 shouldThrowAny { bookService.publish(book, shouldThrows) }47 jpaAuthorRepository.existsById(book.author.id).shouldBeFalse()48 jpaBookRepository.existsById(book.id).shouldBeFalse()49 } else {50 bookService.publish(book, shouldThrows)51 jpaAuthorRepository.existsById(book.author.id).shouldBeTrue()52 jpaBookRepository.existsById(book.id).shouldBeTrue()53 }54 }55 }56 }57}...

Full Screen

Full Screen

RationalTest.kt

Source:RationalTest.kt Github

copy

Full Screen

1import io.kotest.core.spec.style.StringSpec2import io.kotest.property.*3import io.kotest.property.arbitrary.arbitrary4import io.kotest.property.arbitrary.bind5import io.kotest.property.arbitrary.int6import kotlin.math.abs7class RationalTest : StringSpec({8 "Subtraction (Arb 사용)" {9 forAll(10 // 첫번째 인자로 Arb<Rational> 인스턴스를 넘김11 object : Arb<Rational>() {12 override fun edgecase(rs: RandomSource): Rational? = null // 에지 케이스 없음13 override fun sample(rs: RandomSource): Sample<Rational> =14 Sample(Rational.of(rs.random.nextInt(), rs.random.nextInt(0, Int.MAX_VALUE)))15 }16 ){ a: Rational ->17 (a - a).num == 018 }19 }20 val rationalArb = Arb.bind(Arb.int(),Arb.int(0,Int.MAX_VALUE)){x,y->Rational.of(x,y)}21 "Subtraction (Arb.int()와 Arb.bind() 사용)" {22 forAll(rationalArb){ a: Rational ->23 (a - a).num == 024 }25 }26 val rationalArb2 = arbitrary { Rational.of(it.random.nextInt(), it.random.nextInt(0,Int.MAX_VALUE)) }27 "Subtraction (arbitrary() 사용)" {28 forAll(rationalArb2){ a: Rational ->29 (a - a).num == 030 }31 }32})33class Rational private constructor(34 val sign: Int,35 val num: Int,36 val den: Int37) {38 operator fun unaryMinus() = Rational(-sign, num, den)39 operator fun plus(r: Rational): Rational {40 val gcd = gcd(den, r.den)41 val newDen = den/gcd*r.den42 val newNum = newDen/den*num*sign + newDen/r.den*r.num*r.sign43 val newSign = newNum.sign()44 return Rational(newSign, abs(newNum), newDen)45 }46 operator fun minus(r: Rational) = this + (-r)47 operator fun times(r: Rational): Rational {48 return of(sign*r.sign*num*r.num, den*r.den)49 }50 operator fun div(r: Rational): Rational {51 return of(sign*r.sign*num*r.den, den*r.num)52 }53 override fun toString(): String {54 return "${sign*num}${if (den != 1) "/$den" else ""}"55 }56 companion object {57 private fun Int.sign() = when {58 this > 0 -> 159 this < 0 -> -160 else -> 061 }62 private tailrec fun gcd(a: Int, b: Int): Int {63 return if (b == 0) a else gcd(b, a % b)64 }65 fun of(num: Int, den: Int = 1): Rational {66 if (den == 0) throw ArithmeticException("Denominator is zero")67 val sign = num.sign() * den.sign()68 val numAbs = abs(num)69 val denAbs = abs(den)70 val gcd = gcd(numAbs, denAbs)71 return Rational(sign, numAbs/gcd, denAbs/gcd)72 }73 }74}...

Full Screen

Full Screen

Mock.kt

Source:Mock.kt Github

copy

Full Screen

1package com.kakao.ifkakao.studio.test2import com.kakao.ifkakao.studio.domain.account.Account3import com.kakao.ifkakao.studio.domain.emoticon.EmoticonEntity4import io.kotest.property.Arb5import io.kotest.property.arbitrary.arb6import io.kotest.property.arbitrary.chunked7import io.kotest.property.arbitrary.instant8import io.kotest.property.arbitrary.int9import io.kotest.property.arbitrary.long10import io.kotest.property.arbitrary.next11import io.kotest.property.arbitrary.single12import io.kotest.property.arbitrary.string13import io.kotest.property.arbitrary.stringPattern14import java.time.LocalDate15import java.time.LocalTime16import java.time.ZoneId17object Mock {18 fun account(identified: Boolean) = Account(19 id = Arb.long(min = 1).single(),20 name = Arb.string(5..20).single(),21 email = Arb.stringPattern("([a-zA-Z0-9]{5,20})\\@test\\.kakao\\.com").single(),22 identified = identified23 )24 fun emoticonEntity(createdDate: LocalDate, zone: ZoneId) = arb { rs ->25 val accountId = Arb.long(100_000L..200_000L)26 val title = Arb.string(10..100)27 val description = Arb.string(100..300)28 val choco = Arb.int(100..500)29 val images = Arb.stringPattern("([a-zA-Z0-9]{1,10})/([a-zA-Z0-9]{1,10})\\.jpg")30 .chunked(1..10)31 val created = Arb.instant(32 minValue = createdDate.atTime(LocalTime.MIN).atZone(zone).toInstant(),33 maxValue = createdDate.atTime(LocalTime.MAX).atZone(zone).toInstant()34 )35 generateSequence {36 created.next(rs).let { createdAt ->37 EmoticonEntity(38 accountId = accountId.next(rs),39 title = title.next(rs),40 description = description.next(rs),41 choco = choco.next(rs),42 images = images.next(rs),43 createdAt = createdAt,44 updatedAt = createdAt45 )46 }47 }48 }49}...

Full Screen

Full Screen

RestaurantItemArb.kt

Source:RestaurantItemArb.kt Github

copy

Full Screen

1/*2 * Jopiter APP3 * Copyright (C) 2021 Leonardo Colman Lopes4 *5 * This program is free software: you can redistribute it and/or modify6 * it under the terms of the GNU Affero General Public License as published by7 * the Free Software Foundation, either version 3 of the License, or8 * (at your option) any later version.9 *10 * This program is distributed in the hope that it will be useful,11 * but WITHOUT ANY WARRANTY; without even the implied warranty of12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the13 * GNU Affero General Public License for more details.14 *15 * You should have received a copy of the GNU Affero General Public License16 * along with this program. If not, see <https://www.gnu.org/licenses/>.17 */18package app.jopiter.restaurants.model19import io.kotest.property.Arb20import io.kotest.property.arbitrary.arbitrary21import io.kotest.property.arbitrary.enum22import io.kotest.property.arbitrary.int23import io.kotest.property.arbitrary.list24import io.kotest.property.arbitrary.localDate25import io.kotest.property.arbitrary.long26import io.kotest.property.arbitrary.next27import io.kotest.property.arbitrary.orNull28import io.kotest.property.arbitrary.string29val restaurantItemArb = arbitrary {30 RestaurantItem(31 Arb.int(1, 100).next(),32 Arb.localDate().next(),33 Arb.enum<Period>().next(),34 Arb.long().orNull(0.1).next(),35 Arb.string(minSize = 1).next(),36 Arb.string(minSize = 1).next(),37 Arb.string(minSize = 1).next(),38 Arb.list(Arb.string(minSize = 1)).next(),39 Arb.string(minSize = 1).next(),40 Arb.string(1, 50).next()41 )42}...

Full Screen

Full Screen

Arb.kt

Source:Arb.kt Github

copy

Full Screen

1package utils2import io.kotest.property.Arb3import io.kotest.property.Exhaustive4import io.kotest.property.arbitrary.arbitrary5import io.kotest.property.arbitrary.byte6import io.kotest.property.arbitrary.byteArrays7import io.kotest.property.arbitrary.filter8import io.kotest.property.arbitrary.int9import io.kotest.property.arbitrary.merge10import kotlin.random.nextUInt11import kotlin.random.nextULong12operator fun <A> Arb<A>.plus(other: Arb<A>) =13 merge(other)14operator fun <A> Arb<A>.minus(other: Exhaustive<A>) =15 filter { it !in other.values }16operator fun <V : Comparable<V>> Arb<V>.minus(range: ClosedRange<V>) =17 filter { it !in range }18fun Arb.Companion.byteArrays(length: Int) =19 byteArrays(length..length)20fun Arb.Companion.byteArrays(length: IntRange) =21 Arb.byteArrays(Arb.int(length), Arb.byte())22fun Arb.Companion.uint(range: UIntRange = UInt.MIN_VALUE..UInt.MAX_VALUE) = arbitrary(listOf(range.first, range.last)) {23 it.random.nextUInt(range)24}25fun Arb.Companion.ulong() = arbitrary(listOf(ULong.MIN_VALUE, ULong.MAX_VALUE)) {26 it.random.nextULong()27}28inline fun <reified T> Arb.Companion.arrayOf(value: Arb<T>, length: IntRange): Arb<Array<T>> = arbitrary { rs ->29 Array(rs.random.nextInt(length.first, length.last)) {30 value.sample(rs).value31 }32}...

Full Screen

Full Screen

Arb.next

Using AI Code Generation

copy

Full Screen

1 fun <T> next(arb: Arb<T>): T = arb.next(RandomSource.Default)2}3 fun <T> next(arb: Arb<T>, seed: Long): T = arb.next(RandomSource(seed))4}5 fun <T> next(arb: Arb<T>, seed: Long, count: Int): T = arb.next(RandomSource(seed, count))6}7 fun <T> next(arb: Arb<T>, seed: Long, count: Int, attempts: Int): T = arb.next(RandomSource(seed, count, attempts))8}9 fun <T> next(arb: Arb<T>, seed: Long, count: Int, attempts: Int, size: Int): T = arb.next(RandomSource(seed, count, attempts, size))10}11 fun <T> next(arb: Arb<T>, seed: Long, count: Int, attempts: Int, size: Int, shrinker: Shrinker<T>): T = arb.next(RandomSource(seed, count, attempts, size, shrinker))12}13 fun <T> next(arb: Arb<T>, seed: Long, count: Int, attempts: Int, size: Int, shrinker: Shrinker<T>, edgecases: List<T>): T = arb.next(RandomSource(seed, count, attempts, size, shrinker, edgecases))14}15 fun <T> next(arb: Arb<T>, seed: Long, count: Int, attempts: Int, size: Int, shrinker: Shrinker<T>, edgecases: List<T>, maxShrinks: Int): T = arb.next(RandomSource(seed, count, attempts, size, shrinker, edgecases, maxShrinks))16}

Full Screen

Full Screen

Arb.next

Using AI Code Generation

copy

Full Screen

1val gen = Arb.int(1..100)2println(gen.next())3println(gen.next())4println(gen.next())5println(gen.next())6println(gen.next())7val gen = Arb.int(1..100)8println(gen.next())9println(gen.next())10println(gen.next())11println(gen.next())12println(gen.next())

Full Screen

Full Screen

Arb.next

Using AI Code Generation

copy

Full Screen

1val arb: Arb<Int> = Arb.int()2val value: Int = arb.next(RandomSource.Default)3val arb: Arb<Int> = Arb.int()4val value: Int = arb.next(RandomSource.Default)5val arb: Arb<Int> = Arb.int()6val value: Int = arb.next(RandomSource.Default)7val arb: Arb<Int> = Arb.int()8val value: Int = arb.next(RandomSource.Default)9val arb: Arb<Int> = Arb.int()10val value: Int = arb.next(RandomSource.Default)11val arb: Arb<Int> = Arb.int()12val value: Int = arb.next(RandomSource.Default)13val arb: Arb<Int> = Arb.int()14val value: Int = arb.next(RandomSource.Default)15val arb: Arb<Int> = Arb.int()16val value: Int = arb.next(RandomSource.Default)17val arb: Arb<Int> = Arb.int()18val value: Int = arb.next(RandomSource.Default)19val arb: Arb<Int> = Arb.int()20val value: Int = arb.next(RandomSource.Default)21val arb: Arb<Int> = Arb.int()22val value: Int = arb.next(RandomSource.Default)23val arb: Arb<Int> = Arb.int()24val value: Int = arb.next(RandomSource.Default)

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 next

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful