mirror of
https://github.com/jlengrand/atrium.git
synced 2026-03-10 08:01:19 +00:00
rename map assertion functions to new schema in api-fluent
This commit is contained in:
@@ -141,6 +141,7 @@ fun <K, T : Map<out K, *>> Expect<T>.containsKey(key: K): Expect<T> =
|
||||
fun <K, T : Map<out K, *>> Expect<T>.containsNotKey(key: K): Expect<T> =
|
||||
_logicAppend { containsNotKey(::identity, key) }
|
||||
|
||||
//TODO move to mapExpectations.kt with 0.18.0
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (a [Map]) contains the given [key],
|
||||
* creates an [Expect] for the corresponding value and returns the newly created assertion container,
|
||||
@@ -153,6 +154,7 @@ fun <K, T : Map<out K, *>> Expect<T>.containsNotKey(key: K): Expect<T> =
|
||||
fun <K, V, T : Map<out K, V>> Expect<T>.getExisting(key: K): Expect<V> =
|
||||
_logic.getExisting(::identity, key).transform()
|
||||
|
||||
//TODO move to mapExpectations.kt with 0.18.0
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (a [Map]) contains the given [key] and that
|
||||
* the corresponding value holds all assertions the given [assertionCreator] creates for it.
|
||||
@@ -164,6 +166,7 @@ fun <K, V, T : Map<out K, V>> Expect<T>.getExisting(key: K): Expect<V> =
|
||||
fun <K, V, T : Map<out K, V>> Expect<T>.getExisting(key: K, assertionCreator: Expect<V>.() -> Unit): Expect<T> =
|
||||
_logic.getExisting(::identity, key).collectAndAppend(assertionCreator)
|
||||
|
||||
//TODO move to mapExpectations.kt with 0.18.0
|
||||
/**
|
||||
* Creates an [Expect] for the property [Map.keys] of the subject of `this` expectation,
|
||||
* so that further fluent calls are assertions about it.
|
||||
@@ -175,6 +178,7 @@ fun <K, V, T : Map<out K, V>> Expect<T>.getExisting(key: K, assertionCreator: Ex
|
||||
val <K, T : Map<out K, *>> Expect<T>.keys: Expect<Set<K>>
|
||||
get() = _logic.property(Map<out K, *>::keys).transform()
|
||||
|
||||
//TODO move to mapExpectations.kt with 0.18.0
|
||||
/**
|
||||
* Expects that the property [Map.keys] of the subject of `this` expectation
|
||||
* holds all assertions the given [assertionCreator] creates for it and
|
||||
@@ -187,6 +191,7 @@ val <K, T : Map<out K, *>> Expect<T>.keys: Expect<Set<K>>
|
||||
fun <K, V, T : Map<out K, V>> Expect<T>.keys(assertionCreator: Expect<Set<K>>.() -> Unit): Expect<T> =
|
||||
_logic.property(Map<out K, *>::keys).collectAndAppend(assertionCreator)
|
||||
|
||||
//TODO move to mapExpectations.kt with 0.18.0
|
||||
/**
|
||||
* Creates an [Expect] for the property [Map.values] of the subject of `this` expectation,
|
||||
* so that further fluent calls are assertions about it.
|
||||
@@ -198,6 +203,7 @@ fun <K, V, T : Map<out K, V>> Expect<T>.keys(assertionCreator: Expect<Set<K>>.()
|
||||
val <V, T : Map<*, V>> Expect<T>.values: Expect<Collection<V>>
|
||||
get() = _logic.property(Map<out Any?, V>::values).transform()
|
||||
|
||||
//TODO move to mapExpectations.kt with 0.18.0
|
||||
/**
|
||||
* Expects that the property [Map.keys] of the subject of `this` expectation
|
||||
* holds all assertions the given [assertionCreator] creates for it and
|
||||
@@ -210,6 +216,7 @@ val <V, T : Map<*, V>> Expect<T>.values: Expect<Collection<V>>
|
||||
fun <K, V, T : Map<out K, V>> Expect<T>.values(assertionCreator: Expect<Collection<V>>.() -> Unit): Expect<T> =
|
||||
_logic.property(Map<out K, V>::values).collectAndAppend(assertionCreator)
|
||||
|
||||
//TODO move to mapExpectations.kt with 0.18.0
|
||||
/**
|
||||
* Turns `Expect<Map<K, V>>` into `Expect<Set<Map.Entry<K, V>>>`.
|
||||
*
|
||||
@@ -223,6 +230,7 @@ fun <K, V, T : Map<out K, V>> Expect<T>.values(assertionCreator: Expect<Collecti
|
||||
fun <K, V, T : Map<out K, V>> Expect<T>.asEntries(): Expect<Set<Map.Entry<K, V>>> =
|
||||
_logic.changeSubject.unreported { it.entries }
|
||||
|
||||
//TODO move to mapExpectations.kt with 0.18.0
|
||||
/**
|
||||
* Turns `Expect<Map<K, V>>` into `Expect<Set<Map.Entry<K, V>>>` and expects that it holds all assertions the given
|
||||
* [assertionCreator] creates for it.
|
||||
|
||||
@@ -0,0 +1,186 @@
|
||||
package ch.tutteli.atrium.api.fluent.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.logic.*
|
||||
import ch.tutteli.atrium.logic.creating.maplike.contains.searchbehaviours.NoOpSearchBehaviour
|
||||
import ch.tutteli.atrium.logic.creating.maplike.contains.MapLikeContains
|
||||
import ch.tutteli.atrium.logic.creating.typeutils.MapLike
|
||||
import ch.tutteli.kbox.identity
|
||||
|
||||
/**
|
||||
* Starts a sophisticated `toContain` expectation building process based on this [Expect].
|
||||
*
|
||||
* @return The newly created builder.
|
||||
*
|
||||
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.MapExpectationSamples.toContainBuilder
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
val <K, V, T : Map<out K, V>> Expect<T>.toContain: MapLikeContains.EntryPointStep<K, V, T, NoOpSearchBehaviour>
|
||||
get() = _logic.builderContainsInMapLike(::identity)
|
||||
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (a [Map]) contains a key as defined by [keyValuePair]'s [Pair.first]
|
||||
* with a corresponding value as defined by [keyValuePair]'s [Pair.second] -- optionally the same assertions
|
||||
* are created for the [otherPairs].
|
||||
*
|
||||
* Delegates to `toContain.inAnyOrder.entries(keyValuePair, *otherPairs)`
|
||||
*
|
||||
* Notice, that it does not search for unique matches. Meaning, if the map is `mapOf('a' to 1)` and [keyValuePair] is
|
||||
* defined as `'a' to 1` and one of the [otherPairs] is defined as `'a' to 1` as well, then both match,
|
||||
* even though they match the same entry.
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.MapExpectationSamples.toContainPair
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
fun <K, V, T : Map<out K, V>> Expect<T>.toContain(
|
||||
keyValuePair: Pair<K, V>,
|
||||
vararg otherPairs: Pair<K, V>
|
||||
): Expect<T> = toContain.inAnyOrder.entries(keyValuePair, *otherPairs)
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (a [Map]) contains only (in any order) a key as defined by
|
||||
* [keyValuePair]'s [Pair.first] with a corresponding value as defined by [keyValuePair]'s [Pair.second] -- optionally
|
||||
* the same assertions are created for the [otherPairs].
|
||||
*
|
||||
* Delegates to `toContain.inAnyOrder.only.entries(keyValuePair, *otherPairs)`
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.MapExpectationSamples.toContainOnlyPair
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
fun <K, V, T : Map<out K, V>> Expect<T>.toContainOnly(
|
||||
keyValuePair: Pair<K, V>,
|
||||
vararg otherPairs: Pair<K, V>
|
||||
): Expect<T> = toContain.inAnyOrder.only.entries(keyValuePair, *otherPairs)
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (a [Map]) contains a key as defined by [keyValue]'s [KeyValue.key]
|
||||
* with a corresponding value which either holds all assertions [keyValue]'s
|
||||
* [KeyValue.valueAssertionCreatorOrNull] creates or needs to be `null` in case
|
||||
* [KeyValue.valueAssertionCreatorOrNull] is defined as `null`
|
||||
* -- optionally the same assertions are created for the [otherKeyValues].
|
||||
*
|
||||
* Delegates to `toContain.inAnyOrder.entries(keyValue, *otherKeyValues)`
|
||||
*
|
||||
* Notice, that it does not search for unique matches. Meaning, if the map is `mapOf('a' to 1)` and [keyValue] is
|
||||
* defined as `Key('a') { isGreaterThan(0) }` and one of the [otherKeyValues] is defined as `Key('a') { isLessThan(2) }`
|
||||
* , then both match, even though they match the same entry.
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.MapExpectationSamples.toContainKeyValue
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
inline fun <K, reified V : Any, T : Map<out K, V?>> Expect<T>.toContain(
|
||||
keyValue: KeyValue<K, V>,
|
||||
vararg otherKeyValues: KeyValue<K, V>
|
||||
): Expect<T> = toContain.inAnyOrder.entries(keyValue, *otherKeyValues)
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (a [Map]) contains only (in any order) a key as defined by
|
||||
* [keyValue]'s [KeyValue.key] with a corresponding value which either holds all assertions [keyValue]'s
|
||||
* [KeyValue.valueAssertionCreatorOrNull] creates or needs to be `null` in case
|
||||
* [KeyValue.valueAssertionCreatorOrNull] is defined as `null`
|
||||
* -- optionally the same assertions are created for the [otherKeyValues].
|
||||
*
|
||||
* Delegates to `toContain.inAnyOrder.only.entries(keyValue, *otherKeyValues)`
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.MapExpectationSamples.toContainOnlyKeyValue
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
inline fun <K, reified V : Any, T : Map<out K, V?>> Expect<T>.toContainOnly(
|
||||
keyValue: KeyValue<K, V>,
|
||||
vararg otherKeyValues: KeyValue<K, V>
|
||||
): Expect<T> = toContain.inAnyOrder.only.entries(keyValue, *otherKeyValues)
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (a [Map]) contains the key-value pairs of the given [mapLike].
|
||||
*
|
||||
* Delegates to ` toContain.inAnyOrder.entriesOf`
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.MapExpectationSamples.toContainEntriesOf
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
fun <K, V : Any, T : Map<out K, V?>> Expect<T>.toContainEntriesOf(
|
||||
mapLike: MapLike
|
||||
): Expect<T> = toContain.inAnyOrder.entriesOf(mapLike)
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (a [Map]) contains only (in any order) the key-value pairs of
|
||||
* the given [mapLike].
|
||||
*
|
||||
* Delegates to `toContain.inAnyOrder.only.entriesOf`
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.MapExpectationSamples.toContainOnlyEntriesOf
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
fun <K, V : Any, T : Map<out K, V?>> Expect<T>.toContainOnlyEntriesOf(
|
||||
mapLike: MapLike
|
||||
): Expect<T> = toContain.inAnyOrder.only.entriesOf(mapLike)
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (a [Map]) contains the given [key].
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.MapExpectationSamples.toContainKey
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
fun <K, T : Map<out K, *>> Expect<T>.toContainKey(key: K): Expect<T> =
|
||||
_logicAppend { containsKey(::identity, key) }
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (a [Map]) does not contain the given [key].
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.MapExpectationSamples.notToContainKey
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
fun <K, T : Map<out K, *>> Expect<T>.notToContainKey(key: K): Expect<T> =
|
||||
_logicAppend { containsNotKey(::identity, key) }
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (a [Map]) is an empty [Map].
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.MapExpectationSamples.toBeEmpty
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
fun <T : Map<*, *>> Expect<T>.toBeEmpty(): Expect<T> =
|
||||
_logicAppend { isEmpty(::toEntries) }
|
||||
|
||||
/**
|
||||
* Expects that the subject of `this` expectation (a [Map]) is not an empty [Map].
|
||||
*
|
||||
* @return an [Expect] for the subject of `this` expectation.
|
||||
*
|
||||
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.MapExpectationSamples.notToBeEmpty
|
||||
*
|
||||
* @since 0.17.0
|
||||
*/
|
||||
fun <T : Map<*, *>> Expect<T>.notToBeEmpty(): Expect<T> =
|
||||
_logicAppend { isNotEmpty(::toEntries) }
|
||||
|
||||
private fun <T : Map<*, *>> toEntries(t: T): Collection<*> = t.entries
|
||||
@@ -1,236 +0,0 @@
|
||||
package ch.tutteli.atrium.api.fluent.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.logic.utils.mapArguments
|
||||
import ch.tutteli.atrium.specs.*
|
||||
import ch.tutteli.atrium.specs.integration.mfun2
|
||||
import org.spekframework.spek2.Spek
|
||||
import kotlin.jvm.JvmName
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.MapContainsInAnyOrderKeyValueExpectationsSpec.Companion as C
|
||||
|
||||
class MapContainsInAnyOrderKeyValueExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
}) {
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapContainsInAnyOrderKeyValueExpectationsSpec(
|
||||
functionDescription to C::containsKeyValues,
|
||||
(functionDescription to C::containsKeyValuesNullable).withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.MapContainsInAnyOrderKeyValueExpectationsSpec(
|
||||
mfun2<String, Int, Expect<Int>.() -> Unit>(C::contains).adjustName { "$it ${KeyValue::class.simpleName}" },
|
||||
mfun2<String?, Int?, (Expect<Int>.() -> Unit)?>(C::contains).adjustName { "$it ${KeyValue::class.simpleName}" }
|
||||
.withNullableSuffix(),
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
companion object : MapContainsSpecBase() {
|
||||
val functionDescription = "$contains.$inAnyOrder.$keyValue/$keyValues"
|
||||
|
||||
private fun containsKeyValues(
|
||||
expect: Expect<Map<out String, Int>>,
|
||||
a: Pair<String, Expect<Int>.() -> Unit>,
|
||||
aX: Array<out Pair<String, Expect<Int>.() -> Unit>>
|
||||
): Expect<Map<out String, Int>> =
|
||||
mapArguments(a, aX).to { KeyValue(it.first, it.second) }.let { (first, others) ->
|
||||
if (others.isEmpty()) expect.contains.inAnyOrder.entry(first)
|
||||
else expect.contains.inAnyOrder.entries(first, *others)
|
||||
}
|
||||
|
||||
private fun containsKeyValuesNullable(
|
||||
expect: Expect<Map<out String?, Int?>>,
|
||||
a: Pair<String?, (Expect<Int>.() -> Unit)?>,
|
||||
aX: Array<out Pair<String?, (Expect<Int>.() -> Unit)?>>
|
||||
) = mapArguments(a, aX).to { KeyValue(it.first, it.second) }.let { (first, others) ->
|
||||
if (others.isEmpty()) expect.contains.inAnyOrder.entry(first)
|
||||
else expect.contains.inAnyOrder.entries(first, *others)
|
||||
}
|
||||
|
||||
private fun contains(
|
||||
expect: Expect<Map<out String, Int>>,
|
||||
KeyValue: Pair<String, Expect<Int>.() -> Unit>,
|
||||
otherKeyValues: Array<out Pair<String, Expect<Int>.() -> Unit>>
|
||||
) = mapArguments(KeyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) ->
|
||||
expect.contains(first, *others)
|
||||
}
|
||||
|
||||
@JvmName("containsNullable")
|
||||
private fun contains(
|
||||
expect: Expect<Map<out String?, Int?>>,
|
||||
KeyValue: Pair<String?, (Expect<Int>.() -> Unit)?>,
|
||||
otherKeyValues: Array<out Pair<String?, (Expect<Int>.() -> Unit)?>>
|
||||
) = mapArguments(KeyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) ->
|
||||
expect.contains(first, *others)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
private fun ambiguityTest() {
|
||||
var map: Expect<Map<Number, CharSequence>> = notImplemented()
|
||||
var subMap: Expect<LinkedHashMap<out Number, String>> = notImplemented()
|
||||
var nKeyMap: Expect<Map<Number?, CharSequence>> = notImplemented()
|
||||
var nValueMap: Expect<Map<Number, CharSequence?>> = notImplemented()
|
||||
var nKeyValueMap: Expect<Map<Number?, CharSequence?>> = notImplemented()
|
||||
var ronKeyValueMap: Expect<Map<out Number?, CharSequence?>> = notImplemented()
|
||||
var starMap: Expect<Map<*, *>> = notImplemented()
|
||||
|
||||
map = map.contains.inAnyOrder.entry(KeyValue(1) { toEqual("a") })
|
||||
subMap = subMap.contains.inAnyOrder.entry(KeyValue(1) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.entry(KeyValue(1) { toEqual("a") })
|
||||
nValueMap = nValueMap.contains.inAnyOrder.entry(KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.entry(KeyValue(1) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.entry(KeyValue(1) { toEqual("a") })
|
||||
starMap = starMap.contains.inAnyOrder.entry(KeyValue(1) { toEqual("a") })
|
||||
|
||||
map = map.contains.inAnyOrder.entries(KeyValue(1) { toEqual("a") })
|
||||
subMap = subMap.contains.inAnyOrder.entries(KeyValue(1) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.entries(KeyValue(1) { toEqual("a") })
|
||||
nValueMap = nValueMap.contains.inAnyOrder.entries(KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.entries(KeyValue(1) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.entries(KeyValue(1) { toEqual("a") })
|
||||
starMap = starMap.contains.inAnyOrder.entries(KeyValue(1) { toEqual("a") })
|
||||
|
||||
map = map.contains.inAnyOrder.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
subMap = subMap.contains.inAnyOrder.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nValueMap = nValueMap.contains.inAnyOrder.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
starMap = starMap.contains.inAnyOrder.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.entry(KeyValue(null) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.entry(KeyValue(null) { toEqual("a") })
|
||||
nValueMap = nValueMap.contains.inAnyOrder.entry(KeyValue(1.2, null))
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.entry(KeyValue(null) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.entry(KeyValue(null, null))
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.entry(KeyValue(null) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.entry(KeyValue(null, null))
|
||||
starMap = starMap.contains.inAnyOrder.entry(KeyValue(null) { toEqual("a") })
|
||||
starMap = starMap.contains.inAnyOrder.entry(KeyValue(null, null))
|
||||
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.entries(KeyValue(null) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.entries(KeyValue(null) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.entries(KeyValue(null) { toEqual("a") })
|
||||
starMap = starMap.contains.inAnyOrder.entries(KeyValue(null) { toEqual("a") })
|
||||
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.entries(KeyValue(null) { toEqual("a") })
|
||||
nValueMap = nValueMap.contains.inAnyOrder.entries(KeyValue(1, null), KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.entries(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.entries(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
starMap = starMap.contains.inAnyOrder.entries(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
|
||||
/// ------------- shortcuts -----------------------------------------------------------------
|
||||
|
||||
map = map.contains(KeyValue(1) { toEqual("a") })
|
||||
subMap = subMap.contains(KeyValue(1) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.contains(KeyValue(1) { toEqual("a") })
|
||||
nValueMap = nValueMap.contains(KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.contains(KeyValue(1) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.contains(KeyValue(1) { toEqual("a") })
|
||||
starMap = starMap.contains(KeyValue(1) { toEqual("a") })
|
||||
|
||||
map = map.contains(KeyValue(1) { toEqual("a") })
|
||||
subMap = subMap.contains(KeyValue(1) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.contains(KeyValue(1) { toEqual("a") })
|
||||
nValueMap = nValueMap.contains(KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.contains(KeyValue(1) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.contains(KeyValue(1) { toEqual("a") })
|
||||
starMap = starMap.contains(KeyValue(1) { toEqual("a") })
|
||||
|
||||
map = map.contains(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
subMap = subMap.contains(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nKeyMap = nKeyMap.contains(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nValueMap = nValueMap.contains(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nKeyValueMap = nKeyValueMap.contains(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.contains(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
starMap = starMap.contains(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
|
||||
nKeyMap = nKeyMap.contains(KeyValue(null) { toEqual("a") })
|
||||
nValueMap = nValueMap.contains(KeyValue(1.2, null))
|
||||
nKeyValueMap = nKeyValueMap.contains(KeyValue(null) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.contains(KeyValue(null, null))
|
||||
ronKeyValueMap = ronKeyValueMap.contains(KeyValue(null) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.contains(KeyValue(null, null))
|
||||
starMap = starMap.contains(KeyValue(null) { toEqual("a") })
|
||||
starMap = starMap.contains(KeyValue(null, null))
|
||||
|
||||
nKeyMap = nKeyMap.contains(KeyValue(null) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.contains(KeyValue(null) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.contains(KeyValue(null) { toEqual("a") })
|
||||
starMap = starMap.contains(KeyValue(null) { toEqual("a") })
|
||||
|
||||
nKeyMap = nKeyMap.contains(KeyValue(null) { toEqual("a") })
|
||||
nValueMap = nValueMap.contains(KeyValue(1, null), KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.contains(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.contains(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
starMap = starMap.contains(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,152 +0,0 @@
|
||||
package ch.tutteli.atrium.api.fluent.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.specs.*
|
||||
import ch.tutteli.atrium.specs.integration.mfun2
|
||||
import org.spekframework.spek2.Spek
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.MapContainsInAnyOrderKeyValuePairsExpectationsSpec.Companion as C
|
||||
|
||||
class MapContainsInAnyOrderKeyValuePairsExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
}) {
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapContainsInAnyOrderKeyValuePairsExpectationsSpec(
|
||||
functionDescription to C::containsKeyValuePairs,
|
||||
(functionDescription to C::containsKeyValuePairsNullable).withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.MapContainsInAnyOrderKeyValuePairsExpectationsSpec(
|
||||
mfun2<String, Int, Int>(Expect<Map<out String, Int>>::contains),
|
||||
mfun2<String?, Int?, Int?>(Expect<Map<out String?, Int?>>::contains).withNullableSuffix(),
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
companion object : MapContainsSpecBase() {
|
||||
val functionDescription = "$contains.$inAnyOrder.$keyValuePair/$keyValuePairs"
|
||||
|
||||
private fun containsKeyValuePairs(
|
||||
expect: Expect<Map<out String, Int>>,
|
||||
a: Pair<String, Int>,
|
||||
aX: Array<out Pair<String, Int>>
|
||||
): Expect<Map<out String, Int>> =
|
||||
if (aX.isEmpty()) expect.contains.inAnyOrder.entry(a)
|
||||
else expect.contains.inAnyOrder.entries(a, *aX)
|
||||
|
||||
private fun containsKeyValuePairsNullable(
|
||||
expect: Expect<Map<out String?, Int?>>,
|
||||
a: Pair<String?, Int?>,
|
||||
aX: Array<out Pair<String?, Int?>>
|
||||
): Expect<Map<out String?, Int?>> =
|
||||
if (aX.isEmpty()) expect.contains.inAnyOrder.entry(a)
|
||||
else expect.contains.inAnyOrder.entries(a, *aX)
|
||||
}
|
||||
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
private fun ambiguityTest() {
|
||||
var map: Expect<Map<Number, CharSequence>> = notImplemented()
|
||||
var subMap: Expect<LinkedHashMap<out Number, String>> = notImplemented()
|
||||
var nKeyMap: Expect<Map<Number?, CharSequence>> = notImplemented()
|
||||
var nValueMap: Expect<Map<Number, CharSequence?>> = notImplemented()
|
||||
var nKeyValueMap: Expect<Map<Number?, CharSequence?>> = notImplemented()
|
||||
var ronKeyValueMap: Expect<Map<out Number?, CharSequence?>> = notImplemented()
|
||||
var starMap: Expect<Map<*, *>> = notImplemented()
|
||||
|
||||
map = map.contains.inAnyOrder.entry(1 to "a")
|
||||
subMap = subMap.contains.inAnyOrder.entry(1 to "a")
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.entry(1 to "a")
|
||||
nValueMap = nValueMap.contains.inAnyOrder.entry(1 to "a")
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.entry(1 to "a")
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.entry(1 to "a")
|
||||
starMap = starMap.contains.inAnyOrder.entry(1 to "a")
|
||||
|
||||
map = map.contains.inAnyOrder.entries(1 to "a")
|
||||
subMap = subMap.contains.inAnyOrder.entries(1 to "a")
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.entries(1 to "a")
|
||||
nValueMap = nValueMap.contains.inAnyOrder.entries(1 to "a")
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.entries(1 to "a")
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.entries(1 to "a")
|
||||
starMap = starMap.contains.inAnyOrder.entries(1 to "a")
|
||||
|
||||
map = map.contains.inAnyOrder.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
subMap = subMap.contains.inAnyOrder.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
nValueMap = nValueMap.contains.inAnyOrder.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
starMap = starMap.contains.inAnyOrder.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.entry(null to "a")
|
||||
nValueMap = nValueMap.contains.inAnyOrder.entry(1.2 to null)
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.entry(null to null)
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.entry(null to null)
|
||||
starMap = starMap.contains.inAnyOrder.entry(null to null)
|
||||
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.entries(null to "a", 1 to "b")
|
||||
nValueMap = nValueMap.contains.inAnyOrder.entries(1 to null)
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.entries((null to "a"), null to null, 1 to null)
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.entries((null to "a"), null to null, 1 to null)
|
||||
starMap = starMap.contains.inAnyOrder.entries((null to "a"), null to null, 1 to null)
|
||||
|
||||
|
||||
/// ------------- shortcuts -----------------------------------------------------------------
|
||||
|
||||
map = map.contains(1 to "a")
|
||||
subMap = subMap.contains(1 to "a")
|
||||
nKeyMap = nKeyMap.contains(1 to "a")
|
||||
nValueMap = nValueMap.contains(1 to "a")
|
||||
nKeyValueMap = nKeyValueMap.contains(1 to "a")
|
||||
ronKeyValueMap = ronKeyValueMap.contains(1 to "a")
|
||||
starMap = starMap.contains(1 to "a")
|
||||
|
||||
map = map.contains(1 to "a")
|
||||
subMap = subMap.contains(1 to "a")
|
||||
nKeyMap = nKeyMap.contains(1 to "a")
|
||||
nValueMap = nValueMap.contains(1 to "a")
|
||||
nKeyValueMap = nKeyValueMap.contains(1 to "a")
|
||||
ronKeyValueMap = ronKeyValueMap.contains(1 to "a")
|
||||
starMap = starMap.contains(1 to "a")
|
||||
|
||||
map = map.contains(1 as Number to "a", 1.2 to "b")
|
||||
subMap = subMap.contains(1 as Number to "a", 1.2 to "b")
|
||||
nKeyMap = nKeyMap.contains(1 as Number to "a", 1.2 to "b")
|
||||
nValueMap = nValueMap.contains(1 as Number to "a", 1.2 to "b")
|
||||
nKeyValueMap = nKeyValueMap.contains(1 as Number to "a", 1.2 to "b")
|
||||
ronKeyValueMap = ronKeyValueMap.contains(1 as Number to "a", 1.2 to "b")
|
||||
starMap = starMap.contains(1 as Number to "a", 1.2 to "b")
|
||||
|
||||
nKeyMap = nKeyMap.contains(null to "a")
|
||||
nValueMap = nValueMap.contains(1.2 to null)
|
||||
nKeyValueMap = nKeyValueMap.contains(null to null)
|
||||
ronKeyValueMap = ronKeyValueMap.contains(null to "a")
|
||||
starMap = starMap.contains(null to "a")
|
||||
|
||||
nKeyMap = nKeyMap.contains(null to "a")
|
||||
nValueMap = nValueMap.contains(1.2 to null, 1 to null)
|
||||
nKeyValueMap = nKeyValueMap.contains(null to "a", null to null, 1 to null)
|
||||
ronKeyValueMap = ronKeyValueMap.contains(null to "a", null to null, 1 to null)
|
||||
starMap = starMap.contains(null to "a", null to null, 1 to null)
|
||||
}
|
||||
}
|
||||
@@ -1,238 +0,0 @@
|
||||
package ch.tutteli.atrium.api.fluent.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.logic.utils.mapArguments
|
||||
import ch.tutteli.atrium.specs.*
|
||||
import ch.tutteli.atrium.specs.integration.mfun2
|
||||
import org.spekframework.spek2.Spek
|
||||
import kotlin.jvm.JvmName
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.MapContainsInAnyOrderOnlyKeyValueExpectationsSpec.Companion as C
|
||||
|
||||
class MapContainsInAnyOrderOnlyKeyValueExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
}) {
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapContainsInAnyOrderOnlyKeyValueExpectationsSpec(
|
||||
functionDescription to C::containsKeyValues,
|
||||
(functionDescription to C::containsKeyValuesNullable).withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.MapContainsInAnyOrderOnlyKeyValueExpectationsSpec(
|
||||
mfun2<String, Int, Expect<Int>.() -> Unit>(C::containsOnly),
|
||||
mfun2<String?, Int?, (Expect<Int>.() -> Unit)?>(C::containsOnly).withNullableSuffix(),
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
companion object : MapContainsSpecBase() {
|
||||
val functionDescription = "$contains.$inAnyOrder.$only.$keyValue/$keyValues"
|
||||
|
||||
private fun containsKeyValues(
|
||||
expect: Expect<Map<out String, Int>>,
|
||||
a: Pair<String, Expect<Int>.() -> Unit>,
|
||||
aX: Array<out Pair<String, Expect<Int>.() -> Unit>>
|
||||
) = mapArguments(a, aX).to { KeyValue(it.first, it.second) }.let { (first, others) ->
|
||||
if (others.isEmpty()) expect.contains.inAnyOrder.only.entry(first)
|
||||
else expect.contains.inAnyOrder.only.entries(first, *others)
|
||||
}
|
||||
|
||||
private fun containsKeyValuesNullable(
|
||||
expect: Expect<Map<out String?, Int?>>,
|
||||
a: Pair<String?, (Expect<Int>.() -> Unit)?>,
|
||||
aX: Array<out Pair<String?, (Expect<Int>.() -> Unit)?>>
|
||||
) = mapArguments(a, aX).to { KeyValue(it.first, it.second) }.let { (first, others) ->
|
||||
if (others.isEmpty()) expect.contains.inAnyOrder.only.entry(first)
|
||||
else expect.contains.inAnyOrder.only.entries(first, *others)
|
||||
}
|
||||
|
||||
private fun containsOnly(
|
||||
expect: Expect<Map<out String, Int>>,
|
||||
a: Pair<String, Expect<Int>.() -> Unit>,
|
||||
aX: Array<out Pair<String, Expect<Int>.() -> Unit>>
|
||||
): Expect<Map<out String, Int>> =
|
||||
mapArguments(a, aX).to { KeyValue(it.first, it.second) }.let { (first, others) ->
|
||||
expect.containsOnly(first, *others)
|
||||
}
|
||||
|
||||
@JvmName("containsInAnyOrderOnlyNullable")
|
||||
private fun containsOnly(
|
||||
expect: Expect<Map<out String?, Int?>>,
|
||||
a: Pair<String?, (Expect<Int>.() -> Unit)?>,
|
||||
aX: Array<out Pair<String?, (Expect<Int>.() -> Unit)?>>
|
||||
): Expect<Map<out String?, Int?>> =
|
||||
mapArguments(a, aX).to { KeyValue(it.first, it.second) }.let { (first, others) ->
|
||||
expect.containsOnly(first, *others)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
private fun ambiguityTest() {
|
||||
var map: Expect<Map<Number, CharSequence>> = notImplemented()
|
||||
var subMap: Expect<LinkedHashMap<out Number, String>> = notImplemented()
|
||||
var nKeyMap: Expect<Map<Number?, CharSequence>> = notImplemented()
|
||||
var nValueMap: Expect<Map<Number, CharSequence?>> = notImplemented()
|
||||
var nKeyValueMap: Expect<Map<Number?, CharSequence?>> = notImplemented()
|
||||
var ronKeyValueMap: Expect<Map<out Number?, CharSequence?>> = notImplemented()
|
||||
var starMap: Expect<Map<*, *>> = notImplemented()
|
||||
|
||||
map = map.contains.inAnyOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
subMap = subMap.contains.inAnyOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
nValueMap = nValueMap.contains.inAnyOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
starMap = starMap.contains.inAnyOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
|
||||
map = map.contains.inAnyOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
subMap = subMap.contains.inAnyOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
nValueMap = nValueMap.contains.inAnyOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
starMap = starMap.contains.inAnyOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
|
||||
map = map.contains.inAnyOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
subMap = subMap.contains.inAnyOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nValueMap = nValueMap.contains.inAnyOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
starMap = starMap.contains.inAnyOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.only.entry(KeyValue(null) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.only.entry(KeyValue(null) { toEqual("a") })
|
||||
nValueMap = nValueMap.contains.inAnyOrder.only.entry(KeyValue(1.2, null))
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.only.entry(KeyValue(null) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.only.entry(KeyValue(null, null))
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.only.entry(KeyValue(null) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.only.entry(KeyValue(null, null))
|
||||
starMap = starMap.contains.inAnyOrder.only.entry(KeyValue(null) { toEqual("a") })
|
||||
starMap = starMap.contains.inAnyOrder.only.entry(KeyValue(null, null))
|
||||
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.only.entries(KeyValue(null) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.only.entries(KeyValue(null) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.only.entries(KeyValue(null) { toEqual("a") })
|
||||
starMap = starMap.contains.inAnyOrder.only.entries(KeyValue(null) { toEqual("a") })
|
||||
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.only.entries(KeyValue(null) { toEqual("a") })
|
||||
nValueMap = nValueMap.contains.inAnyOrder.only.entries(KeyValue(1, null), KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.only.entries(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.only.entries(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
starMap = starMap.contains.inAnyOrder.only.entries(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
|
||||
/// ------------- shortcuts -----------------------------------------------------------------
|
||||
|
||||
map = map.containsOnly(KeyValue(1) { toEqual("a") })
|
||||
subMap = subMap.containsOnly(KeyValue(1) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.containsOnly(KeyValue(1) { toEqual("a") })
|
||||
nValueMap = nValueMap.containsOnly(KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.containsOnly(KeyValue(1) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.containsOnly(KeyValue(1) { toEqual("a") })
|
||||
starMap = starMap.containsOnly(KeyValue(1) { toEqual("a") })
|
||||
|
||||
map = map.containsOnly(KeyValue(1) { toEqual("a") })
|
||||
subMap = subMap.containsOnly(KeyValue(1) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.containsOnly(KeyValue(1) { toEqual("a") })
|
||||
nValueMap = nValueMap.containsOnly(KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.containsOnly(KeyValue(1) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.containsOnly(KeyValue(1) { toEqual("a") })
|
||||
starMap = starMap.containsOnly(KeyValue(1) { toEqual("a") })
|
||||
|
||||
map = map.containsOnly(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
subMap = subMap.containsOnly(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nKeyMap = nKeyMap.containsOnly(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nValueMap = nValueMap.containsOnly(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nKeyValueMap = nKeyValueMap.containsOnly(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.containsOnly(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
starMap = starMap.containsOnly(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
|
||||
nKeyMap = nKeyMap.containsOnly(KeyValue(null) { toEqual("a") })
|
||||
nValueMap = nValueMap.containsOnly(KeyValue(1.2, null))
|
||||
nKeyValueMap = nKeyValueMap.containsOnly(KeyValue(null) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.containsOnly(KeyValue(null, null))
|
||||
ronKeyValueMap = ronKeyValueMap.containsOnly(KeyValue(null) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.containsOnly(KeyValue(null, null))
|
||||
starMap = starMap.containsOnly(KeyValue(null) { toEqual("a") })
|
||||
starMap = starMap.containsOnly(KeyValue(null, null))
|
||||
|
||||
nKeyMap = nKeyMap.containsOnly(KeyValue(null) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.containsOnly(KeyValue(null) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.containsOnly(KeyValue(null) { toEqual("a") })
|
||||
starMap = starMap.containsOnly(KeyValue(null) { toEqual("a") })
|
||||
|
||||
nKeyMap = nKeyMap.containsOnly(KeyValue(null) { toEqual("a") })
|
||||
nValueMap = nValueMap.containsOnly(KeyValue(1, null), KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.containsOnly(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.containsOnly(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
starMap = starMap.containsOnly(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,153 +0,0 @@
|
||||
package ch.tutteli.atrium.api.fluent.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.specs.*
|
||||
import ch.tutteli.atrium.specs.integration.mfun2
|
||||
import org.spekframework.spek2.Spek
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.MapContainsInAnyOrderOnlyKeyValuePairsExpectationsSpec.Companion as C
|
||||
|
||||
class MapContainsInAnyOrderOnlyKeyValuePairsExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
}) {
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapContainsInAnyOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
functionDescription to C::containsKeyValuePairs,
|
||||
(functionDescription to C::containsKeyValuePairsNullable).withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.MapContainsInAnyOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
mfun2<String, Int, Int>(Expect<Map<out String, Int>>::containsOnly),
|
||||
mfun2<String?, Int?, Int?>(Expect<Map<out String?, Int?>>::containsOnly).withNullableSuffix(),
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
companion object : MapContainsSpecBase() {
|
||||
val functionDescription = "$contains.$inAnyOrder.$only.$keyValuePair/$keyValuePairs"
|
||||
|
||||
private fun containsKeyValuePairs(
|
||||
expect: Expect<Map<out String, Int>>,
|
||||
a: Pair<String, Int>,
|
||||
aX: Array<out Pair<String, Int>>
|
||||
): Expect<Map<out String, Int>> =
|
||||
if (aX.isEmpty()) expect.contains.inAnyOrder.only.entry(a)
|
||||
else expect.contains.inAnyOrder.only.entries(a, *aX)
|
||||
|
||||
private fun containsKeyValuePairsNullable(
|
||||
expect: Expect<Map<out String?, Int?>>,
|
||||
a: Pair<String?, Int?>,
|
||||
aX: Array<out Pair<String?, Int?>>
|
||||
): Expect<Map<out String?, Int?>> =
|
||||
if (aX.isEmpty()) expect.contains.inAnyOrder.only.entry(a)
|
||||
else expect.contains.inAnyOrder.only.entries(a, *aX)
|
||||
}
|
||||
|
||||
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
private fun ambiguityTest() {
|
||||
var map: Expect<Map<Number, CharSequence>> = notImplemented()
|
||||
var subMap: Expect<LinkedHashMap<out Number, String>> = notImplemented()
|
||||
var nKeyMap: Expect<Map<Number?, CharSequence>> = notImplemented()
|
||||
var nValueMap: Expect<Map<Number, CharSequence?>> = notImplemented()
|
||||
var nKeyValueMap: Expect<Map<Number?, CharSequence?>> = notImplemented()
|
||||
var ronKeyValueMap: Expect<Map<out Number?, CharSequence?>> = notImplemented()
|
||||
var starMap: Expect<Map<*, *>> = notImplemented()
|
||||
|
||||
map = map.contains.inAnyOrder.only.entry(1 to "a")
|
||||
subMap = subMap.contains.inAnyOrder.only.entry(1 to "a")
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.only.entry(1 to "a")
|
||||
nValueMap = nValueMap.contains.inAnyOrder.only.entry(1 to "a")
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.only.entry(1 to "a")
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.only.entry(1 to "a")
|
||||
starMap = starMap.contains.inAnyOrder.only.entry(1 to "a")
|
||||
|
||||
map = map.contains.inAnyOrder.only.entries(1 to "a")
|
||||
subMap = subMap.contains.inAnyOrder.only.entries(1 to "a")
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.only.entries(1 to "a")
|
||||
nValueMap = nValueMap.contains.inAnyOrder.only.entries(1 to "a")
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.only.entries(1 to "a")
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.only.entries(1 to "a")
|
||||
starMap = starMap.contains.inAnyOrder.only.entries(1 to "a")
|
||||
|
||||
map = map.contains.inAnyOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
subMap = subMap.contains.inAnyOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
nValueMap = nValueMap.contains.inAnyOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
starMap = starMap.contains.inAnyOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.only.entry(null to "a")
|
||||
nValueMap = nValueMap.contains.inAnyOrder.only.entry(1.2 to null)
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.only.entry(null to null)
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.only.entry(null to null)
|
||||
starMap = starMap.contains.inAnyOrder.only.entry(null to null)
|
||||
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.only.entries(null to "a", 1 to "b")
|
||||
nValueMap = nValueMap.contains.inAnyOrder.only.entries(1 to null)
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.only.entries((null to "a"), null to null, 1 to null)
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.only.entries((null to "a"), null to null, 1 to null)
|
||||
starMap = starMap.contains.inAnyOrder.only.entries((null to "a"), null to null, 1 to null)
|
||||
|
||||
|
||||
/// ------------- shortcuts -----------------------------------------------------------------
|
||||
|
||||
map = map.containsOnly(1 to "a")
|
||||
subMap = subMap.containsOnly(1 to "a")
|
||||
nKeyMap = nKeyMap.containsOnly(1 to "a")
|
||||
nValueMap = nValueMap.containsOnly(1 to "a")
|
||||
nKeyValueMap = nKeyValueMap.containsOnly(1 to "a")
|
||||
ronKeyValueMap = ronKeyValueMap.containsOnly(1 to "a")
|
||||
starMap = starMap.containsOnly(1 to "a")
|
||||
|
||||
map = map.containsOnly(1 to "a")
|
||||
subMap = subMap.containsOnly(1 to "a")
|
||||
nKeyMap = nKeyMap.containsOnly(1 to "a")
|
||||
nValueMap = nValueMap.containsOnly(1 to "a")
|
||||
nKeyValueMap = nKeyValueMap.containsOnly(1 to "a")
|
||||
ronKeyValueMap = ronKeyValueMap.containsOnly(1 to "a")
|
||||
starMap = starMap.containsOnly(1 to "a")
|
||||
|
||||
map = map.containsOnly(1 as Number to "a", 1.2 to "b")
|
||||
subMap = subMap.containsOnly(1 as Number to "a", 1.2 to "b")
|
||||
nKeyMap = nKeyMap.containsOnly(1 as Number to "a", 1.2 to "b")
|
||||
nValueMap = nValueMap.containsOnly(1 as Number to "a", 1.2 to "b")
|
||||
nKeyValueMap = nKeyValueMap.containsOnly(1 as Number to "a", 1.2 to "b")
|
||||
ronKeyValueMap = ronKeyValueMap.containsOnly(1 as Number to "a", 1.2 to "b")
|
||||
starMap = starMap.containsOnly(1 as Number to "a", 1.2 to "b")
|
||||
|
||||
nKeyMap = nKeyMap.containsOnly(null to "a")
|
||||
nValueMap = nValueMap.containsOnly(1.2 to null)
|
||||
nKeyValueMap = nKeyValueMap.containsOnly(null to null)
|
||||
ronKeyValueMap = ronKeyValueMap.containsOnly(null to "a")
|
||||
starMap = starMap.containsOnly(null to "a")
|
||||
|
||||
nKeyMap = nKeyMap.containsOnly(null to "a")
|
||||
nValueMap = nValueMap.containsOnly(1.2 to null, 1 to null)
|
||||
nKeyValueMap = nKeyValueMap.containsOnly(null to "a", null to null, 1 to null)
|
||||
ronKeyValueMap = ronKeyValueMap.containsOnly(null to "a", null to null, 1 to null)
|
||||
starMap = starMap.containsOnly(null to "a", null to null, 1 to null)
|
||||
}
|
||||
}
|
||||
@@ -1,130 +0,0 @@
|
||||
package ch.tutteli.atrium.api.fluent.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.logic.utils.mapArguments
|
||||
import ch.tutteli.atrium.specs.notImplemented
|
||||
import ch.tutteli.atrium.specs.withNullableSuffix
|
||||
import org.spekframework.spek2.Spek
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.MapContainsInOrderOnlyKeyValueExpectationsSpec.Companion as C
|
||||
|
||||
class MapContainsInOrderOnlyKeyValueExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
}) {
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapContainsInOrderOnlyKeyValueExpectationsSpec(
|
||||
functionDescription to C::containsKeyValues,
|
||||
(functionDescription to C::containsKeyValuesNullable).withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
companion object : MapContainsSpecBase() {
|
||||
val functionDescription = "$contains.$inOrder.$only.$keyValue/$keyValues"
|
||||
|
||||
private fun containsKeyValues(
|
||||
expect: Expect<Map<out String, Int>>,
|
||||
a: Pair<String, Expect<Int>.() -> Unit>,
|
||||
aX: Array<out Pair<String, Expect<Int>.() -> Unit>>
|
||||
) = mapArguments(a, aX).to { KeyValue(it.first, it.second) }.let { (first, others) ->
|
||||
if (others.isEmpty()) expect.contains.inOrder.only.entry(first)
|
||||
else expect.contains.inOrder.only.entries(first, *others)
|
||||
}
|
||||
|
||||
private fun containsKeyValuesNullable(
|
||||
expect: Expect<Map<out String?, Int?>>,
|
||||
a: Pair<String?, (Expect<Int>.() -> Unit)?>,
|
||||
aX: Array<out Pair<String?, (Expect<Int>.() -> Unit)?>>
|
||||
) = mapArguments(a, aX).to { KeyValue(it.first, it.second) }.let { (first, others) ->
|
||||
if (others.isEmpty()) expect.contains.inOrder.only.entry(first)
|
||||
else expect.contains.inOrder.only.entries(first, *others)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
private fun ambiguityTest() {
|
||||
var map: Expect<Map<Number, CharSequence>> = notImplemented()
|
||||
var subMap: Expect<LinkedHashMap<out Number, String>> = notImplemented()
|
||||
var nKeyMap: Expect<Map<Number?, CharSequence>> = notImplemented()
|
||||
var nValueMap: Expect<Map<Number, CharSequence?>> = notImplemented()
|
||||
var nKeyValueMap: Expect<Map<Number?, CharSequence?>> = notImplemented()
|
||||
var ronKeyValueMap: Expect<Map<out Number?, CharSequence?>> = notImplemented()
|
||||
var starMap: Expect<Map<*, *>> = notImplemented()
|
||||
|
||||
map = map.contains.inOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
subMap = subMap.contains.inOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.contains.inOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
nValueMap = nValueMap.contains.inOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.contains.inOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
starMap = starMap.contains.inOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
|
||||
map = map.contains.inOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
subMap = subMap.contains.inOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.contains.inOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
nValueMap = nValueMap.contains.inOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.contains.inOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
starMap = starMap.contains.inOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
|
||||
map = map.contains.inOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
subMap = subMap.contains.inOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nKeyMap = nKeyMap.contains.inOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nValueMap = nValueMap.contains.inOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nKeyValueMap = nKeyValueMap.contains.inOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
starMap = starMap.contains.inOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
|
||||
nKeyMap = nKeyMap.contains.inOrder.only.entry(KeyValue(null) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.contains.inOrder.only.entry(KeyValue(null) { toEqual("a") })
|
||||
nValueMap = nValueMap.contains.inOrder.only.entry(KeyValue(1.2, null))
|
||||
nKeyValueMap = nKeyValueMap.contains.inOrder.only.entry(KeyValue(null) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.contains.inOrder.only.entry(KeyValue(null, null))
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inOrder.only.entry(KeyValue(null) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inOrder.only.entry(KeyValue(null, null))
|
||||
starMap = starMap.contains.inOrder.only.entry(KeyValue(null) { toEqual("a") })
|
||||
starMap = starMap.contains.inOrder.only.entry(KeyValue(null, null))
|
||||
|
||||
nKeyMap = nKeyMap.contains.inOrder.only.entries(KeyValue(null) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.contains.inOrder.only.entries(KeyValue(null) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inOrder.only.entries(KeyValue(null) { toEqual("a") })
|
||||
starMap = starMap.contains.inOrder.only.entries(KeyValue(null) { toEqual("a") })
|
||||
|
||||
nKeyMap = nKeyMap.contains.inOrder.only.entries(KeyValue(null) { toEqual("a") })
|
||||
nValueMap = nValueMap.contains.inOrder.only.entries(KeyValue(1, null), KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.contains.inOrder.only.entries(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inOrder.only.entries(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
starMap = starMap.contains.inOrder.only.entries(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -1,107 +0,0 @@
|
||||
package ch.tutteli.atrium.api.fluent.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.specs.notImplemented
|
||||
import ch.tutteli.atrium.specs.withNullableSuffix
|
||||
import org.spekframework.spek2.Spek
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.MapContainsInOrderOnlyKeyValuePairsExpectationsSpec.Companion as C
|
||||
|
||||
class MapContainsInOrderOnlyKeyValuePairsExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
}) {
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapContainsInOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
functionDescription to C::containsKeyValuePairs,
|
||||
(functionDescription to C::containsKeyValuePairsNullable).withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
companion object : MapContainsSpecBase() {
|
||||
val functionDescription = "$contains.$inOrder.$only.$keyValuePair/$keyValuePairs"
|
||||
|
||||
private fun containsKeyValuePairs(
|
||||
expect: Expect<Map<out String, Int>>,
|
||||
a: Pair<String, Int>,
|
||||
aX: Array<out Pair<String, Int>>
|
||||
): Expect<Map<out String, Int>> =
|
||||
if (aX.isEmpty()) expect.contains.inOrder.only.entry(a)
|
||||
else expect.contains.inOrder.only.entries(a, *aX)
|
||||
|
||||
private fun containsKeyValuePairsNullable(
|
||||
expect: Expect<Map<out String?, Int?>>,
|
||||
a: Pair<String?, Int?>,
|
||||
aX: Array<out Pair<String?, Int?>>
|
||||
): Expect<Map<out String?, Int?>> =
|
||||
if (aX.isEmpty()) expect.contains.inOrder.only.entry(a)
|
||||
else expect.contains.inOrder.only.entries(a, *aX)
|
||||
}
|
||||
|
||||
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
private fun ambiguityTest() {
|
||||
var map: Expect<Map<Number, CharSequence>> = notImplemented()
|
||||
var subMap: Expect<LinkedHashMap<out Number, String>> = notImplemented()
|
||||
var nKeyMap: Expect<Map<Number?, CharSequence>> = notImplemented()
|
||||
var nValueMap: Expect<Map<Number, CharSequence?>> = notImplemented()
|
||||
var nKeyValueMap: Expect<Map<Number?, CharSequence?>> = notImplemented()
|
||||
var ronKeyValueMap: Expect<Map<out Number?, CharSequence?>> = notImplemented()
|
||||
var starMap: Expect<Map<*, *>> = notImplemented()
|
||||
|
||||
map = map.contains.inOrder.only.entry(1 to "a")
|
||||
subMap = subMap.contains.inOrder.only.entry(1 to "a")
|
||||
nKeyMap = nKeyMap.contains.inOrder.only.entry(1 to "a")
|
||||
nValueMap = nValueMap.contains.inOrder.only.entry(1 to "a")
|
||||
nKeyValueMap = nKeyValueMap.contains.inOrder.only.entry(1 to "a")
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inOrder.only.entry(1 to "a")
|
||||
starMap = starMap.contains.inOrder.only.entry(1 to "a")
|
||||
|
||||
map = map.contains.inOrder.only.entries(1 to "a")
|
||||
subMap = subMap.contains.inOrder.only.entries(1 to "a")
|
||||
nKeyMap = nKeyMap.contains.inOrder.only.entries(1 to "a")
|
||||
nValueMap = nValueMap.contains.inOrder.only.entries(1 to "a")
|
||||
nKeyValueMap = nKeyValueMap.contains.inOrder.only.entries(1 to "a")
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inOrder.only.entries(1 to "a")
|
||||
starMap = starMap.contains.inOrder.only.entries(1 to "a")
|
||||
|
||||
map = map.contains.inOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
subMap = subMap.contains.inOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
nKeyMap = nKeyMap.contains.inOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
nValueMap = nValueMap.contains.inOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
nKeyValueMap = nKeyValueMap.contains.inOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
starMap = starMap.contains.inOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
|
||||
nKeyMap = nKeyMap.contains.inOrder.only.entry(null to "a")
|
||||
nValueMap = nValueMap.contains.inOrder.only.entry(1.2 to null)
|
||||
nKeyValueMap = nKeyValueMap.contains.inOrder.only.entry(null to null)
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inOrder.only.entry(null to null)
|
||||
starMap = starMap.contains.inOrder.only.entry(null to null)
|
||||
|
||||
nKeyMap = nKeyMap.contains.inOrder.only.entries(null to "a", 1 to "b")
|
||||
nValueMap = nValueMap.contains.inOrder.only.entries(1 to null)
|
||||
nKeyValueMap = nKeyValueMap.contains.inOrder.only.entries((null to "a"), null to null, 1 to null)
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inOrder.only.entries((null to "a"), null to null, 1 to null)
|
||||
starMap = starMap.contains.inOrder.only.entries((null to "a"), null to null, 1 to null)
|
||||
}
|
||||
}
|
||||
@@ -6,16 +6,16 @@ import ch.tutteli.atrium.specs.*
|
||||
import kotlin.jvm.JvmName
|
||||
|
||||
class MapExpectationsSpec : ch.tutteli.atrium.specs.integration.MapExpectationsSpec(
|
||||
fun1(Expect<Map<out String, *>>::containsKey),
|
||||
fun1(Expect<Map<out String?, *>>::containsKey).withNullableSuffix(),
|
||||
fun1(Expect<Map<out String, *>>::containsNotKey),
|
||||
fun1(Expect<Map<out String?, *>>::containsNotKey).withNullableSuffix(),
|
||||
fun1(Expect<Map<out String, *>>::toContainKey),
|
||||
fun1(Expect<Map<out String?, *>>::toContainKey).withNullableSuffix(),
|
||||
fun1(Expect<Map<out String, *>>::notToContainKey),
|
||||
fun1(Expect<Map<out String?, *>>::notToContainKey).withNullableSuffix(),
|
||||
feature1<Map<out String, Int>, String, Int>(Expect<Map<out String, Int>>::getExisting),
|
||||
fun2<Map<out String, Int>, String, Expect<Int>.() -> Unit>(Expect<Map<out String, Int>>::getExisting),
|
||||
feature1<Map<out String?, Int?>, String?, Int?>(Expect<Map<out String?, Int?>>::getExisting).withNullableSuffix(),
|
||||
fun2<Map<out String?, Int?>, String?, Expect<Int?>.() -> Unit>(Expect<Map<out String?, Int?>>::getExisting).withNullableSuffix(),
|
||||
fun0(Expect<Map<*, *>>::isEmpty),
|
||||
fun0(Expect<Map<*, *>>::isNotEmpty),
|
||||
fun0(Expect<Map<*, *>>::toBeEmpty),
|
||||
fun0(Expect<Map<*, *>>::notToBeEmpty),
|
||||
fun1<Map<out String, Int>, Expect<Set<String>>.() -> Unit>(Expect<Map<out String, Int>>::keys),
|
||||
property<Map<out String, Int>, Set<String>>(Expect<Map<out String, Int>>::keys),
|
||||
property<Map<out String, Int>, Collection<Int>>(Expect<Map<out String, Int>>::values),
|
||||
@@ -23,21 +23,21 @@ class MapExpectationsSpec : ch.tutteli.atrium.specs.integration.MapExpectationsS
|
||||
) {
|
||||
|
||||
companion object {
|
||||
private fun contains(
|
||||
private fun toContain(
|
||||
expect: Expect<Map<out String, Int>>,
|
||||
keyValue: Pair<String, Expect<Int>.() -> Unit>,
|
||||
otherKeyValues: Array<out Pair<String, Expect<Int>.() -> Unit>>
|
||||
) = mapArguments<Pair<String, Expect<Int>.() -> Unit>>(keyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) ->
|
||||
expect.contains(first, *others)
|
||||
expect.toContain(first, *others)
|
||||
}
|
||||
|
||||
@JvmName("containsNullable")
|
||||
private fun contains(
|
||||
@JvmName("toContainNullable")
|
||||
private fun toContain(
|
||||
expect: Expect<Map<out String?, Int?>>,
|
||||
keyValue: Pair<String?, (Expect<Int>.() -> Unit)?>,
|
||||
otherKeyValues: Array<out Pair<String?, (Expect<Int>.() -> Unit)?>>
|
||||
) = mapArguments(keyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) ->
|
||||
expect.contains(first, *others)
|
||||
expect.toContain(first, *others)
|
||||
}
|
||||
|
||||
}
|
||||
@@ -52,39 +52,39 @@ class MapExpectationsSpec : ch.tutteli.atrium.specs.integration.MapExpectationsS
|
||||
var readOnlyNullableKeyValueMap: Expect<Map<out Number?, CharSequence?>> = notImplemented()
|
||||
var starMap: Expect<Map<*, *>> = notImplemented()
|
||||
|
||||
map.containsKey(1)
|
||||
map.containsKey(1f)
|
||||
subMap.containsKey(1)
|
||||
subMap.containsKey(1f)
|
||||
nullableKeyMap.containsKey(1)
|
||||
nullableKeyMap.containsKey(1f)
|
||||
readOnlyNullableKeyValueMap.containsKey(1)
|
||||
readOnlyNullableKeyValueMap.containsKey(1f)
|
||||
map.toContainKey(1)
|
||||
map.toContainKey(1f)
|
||||
subMap.toContainKey(1)
|
||||
subMap.toContainKey(1f)
|
||||
nullableKeyMap.toContainKey(1)
|
||||
nullableKeyMap.toContainKey(1f)
|
||||
readOnlyNullableKeyValueMap.toContainKey(1)
|
||||
readOnlyNullableKeyValueMap.toContainKey(1f)
|
||||
|
||||
map.containsNotKey(1)
|
||||
map.containsNotKey(1f)
|
||||
subMap.containsNotKey(1)
|
||||
subMap.containsNotKey(1f)
|
||||
nullableKeyMap.containsNotKey(1)
|
||||
nullableKeyMap.containsNotKey(1f)
|
||||
readOnlyNullableKeyValueMap.containsNotKey(1)
|
||||
readOnlyNullableKeyValueMap.containsNotKey(1f)
|
||||
map.notToContainKey(1)
|
||||
map.notToContainKey(1f)
|
||||
subMap.notToContainKey(1)
|
||||
subMap.notToContainKey(1f)
|
||||
nullableKeyMap.notToContainKey(1)
|
||||
nullableKeyMap.notToContainKey(1f)
|
||||
readOnlyNullableKeyValueMap.notToContainKey(1)
|
||||
readOnlyNullableKeyValueMap.notToContainKey(1f)
|
||||
|
||||
map = map.isEmpty()
|
||||
subMap = subMap.isEmpty()
|
||||
nullableKeyMap = nullableKeyMap.isEmpty()
|
||||
nullableValueMap = nullableValueMap.isEmpty()
|
||||
nullableKeyValueMap = nullableKeyValueMap.isEmpty()
|
||||
readOnlyNullableKeyValueMap = readOnlyNullableKeyValueMap.isEmpty()
|
||||
starMap = starMap.isEmpty()
|
||||
map = map.toBeEmpty()
|
||||
subMap = subMap.toBeEmpty()
|
||||
nullableKeyMap = nullableKeyMap.toBeEmpty()
|
||||
nullableValueMap = nullableValueMap.toBeEmpty()
|
||||
nullableKeyValueMap = nullableKeyValueMap.toBeEmpty()
|
||||
readOnlyNullableKeyValueMap = readOnlyNullableKeyValueMap.toBeEmpty()
|
||||
starMap = starMap.toBeEmpty()
|
||||
|
||||
map = map.isNotEmpty()
|
||||
subMap = subMap.isNotEmpty()
|
||||
nullableKeyMap = nullableKeyMap.isNotEmpty()
|
||||
nullableValueMap = nullableValueMap.isNotEmpty()
|
||||
nullableKeyValueMap = nullableKeyValueMap.isNotEmpty()
|
||||
readOnlyNullableKeyValueMap = readOnlyNullableKeyValueMap.isNotEmpty()
|
||||
starMap = starMap.isNotEmpty()
|
||||
map = map.notToBeEmpty()
|
||||
subMap = subMap.notToBeEmpty()
|
||||
nullableKeyMap = nullableKeyMap.notToBeEmpty()
|
||||
nullableValueMap = nullableValueMap.notToBeEmpty()
|
||||
nullableKeyValueMap = nullableKeyValueMap.notToBeEmpty()
|
||||
readOnlyNullableKeyValueMap = readOnlyNullableKeyValueMap.notToBeEmpty()
|
||||
starMap = starMap.notToBeEmpty()
|
||||
|
||||
map.keys
|
||||
subMap.keys
|
||||
|
||||
@@ -7,24 +7,24 @@ import ch.tutteli.atrium.specs.notImplemented
|
||||
import ch.tutteli.atrium.specs.withNullableSuffix
|
||||
import org.spekframework.spek2.Spek
|
||||
import kotlin.jvm.JvmName
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.MapContainsInAnyOrderEntriesOfExpectationsSpec.Companion as C
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.MapToContainInAnyOrderEntriesOfExpectationsSpec.Companion as C
|
||||
|
||||
class MapContainsInAnyOrderEntriesOfExpectationsSpec : Spek({
|
||||
class MapToContainInAnyOrderEntriesOfExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
include(BuilderMapLikeToIterablePairSpec)
|
||||
include(ShortcutMapLikeToIterablePairSpec)
|
||||
}) {
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapContainsInAnyOrderKeyValuePairsExpectationsSpec(
|
||||
functionDescription to C::containsKeyValuePairs,
|
||||
(functionDescription to C::containsKeyValuePairsNullable).withNullableSuffix(),
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapToContainInAnyOrderKeyValuePairsExpectationsSpec(
|
||||
functionDescription to C::toContainKeyValuePairs,
|
||||
(functionDescription to C::toContainKeyValuePairsNullable).withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.MapContainsInAnyOrderKeyValuePairsExpectationsSpec(
|
||||
mfun2<String, Int, Int>(C::containsEntriesOf),
|
||||
mfun2<String?, Int?, Int?>(C::containsEntriesOf).withNullableSuffix(),
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.MapToContainInAnyOrderKeyValuePairsExpectationsSpec(
|
||||
mfun2<String, Int, Int>(C::toContainEntriesOf),
|
||||
mfun2<String?, Int?, Int?>(C::toContainEntriesOf).withNullableSuffix(),
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
@@ -32,20 +32,20 @@ class MapContainsInAnyOrderEntriesOfExpectationsSpec : Spek({
|
||||
ch.tutteli.atrium.specs.integration.MapLikeToIterablePairSpec<Map<String, Int>>(
|
||||
functionDescription,
|
||||
mapOf("a" to 1),
|
||||
{ input -> contains.inAnyOrder.entriesOf(input) }
|
||||
{ input -> toContain.inAnyOrder.entriesOf(input) }
|
||||
)
|
||||
|
||||
object ShortcutMapLikeToIterablePairSpec :
|
||||
ch.tutteli.atrium.specs.integration.MapLikeToIterablePairSpec<Map<String, Int>>(
|
||||
containsEntriesOf,
|
||||
toContainEntriesOf,
|
||||
mapOf("a" to 1),
|
||||
{ input -> containsEntriesOf(input) }
|
||||
{ input -> toContainEntriesOf(input) }
|
||||
)
|
||||
|
||||
companion object : MapContainsSpecBase() {
|
||||
val functionDescription = "$contains.$inAnyOrder.$entriesOf"
|
||||
companion object : MapToContainSpecBase() {
|
||||
val functionDescription = "$toContain.$inAnyOrder.$entriesOf"
|
||||
|
||||
private fun containsKeyValuePairs(
|
||||
private fun toContainKeyValuePairs(
|
||||
expect: Expect<Map<out String, Int>>,
|
||||
a: Pair<String, Int>,
|
||||
aX: Array<out Pair<String, Int>>
|
||||
@@ -55,30 +55,30 @@ class MapContainsInAnyOrderEntriesOfExpectationsSpec : Spek({
|
||||
} else {
|
||||
mapOf(a, *aX)
|
||||
}
|
||||
return expect.contains.inAnyOrder.entriesOf(mapLike)
|
||||
return expect.toContain.inAnyOrder.entriesOf(mapLike)
|
||||
}
|
||||
|
||||
private fun containsKeyValuePairsNullable(
|
||||
private fun toContainKeyValuePairsNullable(
|
||||
expect: Expect<Map<out String?, Int?>>,
|
||||
a: Pair<String?, Int?>,
|
||||
aX: Array<out Pair<String?, Int?>>
|
||||
): Expect<Map<out String?, Int?>> =
|
||||
expect.contains.inAnyOrder.entriesOf(listOf(a, *aX))
|
||||
expect.toContain.inAnyOrder.entriesOf(listOf(a, *aX))
|
||||
|
||||
private fun containsEntriesOf(
|
||||
private fun toContainEntriesOf(
|
||||
expect: Expect<Map<out String, Int>>,
|
||||
a: Pair<String, Int>,
|
||||
aX: Array<out Pair<String, Int>>
|
||||
): Expect<Map<out String, Int>> =
|
||||
expect.containsEntriesOf(sequenceOf(a, *aX))
|
||||
expect.toContainEntriesOf(sequenceOf(a, *aX))
|
||||
|
||||
@JvmName("containsNullable")
|
||||
private fun containsEntriesOf(
|
||||
@JvmName("toContainNullable")
|
||||
private fun toContainEntriesOf(
|
||||
expect: Expect<Map<out String?, Int?>>,
|
||||
a: Pair<String?, Int?>,
|
||||
aX: Array<out Pair<String?, Int?>>
|
||||
): Expect<Map<out String?, Int?>> =
|
||||
expect.containsEntriesOf(arrayOf(a, *aX))
|
||||
expect.toContainEntriesOf(arrayOf(a, *aX))
|
||||
}
|
||||
|
||||
|
||||
@@ -92,20 +92,20 @@ class MapContainsInAnyOrderEntriesOfExpectationsSpec : Spek({
|
||||
var ronKeyValueMap: Expect<Map<out Number?, CharSequence?>> = notImplemented()
|
||||
var starMap: Expect<Map<*, *>> = notImplemented()
|
||||
|
||||
map = map.contains.inAnyOrder.entriesOf(listOf(1 to "a"))
|
||||
subMap = subMap.contains.inAnyOrder.entriesOf(listOf(1 to "a"))
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.entriesOf(listOf(1 to "a"))
|
||||
nValueMap = nValueMap.contains.inAnyOrder.entriesOf(listOf(1 to "a"))
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.entriesOf(listOf(1 to "a"))
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.entriesOf(listOf(1 to "a"))
|
||||
starMap = starMap.contains.inAnyOrder.entriesOf(listOf(1 to "a"))
|
||||
map = map.toContain.inAnyOrder.entriesOf(listOf(1 to "a"))
|
||||
subMap = subMap.toContain.inAnyOrder.entriesOf(listOf(1 to "a"))
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.entriesOf(listOf(1 to "a"))
|
||||
nValueMap = nValueMap.toContain.inAnyOrder.entriesOf(listOf(1 to "a"))
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.entriesOf(listOf(1 to "a"))
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.entriesOf(listOf(1 to "a"))
|
||||
starMap = starMap.toContain.inAnyOrder.entriesOf(listOf(1 to "a"))
|
||||
|
||||
map = map.containsEntriesOf(listOf(1 to "a"))
|
||||
subMap = subMap.containsEntriesOf(listOf(1 to "a"))
|
||||
nKeyMap = nKeyMap.containsEntriesOf(listOf(1 to "a"))
|
||||
nValueMap = nValueMap.containsEntriesOf(listOf(1 to "a"))
|
||||
nKeyValueMap = nKeyValueMap.containsEntriesOf(listOf(1 to "a"))
|
||||
ronKeyValueMap = ronKeyValueMap.containsEntriesOf(listOf(1 to "a"))
|
||||
starMap = starMap.containsEntriesOf(listOf(1 to "a"))
|
||||
map = map.toContainEntriesOf(listOf(1 to "a"))
|
||||
subMap = subMap.toContainEntriesOf(listOf(1 to "a"))
|
||||
nKeyMap = nKeyMap.toContainEntriesOf(listOf(1 to "a"))
|
||||
nValueMap = nValueMap.toContainEntriesOf(listOf(1 to "a"))
|
||||
nKeyValueMap = nKeyValueMap.toContainEntriesOf(listOf(1 to "a"))
|
||||
ronKeyValueMap = ronKeyValueMap.toContainEntriesOf(listOf(1 to "a"))
|
||||
starMap = starMap.toContainEntriesOf(listOf(1 to "a"))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,236 @@
|
||||
package ch.tutteli.atrium.api.fluent.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.logic.utils.mapArguments
|
||||
import ch.tutteli.atrium.specs.*
|
||||
import ch.tutteli.atrium.specs.integration.mfun2
|
||||
import org.spekframework.spek2.Spek
|
||||
import kotlin.jvm.JvmName
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.MapToContainInAnyOrderKeyValueExpectationsSpec.Companion as C
|
||||
|
||||
class MapToContainInAnyOrderKeyValueExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
}) {
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapToContainInAnyOrderKeyValueExpectationsSpec(
|
||||
functionDescription to C::toContainKeyValues,
|
||||
(functionDescription to C::toContainKeyValuesNullable).withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.MapToContainInAnyOrderKeyValueExpectationsSpec(
|
||||
mfun2<String, Int, Expect<Int>.() -> Unit>(C::toContain).adjustName { "$it ${KeyValue::class.simpleName}" },
|
||||
mfun2<String?, Int?, (Expect<Int>.() -> Unit)?>(C::toContain).adjustName { "$it ${KeyValue::class.simpleName}" }
|
||||
.withNullableSuffix(),
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
companion object : MapToContainSpecBase() {
|
||||
val functionDescription = "$toContain.$inAnyOrder.$keyValue/$keyValues"
|
||||
|
||||
private fun toContainKeyValues(
|
||||
expect: Expect<Map<out String, Int>>,
|
||||
a: Pair<String, Expect<Int>.() -> Unit>,
|
||||
aX: Array<out Pair<String, Expect<Int>.() -> Unit>>
|
||||
): Expect<Map<out String, Int>> =
|
||||
mapArguments(a, aX).to { KeyValue(it.first, it.second) }.let { (first, others) ->
|
||||
if (others.isEmpty()) expect.toContain.inAnyOrder.entry(first)
|
||||
else expect.toContain.inAnyOrder.entries(first, *others)
|
||||
}
|
||||
|
||||
private fun toContainKeyValuesNullable(
|
||||
expect: Expect<Map<out String?, Int?>>,
|
||||
a: Pair<String?, (Expect<Int>.() -> Unit)?>,
|
||||
aX: Array<out Pair<String?, (Expect<Int>.() -> Unit)?>>
|
||||
) = mapArguments(a, aX).to { KeyValue(it.first, it.second) }.let { (first, others) ->
|
||||
if (others.isEmpty()) expect.toContain.inAnyOrder.entry(first)
|
||||
else expect.toContain.inAnyOrder.entries(first, *others)
|
||||
}
|
||||
|
||||
private fun toContain(
|
||||
expect: Expect<Map<out String, Int>>,
|
||||
KeyValue: Pair<String, Expect<Int>.() -> Unit>,
|
||||
otherKeyValues: Array<out Pair<String, Expect<Int>.() -> Unit>>
|
||||
) = mapArguments(KeyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) ->
|
||||
expect.toContain(first, *others)
|
||||
}
|
||||
|
||||
@JvmName("toContainNullable")
|
||||
private fun toContain(
|
||||
expect: Expect<Map<out String?, Int?>>,
|
||||
KeyValue: Pair<String?, (Expect<Int>.() -> Unit)?>,
|
||||
otherKeyValues: Array<out Pair<String?, (Expect<Int>.() -> Unit)?>>
|
||||
) = mapArguments(KeyValue, otherKeyValues).to { KeyValue(it.first, it.second) }.let { (first, others) ->
|
||||
expect.toContain(first, *others)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
private fun ambiguityTest() {
|
||||
var map: Expect<Map<Number, CharSequence>> = notImplemented()
|
||||
var subMap: Expect<LinkedHashMap<out Number, String>> = notImplemented()
|
||||
var nKeyMap: Expect<Map<Number?, CharSequence>> = notImplemented()
|
||||
var nValueMap: Expect<Map<Number, CharSequence?>> = notImplemented()
|
||||
var nKeyValueMap: Expect<Map<Number?, CharSequence?>> = notImplemented()
|
||||
var ronKeyValueMap: Expect<Map<out Number?, CharSequence?>> = notImplemented()
|
||||
var starMap: Expect<Map<*, *>> = notImplemented()
|
||||
|
||||
map = map.toContain.inAnyOrder.entry(KeyValue(1) { toEqual("a") })
|
||||
subMap = subMap.toContain.inAnyOrder.entry(KeyValue(1) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.entry(KeyValue(1) { toEqual("a") })
|
||||
nValueMap = nValueMap.toContain.inAnyOrder.entry(KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.entry(KeyValue(1) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.entry(KeyValue(1) { toEqual("a") })
|
||||
starMap = starMap.toContain.inAnyOrder.entry(KeyValue(1) { toEqual("a") })
|
||||
|
||||
map = map.toContain.inAnyOrder.entries(KeyValue(1) { toEqual("a") })
|
||||
subMap = subMap.toContain.inAnyOrder.entries(KeyValue(1) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.entries(KeyValue(1) { toEqual("a") })
|
||||
nValueMap = nValueMap.toContain.inAnyOrder.entries(KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.entries(KeyValue(1) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.entries(KeyValue(1) { toEqual("a") })
|
||||
starMap = starMap.toContain.inAnyOrder.entries(KeyValue(1) { toEqual("a") })
|
||||
|
||||
map = map.toContain.inAnyOrder.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
subMap = subMap.toContain.inAnyOrder.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nValueMap = nValueMap.toContain.inAnyOrder.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
starMap = starMap.toContain.inAnyOrder.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.entry(KeyValue(null) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.entry(KeyValue(null) { toEqual("a") })
|
||||
nValueMap = nValueMap.toContain.inAnyOrder.entry(KeyValue(1.2, null))
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.entry(KeyValue(null) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.entry(KeyValue(null, null))
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.entry(KeyValue(null) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.entry(KeyValue(null, null))
|
||||
starMap = starMap.toContain.inAnyOrder.entry(KeyValue(null) { toEqual("a") })
|
||||
starMap = starMap.toContain.inAnyOrder.entry(KeyValue(null, null))
|
||||
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.entries(KeyValue(null) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.entries(KeyValue(null) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.entries(KeyValue(null) { toEqual("a") })
|
||||
starMap = starMap.toContain.inAnyOrder.entries(KeyValue(null) { toEqual("a") })
|
||||
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.entries(KeyValue(null) { toEqual("a") })
|
||||
nValueMap = nValueMap.toContain.inAnyOrder.entries(KeyValue(1, null), KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.entries(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.entries(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
starMap = starMap.toContain.inAnyOrder.entries(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
|
||||
/// ------------- shortcuts -----------------------------------------------------------------
|
||||
|
||||
map = map.toContain(KeyValue(1) { toEqual("a") })
|
||||
subMap = subMap.toContain(KeyValue(1) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.toContain(KeyValue(1) { toEqual("a") })
|
||||
nValueMap = nValueMap.toContain(KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.toContain(KeyValue(1) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.toContain(KeyValue(1) { toEqual("a") })
|
||||
starMap = starMap.toContain(KeyValue(1) { toEqual("a") })
|
||||
|
||||
map = map.toContain(KeyValue(1) { toEqual("a") })
|
||||
subMap = subMap.toContain(KeyValue(1) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.toContain(KeyValue(1) { toEqual("a") })
|
||||
nValueMap = nValueMap.toContain(KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.toContain(KeyValue(1) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.toContain(KeyValue(1) { toEqual("a") })
|
||||
starMap = starMap.toContain(KeyValue(1) { toEqual("a") })
|
||||
|
||||
map = map.toContain(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
subMap = subMap.toContain(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nKeyMap = nKeyMap.toContain(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nValueMap = nValueMap.toContain(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nKeyValueMap = nKeyValueMap.toContain(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.toContain(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
starMap = starMap.toContain(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
|
||||
nKeyMap = nKeyMap.toContain(KeyValue(null) { toEqual("a") })
|
||||
nValueMap = nValueMap.toContain(KeyValue(1.2, null))
|
||||
nKeyValueMap = nKeyValueMap.toContain(KeyValue(null) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.toContain(KeyValue(null, null))
|
||||
ronKeyValueMap = ronKeyValueMap.toContain(KeyValue(null) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.toContain(KeyValue(null, null))
|
||||
starMap = starMap.toContain(KeyValue(null) { toEqual("a") })
|
||||
starMap = starMap.toContain(KeyValue(null, null))
|
||||
|
||||
nKeyMap = nKeyMap.toContain(KeyValue(null) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.toContain(KeyValue(null) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.toContain(KeyValue(null) { toEqual("a") })
|
||||
starMap = starMap.toContain(KeyValue(null) { toEqual("a") })
|
||||
|
||||
nKeyMap = nKeyMap.toContain(KeyValue(null) { toEqual("a") })
|
||||
nValueMap = nValueMap.toContain(KeyValue(1, null), KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.toContain(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.toContain(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
starMap = starMap.toContain(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,152 @@
|
||||
package ch.tutteli.atrium.api.fluent.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.specs.*
|
||||
import ch.tutteli.atrium.specs.integration.mfun2
|
||||
import org.spekframework.spek2.Spek
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.MapToContainInAnyOrderKeyValuePairsExpectationsSpec.Companion as C
|
||||
|
||||
class MapToContainInAnyOrderKeyValuePairsExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
}) {
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapToContainInAnyOrderKeyValuePairsExpectationsSpec(
|
||||
functionDescription to C::toContainKeyValuePairs,
|
||||
(functionDescription to C::toContainKeyValuePairsNullable).withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.MapToContainInAnyOrderKeyValuePairsExpectationsSpec(
|
||||
mfun2<String, Int, Int>(Expect<Map<out String, Int>>::toContain),
|
||||
mfun2<String?, Int?, Int?>(Expect<Map<out String?, Int?>>::toContain).withNullableSuffix(),
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
companion object : MapToContainSpecBase() {
|
||||
val functionDescription = "$toContain.$inAnyOrder.$keyValuePair/$keyValuePairs"
|
||||
|
||||
private fun toContainKeyValuePairs(
|
||||
expect: Expect<Map<out String, Int>>,
|
||||
a: Pair<String, Int>,
|
||||
aX: Array<out Pair<String, Int>>
|
||||
): Expect<Map<out String, Int>> =
|
||||
if (aX.isEmpty()) expect.toContain.inAnyOrder.entry(a)
|
||||
else expect.toContain.inAnyOrder.entries(a, *aX)
|
||||
|
||||
private fun toContainKeyValuePairsNullable(
|
||||
expect: Expect<Map<out String?, Int?>>,
|
||||
a: Pair<String?, Int?>,
|
||||
aX: Array<out Pair<String?, Int?>>
|
||||
): Expect<Map<out String?, Int?>> =
|
||||
if (aX.isEmpty()) expect.toContain.inAnyOrder.entry(a)
|
||||
else expect.toContain.inAnyOrder.entries(a, *aX)
|
||||
}
|
||||
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
private fun ambiguityTest() {
|
||||
var map: Expect<Map<Number, CharSequence>> = notImplemented()
|
||||
var subMap: Expect<LinkedHashMap<out Number, String>> = notImplemented()
|
||||
var nKeyMap: Expect<Map<Number?, CharSequence>> = notImplemented()
|
||||
var nValueMap: Expect<Map<Number, CharSequence?>> = notImplemented()
|
||||
var nKeyValueMap: Expect<Map<Number?, CharSequence?>> = notImplemented()
|
||||
var ronKeyValueMap: Expect<Map<out Number?, CharSequence?>> = notImplemented()
|
||||
var starMap: Expect<Map<*, *>> = notImplemented()
|
||||
|
||||
map = map.toContain.inAnyOrder.entry(1 to "a")
|
||||
subMap = subMap.toContain.inAnyOrder.entry(1 to "a")
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.entry(1 to "a")
|
||||
nValueMap = nValueMap.toContain.inAnyOrder.entry(1 to "a")
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.entry(1 to "a")
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.entry(1 to "a")
|
||||
starMap = starMap.toContain.inAnyOrder.entry(1 to "a")
|
||||
|
||||
map = map.toContain.inAnyOrder.entries(1 to "a")
|
||||
subMap = subMap.toContain.inAnyOrder.entries(1 to "a")
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.entries(1 to "a")
|
||||
nValueMap = nValueMap.toContain.inAnyOrder.entries(1 to "a")
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.entries(1 to "a")
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.entries(1 to "a")
|
||||
starMap = starMap.toContain.inAnyOrder.entries(1 to "a")
|
||||
|
||||
map = map.toContain.inAnyOrder.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
subMap = subMap.toContain.inAnyOrder.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
nValueMap = nValueMap.toContain.inAnyOrder.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
starMap = starMap.toContain.inAnyOrder.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.entry(null to "a")
|
||||
nValueMap = nValueMap.toContain.inAnyOrder.entry(1.2 to null)
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.entry(null to null)
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.entry(null to null)
|
||||
starMap = starMap.toContain.inAnyOrder.entry(null to null)
|
||||
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.entries(null to "a", 1 to "b")
|
||||
nValueMap = nValueMap.toContain.inAnyOrder.entries(1 to null)
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.entries((null to "a"), null to null, 1 to null)
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.entries((null to "a"), null to null, 1 to null)
|
||||
starMap = starMap.toContain.inAnyOrder.entries((null to "a"), null to null, 1 to null)
|
||||
|
||||
|
||||
/// ------------- shortcuts -----------------------------------------------------------------
|
||||
|
||||
map = map.toContain(1 to "a")
|
||||
subMap = subMap.toContain(1 to "a")
|
||||
nKeyMap = nKeyMap.toContain(1 to "a")
|
||||
nValueMap = nValueMap.toContain(1 to "a")
|
||||
nKeyValueMap = nKeyValueMap.toContain(1 to "a")
|
||||
ronKeyValueMap = ronKeyValueMap.toContain(1 to "a")
|
||||
starMap = starMap.toContain(1 to "a")
|
||||
|
||||
map = map.toContain(1 to "a")
|
||||
subMap = subMap.toContain(1 to "a")
|
||||
nKeyMap = nKeyMap.toContain(1 to "a")
|
||||
nValueMap = nValueMap.toContain(1 to "a")
|
||||
nKeyValueMap = nKeyValueMap.toContain(1 to "a")
|
||||
ronKeyValueMap = ronKeyValueMap.toContain(1 to "a")
|
||||
starMap = starMap.toContain(1 to "a")
|
||||
|
||||
map = map.toContain(1 as Number to "a", 1.2 to "b")
|
||||
subMap = subMap.toContain(1 as Number to "a", 1.2 to "b")
|
||||
nKeyMap = nKeyMap.toContain(1 as Number to "a", 1.2 to "b")
|
||||
nValueMap = nValueMap.toContain(1 as Number to "a", 1.2 to "b")
|
||||
nKeyValueMap = nKeyValueMap.toContain(1 as Number to "a", 1.2 to "b")
|
||||
ronKeyValueMap = ronKeyValueMap.toContain(1 as Number to "a", 1.2 to "b")
|
||||
starMap = starMap.toContain(1 as Number to "a", 1.2 to "b")
|
||||
|
||||
nKeyMap = nKeyMap.toContain(null to "a")
|
||||
nValueMap = nValueMap.toContain(1.2 to null)
|
||||
nKeyValueMap = nKeyValueMap.toContain(null to null)
|
||||
ronKeyValueMap = ronKeyValueMap.toContain(null to "a")
|
||||
starMap = starMap.toContain(null to "a")
|
||||
|
||||
nKeyMap = nKeyMap.toContain(null to "a")
|
||||
nValueMap = nValueMap.toContain(1.2 to null, 1 to null)
|
||||
nKeyValueMap = nKeyValueMap.toContain(null to "a", null to null, 1 to null)
|
||||
ronKeyValueMap = ronKeyValueMap.toContain(null to "a", null to null, 1 to null)
|
||||
starMap = starMap.toContain(null to "a", null to null, 1 to null)
|
||||
}
|
||||
}
|
||||
@@ -6,24 +6,24 @@ import ch.tutteli.atrium.specs.*
|
||||
import ch.tutteli.atrium.specs.integration.mfun2
|
||||
import org.spekframework.spek2.Spek
|
||||
import kotlin.jvm.JvmName
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.MapContainsInAnyOrderOnlyEntriesOfExpectationsSpec.Companion as C
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.MapToContainInAnyOrderOnlyEntriesOfExpectationsSpec.Companion as C
|
||||
|
||||
class MapContainsInAnyOrderOnlyEntriesOfExpectationsSpec : Spek({
|
||||
class MapToContainInAnyOrderOnlyEntriesOfExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
include(BuilderMapLikeToIterablePairSpec)
|
||||
include(ShortcutMapLikeToIterablePairSpec)
|
||||
}) {
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapContainsInAnyOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
functionDescription to C::containsKeyValuePairs,
|
||||
(functionDescription to C::containsKeyValuePairsNullable).withNullableSuffix(),
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapToContainInAnyOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
functionDescription to C::toContainKeyValuePairs,
|
||||
(functionDescription to C::toContainKeyValuePairsNullable).withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.MapContainsInAnyOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
mfun2<String, Int, Int>(C::containsInAnyOrderOnlyEntriesOf),
|
||||
mfun2<String?, Int?, Int?>(C::containsInAnyOrderOnlyEntriesOf).withNullableSuffix(),
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.MapToContainInAnyOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
mfun2<String, Int, Int>(C::toContainInAnyOrderOnlyEntriesOf),
|
||||
mfun2<String?, Int?, Int?>(C::toContainInAnyOrderOnlyEntriesOf).withNullableSuffix(),
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
@@ -32,20 +32,20 @@ class MapContainsInAnyOrderOnlyEntriesOfExpectationsSpec : Spek({
|
||||
ch.tutteli.atrium.specs.integration.MapLikeToIterablePairSpec<Map<String, Int>>(
|
||||
functionDescription,
|
||||
mapOf("a" to 1),
|
||||
{ input -> contains.inAnyOrder.only.entriesOf(input) }
|
||||
{ input -> toContain.inAnyOrder.only.entriesOf(input) }
|
||||
)
|
||||
|
||||
object ShortcutMapLikeToIterablePairSpec :
|
||||
ch.tutteli.atrium.specs.integration.MapLikeToIterablePairSpec<Map<String, Int>>(
|
||||
containsOnlyEntriesOf,
|
||||
toContainOnlyEntriesOf,
|
||||
mapOf("a" to 1),
|
||||
{ input -> containsOnlyEntriesOf(input) }
|
||||
{ input -> toContainOnlyEntriesOf(input) }
|
||||
)
|
||||
|
||||
companion object : MapContainsSpecBase() {
|
||||
val functionDescription = "$contains.$inAnyOrder.$only.$entriesOf"
|
||||
companion object : MapToContainSpecBase() {
|
||||
val functionDescription = "$toContain.$inAnyOrder.$only.$entriesOf"
|
||||
|
||||
private fun containsKeyValuePairs(
|
||||
private fun toContainKeyValuePairs(
|
||||
expect: Expect<Map<out String, Int>>,
|
||||
a: Pair<String, Int>,
|
||||
aX: Array<out Pair<String, Int>>
|
||||
@@ -55,31 +55,31 @@ class MapContainsInAnyOrderOnlyEntriesOfExpectationsSpec : Spek({
|
||||
} else {
|
||||
mapOf(a, *aX)
|
||||
}
|
||||
return expect.contains.inAnyOrder.only.entriesOf(mapLike)
|
||||
return expect.toContain.inAnyOrder.only.entriesOf(mapLike)
|
||||
}
|
||||
|
||||
private fun containsKeyValuePairsNullable(
|
||||
private fun toContainKeyValuePairsNullable(
|
||||
expect: Expect<Map<out String?, Int?>>,
|
||||
a: Pair<String?, Int?>,
|
||||
aX: Array<out Pair<String?, Int?>>
|
||||
): Expect<Map<out String?, Int?>> =
|
||||
expect.contains.inAnyOrder.only.entriesOf(listOf(a, *aX))
|
||||
expect.toContain.inAnyOrder.only.entriesOf(listOf(a, *aX))
|
||||
|
||||
|
||||
private fun containsInAnyOrderOnlyEntriesOf(
|
||||
private fun toContainInAnyOrderOnlyEntriesOf(
|
||||
expect: Expect<Map<out String, Int>>,
|
||||
a: Pair<String, Int>,
|
||||
aX: Array<out Pair<String, Int>>
|
||||
): Expect<Map<out String, Int>> =
|
||||
expect.containsOnlyEntriesOf(sequenceOf(a, *aX))
|
||||
expect.toContainOnlyEntriesOf(sequenceOf(a, *aX))
|
||||
|
||||
@JvmName("containsInAnyOrderOnlyEntriesOfNullable")
|
||||
private fun containsInAnyOrderOnlyEntriesOf(
|
||||
@JvmName("toContainInAnyOrderOnlyEntriesOfNullable")
|
||||
private fun toContainInAnyOrderOnlyEntriesOf(
|
||||
expect: Expect<Map<out String?, Int?>>,
|
||||
a: Pair<String?, Int?>,
|
||||
aX: Array<out Pair<String?, Int?>>
|
||||
): Expect<Map<out String?, Int?>> =
|
||||
expect.containsOnlyEntriesOf(arrayOf(a, *aX))
|
||||
expect.toContainOnlyEntriesOf(arrayOf(a, *aX))
|
||||
}
|
||||
|
||||
|
||||
@@ -94,20 +94,20 @@ class MapContainsInAnyOrderOnlyEntriesOfExpectationsSpec : Spek({
|
||||
var ronKeyValueMap: Expect<Map<out Number?, CharSequence?>> = notImplemented()
|
||||
var starMap: Expect<Map<*, *>> = notImplemented()
|
||||
|
||||
map = map.contains.inAnyOrder.only.entriesOf(listOf(1 to "a"))
|
||||
subMap = subMap.contains.inAnyOrder.only.entriesOf(listOf(1 to "a"))
|
||||
nKeyMap = nKeyMap.contains.inAnyOrder.only.entriesOf(listOf(1 to "a"))
|
||||
nValueMap = nValueMap.contains.inAnyOrder.only.entriesOf(listOf(1 to "a"))
|
||||
nKeyValueMap = nKeyValueMap.contains.inAnyOrder.only.entriesOf(listOf(1 to "a"))
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inAnyOrder.only.entriesOf(listOf(1 to "a"))
|
||||
starMap = starMap.contains.inAnyOrder.only.entriesOf(listOf(1 to "a"))
|
||||
map = map.toContain.inAnyOrder.only.entriesOf(listOf(1 to "a"))
|
||||
subMap = subMap.toContain.inAnyOrder.only.entriesOf(listOf(1 to "a"))
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.only.entriesOf(listOf(1 to "a"))
|
||||
nValueMap = nValueMap.toContain.inAnyOrder.only.entriesOf(listOf(1 to "a"))
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.only.entriesOf(listOf(1 to "a"))
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.only.entriesOf(listOf(1 to "a"))
|
||||
starMap = starMap.toContain.inAnyOrder.only.entriesOf(listOf(1 to "a"))
|
||||
|
||||
map = map.containsOnlyEntriesOf(listOf(1 to "a"))
|
||||
subMap = subMap.containsOnlyEntriesOf(listOf(1 to "a"))
|
||||
nKeyMap = nKeyMap.containsOnlyEntriesOf(listOf(1 to "a"))
|
||||
nValueMap = nValueMap.containsOnlyEntriesOf(listOf(1 to "a"))
|
||||
nKeyValueMap = nKeyValueMap.containsOnlyEntriesOf(listOf(1 to "a"))
|
||||
ronKeyValueMap = ronKeyValueMap.containsOnlyEntriesOf(listOf(1 to "a"))
|
||||
starMap = starMap.containsOnlyEntriesOf(listOf(1 to "a"))
|
||||
map = map.toContainOnlyEntriesOf(listOf(1 to "a"))
|
||||
subMap = subMap.toContainOnlyEntriesOf(listOf(1 to "a"))
|
||||
nKeyMap = nKeyMap.toContainOnlyEntriesOf(listOf(1 to "a"))
|
||||
nValueMap = nValueMap.toContainOnlyEntriesOf(listOf(1 to "a"))
|
||||
nKeyValueMap = nKeyValueMap.toContainOnlyEntriesOf(listOf(1 to "a"))
|
||||
ronKeyValueMap = ronKeyValueMap.toContainOnlyEntriesOf(listOf(1 to "a"))
|
||||
starMap = starMap.toContainOnlyEntriesOf(listOf(1 to "a"))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,238 @@
|
||||
package ch.tutteli.atrium.api.fluent.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.logic.utils.mapArguments
|
||||
import ch.tutteli.atrium.specs.*
|
||||
import ch.tutteli.atrium.specs.integration.mfun2
|
||||
import org.spekframework.spek2.Spek
|
||||
import kotlin.jvm.JvmName
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.MapToContainInAnyOrderOnlyKeyValueExpectationsSpec.Companion as C
|
||||
|
||||
class MapToContainInAnyOrderOnlyKeyValueExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
}) {
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapToContainInAnyOrderOnlyKeyValueExpectationsSpec(
|
||||
functionDescription to C::toContainKeyValues,
|
||||
(functionDescription to C::toContainKeyValuesNullable).withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.MapToContainInAnyOrderOnlyKeyValueExpectationsSpec(
|
||||
mfun2<String, Int, Expect<Int>.() -> Unit>(C::toContainOnly),
|
||||
mfun2<String?, Int?, (Expect<Int>.() -> Unit)?>(C::toContainOnly).withNullableSuffix(),
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
companion object : MapToContainSpecBase() {
|
||||
val functionDescription = "$toContain.$inAnyOrder.$only.$keyValue/$keyValues"
|
||||
|
||||
private fun toContainKeyValues(
|
||||
expect: Expect<Map<out String, Int>>,
|
||||
a: Pair<String, Expect<Int>.() -> Unit>,
|
||||
aX: Array<out Pair<String, Expect<Int>.() -> Unit>>
|
||||
) = mapArguments(a, aX).to { KeyValue(it.first, it.second) }.let { (first, others) ->
|
||||
if (others.isEmpty()) expect.toContain.inAnyOrder.only.entry(first)
|
||||
else expect.toContain.inAnyOrder.only.entries(first, *others)
|
||||
}
|
||||
|
||||
private fun toContainKeyValuesNullable(
|
||||
expect: Expect<Map<out String?, Int?>>,
|
||||
a: Pair<String?, (Expect<Int>.() -> Unit)?>,
|
||||
aX: Array<out Pair<String?, (Expect<Int>.() -> Unit)?>>
|
||||
) = mapArguments(a, aX).to { KeyValue(it.first, it.second) }.let { (first, others) ->
|
||||
if (others.isEmpty()) expect.toContain.inAnyOrder.only.entry(first)
|
||||
else expect.toContain.inAnyOrder.only.entries(first, *others)
|
||||
}
|
||||
|
||||
private fun toContainOnly(
|
||||
expect: Expect<Map<out String, Int>>,
|
||||
a: Pair<String, Expect<Int>.() -> Unit>,
|
||||
aX: Array<out Pair<String, Expect<Int>.() -> Unit>>
|
||||
): Expect<Map<out String, Int>> =
|
||||
mapArguments(a, aX).to { KeyValue(it.first, it.second) }.let { (first, others) ->
|
||||
expect.toContainOnly(first, *others)
|
||||
}
|
||||
|
||||
@JvmName("toContainInAnyOrderOnlyNullable")
|
||||
private fun toContainOnly(
|
||||
expect: Expect<Map<out String?, Int?>>,
|
||||
a: Pair<String?, (Expect<Int>.() -> Unit)?>,
|
||||
aX: Array<out Pair<String?, (Expect<Int>.() -> Unit)?>>
|
||||
): Expect<Map<out String?, Int?>> =
|
||||
mapArguments(a, aX).to { KeyValue(it.first, it.second) }.let { (first, others) ->
|
||||
expect.toContainOnly(first, *others)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
private fun ambiguityTest() {
|
||||
var map: Expect<Map<Number, CharSequence>> = notImplemented()
|
||||
var subMap: Expect<LinkedHashMap<out Number, String>> = notImplemented()
|
||||
var nKeyMap: Expect<Map<Number?, CharSequence>> = notImplemented()
|
||||
var nValueMap: Expect<Map<Number, CharSequence?>> = notImplemented()
|
||||
var nKeyValueMap: Expect<Map<Number?, CharSequence?>> = notImplemented()
|
||||
var ronKeyValueMap: Expect<Map<out Number?, CharSequence?>> = notImplemented()
|
||||
var starMap: Expect<Map<*, *>> = notImplemented()
|
||||
|
||||
map = map.toContain.inAnyOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
subMap = subMap.toContain.inAnyOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
nValueMap = nValueMap.toContain.inAnyOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
starMap = starMap.toContain.inAnyOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
|
||||
map = map.toContain.inAnyOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
subMap = subMap.toContain.inAnyOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
nValueMap = nValueMap.toContain.inAnyOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
starMap = starMap.toContain.inAnyOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
|
||||
map = map.toContain.inAnyOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
subMap = subMap.toContain.inAnyOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nValueMap = nValueMap.toContain.inAnyOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
starMap = starMap.toContain.inAnyOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.only.entry(KeyValue(null) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.only.entry(KeyValue(null) { toEqual("a") })
|
||||
nValueMap = nValueMap.toContain.inAnyOrder.only.entry(KeyValue(1.2, null))
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.only.entry(KeyValue(null) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.only.entry(KeyValue(null, null))
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.only.entry(KeyValue(null) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.only.entry(KeyValue(null, null))
|
||||
starMap = starMap.toContain.inAnyOrder.only.entry(KeyValue(null) { toEqual("a") })
|
||||
starMap = starMap.toContain.inAnyOrder.only.entry(KeyValue(null, null))
|
||||
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.only.entries(KeyValue(null) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.only.entries(KeyValue(null) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.only.entries(KeyValue(null) { toEqual("a") })
|
||||
starMap = starMap.toContain.inAnyOrder.only.entries(KeyValue(null) { toEqual("a") })
|
||||
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.only.entries(KeyValue(null) { toEqual("a") })
|
||||
nValueMap = nValueMap.toContain.inAnyOrder.only.entries(KeyValue(1, null), KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.only.entries(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.only.entries(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
starMap = starMap.toContain.inAnyOrder.only.entries(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
|
||||
/// ------------- shortcuts -----------------------------------------------------------------
|
||||
|
||||
map = map.toContainOnly(KeyValue(1) { toEqual("a") })
|
||||
subMap = subMap.toContainOnly(KeyValue(1) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.toContainOnly(KeyValue(1) { toEqual("a") })
|
||||
nValueMap = nValueMap.toContainOnly(KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.toContainOnly(KeyValue(1) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.toContainOnly(KeyValue(1) { toEqual("a") })
|
||||
starMap = starMap.toContainOnly(KeyValue(1) { toEqual("a") })
|
||||
|
||||
map = map.toContainOnly(KeyValue(1) { toEqual("a") })
|
||||
subMap = subMap.toContainOnly(KeyValue(1) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.toContainOnly(KeyValue(1) { toEqual("a") })
|
||||
nValueMap = nValueMap.toContainOnly(KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.toContainOnly(KeyValue(1) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.toContainOnly(KeyValue(1) { toEqual("a") })
|
||||
starMap = starMap.toContainOnly(KeyValue(1) { toEqual("a") })
|
||||
|
||||
map = map.toContainOnly(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
subMap = subMap.toContainOnly(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nKeyMap = nKeyMap.toContainOnly(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nValueMap = nValueMap.toContainOnly(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nKeyValueMap = nKeyValueMap.toContainOnly(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.toContainOnly(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
starMap = starMap.toContainOnly(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
|
||||
nKeyMap = nKeyMap.toContainOnly(KeyValue(null) { toEqual("a") })
|
||||
nValueMap = nValueMap.toContainOnly(KeyValue(1.2, null))
|
||||
nKeyValueMap = nKeyValueMap.toContainOnly(KeyValue(null) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.toContainOnly(KeyValue(null, null))
|
||||
ronKeyValueMap = ronKeyValueMap.toContainOnly(KeyValue(null) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.toContainOnly(KeyValue(null, null))
|
||||
starMap = starMap.toContainOnly(KeyValue(null) { toEqual("a") })
|
||||
starMap = starMap.toContainOnly(KeyValue(null, null))
|
||||
|
||||
nKeyMap = nKeyMap.toContainOnly(KeyValue(null) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.toContainOnly(KeyValue(null) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.toContainOnly(KeyValue(null) { toEqual("a") })
|
||||
starMap = starMap.toContainOnly(KeyValue(null) { toEqual("a") })
|
||||
|
||||
nKeyMap = nKeyMap.toContainOnly(KeyValue(null) { toEqual("a") })
|
||||
nValueMap = nValueMap.toContainOnly(KeyValue(1, null), KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.toContainOnly(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.toContainOnly(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
starMap = starMap.toContainOnly(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,153 @@
|
||||
package ch.tutteli.atrium.api.fluent.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.specs.*
|
||||
import ch.tutteli.atrium.specs.integration.mfun2
|
||||
import org.spekframework.spek2.Spek
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.MapToContainInAnyOrderOnlyKeyValuePairsExpectationsSpec.Companion as C
|
||||
|
||||
class MapToContainInAnyOrderOnlyKeyValuePairsExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
}) {
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapToContainInAnyOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
functionDescription to C::toContainKeyValuePairs,
|
||||
(functionDescription to C::toContainKeyValuePairsNullable).withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.MapToContainInAnyOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
mfun2<String, Int, Int>(Expect<Map<out String, Int>>::toContainOnly),
|
||||
mfun2<String?, Int?, Int?>(Expect<Map<out String?, Int?>>::toContainOnly).withNullableSuffix(),
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
companion object : MapToContainSpecBase() {
|
||||
val functionDescription = "$toContain.$inAnyOrder.$only.$keyValuePair/$keyValuePairs"
|
||||
|
||||
private fun toContainKeyValuePairs(
|
||||
expect: Expect<Map<out String, Int>>,
|
||||
a: Pair<String, Int>,
|
||||
aX: Array<out Pair<String, Int>>
|
||||
): Expect<Map<out String, Int>> =
|
||||
if (aX.isEmpty()) expect.toContain.inAnyOrder.only.entry(a)
|
||||
else expect.toContain.inAnyOrder.only.entries(a, *aX)
|
||||
|
||||
private fun toContainKeyValuePairsNullable(
|
||||
expect: Expect<Map<out String?, Int?>>,
|
||||
a: Pair<String?, Int?>,
|
||||
aX: Array<out Pair<String?, Int?>>
|
||||
): Expect<Map<out String?, Int?>> =
|
||||
if (aX.isEmpty()) expect.toContain.inAnyOrder.only.entry(a)
|
||||
else expect.toContain.inAnyOrder.only.entries(a, *aX)
|
||||
}
|
||||
|
||||
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
private fun ambiguityTest() {
|
||||
var map: Expect<Map<Number, CharSequence>> = notImplemented()
|
||||
var subMap: Expect<LinkedHashMap<out Number, String>> = notImplemented()
|
||||
var nKeyMap: Expect<Map<Number?, CharSequence>> = notImplemented()
|
||||
var nValueMap: Expect<Map<Number, CharSequence?>> = notImplemented()
|
||||
var nKeyValueMap: Expect<Map<Number?, CharSequence?>> = notImplemented()
|
||||
var ronKeyValueMap: Expect<Map<out Number?, CharSequence?>> = notImplemented()
|
||||
var starMap: Expect<Map<*, *>> = notImplemented()
|
||||
|
||||
map = map.toContain.inAnyOrder.only.entry(1 to "a")
|
||||
subMap = subMap.toContain.inAnyOrder.only.entry(1 to "a")
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.only.entry(1 to "a")
|
||||
nValueMap = nValueMap.toContain.inAnyOrder.only.entry(1 to "a")
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.only.entry(1 to "a")
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.only.entry(1 to "a")
|
||||
starMap = starMap.toContain.inAnyOrder.only.entry(1 to "a")
|
||||
|
||||
map = map.toContain.inAnyOrder.only.entries(1 to "a")
|
||||
subMap = subMap.toContain.inAnyOrder.only.entries(1 to "a")
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.only.entries(1 to "a")
|
||||
nValueMap = nValueMap.toContain.inAnyOrder.only.entries(1 to "a")
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.only.entries(1 to "a")
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.only.entries(1 to "a")
|
||||
starMap = starMap.toContain.inAnyOrder.only.entries(1 to "a")
|
||||
|
||||
map = map.toContain.inAnyOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
subMap = subMap.toContain.inAnyOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
nValueMap = nValueMap.toContain.inAnyOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
starMap = starMap.toContain.inAnyOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.only.entry(null to "a")
|
||||
nValueMap = nValueMap.toContain.inAnyOrder.only.entry(1.2 to null)
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.only.entry(null to null)
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.only.entry(null to null)
|
||||
starMap = starMap.toContain.inAnyOrder.only.entry(null to null)
|
||||
|
||||
nKeyMap = nKeyMap.toContain.inAnyOrder.only.entries(null to "a", 1 to "b")
|
||||
nValueMap = nValueMap.toContain.inAnyOrder.only.entries(1 to null)
|
||||
nKeyValueMap = nKeyValueMap.toContain.inAnyOrder.only.entries((null to "a"), null to null, 1 to null)
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inAnyOrder.only.entries((null to "a"), null to null, 1 to null)
|
||||
starMap = starMap.toContain.inAnyOrder.only.entries((null to "a"), null to null, 1 to null)
|
||||
|
||||
|
||||
/// ------------- shortcuts -----------------------------------------------------------------
|
||||
|
||||
map = map.toContainOnly(1 to "a")
|
||||
subMap = subMap.toContainOnly(1 to "a")
|
||||
nKeyMap = nKeyMap.toContainOnly(1 to "a")
|
||||
nValueMap = nValueMap.toContainOnly(1 to "a")
|
||||
nKeyValueMap = nKeyValueMap.toContainOnly(1 to "a")
|
||||
ronKeyValueMap = ronKeyValueMap.toContainOnly(1 to "a")
|
||||
starMap = starMap.toContainOnly(1 to "a")
|
||||
|
||||
map = map.toContainOnly(1 to "a")
|
||||
subMap = subMap.toContainOnly(1 to "a")
|
||||
nKeyMap = nKeyMap.toContainOnly(1 to "a")
|
||||
nValueMap = nValueMap.toContainOnly(1 to "a")
|
||||
nKeyValueMap = nKeyValueMap.toContainOnly(1 to "a")
|
||||
ronKeyValueMap = ronKeyValueMap.toContainOnly(1 to "a")
|
||||
starMap = starMap.toContainOnly(1 to "a")
|
||||
|
||||
map = map.toContainOnly(1 as Number to "a", 1.2 to "b")
|
||||
subMap = subMap.toContainOnly(1 as Number to "a", 1.2 to "b")
|
||||
nKeyMap = nKeyMap.toContainOnly(1 as Number to "a", 1.2 to "b")
|
||||
nValueMap = nValueMap.toContainOnly(1 as Number to "a", 1.2 to "b")
|
||||
nKeyValueMap = nKeyValueMap.toContainOnly(1 as Number to "a", 1.2 to "b")
|
||||
ronKeyValueMap = ronKeyValueMap.toContainOnly(1 as Number to "a", 1.2 to "b")
|
||||
starMap = starMap.toContainOnly(1 as Number to "a", 1.2 to "b")
|
||||
|
||||
nKeyMap = nKeyMap.toContainOnly(null to "a")
|
||||
nValueMap = nValueMap.toContainOnly(1.2 to null)
|
||||
nKeyValueMap = nKeyValueMap.toContainOnly(null to null)
|
||||
ronKeyValueMap = ronKeyValueMap.toContainOnly(null to "a")
|
||||
starMap = starMap.toContainOnly(null to "a")
|
||||
|
||||
nKeyMap = nKeyMap.toContainOnly(null to "a")
|
||||
nValueMap = nValueMap.toContainOnly(1.2 to null, 1 to null)
|
||||
nKeyValueMap = nKeyValueMap.toContainOnly(null to "a", null to null, 1 to null)
|
||||
ronKeyValueMap = ronKeyValueMap.toContainOnly(null to "a", null to null, 1 to null)
|
||||
starMap = starMap.toContainOnly(null to "a", null to null, 1 to null)
|
||||
}
|
||||
}
|
||||
@@ -5,15 +5,15 @@ import ch.tutteli.atrium.logic.creating.typeutils.MapLike
|
||||
import ch.tutteli.atrium.specs.notImplemented
|
||||
import ch.tutteli.atrium.specs.withNullableSuffix
|
||||
import org.spekframework.spek2.Spek
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.MapContainsInOrderOnlyEntriesOfExpectationsSpec.Companion as C
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.MapToContainInOrderOnlyEntriesOfExpectationsSpec.Companion as C
|
||||
|
||||
class MapContainsInOrderOnlyEntriesOfExpectationsSpec : Spek({
|
||||
class MapToContainInOrderOnlyEntriesOfExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
}) {
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapContainsInOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
functionDescription to C::containsKeyValuePairs,
|
||||
(functionDescription to C::containsKeyValuePairsNullable).withNullableSuffix(),
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapToContainInOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
functionDescription to C::toContainKeyValuePairs,
|
||||
(functionDescription to C::toContainKeyValuePairsNullable).withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
@@ -21,13 +21,13 @@ class MapContainsInOrderOnlyEntriesOfExpectationsSpec : Spek({
|
||||
ch.tutteli.atrium.specs.integration.MapLikeToIterablePairSpec<Map<String, Int>>(
|
||||
functionDescription,
|
||||
mapOf("a" to 1),
|
||||
{ input -> contains.inOrder.only.entriesOf(input) }
|
||||
{ input -> toContain.inOrder.only.entriesOf(input) }
|
||||
)
|
||||
|
||||
companion object : MapContainsSpecBase() {
|
||||
val functionDescription = "$contains.$inOrder.$only.$entriesOf"
|
||||
companion object : MapToContainSpecBase() {
|
||||
val functionDescription = "$toContain.$inOrder.$only.$entriesOf"
|
||||
|
||||
private fun containsKeyValuePairs(
|
||||
private fun toContainKeyValuePairs(
|
||||
expect: Expect<Map<out String, Int>>,
|
||||
a: Pair<String, Int>,
|
||||
aX: Array<out Pair<String, Int>>
|
||||
@@ -37,15 +37,15 @@ class MapContainsInOrderOnlyEntriesOfExpectationsSpec : Spek({
|
||||
} else {
|
||||
mapOf(a, *aX)
|
||||
}
|
||||
return expect.contains.inOrder.only.entriesOf(mapLike)
|
||||
return expect.toContain.inOrder.only.entriesOf(mapLike)
|
||||
}
|
||||
|
||||
private fun containsKeyValuePairsNullable(
|
||||
private fun toContainKeyValuePairsNullable(
|
||||
expect: Expect<Map<out String?, Int?>>,
|
||||
a: Pair<String?, Int?>,
|
||||
aX: Array<out Pair<String?, Int?>>
|
||||
): Expect<Map<out String?, Int?>> =
|
||||
expect.contains.inOrder.only.entriesOf(arrayOf(a, *aX))
|
||||
expect.toContain.inOrder.only.entriesOf(arrayOf(a, *aX))
|
||||
}
|
||||
|
||||
|
||||
@@ -60,12 +60,12 @@ class MapContainsInOrderOnlyEntriesOfExpectationsSpec : Spek({
|
||||
var ronKeyValueMap: Expect<Map<out Number?, CharSequence?>> = notImplemented()
|
||||
var starMap: Expect<Map<*, *>> = notImplemented()
|
||||
|
||||
map = map.contains.inOrder.only.entriesOf(listOf(1 to "a"))
|
||||
subMap = subMap.contains.inOrder.only.entriesOf(listOf(1 to "a"))
|
||||
nKeyMap = nKeyMap.contains.inOrder.only.entriesOf(listOf(1 to "a"))
|
||||
nValueMap = nValueMap.contains.inOrder.only.entriesOf(listOf(1 to "a"))
|
||||
nKeyValueMap = nKeyValueMap.contains.inOrder.only.entriesOf(listOf(1 to "a"))
|
||||
ronKeyValueMap = ronKeyValueMap.contains.inOrder.only.entriesOf(listOf(1 to "a"))
|
||||
starMap = starMap.contains.inOrder.only.entriesOf(listOf(1 to "a"))
|
||||
map = map.toContain.inOrder.only.entriesOf(listOf(1 to "a"))
|
||||
subMap = subMap.toContain.inOrder.only.entriesOf(listOf(1 to "a"))
|
||||
nKeyMap = nKeyMap.toContain.inOrder.only.entriesOf(listOf(1 to "a"))
|
||||
nValueMap = nValueMap.toContain.inOrder.only.entriesOf(listOf(1 to "a"))
|
||||
nKeyValueMap = nKeyValueMap.toContain.inOrder.only.entriesOf(listOf(1 to "a"))
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inOrder.only.entriesOf(listOf(1 to "a"))
|
||||
starMap = starMap.toContain.inOrder.only.entriesOf(listOf(1 to "a"))
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
package ch.tutteli.atrium.api.fluent.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.logic.utils.mapArguments
|
||||
import ch.tutteli.atrium.specs.notImplemented
|
||||
import ch.tutteli.atrium.specs.withNullableSuffix
|
||||
import org.spekframework.spek2.Spek
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.MapToContainInOrderOnlyKeyValueExpectationsSpec.Companion as C
|
||||
|
||||
class MapToContainInOrderOnlyKeyValueExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
}) {
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapToContainInOrderOnlyKeyValueExpectationsSpec(
|
||||
functionDescription to C::toContainKeyValues,
|
||||
(functionDescription to C::toContainKeyValuesNullable).withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
companion object : MapToContainSpecBase() {
|
||||
val functionDescription = "$toContain.$inOrder.$only.$keyValue/$keyValues"
|
||||
|
||||
private fun toContainKeyValues(
|
||||
expect: Expect<Map<out String, Int>>,
|
||||
a: Pair<String, Expect<Int>.() -> Unit>,
|
||||
aX: Array<out Pair<String, Expect<Int>.() -> Unit>>
|
||||
) = mapArguments(a, aX).to { KeyValue(it.first, it.second) }.let { (first, others) ->
|
||||
if (others.isEmpty()) expect.toContain.inOrder.only.entry(first)
|
||||
else expect.toContain.inOrder.only.entries(first, *others)
|
||||
}
|
||||
|
||||
private fun toContainKeyValuesNullable(
|
||||
expect: Expect<Map<out String?, Int?>>,
|
||||
a: Pair<String?, (Expect<Int>.() -> Unit)?>,
|
||||
aX: Array<out Pair<String?, (Expect<Int>.() -> Unit)?>>
|
||||
) = mapArguments(a, aX).to { KeyValue(it.first, it.second) }.let { (first, others) ->
|
||||
if (others.isEmpty()) expect.toContain.inOrder.only.entry(first)
|
||||
else expect.toContain.inOrder.only.entries(first, *others)
|
||||
}
|
||||
}
|
||||
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
private fun ambiguityTest() {
|
||||
var map: Expect<Map<Number, CharSequence>> = notImplemented()
|
||||
var subMap: Expect<LinkedHashMap<out Number, String>> = notImplemented()
|
||||
var nKeyMap: Expect<Map<Number?, CharSequence>> = notImplemented()
|
||||
var nValueMap: Expect<Map<Number, CharSequence?>> = notImplemented()
|
||||
var nKeyValueMap: Expect<Map<Number?, CharSequence?>> = notImplemented()
|
||||
var ronKeyValueMap: Expect<Map<out Number?, CharSequence?>> = notImplemented()
|
||||
var starMap: Expect<Map<*, *>> = notImplemented()
|
||||
|
||||
map = map.toContain.inOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
subMap = subMap.toContain.inOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.toContain.inOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
nValueMap = nValueMap.toContain.inOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.toContain.inOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
starMap = starMap.toContain.inOrder.only.entry(KeyValue(1) { toEqual("a") })
|
||||
|
||||
map = map.toContain.inOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
subMap = subMap.toContain.inOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.toContain.inOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
nValueMap = nValueMap.toContain.inOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.toContain.inOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
starMap = starMap.toContain.inOrder.only.entries(KeyValue(1) { toEqual("a") })
|
||||
|
||||
map = map.toContain.inOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
subMap = subMap.toContain.inOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nKeyMap = nKeyMap.toContain.inOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nValueMap = nValueMap.toContain.inOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
nKeyValueMap = nKeyValueMap.toContain.inOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
starMap = starMap.toContain.inOrder.only.entries(
|
||||
KeyValue(1 as Number) { toEqual("a") },
|
||||
KeyValue(1.2) { toEqual("b") }
|
||||
)
|
||||
|
||||
nKeyMap = nKeyMap.toContain.inOrder.only.entry(KeyValue(null) { toEqual("a") })
|
||||
nKeyMap = nKeyMap.toContain.inOrder.only.entry(KeyValue(null) { toEqual("a") })
|
||||
nValueMap = nValueMap.toContain.inOrder.only.entry(KeyValue(1.2, null))
|
||||
nKeyValueMap = nKeyValueMap.toContain.inOrder.only.entry(KeyValue(null) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.toContain.inOrder.only.entry(KeyValue(null, null))
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inOrder.only.entry(KeyValue(null) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inOrder.only.entry(KeyValue(null, null))
|
||||
starMap = starMap.toContain.inOrder.only.entry(KeyValue(null) { toEqual("a") })
|
||||
starMap = starMap.toContain.inOrder.only.entry(KeyValue(null, null))
|
||||
|
||||
nKeyMap = nKeyMap.toContain.inOrder.only.entries(KeyValue(null) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.toContain.inOrder.only.entries(KeyValue(null) { toEqual("a") })
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inOrder.only.entries(KeyValue(null) { toEqual("a") })
|
||||
starMap = starMap.toContain.inOrder.only.entries(KeyValue(null) { toEqual("a") })
|
||||
|
||||
nKeyMap = nKeyMap.toContain.inOrder.only.entries(KeyValue(null) { toEqual("a") })
|
||||
nValueMap = nValueMap.toContain.inOrder.only.entries(KeyValue(1, null), KeyValue(1) { toEqual("a") })
|
||||
nKeyValueMap = nKeyValueMap.toContain.inOrder.only.entries(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inOrder.only.entries(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
starMap = starMap.toContain.inOrder.only.entries(
|
||||
KeyValue(null) { toEqual("a") },
|
||||
KeyValue(null, null),
|
||||
KeyValue(1, null)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,107 @@
|
||||
package ch.tutteli.atrium.api.fluent.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.specs.notImplemented
|
||||
import ch.tutteli.atrium.specs.withNullableSuffix
|
||||
import org.spekframework.spek2.Spek
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.MapToContainInOrderOnlyKeyValuePairsExpectationsSpec.Companion as C
|
||||
|
||||
class MapToContainInOrderOnlyKeyValuePairsExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
}) {
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapToContainInOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
functionDescription to C::toContainKeyValuePairs,
|
||||
(functionDescription to C::toContainKeyValuePairsNullable).withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
companion object : MapToContainSpecBase() {
|
||||
val functionDescription = "$toContain.$inOrder.$only.$keyValuePair/$keyValuePairs"
|
||||
|
||||
private fun toContainKeyValuePairs(
|
||||
expect: Expect<Map<out String, Int>>,
|
||||
a: Pair<String, Int>,
|
||||
aX: Array<out Pair<String, Int>>
|
||||
): Expect<Map<out String, Int>> =
|
||||
if (aX.isEmpty()) expect.toContain.inOrder.only.entry(a)
|
||||
else expect.toContain.inOrder.only.entries(a, *aX)
|
||||
|
||||
private fun toContainKeyValuePairsNullable(
|
||||
expect: Expect<Map<out String?, Int?>>,
|
||||
a: Pair<String?, Int?>,
|
||||
aX: Array<out Pair<String?, Int?>>
|
||||
): Expect<Map<out String?, Int?>> =
|
||||
if (aX.isEmpty()) expect.toContain.inOrder.only.entry(a)
|
||||
else expect.toContain.inOrder.only.entries(a, *aX)
|
||||
}
|
||||
|
||||
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
private fun ambiguityTest() {
|
||||
var map: Expect<Map<Number, CharSequence>> = notImplemented()
|
||||
var subMap: Expect<LinkedHashMap<out Number, String>> = notImplemented()
|
||||
var nKeyMap: Expect<Map<Number?, CharSequence>> = notImplemented()
|
||||
var nValueMap: Expect<Map<Number, CharSequence?>> = notImplemented()
|
||||
var nKeyValueMap: Expect<Map<Number?, CharSequence?>> = notImplemented()
|
||||
var ronKeyValueMap: Expect<Map<out Number?, CharSequence?>> = notImplemented()
|
||||
var starMap: Expect<Map<*, *>> = notImplemented()
|
||||
|
||||
map = map.toContain.inOrder.only.entry(1 to "a")
|
||||
subMap = subMap.toContain.inOrder.only.entry(1 to "a")
|
||||
nKeyMap = nKeyMap.toContain.inOrder.only.entry(1 to "a")
|
||||
nValueMap = nValueMap.toContain.inOrder.only.entry(1 to "a")
|
||||
nKeyValueMap = nKeyValueMap.toContain.inOrder.only.entry(1 to "a")
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inOrder.only.entry(1 to "a")
|
||||
starMap = starMap.toContain.inOrder.only.entry(1 to "a")
|
||||
|
||||
map = map.toContain.inOrder.only.entries(1 to "a")
|
||||
subMap = subMap.toContain.inOrder.only.entries(1 to "a")
|
||||
nKeyMap = nKeyMap.toContain.inOrder.only.entries(1 to "a")
|
||||
nValueMap = nValueMap.toContain.inOrder.only.entries(1 to "a")
|
||||
nKeyValueMap = nKeyValueMap.toContain.inOrder.only.entries(1 to "a")
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inOrder.only.entries(1 to "a")
|
||||
starMap = starMap.toContain.inOrder.only.entries(1 to "a")
|
||||
|
||||
map = map.toContain.inOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
subMap = subMap.toContain.inOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
nKeyMap = nKeyMap.toContain.inOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
nValueMap = nValueMap.toContain.inOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
nKeyValueMap = nKeyValueMap.toContain.inOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
starMap = starMap.toContain.inOrder.only.entries(
|
||||
1 as Number to "a",
|
||||
1.2 to "b"
|
||||
)
|
||||
|
||||
nKeyMap = nKeyMap.toContain.inOrder.only.entry(null to "a")
|
||||
nValueMap = nValueMap.toContain.inOrder.only.entry(1.2 to null)
|
||||
nKeyValueMap = nKeyValueMap.toContain.inOrder.only.entry(null to null)
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inOrder.only.entry(null to null)
|
||||
starMap = starMap.toContain.inOrder.only.entry(null to null)
|
||||
|
||||
nKeyMap = nKeyMap.toContain.inOrder.only.entries(null to "a", 1 to "b")
|
||||
nValueMap = nValueMap.toContain.inOrder.only.entries(1 to null)
|
||||
nKeyValueMap = nKeyValueMap.toContain.inOrder.only.entries((null to "a"), null to null, 1 to null)
|
||||
ronKeyValueMap = ronKeyValueMap.toContain.inOrder.only.entries((null to "a"), null to null, 1 to null)
|
||||
starMap = starMap.toContain.inOrder.only.entries((null to "a"), null to null, 1 to null)
|
||||
}
|
||||
}
|
||||
@@ -7,11 +7,11 @@ import kotlin.reflect.KProperty
|
||||
import kotlin.reflect.KFunction2
|
||||
import kotlin.reflect.KFunction3
|
||||
|
||||
abstract class MapContainsSpecBase {
|
||||
private val containsProp: KProperty<*> = Expect<Map<*, *>>::contains
|
||||
protected val contains = containsProp.name
|
||||
protected val containsEntriesOf = Expect<Map<*, *>>::containsEntriesOf.name
|
||||
protected val containsOnlyEntriesOf = Expect<Map<*, *>>::containsOnlyEntriesOf.name
|
||||
abstract class MapToContainSpecBase {
|
||||
private val toContainProp: KProperty<*> = Expect<Map<*, *>>::toContain
|
||||
protected val toContain = toContainProp.name
|
||||
protected val toContainEntriesOf = Expect<Map<*, *>>::toContainEntriesOf.name
|
||||
protected val toContainOnlyEntriesOf = Expect<Map<*, *>>::toContainOnlyEntriesOf.name
|
||||
|
||||
//@formatter:off
|
||||
protected val inAnyOrder = MapLikeContains.EntryPointStep<String, Int, Map<String, Int>, NoOpSearchBehaviour>::inAnyOrder.name
|
||||
@@ -59,7 +59,7 @@ class ListExpectationSamples {
|
||||
.get(0) {
|
||||
toBeGreaterThan(2) // fails
|
||||
toBeLessThan(0) // still evaluated even though `isGreaterThan(2)` already fails,
|
||||
// use the `.get(index).` if you want a fail fast behaviour
|
||||
// use `.get(index).` if you want a fail fast behaviour
|
||||
}
|
||||
}.messageContains(
|
||||
"is greater than: 2",
|
||||
|
||||
@@ -0,0 +1,255 @@
|
||||
package ch.tutteli.atrium.api.fluent.en_GB.samples
|
||||
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.*
|
||||
import ch.tutteli.atrium.api.verbs.internal.expect
|
||||
import kotlin.test.Test
|
||||
|
||||
class MapExpectationSamples {
|
||||
|
||||
@Test
|
||||
fun toContainBuilder() {
|
||||
expect(mapOf(1 to "a")).toContain.inAnyOrder.entries(1 to "a")
|
||||
|
||||
fails { // because the map does not contain key 1 with value "b"
|
||||
expect(mapOf(1 to "a")).toContain.inAnyOrder.entries(1 to "b")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun toContainPair() {
|
||||
expect(mapOf(1 to "a")).toContain(1 to "a")
|
||||
|
||||
fails { // because the map does not contain key 1 with value "b"
|
||||
expect(mapOf(1 to "a")).toContain(1 to "b")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun toContainOnlyPair() {
|
||||
expect(mapOf(1 to "a")).toContainOnly(1 to "a")
|
||||
|
||||
fails { // because the map contains key 2 with value "b" in addition
|
||||
expect(mapOf(1 to "a", 2 to "b")).toContainOnly(1 to "a")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun toContainKeyValue() {
|
||||
expect(mapOf(1 to "a"))
|
||||
.toContain(KeyValue(1) { // subject inside this block is of type String (actually "a")
|
||||
toEqual("a")
|
||||
})
|
||||
|
||||
fails {
|
||||
expect(mapOf(1 to "a"))
|
||||
.toContain(KeyValue(1) { // subject inside this block is of type String (actually "a")
|
||||
toEqual("b") // fails because "a" is not equal to "b"
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun toContainOnlyKeyValue() {
|
||||
expect(mapOf(1 to "a"))
|
||||
.toContainOnly(KeyValue(1) { // subject inside this block is of type String (actually "a")
|
||||
toEqual("a")
|
||||
})
|
||||
|
||||
fails {
|
||||
expect(mapOf(1 to "a", 2 to "b"))
|
||||
.toContainOnly(KeyValue(1) { // subject inside this block is of type String (actually "a")
|
||||
toEqual("a")
|
||||
}) // fails because the map contains key 2 with value "b" in addition
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun toContainEntriesOf() {
|
||||
expect(mapOf(1 to "a")).toContainEntriesOf(mapOf(1 to "a"))
|
||||
|
||||
fails { // because the map does not contain entry with key 1 and value "b"
|
||||
expect(mapOf(1 to "a")).toContainEntriesOf(mapOf(1 to "b"))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun toContainOnlyEntriesOf() {
|
||||
expect(mapOf(1 to "a")).toContainOnlyEntriesOf(mapOf(1 to "a"))
|
||||
|
||||
fails { // because the map contains key 2 with value "b" in addition
|
||||
expect(mapOf(1 to "a", 2 to "b"))
|
||||
.toContainOnlyEntriesOf(mapOf(1 to "a"))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun toContainKey() {
|
||||
expect(mapOf(1 to "a")).toContainKey(1)
|
||||
|
||||
fails { // because the map does not contain a key that equals 2
|
||||
expect(mapOf(1 to "a")).toContainKey(2)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun notToContainKey() {
|
||||
expect(mapOf(1 to "a")).notToContainKey(2)
|
||||
|
||||
fails { // because the map contains a key which equals 1
|
||||
expect(mapOf(1 to "a")).notToContainKey(1)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getExistingFeature() {
|
||||
expect(mapOf(1 to "a"))
|
||||
.getExisting(1) // subject is of type String (actually "a")
|
||||
.toEqual("a")
|
||||
|
||||
fails {
|
||||
expect(mapOf(1 to "a"))
|
||||
.getExisting(1) // subject is of type String (actually "a")
|
||||
.toEqual("b") // fails because "a" is not equal to "b"
|
||||
}
|
||||
|
||||
fails {
|
||||
expect(mapOf(1 to "a"))
|
||||
.getExisting(2) // expectation fails because key 2 does not exist
|
||||
.toEqual("a") // not reported, use `getExisting(key) { ... }`
|
||||
// if you want that all expectations are evaluated
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun getExisting() {
|
||||
expect(mapOf(1 to "a"))
|
||||
.getExisting(1) { // subject inside this block is of type String (actually "a")
|
||||
toEqual("a")
|
||||
}
|
||||
|
||||
fails {
|
||||
expect(mapOf(1 to "a"))
|
||||
.getExisting(1) { // subject inside this block is of type String (actually "a")
|
||||
toEqual("b") // fails because "a" is not equal to "b"
|
||||
}
|
||||
}
|
||||
|
||||
fails {
|
||||
// all expectations are evaluated inside an expectation group block; for more details:
|
||||
// https://github.com/robstoll/atrium#define-single-assertions-or-assertion-groups
|
||||
|
||||
expect(mapOf(1 to "a"))
|
||||
.getExisting(2) { // fails because key 2 does not exist
|
||||
toEqual("a") // still evaluated because we use an expectation group block
|
||||
// use `.getExisting(key).` if you want a fail fast behaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun keysFeature() {
|
||||
expect(mapOf(1 to "a"))
|
||||
.keys // subject is now of type Set<Int> (containing 1)
|
||||
.toContain(1)
|
||||
|
||||
fails {
|
||||
expect(mapOf(1 to "a"))
|
||||
.keys // subject is now of type Set<Int> (containing 1)
|
||||
.toContain(2) // fails because 1 is not equal to 2
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun keys() {
|
||||
expect(mapOf(1 to "a"))
|
||||
.keys { // subject inside this block is of type Set<Int> (containing 1)
|
||||
toEqual(setOf(1))
|
||||
}
|
||||
|
||||
fails {
|
||||
// all expectations are evaluated inside an expectation group block; for more details:
|
||||
// https://github.com/robstoll/atrium#define-single-assertions-or-assertion-groups
|
||||
|
||||
expect(mapOf(1 to "a"))
|
||||
.keys { // subject inside this block is of type Set<Int> (containing 1)
|
||||
toEqual(setOf(2)) // fails because 1 is not equal to 2
|
||||
toHaveSize(3) // still evaluated because we use an expectation group block
|
||||
// use `.keys.` if you want a fail fast behaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun valuesFeature() {
|
||||
expect(mapOf(1 to "a"))
|
||||
.values // subject is now of type Collection<String> (containing "a")
|
||||
.toContain("a")
|
||||
|
||||
fails {
|
||||
expect(mapOf(1 to "a"))
|
||||
.values // subject is now of type Collection<String> (containing "a")
|
||||
.toContain("b") // fails because "a" is not equal to "b"
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun values() {
|
||||
expect(mapOf(1 to "a"))
|
||||
.values { // subject inside this block is of type Collection<String> (containing "a")
|
||||
toEqual(setOf("a"))
|
||||
}
|
||||
|
||||
fails {
|
||||
// all expectations are evaluated inside an expectation group block; for more details:
|
||||
// https://github.com/robstoll/atrium#define-single-assertions-or-assertion-groups
|
||||
|
||||
expect(mapOf(1 to "a"))
|
||||
.values { // subject inside this block is of type Collection<String> (containing <"a">)
|
||||
toEqual(setOf("b")) // fails because "a" is not equal to "b"
|
||||
// use `.values.` if you want a fail fast behaviour
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun asEntriesFeature() {
|
||||
expect(mapOf(1 to "a")).asEntries()
|
||||
.toEqual(mapOf(1 to "a").entries)
|
||||
|
||||
fails { // because <1,"a"> is not equal to <1,"b">
|
||||
expect(mapOf(1 to "a")).asEntries()
|
||||
.toEqual(mapOf(1 to "b").entries)
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun asEntries() {
|
||||
expect(mapOf(1 to "a")).asEntries { // subject inside this block is of type Map.Entry<Int, String> (actually <1,"a">)
|
||||
toEqual(mapOf(1 to "a").entries)
|
||||
}
|
||||
|
||||
fails {
|
||||
expect(mapOf(1 to "a")).asEntries { // subject inside this block is of type Map.Entry<Int, String> (actually <1,"a">)
|
||||
toEqual(mapOf(1 to "b").entries) // fails because <1,"a"> is not equal to <1,"b">
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun toBeEmpty() {
|
||||
expect(emptyMap<Int, String>()).isEmpty()
|
||||
|
||||
fails { // because the map is not empty
|
||||
expect(mapOf(1 to "a")).isEmpty()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun notToBeEmpty() {
|
||||
expect(mapOf(1 to "a")).isNotEmpty()
|
||||
|
||||
fails { // because the map is empty
|
||||
expect(emptyMap<Int, String>()).isNotEmpty()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,13 +14,13 @@ class MapContainsInAnyOrderEntriesOfExpectationsSpec : Spek({
|
||||
include(BuilderMapLikeToIterablePairSpec)
|
||||
include(ShortcutMapLikeToIterablePairSpec)
|
||||
}) {
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapContainsInAnyOrderKeyValuePairsExpectationsSpec(
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapToContainInAnyOrderKeyValuePairsExpectationsSpec(
|
||||
containsKeyValuePair_s to C::containsKeyValuePairs,
|
||||
(containsKeyValuePair_s to C::containsKeyValuePairsNullable).withNullableSuffix(),
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.MapContainsInAnyOrderKeyValuePairsExpectationsSpec(
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.MapToContainInAnyOrderKeyValuePairsExpectationsSpec(
|
||||
mfun2<String, Int, Int>(C::containsEntriesOf),
|
||||
mfun2<String?, Int?, Int?>(C::containsEntriesOf).withNullableSuffix(),
|
||||
"[Atrium][Shortcut] "
|
||||
|
||||
@@ -12,13 +12,13 @@ class MapContainsInAnyOrderKeyValueExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
}) {
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapContainsInAnyOrderKeyValueExpectationsSpec(
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapToContainInAnyOrderKeyValueExpectationsSpec(
|
||||
containsKeyValue_s to C::containsKeyValues,
|
||||
(containsKeyValue_s to C::containsKeyValuesNullable).withNullableSuffix(),
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.MapContainsInAnyOrderKeyValueExpectationsSpec(
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.MapToContainInAnyOrderKeyValueExpectationsSpec(
|
||||
mfun2<String, Int, Expect<Int>.() -> Unit>(C::contains),
|
||||
mfun2<String?, Int?, (Expect<Int>.() -> Unit)?>(C::contains).withNullableSuffix(),
|
||||
"[Atrium][Shortcut] "
|
||||
|
||||
@@ -11,13 +11,13 @@ class MapContainsInAnyOrderKeyValuePairsExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
}) {
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapContainsInAnyOrderKeyValuePairsExpectationsSpec(
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapToContainInAnyOrderKeyValuePairsExpectationsSpec(
|
||||
containsKeyValuePair_s to C::containsKeyValuePairs,
|
||||
(containsKeyValuePair_s to C::containsKeyValuePairsNullable).withNullableSuffix(),
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.MapContainsInAnyOrderKeyValuePairsExpectationsSpec(
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.MapToContainInAnyOrderKeyValuePairsExpectationsSpec(
|
||||
mfun2<String, Int, Int>(C::contains),
|
||||
mfun2<String?, Int?, Int?>(C::contains).withNullableSuffix(),
|
||||
"[Atrium][Shortcut] "
|
||||
|
||||
@@ -15,13 +15,13 @@ class MapContainsInAnyOrderOnlyEntriesOfExpectationsSpec : Spek({
|
||||
include(ShortcutMapLikeToIterablePairSpec)
|
||||
}) {
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapContainsInAnyOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapToContainInAnyOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
containsKeyValuePair_s to C::containsKeyValuePairs,
|
||||
(containsKeyValuePair_s to C::containsKeyValuePairsNullable).withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.MapContainsInAnyOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.MapToContainInAnyOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
mfun2<String, Int, Int>(C::containsOnlyEntriesOf),
|
||||
mfun2<String?, Int?, Int?>(C::containsOnlyEntriesOf).withNullableSuffix()
|
||||
)
|
||||
|
||||
@@ -13,13 +13,13 @@ class MapContainsInAnyOrderOnlyKeyValueExpectationsSpec : Spek({
|
||||
include(ShortcutSpec)
|
||||
}) {
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapContainsInAnyOrderOnlyKeyValueExpectationsSpec(
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapToContainInAnyOrderOnlyKeyValueExpectationsSpec(
|
||||
containsKeyValue_s to C::containsKeyValues,
|
||||
(containsKeyValue_s to C::containsKeyValuesNullable).withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.MapContainsInAnyOrderOnlyKeyValueExpectationsSpec(
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.MapToContainInAnyOrderOnlyKeyValueExpectationsSpec(
|
||||
mfun2<String, Int, Expect<Int>.() -> Unit>(C::containsOnly),
|
||||
mfun2<String?, Int?, (Expect<Int>.() -> Unit)?>(C::containsOnly).withNullableSuffix(),
|
||||
"[Atrium][Shortcut] "
|
||||
|
||||
@@ -12,13 +12,13 @@ class MapContainsInAnyOrderOnlyKeyValuePairsExpectationsSpec : Spek({
|
||||
include(ShortcutSpec)
|
||||
}) {
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapContainsInAnyOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapToContainInAnyOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
containsKeyValuePair_s to C::containsKeyValuePairs,
|
||||
(containsKeyValuePair_s to C::containsKeyValuePairsNullable).withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.MapContainsInAnyOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.MapToContainInAnyOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
mfun2<String, Int, Int>(C::containsInAnyOrderOnly),
|
||||
mfun2<String?, Int?, Int?>(C::containsInAnyOrderOnly).withNullableSuffix(),
|
||||
"[Atrium][Shortcut] "
|
||||
|
||||
@@ -11,7 +11,7 @@ class MapContainsInOrderOnlyEntriesOfExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
}) {
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapContainsInOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapToContainInOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
containsKeyValuePair_s to C::containsKeyValuePairs,
|
||||
(containsKeyValuePair_s to C::containsKeyValuePairsNullable).withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
|
||||
@@ -10,7 +10,7 @@ class MapContainsInOrderOnlyKeyValueExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
}) {
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapContainsInOrderOnlyKeyValueExpectationsSpec(
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapToContainInOrderOnlyKeyValueExpectationsSpec(
|
||||
containsKeyValue_s to C::containsKeyValues,
|
||||
(containsKeyValue_s to C::containsKeyValuesNullable).withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
|
||||
@@ -10,7 +10,7 @@ class MapContainsInOrderOnlyKeyValuePairsExpectationsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
}) {
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapContainsInOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.MapToContainInOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
containsKeyValuePair_s to C::containsKeyValuePairs,
|
||||
(containsKeyValuePair_s to C::containsKeyValuePairsNullable).withNullableSuffix(),
|
||||
"[Atrium][Builder] "
|
||||
|
||||
@@ -8,7 +8,7 @@ import ch.tutteli.atrium.core.polyfills.fullName
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.reporting.Text
|
||||
import ch.tutteli.atrium.specs.*
|
||||
import ch.tutteli.atrium.specs.integration.MapLikeContainsSpecBase.Companion.separator
|
||||
import ch.tutteli.atrium.specs.integration.MapLikeToContainSpecBase.Companion.separator
|
||||
import ch.tutteli.atrium.translations.DescriptionAnyAssertion.*
|
||||
import ch.tutteli.atrium.translations.DescriptionAnyAssertion.NOT_TO_BE
|
||||
import ch.tutteli.atrium.translations.DescriptionAnyAssertion.TO_BE
|
||||
|
||||
@@ -31,7 +31,7 @@ abstract class MapAsEntriesExpectationsSpec(
|
||||
toContain.inAnyOrder.only.entries(
|
||||
{ isKeyValue("b", 2) },
|
||||
{
|
||||
key { toStartWith("a") }
|
||||
key.toStartWith("a")
|
||||
value.toBeGreaterThanOrEqualTo(1)
|
||||
}
|
||||
)
|
||||
|
||||
@@ -10,16 +10,16 @@ import org.spekframework.spek2.Spek
|
||||
import org.spekframework.spek2.style.specification.Suite
|
||||
|
||||
abstract class MapExpectationsSpec(
|
||||
containsKey: Fun1<Map<out String, *>, String>,
|
||||
containsKeyNullable: Fun1<Map<out String?, *>, String?>,
|
||||
containsNotKey: Fun1<Map<out String, *>, String>,
|
||||
containsNotKeyNullable: Fun1<Map<out String?, *>, String?>,
|
||||
toContainKey: Fun1<Map<out String, *>, String>,
|
||||
toContainKeyNullable: Fun1<Map<out String?, *>, String?>,
|
||||
notToContainKey: Fun1<Map<out String, *>, String>,
|
||||
notToContainKeyNullable: Fun1<Map<out String?, *>, String?>,
|
||||
getExistingFeature: Feature1<Map<out String, Int>, String, Int>,
|
||||
getExisting: Fun2<Map<out String, Int>, String, Expect<Int>.() -> Unit>,
|
||||
getExistingNullableFeature: Feature1<Map<out String?, Int?>, String?, Int?>,
|
||||
getExistingNullable: Fun2<Map<out String?, Int?>, String?, Expect<Int?>.() -> Unit>,
|
||||
isEmpty: Fun0<Map<*, *>>,
|
||||
isNotEmpty: Fun0<Map<*, *>>,
|
||||
toBeEmpty: Fun0<Map<*, *>>,
|
||||
notToBeEmpty: Fun0<Map<*, *>>,
|
||||
keys: Fun1<Map<out String, Int>, Expect<Set<String>>.() -> Unit>,
|
||||
keysFeature: Feature0<Map<out String, Int>, Set<String>>,
|
||||
valuesFeature: Feature0<Map<out String, Int>, Collection<Int>>,
|
||||
@@ -33,10 +33,10 @@ abstract class MapExpectationsSpec(
|
||||
|
||||
include(object : SubjectLessSpec<Map<out String, Int>>(
|
||||
describePrefix,
|
||||
containsKey.forSubjectLess("a").unchecked1(),
|
||||
containsNotKey.forSubjectLess("a").unchecked1(),
|
||||
isEmpty.forSubjectLess().unchecked1(),
|
||||
isNotEmpty.forSubjectLess().unchecked1(),
|
||||
toContainKey.forSubjectLess("a").unchecked1(),
|
||||
notToContainKey.forSubjectLess("a").unchecked1(),
|
||||
toBeEmpty.forSubjectLess().unchecked1(),
|
||||
notToBeEmpty.forSubjectLess().unchecked1(),
|
||||
keysFeature.forSubjectLess(),
|
||||
keys.forSubjectLess { this.toBeEmpty() },
|
||||
valuesFeature.forSubjectLess(),
|
||||
@@ -47,8 +47,8 @@ abstract class MapExpectationsSpec(
|
||||
|
||||
include(object : SubjectLessSpec<Map<out String?, Int?>>(
|
||||
"$describePrefix[nullable Key] ",
|
||||
containsKeyNullable.forSubjectLess(null).unchecked1(),
|
||||
containsNotKeyNullable.forSubjectLess(null).unchecked1(),
|
||||
toContainKeyNullable.forSubjectLess(null).unchecked1(),
|
||||
notToContainKeyNullable.forSubjectLess(null).unchecked1(),
|
||||
getExistingNullableFeature.forSubjectLess("a"),
|
||||
getExistingNullable.forSubjectLess("a") { toEqual(null) }
|
||||
) {})
|
||||
@@ -76,102 +76,102 @@ abstract class MapExpectationsSpec(
|
||||
val nullableFluent = expect(nullableMap)
|
||||
|
||||
val empty = DescriptionCollectionAssertion.EMPTY.getDefault()
|
||||
val containsKeyDescr = DescriptionMapLikeAssertion.CONTAINS_KEY.getDefault()
|
||||
val containsNotKeyDescr = DescriptionMapLikeAssertion.CONTAINS_NOT_KEY.getDefault()
|
||||
val toContainKeyDescr = DescriptionMapLikeAssertion.CONTAINS_KEY.getDefault()
|
||||
val notToContainKeyDescr = DescriptionMapLikeAssertion.CONTAINS_NOT_KEY.getDefault()
|
||||
val keyDoesNotExist = DescriptionMapLikeAssertion.KEY_DOES_NOT_EXIST.getDefault()
|
||||
|
||||
describeFun(containsKey, containsKeyNullable, containsNotKey, containsNotKeyNullable) {
|
||||
val containsKeyFunctions = uncheckedToNonNullable(containsKey, containsKeyNullable)
|
||||
val containsNotKeyFunctions = uncheckedToNonNullable(containsNotKey, containsNotKeyNullable)
|
||||
describeFun(toContainKey, toContainKeyNullable, notToContainKey, notToContainKeyNullable) {
|
||||
val toContainKeyFunctions = uncheckedToNonNullable(toContainKey, toContainKeyNullable)
|
||||
val notToContainKeyFunctions = uncheckedToNonNullable(notToContainKey, notToContainKeyNullable)
|
||||
|
||||
val fluent2 = expect(map as Map<out String, *>)
|
||||
|
||||
context("$map") {
|
||||
containsKeyFunctions.forEach { (name, containsKeyFun) ->
|
||||
it("$name - does not throw if the map contains the key") {
|
||||
fluent2.containsKeyFun("a")
|
||||
toContainKeyFunctions.forEach { (name, toContainKeyFun) ->
|
||||
it("$name - does not throw if the map toContain the key") {
|
||||
fluent2.toContainKeyFun("a")
|
||||
}
|
||||
|
||||
it("$name - throws an AssertionError if the map does not contain the key") {
|
||||
expect {
|
||||
fluent2.containsKeyFun("c")
|
||||
}.toThrow<AssertionError> { messageContains("$containsKeyDescr: \"c\"") }
|
||||
fluent2.toContainKeyFun("c")
|
||||
}.toThrow<AssertionError> { messageContains("$toContainKeyDescr: \"c\"") }
|
||||
}
|
||||
|
||||
it("$name - does not throw if null is passed and the map contains null as key") {
|
||||
fluent2.containsKeyFun("a")
|
||||
it("$name - does not throw if null is passed and the map toContain null as key") {
|
||||
fluent2.toContainKeyFun("a")
|
||||
}
|
||||
}
|
||||
|
||||
containsNotKeyFunctions.forEach { (name, containsNotKeyFun) ->
|
||||
notToContainKeyFunctions.forEach { (name, notToContainKeyFun) ->
|
||||
it("$name - does not throw if the map does not contain the key") {
|
||||
fluent2.containsNotKeyFun("c")
|
||||
fluent2.notToContainKeyFun("c")
|
||||
}
|
||||
|
||||
it("$name - throws an AssertionError if the map contains the key") {
|
||||
it("$name - throws an AssertionError if the map toContain the key") {
|
||||
expect {
|
||||
fluent2.containsNotKeyFun("a")
|
||||
}.toThrow<AssertionError> { messageContains("$containsNotKeyDescr: \"a\"") }
|
||||
fluent2.notToContainKeyFun("a")
|
||||
}.toThrow<AssertionError> { messageContains("$notToContainKeyDescr: \"a\"") }
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
describeFun(containsKeyNullable, containsNotKeyNullable) {
|
||||
val containsNullableKeyFun = containsKeyNullable.lambda
|
||||
val containsNotNullableKeyFun = containsNotKeyNullable.lambda
|
||||
describeFun(toContainKeyNullable, notToContainKeyNullable) {
|
||||
val toContainNullableKeyFun = toContainKeyNullable.lambda
|
||||
val notToContainNullableKeyFun = notToContainKeyNullable.lambda
|
||||
|
||||
val map2: Map<out String?, *> = mapOf("a" to 1, null to 2)
|
||||
context("$map2") {
|
||||
it("${containsKeyNullable.name} - does not throw if the map contains the key") {
|
||||
expect(map2).containsNullableKeyFun(null)
|
||||
it("${toContainKeyNullable.name} - does not throw if the map toContain the key") {
|
||||
expect(map2).toContainNullableKeyFun(null)
|
||||
}
|
||||
|
||||
it("${containsNotKeyNullable.name} - throws an AssertionError if the map contains the key") {
|
||||
it("${notToContainKeyNullable.name} - throws an AssertionError if the map toContain the key") {
|
||||
expect {
|
||||
expect(map2).containsNotNullableKeyFun(null)
|
||||
}.toThrow<AssertionError> { messageContains("$containsNotKeyDescr: null") }
|
||||
expect(map2).notToContainNullableKeyFun(null)
|
||||
}.toThrow<AssertionError> { messageContains("$notToContainKeyDescr: null") }
|
||||
}
|
||||
}
|
||||
|
||||
val map3: Map<out String?, *> = mapOf("a" to 1, "b" to 2)
|
||||
context("$map3") {
|
||||
it("${containsKeyNullable.name} - throws an AssertionError if the map does not contain the key") {
|
||||
it("${toContainKeyNullable.name} - throws an AssertionError if the map does not contain the key") {
|
||||
expect {
|
||||
expect(map3).containsNullableKeyFun(null)
|
||||
}.toThrow<AssertionError> { messageContains("$containsKeyDescr: null") }
|
||||
expect(map3).toContainNullableKeyFun(null)
|
||||
}.toThrow<AssertionError> { messageContains("$toContainKeyDescr: null") }
|
||||
}
|
||||
|
||||
it("${containsNotKeyNullable.name} - does not throw if the map does not contain the key") {
|
||||
expect(map3).containsNotNullableKeyFun(null)
|
||||
it("${notToContainKeyNullable.name} - does not throw if the map does not contain the key") {
|
||||
expect(map3).notToContainNullableKeyFun(null)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
describeFun(isEmpty, isNotEmpty) {
|
||||
val isEmptyFun = isEmpty.lambda
|
||||
val isNotEmptyFun = isNotEmpty.lambda
|
||||
describeFun(toBeEmpty, notToBeEmpty) {
|
||||
val toBeEmptyFun = toBeEmpty.lambda
|
||||
val notToBeEmptyFun = notToBeEmpty.lambda
|
||||
|
||||
val map2: Map<*, *> = mapOf<String, Int>()
|
||||
context("empty Map") {
|
||||
it("${isEmpty.name} - does not throw") {
|
||||
expect(map2).isEmptyFun()
|
||||
it("${toBeEmpty.name} - does not throw") {
|
||||
expect(map2).toBeEmptyFun()
|
||||
}
|
||||
|
||||
it("${isNotEmpty.name} - throws an AssertionError") {
|
||||
it("${notToBeEmpty.name} - throws an AssertionError") {
|
||||
expect {
|
||||
expect(map2).isNotEmptyFun()
|
||||
expect(map2).notToBeEmptyFun()
|
||||
}.toThrow<AssertionError> { messageContains("$isNotDescr: $empty") }
|
||||
}
|
||||
}
|
||||
context("$map") {
|
||||
it("${isEmpty.name} - throws an AssertionError") {
|
||||
it("${toBeEmpty.name} - throws an AssertionError") {
|
||||
expect {
|
||||
expect(map as Map<*, *>).isEmptyFun()
|
||||
expect(map as Map<*, *>).toBeEmptyFun()
|
||||
}.toThrow<AssertionError> { messageContains("$isDescr: $empty") }
|
||||
}
|
||||
it("${isNotEmpty.name} - does not throw") {
|
||||
expect(map as Map<*, *>).isNotEmptyFun()
|
||||
it("${notToBeEmpty.name} - does not throw") {
|
||||
expect(map as Map<*, *>).notToBeEmptyFun()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,18 +9,18 @@ import ch.tutteli.atrium.translations.DescriptionCollectionAssertion
|
||||
import ch.tutteli.atrium.translations.DescriptionMapLikeAssertion
|
||||
import org.spekframework.spek2.dsl.Root
|
||||
|
||||
abstract class MapLikeContainsFormatSpecBase(spec: Root.() -> Unit) : MapLikeContainsSpecBase(spec) {
|
||||
abstract class MapLikeToContainFormatSpecBase(spec: Root.() -> Unit) : MapLikeToContainSpecBase(spec) {
|
||||
|
||||
companion object {
|
||||
val sizeDescr = DescriptionCollectionAssertion.SIZE.getDefault()
|
||||
val additionalEntriesDescr = DescriptionMapLikeAssertion.WARNING_ADDITIONAL_ENTRIES.getDefault()
|
||||
|
||||
fun Expect<String>.containsSize(actual: Int, expected: Int) =
|
||||
fun Expect<String>.toContainsSize(actual: Int, expected: Int) =
|
||||
toContain.exactly(1)
|
||||
.regex("\\Q$rootBulletPoint$featureArrow$sizeDescr\\E: $actual[^:]+${DescriptionAnyAssertion.TO_BE.getDefault()}: $expected")
|
||||
|
||||
|
||||
fun Expect<String>.containsInAnyOrderOnlyDescr() =
|
||||
fun Expect<String>.toContainInAnyOrderOnlyDescr() =
|
||||
toContain.exactly(1).value(
|
||||
"$rootBulletPoint${
|
||||
DescriptionMapLikeAssertion.IN_ANY_ORDER_ONLY.getDefault()
|
||||
@@ -29,7 +29,7 @@ abstract class MapLikeContainsFormatSpecBase(spec: Root.() -> Unit) : MapLikeCon
|
||||
)
|
||||
|
||||
|
||||
fun Expect<String>.containsInOrderOnlyDescr() =
|
||||
fun Expect<String>.toContainInOrderOnlyDescr() =
|
||||
toContain.exactly(1).value(
|
||||
"$rootBulletPoint${
|
||||
DescriptionMapLikeAssertion.IN_ORDER_ONLY.getDefault()
|
||||
@@ -17,11 +17,11 @@ fun <K, V, T> mfun2(
|
||||
f: KFunction3<Expect<Map<out K, V>>, Pair<K, T>, Array<out Pair<K, T>>, Expect<Map<out K, V>>>
|
||||
) = fun2(f)
|
||||
|
||||
abstract class MapLikeContainsSpecBase(spec: Root.() -> Unit) : Spek(spec) {
|
||||
abstract class MapLikeToContainSpecBase(spec: Root.() -> Unit) : Spek(spec) {
|
||||
|
||||
companion object {
|
||||
val keyDoesNotExist = DescriptionMapLikeAssertion.KEY_DOES_NOT_EXIST.getDefault()
|
||||
val lessThanDescr = DescriptionComparableAssertion.IS_LESS_THAN.getDefault()
|
||||
val toBeLessThanDescr = DescriptionComparableAssertion.IS_LESS_THAN.getDefault()
|
||||
|
||||
val separator = lineSeparator
|
||||
|
||||
@@ -14,11 +14,11 @@ fun keyNullableValue(
|
||||
assertionCreator: (Expect<Int>.() -> Unit)?
|
||||
): Pair<String?, (Expect<Int>.() -> Unit)?> = key to assertionCreator
|
||||
|
||||
abstract class MapContainsInAnyOrderKeyValueExpectationsSpec(
|
||||
abstract class MapToContainInAnyOrderKeyValueExpectationsSpec(
|
||||
keyWithValueAssertions: MFun2<String, Int, Expect<Int>.() -> Unit>,
|
||||
keyWithNullableValueAssertions: MFun2<String?, Int?, (Expect<Int>.() -> Unit)?>,
|
||||
describePrefix: String = "[Atrium] "
|
||||
) : MapLikeContainsSpecBase({
|
||||
) : MapLikeToContainSpecBase({
|
||||
|
||||
include(object : SubjectLessSpec<Map<out String, Int>>(
|
||||
describePrefix,
|
||||
@@ -56,14 +56,14 @@ abstract class MapContainsInAnyOrderKeyValueExpectationsSpec(
|
||||
describeFunTemplate(describePrefix, pairs.map { it.name }.toTypedArray(), body = body)
|
||||
|
||||
describeFun(keyWithValueAssertions, keyWithNullableValueAssertions) {
|
||||
val containsKeyWithValueAssertionsFunctions = uncheckedToNonNullable(
|
||||
val toContainKeyWithValueAssertionsFunctions = uncheckedToNonNullable(
|
||||
keyWithValueAssertions,
|
||||
keyWithNullableValueAssertions
|
||||
)
|
||||
val fluent = expect(map)
|
||||
|
||||
context("map $map") {
|
||||
containsKeyWithValueAssertionsFunctions.forEach { (name, containsKeyWithValueAssertionsFun) ->
|
||||
toContainKeyWithValueAssertionsFunctions.forEach { (name, toContainKeyWithValueAssertionsFun) ->
|
||||
listOf(
|
||||
"a { toBe(1) }" to listOf(keyValue("a") { toEqual(1) }),
|
||||
"b { toBe(2) }" to listOf(keyValue("b") { toEqual(2) }),
|
||||
@@ -71,12 +71,12 @@ abstract class MapContainsInAnyOrderKeyValueExpectationsSpec(
|
||||
"b { toBe(2) }, a { toBe(1) }" to listOf(keyValue("b") { toEqual(2) }, keyValue("a") { toEqual(1) })
|
||||
).forEach { (description, keyValues) ->
|
||||
it("$name - $description does not throw") {
|
||||
fluent.containsKeyWithValueAssertionsFun(keyValues.first(), keyValues.drop(1).toTypedArray())
|
||||
fluent.toContainKeyWithValueAssertionsFun(keyValues.first(), keyValues.drop(1).toTypedArray())
|
||||
}
|
||||
}
|
||||
|
||||
it("$name - a { isLessThan(2) } and a { isGreaterThan(0) } does not throw (no unique match)") {
|
||||
fluent.containsKeyWithValueAssertionsFun(
|
||||
fluent.toContainKeyWithValueAssertionsFun(
|
||||
keyValue("a") { toBeLessThan(2) },
|
||||
arrayOf(keyValue("a") { toBeGreaterThan(0) })
|
||||
)
|
||||
@@ -84,7 +84,7 @@ abstract class MapContainsInAnyOrderKeyValueExpectationsSpec(
|
||||
|
||||
it("$name - a { isLessThan(3) }, b { isLessThan(2) }, c { isLessThan(1) }} throws AssertionError, reports b and c") {
|
||||
expect {
|
||||
fluent.containsKeyWithValueAssertionsFun(
|
||||
fluent.toContainKeyWithValueAssertionsFun(
|
||||
keyValue("a") { toBeLessThan(3) },
|
||||
arrayOf(keyValue("b") { toBeLessThan(2) }, keyValue("c") { toBeLessThan(1) })
|
||||
)
|
||||
@@ -92,9 +92,9 @@ abstract class MapContainsInAnyOrderKeyValueExpectationsSpec(
|
||||
message {
|
||||
toContain(
|
||||
entry("b", 2),
|
||||
"$lessThanDescr: 2",
|
||||
"$toBeLessThanDescr: 2",
|
||||
entry("c", keyDoesNotExist),
|
||||
"$lessThanDescr: 1"
|
||||
"$toBeLessThanDescr: 1"
|
||||
)
|
||||
notToContain(entry("a"))
|
||||
}
|
||||
@@ -105,7 +105,7 @@ abstract class MapContainsInAnyOrderKeyValueExpectationsSpec(
|
||||
}
|
||||
|
||||
describeFun(keyWithNullableValueAssertions) {
|
||||
val containsFun = keyWithNullableValueAssertions.lambda
|
||||
val toContainFun = keyWithNullableValueAssertions.lambda
|
||||
val nullableFluent = expect(nullableMap)
|
||||
|
||||
context("map $nullableMap") {
|
||||
@@ -135,13 +135,13 @@ abstract class MapContainsInAnyOrderKeyValueExpectationsSpec(
|
||||
)
|
||||
).forEach { (description, keyValues) ->
|
||||
it("$description does not throw") {
|
||||
nullableFluent.containsFun(keyValues.first(), keyValues.drop(1).toTypedArray())
|
||||
nullableFluent.toContainFun(keyValues.first(), keyValues.drop(1).toTypedArray())
|
||||
}
|
||||
}
|
||||
|
||||
it("(a, null), b { isLessThan(2) }, c { isLessThan(1) }} throws AssertionError, reports b and c") {
|
||||
expect {
|
||||
nullableFluent.containsFun(
|
||||
nullableFluent.toContainFun(
|
||||
keyNullableValue("a", null), arrayOf(
|
||||
keyNullableValue("b") { toBeLessThan(2) },
|
||||
keyNullableValue("c") { toBeLessThan(1) }
|
||||
@@ -151,9 +151,9 @@ abstract class MapContainsInAnyOrderKeyValueExpectationsSpec(
|
||||
message {
|
||||
toContain(
|
||||
entry("b", 2),
|
||||
"$lessThanDescr: 2",
|
||||
"$toBeLessThanDescr: 2",
|
||||
entry("c", keyDoesNotExist),
|
||||
"$lessThanDescr: 1"
|
||||
"$toBeLessThanDescr: 1"
|
||||
)
|
||||
notToContain(entry("a"))
|
||||
}
|
||||
@@ -2,17 +2,15 @@ package ch.tutteli.atrium.specs.integration
|
||||
|
||||
import ch.tutteli.atrium.api.fluent.en_GB.*
|
||||
import ch.tutteli.atrium.api.verbs.internal.expect
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.specs.*
|
||||
import org.spekframework.spek2.style.specification.Suite
|
||||
import kotlin.reflect.KFunction3
|
||||
|
||||
|
||||
abstract class MapContainsInAnyOrderKeyValuePairsExpectationsSpec(
|
||||
abstract class MapToContainInAnyOrderKeyValuePairsExpectationsSpec(
|
||||
keyValuePairs: MFun2<String, Int, Int>,
|
||||
keyValuePairsNullable: MFun2<String?, Int?, Int?>,
|
||||
describePrefix: String = "[Atrium] "
|
||||
) : MapLikeContainsSpecBase({
|
||||
) : MapLikeToContainSpecBase({
|
||||
|
||||
include(object : SubjectLessSpec<Map<out String, Int>>(
|
||||
describePrefix,
|
||||
@@ -31,10 +29,10 @@ abstract class MapContainsInAnyOrderKeyValuePairsExpectationsSpec(
|
||||
val nullableFluent = expect(nullableMap)
|
||||
|
||||
describeFun(keyValuePairs, keyValuePairsNullable) {
|
||||
val containsFunctions = uncheckedToNonNullable(keyValuePairs, keyValuePairsNullable)
|
||||
val toContainFunctions = uncheckedToNonNullable(keyValuePairs, keyValuePairsNullable)
|
||||
|
||||
context("map $map") {
|
||||
containsFunctions.forEach { (name, containsFun) ->
|
||||
toContainFunctions.forEach { (name, toContainFun) ->
|
||||
listOf(
|
||||
listOf("a" to 1),
|
||||
listOf("b" to 2),
|
||||
@@ -42,17 +40,17 @@ abstract class MapContainsInAnyOrderKeyValuePairsExpectationsSpec(
|
||||
listOf("b" to 2, "a" to 1)
|
||||
).forEach {
|
||||
it("$name - $it does not throw") {
|
||||
fluent.containsFun(it.first(), it.drop(1).toTypedArray())
|
||||
fluent.toContainFun(it.first(), it.drop(1).toTypedArray())
|
||||
}
|
||||
}
|
||||
|
||||
it("$name - a to 1 and a to 1 does not throw (no unique match)") {
|
||||
fluent.containsFun("a" to 1, arrayOf("a" to 1))
|
||||
fluent.toContainFun("a" to 1, arrayOf("a" to 1))
|
||||
}
|
||||
|
||||
it("$name - {a to 1, b to 3, c to 4} throws AssertionError, reports b and c") {
|
||||
expect {
|
||||
fluent.containsFun("a" to 1, arrayOf("b" to 3, "c" to 4))
|
||||
fluent.toContainFun("a" to 1, arrayOf("b" to 3, "c" to 4))
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
toContain(
|
||||
@@ -70,7 +68,7 @@ abstract class MapContainsInAnyOrderKeyValuePairsExpectationsSpec(
|
||||
}
|
||||
|
||||
describeFun(keyValuePairsNullable) {
|
||||
val containsNullableFun = keyValuePairsNullable.lambda
|
||||
val toContainNullableFun = keyValuePairsNullable.lambda
|
||||
context("map $nullableMap") {
|
||||
listOf(
|
||||
listOf("a" to null),
|
||||
@@ -83,17 +81,17 @@ abstract class MapContainsInAnyOrderKeyValuePairsExpectationsSpec(
|
||||
listOf("b" to 2, null to 1, "a" to null)
|
||||
).forEach {
|
||||
it("$it does not throw") {
|
||||
nullableFluent.containsNullableFun(it.first(), it.drop(1).toTypedArray())
|
||||
nullableFluent.toContainNullableFun(it.first(), it.drop(1).toTypedArray())
|
||||
}
|
||||
}
|
||||
|
||||
it("a to null and a to null does not throw (no unique match)") {
|
||||
nullableFluent.containsNullableFun("a" to null, arrayOf("a" to null))
|
||||
nullableFluent.toContainNullableFun("a" to null, arrayOf("a" to null))
|
||||
}
|
||||
|
||||
it("{a to null, null to 2, b to 3, c to 4} throws AssertionError, reports a, null, b and c") {
|
||||
expect {
|
||||
nullableFluent.containsNullableFun("a" to null, arrayOf(null to 2, "b" to 3, "c" to 4))
|
||||
nullableFluent.toContainNullableFun("a" to null, arrayOf(null to 2, "b" to 3, "c" to 4))
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
toContain(
|
||||
@@ -6,11 +6,11 @@ import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.specs.*
|
||||
import org.spekframework.spek2.style.specification.Suite
|
||||
|
||||
abstract class MapContainsInAnyOrderOnlyKeyValueExpectationsSpec(
|
||||
abstract class MapToContainInAnyOrderOnlyKeyValueExpectationsSpec(
|
||||
keyWithValueAssertions: MFun2<String, Int, Expect<Int>.() -> Unit>,
|
||||
keyWithNullableValueAssertions: MFun2<String?, Int?, (Expect<Int>.() -> Unit)?>,
|
||||
describePrefix: String = "[Atrium] "
|
||||
) : MapLikeContainsFormatSpecBase({
|
||||
) : MapLikeToContainFormatSpecBase({
|
||||
|
||||
include(
|
||||
object : SubjectLessSpec<Map<out String, Int>>(
|
||||
@@ -33,7 +33,7 @@ abstract class MapContainsInAnyOrderOnlyKeyValueExpectationsSpec(
|
||||
include(
|
||||
object : AssertionCreatorSpec<Map<out String, Int>>(
|
||||
describePrefix, map,
|
||||
assertionCreatorSpecTriple(keyWithValueAssertions.name, "$lessThanDescr: 2",
|
||||
assertionCreatorSpecTriple(keyWithValueAssertions.name, "$toBeLessThanDescr: 2",
|
||||
{
|
||||
keyWithValueAssertions(
|
||||
this,
|
||||
@@ -48,7 +48,7 @@ abstract class MapContainsInAnyOrderOnlyKeyValueExpectationsSpec(
|
||||
include(
|
||||
object : AssertionCreatorSpec<Map<out String?, Int?>>(
|
||||
"$describePrefix[nullable] ", mapOf("a" to 1, "b" to null),
|
||||
assertionCreatorSpecTriple(keyWithNullableValueAssertions.name, "$lessThanDescr: 2",
|
||||
assertionCreatorSpecTriple(keyWithNullableValueAssertions.name, "$toBeLessThanDescr: 2",
|
||||
{
|
||||
keyWithNullableValueAssertions(
|
||||
this,
|
||||
@@ -66,19 +66,19 @@ abstract class MapContainsInAnyOrderOnlyKeyValueExpectationsSpec(
|
||||
|
||||
describeFun(keyWithValueAssertions, keyWithValueAssertions)
|
||||
{
|
||||
val containsKeyWithValueAssertionsFunctions =
|
||||
val toContainKeyWithValueAssertionsFunctions =
|
||||
uncheckedToNonNullable(keyWithValueAssertions, keyWithNullableValueAssertions)
|
||||
val emptyMap: Map<out String, Int> = mapOf()
|
||||
|
||||
context("empty map") {
|
||||
containsKeyWithValueAssertionsFunctions.forEach { (name, containsFun) ->
|
||||
toContainKeyWithValueAssertionsFunctions.forEach { (name, toContainFun) ->
|
||||
it("$name - a to { toBe(1) } throws AssertionError, reports a") {
|
||||
expect {
|
||||
expect(emptyMap).containsFun(keyValue("a") { toEqual(1) }, arrayOf())
|
||||
expect(emptyMap).toContainFun(keyValue("a") { toEqual(1) }, arrayOf())
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
containsInAnyOrderOnlyDescr()
|
||||
containsSize(0, 1)
|
||||
toContainInAnyOrderOnlyDescr()
|
||||
toContainsSize(0, 1)
|
||||
entryNonExisting("a", "$toBeDescr: 1")
|
||||
notToContain(additionalEntriesDescr)
|
||||
}
|
||||
@@ -87,7 +87,7 @@ abstract class MapContainsInAnyOrderOnlyKeyValueExpectationsSpec(
|
||||
|
||||
it("$name - a to { isLessThan(1) }, b to { toBe(3) }, c to { isLessThan(4) } } throws AssertionError, reports a, b and c") {
|
||||
expect {
|
||||
expect(emptyMap).containsFun(
|
||||
expect(emptyMap).toContainFun(
|
||||
keyValue("a") { toBeLessThan(1) },
|
||||
arrayOf(
|
||||
keyValue("b") { toEqual(3) },
|
||||
@@ -95,11 +95,11 @@ abstract class MapContainsInAnyOrderOnlyKeyValueExpectationsSpec(
|
||||
))
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
containsInAnyOrderOnlyDescr()
|
||||
containsSize(0, 3)
|
||||
entryNonExisting("a", "$lessThanDescr: 1")
|
||||
toContainInAnyOrderOnlyDescr()
|
||||
toContainsSize(0, 3)
|
||||
entryNonExisting("a", "$toBeLessThanDescr: 1")
|
||||
entryNonExisting("b", "$toBeDescr: 3")
|
||||
entryNonExisting("c", "$lessThanDescr: 4")
|
||||
entryNonExisting("c", "$toBeLessThanDescr: 4")
|
||||
notToContain(additionalEntriesDescr)
|
||||
}
|
||||
}
|
||||
@@ -108,7 +108,7 @@ abstract class MapContainsInAnyOrderOnlyKeyValueExpectationsSpec(
|
||||
}
|
||||
|
||||
context("map $map") {
|
||||
containsKeyWithValueAssertionsFunctions.forEach { (name, containsFun) ->
|
||||
toContainKeyWithValueAssertionsFunctions.forEach { (name, toContainFun) ->
|
||||
listOf(
|
||||
"a to { toBe(1) }, b to { toBe(2) }" to listOf(
|
||||
keyValue("a") { toEqual(1) },
|
||||
@@ -124,18 +124,18 @@ abstract class MapContainsInAnyOrderOnlyKeyValueExpectationsSpec(
|
||||
keyValue("b") { toBeLessThan(3) })
|
||||
).forEach { (description, list) ->
|
||||
it("$name - $description does not throw") {
|
||||
expect(map).containsFun(list.first(), list.drop(1).toTypedArray())
|
||||
expect(map).toContainFun(list.first(), list.drop(1).toTypedArray())
|
||||
}
|
||||
}
|
||||
|
||||
it("$name - a to { isLessThan(2) } throws AssertionError, reports second a and missing b") {
|
||||
expect {
|
||||
expect(map).containsFun(keyValue("a") { toBeLessThan(2) }, arrayOf())
|
||||
expect(map).toContainFun(keyValue("a") { toBeLessThan(2) }, arrayOf())
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
containsInAnyOrderOnlyDescr()
|
||||
containsSize(2, 1)
|
||||
entrySuccess("a", 1, "$lessThanDescr: 2")
|
||||
toContainInAnyOrderOnlyDescr()
|
||||
toContainsSize(2, 1)
|
||||
entrySuccess("a", 1, "$toBeLessThanDescr: 2")
|
||||
additionalEntries("b" to 2)
|
||||
}
|
||||
}
|
||||
@@ -143,11 +143,11 @@ abstract class MapContainsInAnyOrderOnlyKeyValueExpectationsSpec(
|
||||
|
||||
it("$name - a to { isLessThan(2) }, a to { toBe(1) } throws AssertionError, reports second a and missing b") {
|
||||
expect {
|
||||
expect(map).containsFun(keyValue("a") { toBeLessThan(2) }, arrayOf(keyValue("a") { toEqual(1) }))
|
||||
expect(map).toContainFun(keyValue("a") { toBeLessThan(2) }, arrayOf(keyValue("a") { toEqual(1) }))
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
containsInAnyOrderOnlyDescr()
|
||||
entrySuccess("a", 1, "$lessThanDescr: 2")
|
||||
toContainInAnyOrderOnlyDescr()
|
||||
entrySuccess("a", 1, "$toBeLessThanDescr: 2")
|
||||
entryNonExisting("a", "$toBeDescr: 1")
|
||||
additionalEntries("b" to 2)
|
||||
|
||||
@@ -158,7 +158,7 @@ abstract class MapContainsInAnyOrderOnlyKeyValueExpectationsSpec(
|
||||
|
||||
it("$name - a to { isLessThan(3), b to { isLessThan(1), c to { toBe(4) } throws AssertionError, reports b and c") {
|
||||
expect {
|
||||
expect(map).containsFun(
|
||||
expect(map).toContainFun(
|
||||
keyValue("a") { toBeLessThan(3) },
|
||||
arrayOf(
|
||||
keyValue("b") { toBeLessThan(1) },
|
||||
@@ -167,10 +167,10 @@ abstract class MapContainsInAnyOrderOnlyKeyValueExpectationsSpec(
|
||||
)
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
containsInAnyOrderOnlyDescr()
|
||||
containsSize(2, 3)
|
||||
entrySuccess("a", 1, "$lessThanDescr: 3")
|
||||
entryFailing("b", 2, "$lessThanDescr: 1")
|
||||
toContainInAnyOrderOnlyDescr()
|
||||
toContainsSize(2, 3)
|
||||
entrySuccess("a", 1, "$toBeLessThanDescr: 3")
|
||||
entryFailing("b", 2, "$toBeLessThanDescr: 1")
|
||||
entryNonExisting("c", "$toBeDescr: 4")
|
||||
|
||||
notToContain(additionalEntriesDescr)
|
||||
@@ -183,7 +183,7 @@ abstract class MapContainsInAnyOrderOnlyKeyValueExpectationsSpec(
|
||||
|
||||
describeFun(keyWithNullableValueAssertions)
|
||||
{
|
||||
val containsKeyWithNullableValueAssertionsFun = keyWithNullableValueAssertions.lambda
|
||||
val toContainKeyWithNullableValueAssertionsFun = keyWithNullableValueAssertions.lambda
|
||||
context("map: $nullableMap") {
|
||||
listOf(
|
||||
"null { toBe(1) }, (a, null), b{ toBe(2) }" to
|
||||
@@ -199,7 +199,7 @@ abstract class MapContainsInAnyOrderOnlyKeyValueExpectationsSpec(
|
||||
)
|
||||
).forEach { (description, keyValues) ->
|
||||
it("$description does not throw") {
|
||||
expect(nullableMap).containsKeyWithNullableValueAssertionsFun(
|
||||
expect(nullableMap).toContainKeyWithNullableValueAssertionsFun(
|
||||
keyValues.first(),
|
||||
keyValues.drop(1).toTypedArray()
|
||||
)
|
||||
@@ -207,14 +207,14 @@ abstract class MapContainsInAnyOrderOnlyKeyValueExpectationsSpec(
|
||||
}
|
||||
it("a to { toBe(1) } throws AssertionError, reports failure and missing null and b") {
|
||||
expect {
|
||||
expect(nullableMap).containsKeyWithNullableValueAssertionsFun(
|
||||
expect(nullableMap).toContainKeyWithNullableValueAssertionsFun(
|
||||
keyNullableValue("a") { toEqual(1) },
|
||||
arrayOf()
|
||||
)
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
containsInAnyOrderOnlyDescr()
|
||||
containsSize(3, 1)
|
||||
toContainInAnyOrderOnlyDescr()
|
||||
toContainsSize(3, 1)
|
||||
entryFailingExplaining("a", null, "$toBeDescr: 1")
|
||||
additionalEntries(null to 1, "b" to 2)
|
||||
}
|
||||
@@ -223,7 +223,7 @@ abstract class MapContainsInAnyOrderOnlyKeyValueExpectationsSpec(
|
||||
|
||||
it("a to { toBe(1) }, c to { isLessThan(3) }, null to null, b to { isLessThan(3) } throws AssertionError, reports all but b") {
|
||||
expect {
|
||||
expect(nullableMap).containsKeyWithNullableValueAssertionsFun(
|
||||
expect(nullableMap).toContainKeyWithNullableValueAssertionsFun(
|
||||
keyNullableValue("a") { toEqual(1) },
|
||||
arrayOf(
|
||||
keyNullableValue("c") { toBeLessThan(3) },
|
||||
@@ -233,12 +233,12 @@ abstract class MapContainsInAnyOrderOnlyKeyValueExpectationsSpec(
|
||||
)
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
containsInAnyOrderOnlyDescr()
|
||||
containsSize(3, 4)
|
||||
toContainInAnyOrderOnlyDescr()
|
||||
toContainsSize(3, 4)
|
||||
entryFailingExplaining("a", null, "$toBeDescr: 1")
|
||||
entryNonExisting("c", "$lessThanDescr: 3")
|
||||
entryNonExisting("c", "$toBeLessThanDescr: 3")
|
||||
entryFailing(null, "1", "$toBeDescr: null")
|
||||
entrySuccess("b", "2", "$lessThanDescr: 3")
|
||||
entrySuccess("b", "2", "$toBeLessThanDescr: 3")
|
||||
|
||||
notToContain(additionalEntriesDescr)
|
||||
}
|
||||
@@ -5,11 +5,11 @@ import ch.tutteli.atrium.api.verbs.internal.expect
|
||||
import ch.tutteli.atrium.specs.*
|
||||
import org.spekframework.spek2.style.specification.Suite
|
||||
|
||||
abstract class MapContainsInAnyOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
abstract class MapToContainInAnyOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
keyValuePairs: MFun2<String, Int, Int>,
|
||||
keyValuePairsNullable: MFun2<String?, Int?, Int?>,
|
||||
describePrefix: String = "[Atrium] "
|
||||
) : MapLikeContainsFormatSpecBase({
|
||||
) : MapLikeToContainFormatSpecBase({
|
||||
|
||||
include(object : SubjectLessSpec<Map<out String, Int>>(
|
||||
describePrefix,
|
||||
@@ -25,17 +25,17 @@ abstract class MapContainsInAnyOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
describeFunTemplate(describePrefix, pairs.map { it.name }.toTypedArray(), body = body)
|
||||
|
||||
describeFun(keyValuePairs, keyValuePairsNullable) {
|
||||
val containsKeyValuePairsFunctions = uncheckedToNonNullable(keyValuePairs, keyValuePairsNullable)
|
||||
val toContainKeyValuePairsFunctions = uncheckedToNonNullable(keyValuePairs, keyValuePairsNullable)
|
||||
|
||||
context("empty map") {
|
||||
containsKeyValuePairsFunctions.forEach { (name, containsFun) ->
|
||||
toContainKeyValuePairsFunctions.forEach { (name, toContainFun) ->
|
||||
it("$name - a to 1 throws AssertionError, reports a") {
|
||||
expect {
|
||||
expect(emptyMap).containsFun("a" to 1, arrayOf())
|
||||
expect(emptyMap).toContainFun("a" to 1, arrayOf())
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
containsInAnyOrderOnlyDescr()
|
||||
containsSize(0, 1)
|
||||
toContainInAnyOrderOnlyDescr()
|
||||
toContainsSize(0, 1)
|
||||
entryNonExisting("a", "$toBeDescr: 1")
|
||||
}
|
||||
}
|
||||
@@ -43,11 +43,11 @@ abstract class MapContainsInAnyOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
|
||||
it("$name - a to 1, b to 3, c to 4 throws AssertionError, reports a, b and c") {
|
||||
expect {
|
||||
expect(emptyMap).containsFun("a" to 1, arrayOf("b" to 3, "c" to 4))
|
||||
expect(emptyMap).toContainFun("a" to 1, arrayOf("b" to 3, "c" to 4))
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
containsInAnyOrderOnlyDescr()
|
||||
containsSize(0, 3)
|
||||
toContainInAnyOrderOnlyDescr()
|
||||
toContainsSize(0, 3)
|
||||
entryNonExisting("a", "$toBeDescr: 1")
|
||||
entryNonExisting("b", "$toBeDescr: 3")
|
||||
entryNonExisting("c", "$toBeDescr: 4")
|
||||
@@ -58,23 +58,23 @@ abstract class MapContainsInAnyOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
}
|
||||
|
||||
context("map $map") {
|
||||
containsKeyValuePairsFunctions.forEach { (name, containsFun) ->
|
||||
toContainKeyValuePairsFunctions.forEach { (name, toContainFun) ->
|
||||
listOf(
|
||||
listOf("a" to 1, "b" to 2),
|
||||
listOf("b" to 2, "a" to 1)
|
||||
).forEach {
|
||||
it("$name - ${it.joinToString()} does not throw") {
|
||||
expect(map).containsFun(it.first(), it.drop(1).toTypedArray())
|
||||
expect(map).toContainFun(it.first(), it.drop(1).toTypedArray())
|
||||
}
|
||||
}
|
||||
|
||||
it("$name - a to 1 throws AssertionError, reports second a and missing b") {
|
||||
expect {
|
||||
expect(map).containsFun("a" to 1, arrayOf())
|
||||
expect(map).toContainFun("a" to 1, arrayOf())
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
containsSize(2, 1)
|
||||
containsInAnyOrderOnlyDescr()
|
||||
toContainsSize(2, 1)
|
||||
toContainInAnyOrderOnlyDescr()
|
||||
entrySuccess("a", 1, "$toBeDescr: 1")
|
||||
additionalEntries("b" to 2)
|
||||
}
|
||||
@@ -83,10 +83,10 @@ abstract class MapContainsInAnyOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
|
||||
it("$name - a to 1, a to 1 throws AssertionError, reports second a and missing b") {
|
||||
expect {
|
||||
expect(map).containsFun("a" to 1, arrayOf("a" to 1))
|
||||
expect(map).toContainFun("a" to 1, arrayOf("a" to 1))
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
containsInAnyOrderOnlyDescr()
|
||||
toContainInAnyOrderOnlyDescr()
|
||||
entrySuccess("a", 1, "$toBeDescr: 1")
|
||||
entryNonExisting("a", "$toBeDescr: 1")
|
||||
additionalEntries("b" to 2)
|
||||
@@ -97,11 +97,11 @@ abstract class MapContainsInAnyOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
|
||||
it("$name - a to 1, b to 3, c to 4 throws AssertionError, reports b and c") {
|
||||
expect {
|
||||
expect(map).containsFun("a" to 1, arrayOf("b" to 3, "c" to 4))
|
||||
expect(map).toContainFun("a" to 1, arrayOf("b" to 3, "c" to 4))
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
containsInAnyOrderOnlyDescr()
|
||||
containsSize(2, 3)
|
||||
toContainInAnyOrderOnlyDescr()
|
||||
toContainsSize(2, 3)
|
||||
entrySuccess("a", 1, "$toBeDescr: 1")
|
||||
entryFailing("b", 2, "$toBeDescr: 3")
|
||||
entryNonExisting("c", "$toBeDescr: 4")
|
||||
@@ -114,7 +114,7 @@ abstract class MapContainsInAnyOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
}
|
||||
|
||||
describeFun(keyValuePairsNullable) {
|
||||
val containsFun = keyValuePairsNullable.lambda
|
||||
val toContainFun = keyValuePairsNullable.lambda
|
||||
context("map: $nullableMap") {
|
||||
listOf(
|
||||
listOf("a" to null, null to 1, "b" to 2),
|
||||
@@ -123,16 +123,16 @@ abstract class MapContainsInAnyOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
listOf(null to 1, "a" to null, "b" to 2)
|
||||
).forEach {
|
||||
it("$it does not throw") {
|
||||
expect(nullableMap).containsFun(it.first(), it.drop(1).toTypedArray())
|
||||
expect(nullableMap).toContainFun(it.first(), it.drop(1).toTypedArray())
|
||||
}
|
||||
}
|
||||
it("a to 1, c to 3, null to null, b to 2 throws AssertionError, reports all but b") {
|
||||
expect {
|
||||
expect(nullableMap).containsFun("a" to 1, arrayOf("c" to 3, null to null, "b" to 2))
|
||||
expect(nullableMap).toContainFun("a" to 1, arrayOf("c" to 3, null to null, "b" to 2))
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
containsInAnyOrderOnlyDescr()
|
||||
containsSize(3, 4)
|
||||
toContainInAnyOrderOnlyDescr()
|
||||
toContainsSize(3, 4)
|
||||
entryFailing("a", null, "$toBeDescr: 1")
|
||||
entryNonExisting("c", "$toBeDescr: 3")
|
||||
entryFailing(null, "1", "$toBeDescr: null")
|
||||
@@ -6,11 +6,11 @@ import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.specs.*
|
||||
import org.spekframework.spek2.style.specification.Suite
|
||||
|
||||
abstract class MapContainsInOrderOnlyKeyValueExpectationsSpec(
|
||||
abstract class MapToContainInOrderOnlyKeyValueExpectationsSpec(
|
||||
keyWithValueAssertions: MFun2<String, Int, Expect<Int>.() -> Unit>,
|
||||
keyWithNullableValueAssertions: MFun2<String?, Int?, (Expect<Int>.() -> Unit)?>,
|
||||
describePrefix: String = "[Atrium] "
|
||||
) : MapLikeContainsFormatSpecBase({
|
||||
) : MapLikeToContainFormatSpecBase({
|
||||
|
||||
include(object : SubjectLessSpec<Map<out String, Int>>(
|
||||
describePrefix,
|
||||
@@ -30,7 +30,7 @@ abstract class MapContainsInOrderOnlyKeyValueExpectationsSpec(
|
||||
|
||||
include(object : AssertionCreatorSpec<Map<out String, Int>>(
|
||||
describePrefix, map,
|
||||
assertionCreatorSpecTriple(keyWithValueAssertions.name, "$lessThanDescr: 2",
|
||||
assertionCreatorSpecTriple(keyWithValueAssertions.name, "$toBeLessThanDescr: 2",
|
||||
{
|
||||
keyWithValueAssertions(
|
||||
this,
|
||||
@@ -44,7 +44,7 @@ abstract class MapContainsInOrderOnlyKeyValueExpectationsSpec(
|
||||
|
||||
include(object : AssertionCreatorSpec<Map<out String?, Int?>>(
|
||||
"$describePrefix[nullable] ", mapOf("a" to 1, "b" to null),
|
||||
assertionCreatorSpecTriple(keyWithNullableValueAssertions.name, "$lessThanDescr: 2",
|
||||
assertionCreatorSpecTriple(keyWithNullableValueAssertions.name, "$toBeLessThanDescr: 2",
|
||||
{
|
||||
keyWithNullableValueAssertions(
|
||||
this,
|
||||
@@ -129,21 +129,21 @@ abstract class MapContainsInOrderOnlyKeyValueExpectationsSpec(
|
||||
}
|
||||
|
||||
describeFun(keyWithValueAssertions, keyWithNullableValueAssertions) {
|
||||
val containsKeyWithValueAssertionsFunctions = uncheckedToNonNullable(
|
||||
val toContainKeyWithValueAssertionsFunctions = uncheckedToNonNullable(
|
||||
keyWithValueAssertions,
|
||||
keyWithNullableValueAssertions
|
||||
)
|
||||
|
||||
context("empty map") {
|
||||
containsKeyWithValueAssertionsFunctions.forEach { (name, containsFun) ->
|
||||
toContainKeyWithValueAssertionsFunctions.forEach { (name, toContainFun) ->
|
||||
it("$name - a to { toBe(1) } throws AssertionError, reports a") {
|
||||
expect {
|
||||
expect(emptyMap).containsFun(keyValue("a") { toEqual(1) }, arrayOf())
|
||||
expect(emptyMap).toContainFun(keyValue("a") { toEqual(1) }, arrayOf())
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
containsInOrderOnlyDescr()
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.contains
|
||||
//containsSize(0, 1)
|
||||
toContainInOrderOnlyDescr()
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.toContain
|
||||
//toContainsSize(0, 1)
|
||||
elementOutOfBound(0, "a", "$toBeDescr: 1")
|
||||
}
|
||||
}
|
||||
@@ -151,7 +151,7 @@ abstract class MapContainsInOrderOnlyKeyValueExpectationsSpec(
|
||||
|
||||
it("$name - a to { isLessThan(1) }, b to { toBe(3) }, c to { isLessThan(4) } } throws AssertionError, reports a, b and c") {
|
||||
expect {
|
||||
expect(emptyMap).containsFun(
|
||||
expect(emptyMap).toContainFun(
|
||||
keyValue("a") { toBeLessThan(1) },
|
||||
arrayOf(
|
||||
keyValue("b") { toEqual(3) },
|
||||
@@ -159,12 +159,12 @@ abstract class MapContainsInOrderOnlyKeyValueExpectationsSpec(
|
||||
))
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
containsInOrderOnlyDescr()
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.contains
|
||||
//containsSize(0, 3)
|
||||
elementOutOfBound(0, "a", "$lessThanDescr: 1")
|
||||
toContainInOrderOnlyDescr()
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.toContain
|
||||
//toContainsSize(0, 3)
|
||||
elementOutOfBound(0, "a", "$toBeLessThanDescr: 1")
|
||||
elementOutOfBound(1, "b", "$toBeDescr: 3")
|
||||
elementOutOfBound(2, "c", "$lessThanDescr: 4")
|
||||
elementOutOfBound(2, "c", "$toBeLessThanDescr: 4")
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -174,7 +174,7 @@ abstract class MapContainsInOrderOnlyKeyValueExpectationsSpec(
|
||||
context("map $map") {
|
||||
val fluent = expect(map)
|
||||
|
||||
containsKeyWithValueAssertionsFunctions.forEach { (name, containsFun) ->
|
||||
toContainKeyWithValueAssertionsFunctions.forEach { (name, toContainFun) ->
|
||||
listOf(
|
||||
"a to { toBe(1) }, b to { toBe(2) }" to listOf(
|
||||
keyValue("a") { toEqual(1) },
|
||||
@@ -184,13 +184,13 @@ abstract class MapContainsInOrderOnlyKeyValueExpectationsSpec(
|
||||
keyValue("b") { toBeLessThan(3) })
|
||||
).forEach { (description, list) ->
|
||||
it("$name - $description does not throw") {
|
||||
expect(map).containsFun(list.first(), list.drop(1).toTypedArray())
|
||||
expect(map).toContainFun(list.first(), list.drop(1).toTypedArray())
|
||||
}
|
||||
}
|
||||
|
||||
it("$name - a to { toBe(1) } throws AssertionError, missing b") {
|
||||
expect {
|
||||
fluent.containsFun(
|
||||
fluent.toContainFun(
|
||||
keyValue("a") { toEqual(1) },
|
||||
arrayOf()
|
||||
)
|
||||
@@ -198,15 +198,15 @@ abstract class MapContainsInOrderOnlyKeyValueExpectationsSpec(
|
||||
message {
|
||||
elementSuccess(0, "a=1", "a", "$toBeDescr: 1")
|
||||
additionalEntries(1 to "b=2")
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.contains
|
||||
// containsSize(2, 1)
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.toContain
|
||||
// toContainsSize(2, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
it("$name - b to { toBe(2) }, a to { toBe(1) } throws AssertionError, wrong order") {
|
||||
expect {
|
||||
fluent.containsFun(
|
||||
fluent.toContainFun(
|
||||
keyValue("b") { toEqual(2) },
|
||||
arrayOf(keyValue("a") { toEqual(1) })
|
||||
)
|
||||
@@ -215,8 +215,8 @@ abstract class MapContainsInOrderOnlyKeyValueExpectationsSpec(
|
||||
elementFailing(0, "a=1", "b", "$toBeDescr: 2")
|
||||
elementFailing(1, "b=2", "a", "$toBeDescr: 1")
|
||||
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.contains
|
||||
// containsNot(sizeDescr)
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.toContain
|
||||
// toContainNot(sizeDescr)
|
||||
notToContain(additionalEntriesDescr)
|
||||
}
|
||||
}
|
||||
@@ -224,15 +224,15 @@ abstract class MapContainsInOrderOnlyKeyValueExpectationsSpec(
|
||||
|
||||
it("$name - a { isLessThan(3) }, b { isLessThan(2) }, c { isLessThan(1) }} throws AssertionError, reports b and c") {
|
||||
expect {
|
||||
fluent.containsFun(
|
||||
fluent.toContainFun(
|
||||
keyValue("a") { toBeLessThan(3) },
|
||||
arrayOf(keyValue("b") { toBeLessThan(2) }, keyValue("c") { toBeLessThan(1) })
|
||||
)
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
elementSuccess(0, "a=1", "a", "$lessThanDescr: 3")
|
||||
elementFailing(1, "b=2", "b", "$lessThanDescr: 2")
|
||||
elementOutOfBound(2, "c", "$lessThanDescr: 1")
|
||||
elementSuccess(0, "a=1", "a", "$toBeLessThanDescr: 3")
|
||||
elementFailing(1, "b=2", "b", "$toBeLessThanDescr: 2")
|
||||
elementOutOfBound(2, "c", "$toBeLessThanDescr: 1")
|
||||
notToContain(additionalEntriesDescr)
|
||||
}
|
||||
}
|
||||
@@ -242,7 +242,7 @@ abstract class MapContainsInOrderOnlyKeyValueExpectationsSpec(
|
||||
}
|
||||
|
||||
describeFun(keyWithNullableValueAssertions) {
|
||||
val containsFun = keyWithNullableValueAssertions.lambda
|
||||
val toContainFun = keyWithNullableValueAssertions.lambda
|
||||
val nullableFluent = expect(nullableMap)
|
||||
|
||||
context("map $nullableMap") {
|
||||
@@ -261,7 +261,7 @@ abstract class MapContainsInOrderOnlyKeyValueExpectationsSpec(
|
||||
)
|
||||
).forEach { (description, keyValues) ->
|
||||
it("$description does not throw") {
|
||||
nullableFluent.containsFun(
|
||||
nullableFluent.toContainFun(
|
||||
keyValues.first(),
|
||||
keyValues.drop(1).toTypedArray()
|
||||
)
|
||||
@@ -270,20 +270,20 @@ abstract class MapContainsInOrderOnlyKeyValueExpectationsSpec(
|
||||
|
||||
it("(a, null) throws AssertionError, missing b") {
|
||||
expect {
|
||||
nullableFluent.containsFun(keyNullableValue("a", null), arrayOf())
|
||||
nullableFluent.toContainFun(keyNullableValue("a", null), arrayOf())
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
elementSuccess(0, "a=null", "a", "$toBeDescr: null")
|
||||
additionalEntries(1 to "null=1", 2 to "b=2")
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.contains
|
||||
// containsSize(3, 1)
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.toContain
|
||||
// toContainsSize(3, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
it("b to { toBe(2) }, (a, null), null to { toBe(1) } throws AssertionError, wrong order") {
|
||||
expect {
|
||||
nullableFluent.containsFun(
|
||||
nullableFluent.toContainFun(
|
||||
keyNullableValue("b") { toEqual(2) },
|
||||
arrayOf(
|
||||
keyNullableValue("a", null),
|
||||
@@ -296,8 +296,8 @@ abstract class MapContainsInOrderOnlyKeyValueExpectationsSpec(
|
||||
elementFailing(1, "null=1", "a", "$toBeDescr: null")
|
||||
elementFailing(2, "b=2", null, "$toBeDescr: 1")
|
||||
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.contains
|
||||
// containsNot(sizeDescr)
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.toContain
|
||||
// toContainNot(sizeDescr)
|
||||
notToContain(additionalEntriesDescr)
|
||||
|
||||
}
|
||||
@@ -307,7 +307,7 @@ abstract class MapContainsInOrderOnlyKeyValueExpectationsSpec(
|
||||
|
||||
it("(a, null), c { isLessThan(1) }, b { isLessThan(2) } throws AssertionError, reports b and c") {
|
||||
expect {
|
||||
nullableFluent.containsFun(
|
||||
nullableFluent.toContainFun(
|
||||
keyNullableValue("a", null), arrayOf(
|
||||
keyNullableValue("c") { toBeLessThan(1) },
|
||||
keyNullableValue("b") { toBeLessThan(2) }
|
||||
@@ -316,11 +316,11 @@ abstract class MapContainsInOrderOnlyKeyValueExpectationsSpec(
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
elementSuccess(0, "a=null", "a", "$toBeDescr: null")
|
||||
elementFailing(1, "null=1", "c", "$lessThanDescr: 1")
|
||||
elementFailing(2, "b=2", "b", "$lessThanDescr: 2")
|
||||
elementFailing(1, "null=1", "c", "$toBeLessThanDescr: 1")
|
||||
elementFailing(2, "b=2", "b", "$toBeLessThanDescr: 2")
|
||||
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.contains
|
||||
// containsNot(sizeDescr)
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.toContain
|
||||
// toContainNot(sizeDescr)
|
||||
notToContain(additionalEntriesDescr)
|
||||
}
|
||||
}
|
||||
@@ -6,11 +6,11 @@ import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.specs.*
|
||||
import org.spekframework.spek2.style.specification.Suite
|
||||
|
||||
abstract class MapContainsInOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
abstract class MapToContainInOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
keyValuePairs: MFun2<String, Int, Int>,
|
||||
keyValuePairsNullable: MFun2<String?, Int?, Int?>,
|
||||
describePrefix: String = "[Atrium] "
|
||||
) : MapLikeContainsFormatSpecBase({
|
||||
) : MapLikeToContainFormatSpecBase({
|
||||
|
||||
include(object : SubjectLessSpec<Map<out String, Int>>(
|
||||
describePrefix,
|
||||
@@ -95,18 +95,18 @@ abstract class MapContainsInOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
}
|
||||
|
||||
describeFun(keyValuePairs, keyValuePairsNullable) {
|
||||
val containsKeyValuePairsFunctions = uncheckedToNonNullable(keyValuePairs, keyValuePairsNullable)
|
||||
val toContainKeyValuePairsFunctions = uncheckedToNonNullable(keyValuePairs, keyValuePairsNullable)
|
||||
|
||||
context("empty map") {
|
||||
containsKeyValuePairsFunctions.forEach { (name, containsFun) ->
|
||||
toContainKeyValuePairsFunctions.forEach { (name, toContainFun) ->
|
||||
it("$name - a to 1 throws AssertionError, reports a") {
|
||||
expect {
|
||||
expect(emptyMap).containsFun("a" to 1, arrayOf())
|
||||
expect(emptyMap).toContainFun("a" to 1, arrayOf())
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
containsInOrderOnlyDescr()
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.contains
|
||||
//containsSize(0, 1)
|
||||
toContainInOrderOnlyDescr()
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.toContain
|
||||
//toContainsSize(0, 1)
|
||||
elementOutOfBound(0, "a", 1)
|
||||
}
|
||||
}
|
||||
@@ -114,12 +114,12 @@ abstract class MapContainsInOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
|
||||
it("$name - a to 2, b to 3, c to 4 } throws AssertionError, reports a, b and c") {
|
||||
expect {
|
||||
expect(emptyMap).containsFun("a" to 2, arrayOf("b" to 3, "c" to 4))
|
||||
expect(emptyMap).toContainFun("a" to 2, arrayOf("b" to 3, "c" to 4))
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
containsInOrderOnlyDescr()
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.contains
|
||||
//containsSize(0, 3)
|
||||
toContainInOrderOnlyDescr()
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.toContain
|
||||
//toContainsSize(0, 3)
|
||||
elementOutOfBound(0, "a", 2)
|
||||
elementOutOfBound(1, "b", 3)
|
||||
elementOutOfBound(2, "c", 4)
|
||||
@@ -132,38 +132,38 @@ abstract class MapContainsInOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
context("map $map") {
|
||||
val fluent = expect(map)
|
||||
|
||||
containsKeyValuePairsFunctions.forEach { (name, containsFun) ->
|
||||
toContainKeyValuePairsFunctions.forEach { (name, toContainFun) ->
|
||||
listOf(
|
||||
listOf("a" to 1, "b" to 2)
|
||||
).forEach {
|
||||
it("$name - ${it.joinToString()} does not throw") {
|
||||
fluent.containsFun(it.first(), it.drop(1).toTypedArray())
|
||||
fluent.toContainFun(it.first(), it.drop(1).toTypedArray())
|
||||
}
|
||||
}
|
||||
|
||||
it("$name - a to 1 throws AssertionError, missing b") {
|
||||
expect {
|
||||
fluent.containsFun("a" to 1, arrayOf())
|
||||
fluent.toContainFun("a" to 1, arrayOf())
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
elementSuccess(0, "a=1", "a", 1)
|
||||
additionalEntries(1 to "b=2")
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.contains
|
||||
// containsSize(2, 1)
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.toContain
|
||||
// toContainsSize(2, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
it("$name - b 2, a to 1 throws AssertionError, wrong order") {
|
||||
expect {
|
||||
fluent.containsFun("b" to 2, arrayOf("a" to 1))
|
||||
fluent.toContainFun("b" to 2, arrayOf("a" to 1))
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
elementFailing(0, "a=1", "b", 2)
|
||||
elementFailing(1, "b=2", "a", 1)
|
||||
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.contains
|
||||
// containsNot(sizeDescr)
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.toContain
|
||||
// toContainNot(sizeDescr)
|
||||
notToContain(additionalEntriesDescr)
|
||||
}
|
||||
}
|
||||
@@ -171,7 +171,7 @@ abstract class MapContainsInOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
|
||||
it("$name - a to 1, b to 1, c to 4 throws AssertionError, reports b and c") {
|
||||
expect {
|
||||
fluent.containsFun("a" to 1, arrayOf("b" to 1, "c" to 4))
|
||||
fluent.toContainFun("a" to 1, arrayOf("b" to 1, "c" to 4))
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
elementSuccess(0, "a=1", "a", 1)
|
||||
@@ -186,7 +186,7 @@ abstract class MapContainsInOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
}
|
||||
|
||||
describeFun(keyValuePairsNullable) {
|
||||
val containsFun = keyValuePairsNullable.lambda
|
||||
val toContainFun = keyValuePairsNullable.lambda
|
||||
val nullableFluent = expect(nullableMap)
|
||||
|
||||
context("map: $nullableMap") {
|
||||
@@ -194,34 +194,34 @@ abstract class MapContainsInOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
listOf("a" to null, null to 1, "b" to 2)
|
||||
).forEach {
|
||||
it("$it does not throw") {
|
||||
expect(nullableMap).containsFun(it.first(), it.drop(1).toTypedArray())
|
||||
expect(nullableMap).toContainFun(it.first(), it.drop(1).toTypedArray())
|
||||
}
|
||||
}
|
||||
|
||||
it("a to null throws AssertionError, missing b") {
|
||||
expect {
|
||||
nullableFluent.containsFun("a" to null, arrayOf())
|
||||
nullableFluent.toContainFun("a" to null, arrayOf())
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
elementSuccess(0, "a=null", "a", null)
|
||||
additionalEntries(1 to "null=1", 2 to "b=2")
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.contains
|
||||
// containsSize(3, 1)
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.toContain
|
||||
// toContainsSize(3, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
it("b to 2, a to null, null to 1 throws AssertionError, wrong order") {
|
||||
expect {
|
||||
nullableFluent.containsFun("b" to 2, arrayOf("a" to null, null to 1))
|
||||
nullableFluent.toContainFun("b" to 2, arrayOf("a" to null, null to 1))
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
elementFailing(0, "a=null", "b", 2)
|
||||
elementFailing(1, "null=1", "a", null)
|
||||
elementFailing(2, "b=2", null, 1)
|
||||
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.contains
|
||||
// containsNot(sizeDescr)
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.toContain
|
||||
// toContainNot(sizeDescr)
|
||||
notToContain(additionalEntriesDescr)
|
||||
|
||||
}
|
||||
@@ -231,15 +231,15 @@ abstract class MapContainsInOrderOnlyKeyValuePairsExpectationsSpec(
|
||||
|
||||
it("a to null, c to 3, b to 3 throws AssertionError, reports b and c") {
|
||||
expect {
|
||||
nullableFluent.containsFun("a" to null, arrayOf("c" to 3, "b" to 3))
|
||||
nullableFluent.toContainFun("a" to null, arrayOf("c" to 3, "b" to 3))
|
||||
}.toThrow<AssertionError> {
|
||||
message {
|
||||
elementSuccess(0, "a=null", "a", null)
|
||||
elementFailing(1, "null=1", "c", 3)
|
||||
elementFailing(2, "b=2", "b", 3)
|
||||
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.contains
|
||||
// containsNot(sizeDescr)
|
||||
// TODO 0.18.0 wait for size to be moved out of Iterable.toContain
|
||||
// toContainNot(sizeDescr)
|
||||
notToContain(additionalEntriesDescr)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user