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.assertions.assertSoftly
import io.kotest.inspectors.forAll

/** Asserts the specified [softAssertions]. */
public inline fun testAll(softAssertions: () -> Unit) {
    assertSoftly(softAssertions)
}

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

/** Asserts the specified [softAssertions] for each of this [Array]. */
public inline fun  Array.testAll(softAssertions: (T) -> Unit) {
    asList().testAll(softAssertions)
}

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

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy