fun <T : Number> Collection<T>.shouldHaveVariance(value: BigDecimal, precision: Int = 4): Unit
Asserts that variance of the Collection elements equals to value with default or specific precision. Default precision equals 4 digits after decimal point.
Opposite of shouldNotHaveVariance
Example:
val collection = listOf(1, 2, 3)
val firstVariance = BigDecimal("0.66667")
val secondVariance = BigDecimal("0.6667")
collection.shouldHaveVariance(firstVariance, 5) // Assertion passes
collection.shouldHaveVariance(secondVariance) // Assertion passes
collection.shouldHaveVariance(firstVariance) // Assertion fails
collection.shouldHaveVariance(secondVariance, 5) // Assertion fails
fun <T : Number> Collection<T>.shouldHaveVariance(value: Double, precision: Int = 4): Unit
Asserts that variance of the Collection elements equals to value with default or specific precision. Default precision equals 4 digits after decimal point.
Opposite of shouldNotHaveVariance
Example:
val collection = listOf(1, 2, 3)
collection.shouldHaveVariance(0.66667, 5) // Assertion passes
collection.shouldHaveVariance(0.6667) // Assertion passes
collection.shouldHaveVariance(0.67) // Assertion fails
collection.shouldHaveVariance(0.6667, 5) // Assertion fails