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

commonMain.com.bkahlert.kommons.test.testAll.kt Maven / Gradle / Ivy

There is a newer version: 2.8.0
Show newest version
package com.bkahlert.kommons.test

import io.kotest.inspectors.forAll

/** Asserts the specified [softAssertions] for each of the specified [subjects]. */
public inline fun  testAll(vararg subjects: T, softAssertions: (T) -> R) {
    subjects.asList().testAll(softAssertions)
}

/** Asserts the specified [softAssertions] for each element of this [Collection]. */
public inline fun  Iterable.testAll(softAssertions: (T) -> R) {
    val subjects = toList()
    require(subjects.isNotEmpty()) { "At least one subject must be provided for testing." }
    subjects.forAll {
        test { softAssertions(it) }
    }
}

/** Asserts the specified [softAssertions] for each element of this [Sequence]. */
public inline fun  Sequence.testAll(softAssertions: (T) -> R) {
    toList().testAll(softAssertions)
}

/** Asserts the specified [softAssertions] for each entry of this [Map]. */
public inline fun  Map.testAll(softAssertions: (Map.Entry) -> R) {
    entries.testAll(softAssertions)
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy