fun <T : Number> Collection<T>.shouldHaveMean(value: BigDecimal, precision: Int = 4): Unit
Asserts that mean of the Collection elements equals to value with default or specific precision. Default precision equals 4 digits after decimal point.
Opposite of shouldNotHaveMean
Example:
val collection = listOf(1, 1, 3)
val firstMean = BigDecimal("1.66667")
val secondMean = BigDecimal("1.6667")
collection.shouldHaveMean(firstMean, 5) // Assertion passes
collection.shouldHaveMean(secondMean) // Assertion passes
collection.shouldHaveMean(firstMean) // Assertion fails
collection.shouldHaveMean(secondMean, 5) // Assertion fails
fun <T : Number> Collection<T>.shouldHaveMean(value: Double, precision: Int = 4): Unit
Asserts that mean of the Collection elements equals to value with default or specific precision. Default precision equals 4 digits after decimal point.
Opposite of shouldNotHaveMean
Example:
val collection = listOf(1, 1, 3)
val firstMean = 1.66667
val secondMean = 1.6667
collection.shouldHaveMean(firstMean, 5) // Assertion passes
collection.shouldHaveMean(secondMean) // Assertion passes
collection.shouldHaveMean(firstMean) // Assertion fails
collection.shouldHaveMean(secondMean, 5) // Assertion fails