Best Kotest code snippet using io.kotest.matchers.collections.bein
spider.kt
Source:spider.kt
1package assimp.obj2import assimp.*3import glm_.mat4x4.Mat44import glm_.vec3.Vec35import io.kotest.matchers.collections.shouldContain6import io.kotest.matchers.shouldBe7import java.io.File8import java.net.URL9import java.util.*10object spider {11 var isObj = false12 var isFbx = false13 fun reset() {14 isObj = false15 isFbx = false16 }17 object obj {18 operator fun invoke(directory: String) {19 isObj = true20 val urls = File(getResource(directory).toURI())21 .listFiles()!!22 .filterNot { it.absolutePath.endsWith("spider.obj", ignoreCase = true) }23 .map { it.toURI().toURL() }24 .toTypedArray()25 val objFile = getResource("$directory/spider.obj")26 check(objFile, *urls)27 reset()28 }29 }30 object fbx {31 operator fun invoke(directory: String,32 objFileMeshIndices: Boolean = true) {33 isFbx = true34 check(getResource("$directory/spider.fbx"))35 reset()36 }37 }38 fun check(vararg urls: URL) =39 Importer().testURLs(*urls) {40 with(rootNode) {41 transformation shouldBe Mat4()42 numChildren shouldBe 1943 val remainingNames = mutableListOf("HLeib01", "OK", "Bein1Li", "Bein1Re", "Bein2Li", "Bein2Re", "Bein3Re", "Bein3Li", "Bein4Re",44 "Bein4Li", "Zahn", "klZahn", "Kopf", "Brust", "Kopf2", "Zahn2", "klZahn2", "Auge", "Duplicate05")45 (0 until numChildren).map {46 val childNode = children[it]47 when {48 isObj -> remainingNames[0] shouldBe childNode.name49 else -> remainingNames shouldContain childNode.name50 }51 remainingNames -= childNode.name52 childNode.meshes[0] shouldBe it53 }54 numMeshes shouldBe 055 }56 numMeshes shouldBe 1957 with(meshes.find { it.name == "HLeib01" }!!) {58 primitiveTypes shouldBe AiPrimitiveType.TRIANGLE.i59 numVertices shouldBe 24060 numFaces shouldBe 8061 vertices[0].shouldEqual(Vec3(x = 1.160379, y = 4.512684, z = 6.449167), epsilon)62 vertices[numVertices - 1].shouldEqual(Vec3(x = -4.421391, y = -3.605049, z = -20.462471), epsilon)63 normals[0].shouldEqual(Vec3(-0.537588000, -0.0717979968, 0.840146005), epsilon)64 normals[numVertices - 1].shouldEqual(Vec3(-0.728103995, -0.400941998, -0.555975974), epsilon)65 // TODO check for kotlintest 2.0 array check66 textureCoords[0][0].contentEquals(floatArrayOf(0.186192f, 0.222718f)) shouldBe true67 textureCoords[0][numVertices - 1].contentEquals(floatArrayOf(0.103881f, 0.697021f)) shouldBe true68 textureCoords[0][0].size shouldBe 269 faces[0] shouldBe listOf(0, 1, 2)70 faces[numFaces - 1] shouldBe listOf(237, 238, 239)71 materials[materialIndex].name shouldBe "HLeibTex"72 }73 with(meshes.find { it.name == "OK" }!!) {74 primitiveTypes shouldBe AiPrimitiveType.TRIANGLE.i75 numVertices shouldBe 18076 numFaces shouldBe 6077 vertices[0].shouldEqual(Vec3(x = -41.8566132f, y = -0.754845977f, z = 9.43077183f), epsilon)78 vertices[numVertices - 1].shouldEqual(Vec3(x = -49.7138367f, y = -2.98359, z = -21.4211159f), epsilon)79 normals[0].shouldEqual(Vec3(x = -0.236278996f, y = 0.0291850008f, z = 0.971247017f), epsilon)80 normals[numVertices - 1].shouldEqual(Vec3(x = -0.862017989f, y = 0.0830229968f, z = -0.500032008f), epsilon)81 textureCoords[0][0].contentEquals(floatArrayOf(-0.0658710003f, -0.410016000f)) shouldBe true82 textureCoords[0][numVertices - 1].contentEquals(floatArrayOf(-0.318565995f, 1.05051804f)) shouldBe true83 textureCoords[0][0].size shouldBe 284 faces[0] shouldBe listOf(0, 1, 2)85 faces[numFaces - 1] shouldBe listOf(177, 178, 179)86 materials[materialIndex].name shouldBe "Skin"87 }88 with(meshes.find { it.name == "Duplicate05" }!!) {89 primitiveTypes shouldBe AiPrimitiveType.TRIANGLE.i90 numVertices shouldBe 11491 numFaces shouldBe 3892 vertices[0].shouldEqual(Vec3(x = -59.4670486f, y = 18.1400757f, z = -17.1943588), epsilon)93 vertices[numVertices - 1].shouldEqual(Vec3(x = -62.2673569f, y = 15.2776031f, z = -14.7453232f), epsilon)94 normals[0].shouldEqual(Vec3(x = 0.0751359984f, y = 0.741809011f, z = -0.666388988f), epsilon)95 normals[numVertices - 1].shouldEqual(Vec3(x = -0.776385009f, y = -0.629855990f, z = 0.0225169994f), epsilon)96 textureCoords[0][0].contentEquals(floatArrayOf(0.899282992f, 0.970311999f)) shouldBe true97 textureCoords[0][numVertices - 1].contentEquals(floatArrayOf(0.372330993f, 0.198948994f)) shouldBe true98 textureCoords[0][0].size shouldBe 299 faces[0] shouldBe listOf(0, 1, 2)100 faces[numFaces - 1] shouldBe listOf(111, 112, 113)101 materials[materialIndex].name shouldBe "Augentex"102 }103 if (isObj) {104 /*105 TODO the material data in the fbx file is different from the obj file(mat file)106 because of that we just don't check the material data in the fbx file right now.107 */108 with(materials.find { it.name == "Skin" }!!) {109 shadingModel shouldBe AiShadingMode.gouraud110 with(color!!) {111 ambient!!.shouldEqual(Vec3(0.200000003f), epsilon)112 diffuse!!.shouldEqual(Vec3(0.827450991f, 0.792156994f, 0.772548974f), epsilon)113 specular!!.shouldEqual(Vec3(0), epsilon)114 emissive!!.shouldEqual(Vec3(0), epsilon)115 shininess shouldBe 0f116 opacity shouldBe 1f117 refracti shouldBe 1f118 }119 textures[0].file shouldBe ".\\wal67ar_small.jpg"120 }121 with(materials.find { it.name == "Brusttex" }!!) {122 shadingModel shouldBe AiShadingMode.gouraud123 with(color!!) {124 ambient!!.shouldEqual(Vec3(0.200000003f), epsilon)125 diffuse!!.shouldEqual(Vec3(0.800000012f), epsilon)126 specular!!.shouldEqual(Vec3(0), epsilon)127 emissive!!.shouldEqual(Vec3(0), epsilon)128 shininess shouldBe 0f129 opacity shouldBe 1f130 refracti shouldBe 1f131 }132 textures[0].file shouldBe ".\\wal69ar_small.jpg"133 }134 with(materials.find { it.name == "HLeibTex" }!!) {135 shadingModel shouldBe AiShadingMode.gouraud136 with(color!!) {137 ambient!!.shouldEqual(Vec3(0.200000003f), epsilon)138 diffuse!!.shouldEqual(Vec3(0.690195978f, 0.639216006f, 0.615685999f), epsilon)139 specular!!.shouldEqual(Vec3(0), epsilon)140 emissive!!.shouldEqual(Vec3(0), epsilon)141 shininess shouldBe 0f142 opacity shouldBe 1f143 refracti shouldBe 1f144 }145 textures[0].file shouldBe ".\\SpiderTex.jpg"146 }147 with(materials.find { it.name == "BeinTex" }!!) {148 shadingModel shouldBe AiShadingMode.gouraud149 with(color!!) {150 ambient!!.shouldEqual(Vec3(0.200000003f), epsilon)151 diffuse!!.shouldEqual(Vec3(0.800000012f), epsilon)152 specular!!.shouldEqual(Vec3(0), epsilon)153 emissive!!.shouldEqual(Vec3(0), epsilon)154 shininess shouldBe 0f155 opacity shouldBe 1f156 refracti shouldBe 1f157 }158 textures[0].file shouldBe ".\\drkwood2.jpg"159 }160 with(materials.find { it.name == "Augentex" }!!) {161 name shouldBe "Augentex"162 shadingModel shouldBe AiShadingMode.gouraud163 with(color!!) {164 ambient!!.shouldEqual(Vec3(0.200000003f), epsilon)165 diffuse!!.shouldEqual(Vec3(0.800000012f), epsilon)166 specular!!.shouldEqual(Vec3(0), epsilon)167 emissive!!.shouldEqual(Vec3(0), epsilon)168 shininess shouldBe 0f169 opacity shouldBe 1f170 refracti shouldBe 1f171 }172 textures[0].file shouldBe ".\\engineflare1.jpg"173 }174 if (!isObj)175 numTextures shouldBe 5 // TODO numTextures is not set in obj176 textures.size shouldBe 5177 }178 }179}...
bein.kt
Source:bein.kt
1package io.kotest.matchers.collections2import io.kotest.assertions.print.print3import io.kotest.matchers.Matcher4import io.kotest.matchers.MatcherResult5import io.kotest.matchers.should6import io.kotest.matchers.shouldNot7import kotlin.jvm.JvmName8/**9 * Verifies that this element is in [collection] by comparing value10 *11 * Assertion to check that this element is in [collection]. This assertion checks by value, and not by reference,12 * therefore even if the exact instance is not in [collection] but another instance with same value is present, the13 * test will pass.14 *15 * An empty collection will always fail. If you need to check for empty collection, use [Collection.shouldBeEmpty]16 *17 * @see [shouldNotBeIn]18 * @see [beIn]19 */20infix fun <T> T.shouldBeIn(collection: Collection<T>): T {21 this should beIn(collection)22 return this23}24/**25 * Verifies that this element is NOT any of [collection]26 *27 * Assertion to check that this element is not any of [collection]. This assertion checks by value, and not by reference,28 * therefore any instance with same value must not be in [collection], or this will fail.29 *30 * An empty collection will always fail. If you need to check for empty collection, use [Collection.shouldBeEmpty]31 *32 * @see [shouldNotBeIn]33 * @see [beIn]34 */35infix fun <T> T.shouldNotBeIn(collection: Collection<T>): T {36 this shouldNot beIn(collection.toList())37 return this38}39/**40 * Verifies that this element is any of [any] by comparing value41 *42 * Assertion to check that this element is any of [any]. This assertion checks by value, and not by reference,43 * therefore even if the exact instance is not any of [any] but another instance with same value is present, the44 * test will pass.45 *46 * An empty collection will always fail. If you need to check for empty collection, use [Collection.shouldBeEmpty]47 *48 * @see [shouldNotBeIn]49 * @see [beIn]50 */51fun <T> T.shouldBeIn(vararg any: T): T {52 this should beIn(any.toList())53 return this54}55/**56 * Verifies that this element is NOT any of [any]57 *58 * Assertion to check that this element is not any of [any]. This assertion checks by value, and not by reference,59 * therefore any instance with same value must not be in [any], or this will fail.60 *61 * An empty collection will always fail. If you need to check for empty collection, use [Collection.shouldBeEmpty]62 *63 * @see [shouldNotBeIn]64 * @see [beIn]65 */66fun <T> T.shouldNotBeIn(vararg any: T): T {67 this shouldNot beIn(any.toList())68 return this69}70/**71 * Verifies that this element is in [array] by comparing value72 *73 * Assertion to check that this element is in [array]. This assertion checks by value, and not by reference,74 * therefore even if the exact instance is not in [array] but another instance with same value is present, the75 * test will pass.76 *77 * An empty array will always fail. If you need to check for empty array, use [Array.shouldBeEmpty]78 *79 * @see [shouldNotBeIn]80 * @see [beIn]81 */82@JvmName("shouldBeInArray")83infix fun <T> T.shouldBeIn(array: Array<T>): T {84 this should beIn(array.toList())85 return this86}87/**88 * Verifies that this element is NOT any of [array]89 *90 * Assertion to check that this element is not any of [array]. This assertion checks by value, and not by reference,91 * therefore any instance with same value must not be in [array], or this will fail.92 *93 * An empty array will always fail. If you need to check for empty array, use [Array.shouldBeEmpty]94 *95 * @see [shouldNotBeIn]96 * @see [beIn]97 */98@JvmName("shouldNotBeInArray")99infix fun <T> T.shouldNotBeIn(array: Array<T>): T {100 this shouldNot beIn(array.toList())101 return this102}103/**104 * Matcher that verifies that this element is in [collection] by comparing value105 *106 * Assertion to check that this element is in [collection]. This assertion checks by value, and not by reference,107 * therefore even if the exact instance is not in [collection] but another instance with same value is present, the108 * test will pass.109 *110 * An empty collection will always fail. If you need to check for empty collection, use [Collection.shouldBeEmpty]111 *112 * @see [shouldBeOneOf]113 * @see [shouldNotBeOneOf]114 */115fun <T> beIn(collection: Collection<T>) = object : Matcher<T> {116 override fun test(value: T): MatcherResult {117 if (collection.isEmpty()) throwEmptyCollectionError()118 val match = value in collection119 return MatcherResult(120 match,121 { "Collection should contain ${value.print().value}, but doesn't. Possible values: ${collection.print().value}" },122 {123 "Collection should not contain ${value.print().value}, but does. Forbidden values: ${collection.print().value}"124 })125 }126}...
matchers.kt
Source:matchers.kt
1package physics2d.core2import io.kotest.assertions.withClue3import io.kotest.matchers.Matcher4import io.kotest.matchers.MatcherResult5import physics2d.core.api.Vec6import physics2d.core.internal.eq7import io.kotest.matchers.collections.beIn as beInMatcher8infix fun <T> Iterable<T>.forEachAssert(match: (T) -> Unit) {9 forEach { cur ->10 withClue("given collection item: $cur"){11 match(cur)12 }13 }14}15fun beDouble(other: Double) = matcher<Double?> {16 MatcherResult(17 this != null && eq(other),18 "$this should be $other",19 "$this is not $other"20 )21}22fun beOrthogonalTo(other: Vec) = matcher<Vec?> {23 MatcherResult(24 this != null && 0.0.eq(x * other.x + y * other.y),25 "$this should be orthogonal to $other",26 "$this is not orthogonal to $other"27 )28}29fun <T> matcher(test: T.() -> MatcherResult) = object : Matcher<T> {30 override fun test(value: T) = test(value)31}32fun <T> beIn(vararg e: T): Matcher<T> = beInMatcher(e.asList())...
bein
Using AI Code Generation
1 import io.kotest.matchers.collections.shouldContain2 import io.kotest.matchers.collections.shouldContainAll3 import io.kotest.matchers.collections.shouldContainInOrder4 import io.kotest.matchers.collections.shouldContainExactly5 import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder6 import io.kotest.matchers.collections.shouldContainNone7 import io.kotest.matchers.collections.shouldContainSame8 import io.kotest.matchers.collections.shouldContainSameInOrder9 import io.kotest.matchers.collections.shouldContainSameExactly10 import io.kotest.matchers.collections.shouldContainSameExactlyInAnyOrder11 import io.kotest.matchers.collections.shouldContainSameNone12 import io.kotest.matchers.collections.shouldContainSameElementsAs13 import io.kotest.matchers.collections.shouldContainSameElementsInOrderAs14 import io.kotest.matchers.collections.shouldContainSameElementsInOrder15 import io.kotest.matchers.collections.shouldContainSameElementsExactlyAs16 import io.kotest.matchers.collections.shouldContainSameElementsExactlyInAnyOrderAs17 import io.kotest.matchers.collections.shouldContainSameElementsExactlyInAnyOrder18 import io.kotest.matchers.collections.shouldContainSameElementsNone19 import io.kotest.matchers.collections.shouldContainSameElementsInAnyOrder20 import io.kotest.matchers.collections.shouldContainSameKeys21 import io.kotest.matchers.collections.shouldContainSameKeysInAnyOrder22 import io.kotest.matchers.collections.shouldContainSameKeysInOrder23 import io.kotest.matchers.collections.shouldContainSameKeysExactly24 import io.kotest.matchers.collections.shouldContainSameKeysExactlyInAnyOrder25 import io.kotest.matchers.collections.shouldContainSameKeysNone26 import io.kotest.matchers.collections.shouldContainSameValues27 import io.kotest.matchers.collections.shouldContainSameValuesInAnyOrder28 import io.kotest.matchers.collections.shouldContainSameValuesInOrder29 import io.kotest.matchers.collections.shouldContainSameValuesExactly30 import io.kotest.matchers.collections.shouldContainSameValuesExactlyInAnyOrder31 import io.kotest.matchers.collections.shouldContainSameValuesNone32 import io.kotest.matchers.collections.shouldContainSize33 import io.kotest.matchers
bein
Using AI Code Generation
1val list = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)2list should containAll(listOf(1, 2, 3))3list should containAll(1, 2, 3)4list should containAll(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)5list should containAll(listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))6list should containAll(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)7list should containAll(listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))8list should containAll(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)9list should containAll(listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))10list should containAll(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)11list should containAll(listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))12list should containAll(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)13list should containAll(listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))14list should containAll(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)15list should containAll(listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10))16list should containAll(1, 2, 3, 4,
bein
Using AI Code Generation
1val list = listOf(1, 2, 3, 4, 5)2list.shouldContain(1, 2, 3, 4, 5)3list.shouldContainAll(1, 2, 3, 4, 5)4list.shouldContainExactly(1, 2, 3, 4, 5)5list.shouldContainExactlyInAnyOrder(1, 2, 3, 4, 5)6list.shouldContainExactlyInAnyOrder(1, 2, 3, 4, 5)7list.shouldContainInOrder(1, 2, 3, 4, 5)8list.shouldContainInOrderOnly(1, 2, 3, 4, 5)9list.shouldContainOnly(1, 2, 3, 4, 5)10list.shouldContainOnlyNulls()11list.shouldContainNull()12list.shouldContainNulls(1, 2, 3, 4, 5)13list.shouldContainSame(1, 2, 3, 4, 5)14list.shouldContainSameInAnyOrder(1, 2, 3, 4, 5)15list.shouldContainSameInOrder(1, 2, 3, 4, 5)16list.shouldContainSameInOrderOnly(1, 2, 3, 4, 5)17list.shouldContainSubList(1, 2, 3)18list.shouldContainSubListInOrder(1, 2, 3)19list.shouldContainSubListInOrderOnly(1, 2, 3)20list.shouldContainSubListOnly(1, 2, 3)21list.shouldHaveAtLeast(1, 2)22list.shouldHaveAtMost(1, 2)23list.shouldHaveCount(5)24list.shouldHaveDuplicates()25list.shouldHaveDuplicates(1, 2)26list.shouldHaveDuplicates(1, 2)
bein
Using AI Code Generation
1val list = listOf("a", "b", "c")2val list = listOf("a", "b", "c")3val list = listOf("a", "b", "c")4val list = listOf("a", "b", "c")5val list = listOf("a", "b", "c")6val list = listOf("a", "b", "c")7val list = listOf("a", "b", "c")8val list = listOf("a", "b", "c")
bein
Using AI Code Generation
1val list = listOf(1, 2, 3, 4, 5)2list.shouldContainAll(2, 3, 5)3val list = listOf(1, 2, 3, 4, 5)4list.shouldContainAll(2, 3, 5)5val list = listOf(1, 2, 3, 4, 5)6list.shouldContainAll(2, 3, 5)7val list = listOf(1, 2, 3, 4, 5)8list.shouldContainAll(2, 3, 5)9val list = listOf(1, 2, 3, 4, 5)10list.shouldContainAll(2, 3, 5)11val list = listOf(1, 2, 3, 4, 5)12list.shouldContainAll(2, 3, 5)13val list = listOf(1, 2, 3, 4, 5)14list.shouldContainAll(2, 3, 5)15val list = listOf(1, 2, 3, 4, 5)16list.shouldContainAll(2, 3, 5)17val list = listOf(1, 2, 3, 4, 5)18list.shouldContainAll(2, 3, 5)19val list = listOf(1, 2, 3, 4, 5)20list.shouldContainAll(2, 3, 5)21val list = listOf(1,
bein
Using AI Code Generation
1val list = listOf(1, 2, 3)2list should haveSize(3)3int should beGreaterThan(0)4long should beLessThan(2L)5val map = mapOf(1 to "a", 2 to "b")6map should haveKey(1)7nullable should beNull()8short should beLessThan(2)9string should haveLength(3)10any should beInstanceOf<Int>()11double should beGreaterThan(0.0)12float should beGreaterThan(0.0f)13int should beGreaterThan(0)14long should beLessThan(2L)15short should beLessThan(2)
bein
Using AI Code Generation
1@kotlin . test . Test fun `should return true when collection is empty`() { val list = listOf ( ) list . shouldNotBeEmpty ( ) }2@kotlin . test . Test fun `should return true when collection is not empty`() { val list = listOf ( 1 , 2 , 3 ) list . shouldNotBeEmpty ( ) }3@kotlin . test . Test fun `should return true when collection is empty`() { val list = listOf ( ) list . shouldNotBeEmpty ( ) }4@kotlin . test . Test fun `should return true when collection is not empty`() { val list = listOf ( 1 , 2 , 3 ) list . shouldNotBeEmpty ( ) }5@kotlin . test . Test fun `should return true when collection is empty`() { val list = listOf ( ) list . shouldNotBeEmpty ( ) }6@kotlin . test . Test fun `should return true when collection is not empty`() { val list = listOf ( 1 , 2 , 3 ) list . shouldNotBeEmpty ( ) }7@kotlin . test . Test fun `should return true when collection is empty`() { val list = listOf ( ) list . shouldNotBeEmpty ( ) }8@kotlin . test . Test fun `should return true when collection is not empty`() { val list = listOf ( 1 , 2 , 3 ) list . shouldNotBeEmpty ( ) }9@kotlin . test . Test fun `should return true when collection is empty`() { val list = listOf ( ) list . shouldNotBeEmpty ( ) }10@kotlin . test . Test fun `should return true when collection is not empty`() { val list = listOf ( 1 , 2 , 3 ) list . shouldNotBeEmpty ( ) }11@kotlin . test . Test fun `should return true when collection is empty`() { val list = listOf ( ) list . shouldNotBeEmpty ( ) }12@kotlin . test . Test fun `should return true when collection is not empty`() { val list = listOf ( 1 , 2 , 3 ) list . shouldNotBeEmpty ( ) }13@kotlin . test . Test fun `should return true when collection is empty`() { val list = listOf ( ) list . shouldNotBeEmpty (
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.
You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.
Get 100 minutes of automation test minutes FREE!!