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

com.github.spoptchev.kotlin.preconditions.matcher.MapMatcher.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 MapMatcher {

    fun  hasKey(key: K) = object : Matcher>() {
        override fun test(condition: Condition>) = condition.test {
            withResult(value.containsKey(key)) { "$expectedTo contain key $key" }
        }
    }

    fun  hasValue(v: V) = object : Matcher>() {
        override fun test(condition: Condition>) = condition.test {
            withResult(value.containsValue(v)) { "$expectedTo contain value $v" }
        }
    }

    fun  contains(key: K, v: V) = object : Matcher>() {
        override fun test(condition: Condition>) = condition.test {
            withResult(value[key] == v) { "$expectedTo contain $key=$v" }
        }
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy