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

com.github.spoptchev.kotlin.preconditions.matcher.ObjectMatcher.kt Maven / Gradle / Ivy

There is a newer version: 6.1.0
Show newest version
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