com.github.spoptchev.kotlin.preconditions.matcher.ObjectMatcher.kt Maven / Gradle / Ivy
package com.github.spoptchev.kotlin.preconditions.matcher
import com.github.spoptchev.kotlin.preconditions.Condition
import com.github.spoptchev.kotlin.preconditions.Matcher
interface ObjectMatcher {
fun isNull() = object : Matcher() {
override fun test(condition: Condition) = condition.test {
withResult(value == null) { "$expectedTo be null" }
}
}
fun isEqualTo(other: T) = object : Matcher() {
override fun test(condition: Condition) = condition.test {
withResult(value == other) { "$expectedTo be equal to $other" }
}
}
fun isSameInstanceAs(reference: T) = object : Matcher() {
override fun test(condition: Condition) = condition.test {
withResult(value === reference) { "$expectedTo have the same reference as $reference" }
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy