How to use test method of io.kotest.matchers.collections.bein class

Best Kotest code snippet using io.kotest.matchers.collections.bein.test

spider.kt

Source:spider.kt Github

copy

Full Screen

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)...

Full Screen

Full Screen

bein.kt

Source:bein.kt Github

copy

Full Screen

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}...

Full Screen

Full Screen

matchers.kt

Source:matchers.kt Github

copy

Full Screen

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())...

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 bein

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful