All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.io.gianluigip.spectacle.dsl.assertions.CollectionsAssertionsExtensions.kt Maven / Gradle / Ivy

The newest version!
package io.gianluigip.spectacle.dsl.assertions

import kotlin.test.assertEquals
import kotlin.test.assertTrue

private val Any?.expectedTo get() = "Expected '$this' to"

@AssertionDslMarker
infix fun Collection<*>?.shouldHasSize(expectedSize: Int) =
    assertEquals(this?.size, expectedSize, "$expectedTo has size $expectedSize")

@AssertionDslMarker
fun Collection<*>?.shouldBeEmpty() =
    assertTrue(this?.isEmpty() ?: false, "$expectedTo be empty")

@AssertionDslMarker
fun Collection<*>?.shouldNotBeEmpty() =
    assertTrue(this?.isNotEmpty() ?: false, "$expectedTo not be empty")

@AssertionDslMarker
infix fun  Collection?.shouldContainsAll(elements: Collection?) =
    assertTrue(this?.containsAll(elements ?: emptyList()) ?: false, "$expectedTo contains all elements in '$elements'")

@AssertionDslMarker
infix fun  Collection?.shouldContains(element: T?) =
    assertTrue(this?.contains(element) ?: false, "$expectedTo contains '$element'")

@AssertionDslMarker
infix fun  Collection?.shouldNotContains(element: T?) =
    assertTrue(!(this?.contains(element) ?: false), "$expectedTo not contains '$element'")




© 2015 - 2024 Weber Informatics LLC | Privacy Policy