mirror of
https://github.com/jlengrand/atrium.git
synced 2026-03-10 08:01:19 +00:00
add iterable to the new infix API
this commit includes:
- turning the extension val `contains` into a fun `contains o`
likewise `containsNot o`
- remove the pseudo-keyword `not` as in `contains not`, i.e. turn
`expect("h") contains not` into `expect("h") containsNot o`
- improve ambiguity tests for Iterable...Spec
This commit is contained in:
@@ -4,7 +4,7 @@ import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.domain.builders.ExpectImpl
|
||||
import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion
|
||||
import ch.tutteli.atrium.domain.builders.utils.toVarArg
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains.CheckerOption
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderSearchBehaviour
|
||||
import ch.tutteli.kbox.glue
|
||||
|
||||
@@ -19,7 +19,7 @@ import ch.tutteli.kbox.glue
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
fun <E, T : Iterable<E>> IterableContains.CheckerOption<E, T, InAnyOrderSearchBehaviour>.value(expected: E): Expect<T> =
|
||||
fun <E, T : Iterable<E>> CheckerOption<E, T, InAnyOrderSearchBehaviour>.value(expected: E): Expect<T> =
|
||||
values(expected)
|
||||
|
||||
/**
|
||||
@@ -42,7 +42,7 @@ fun <E, T : Iterable<E>> IterableContains.CheckerOption<E, T, InAnyOrderSearchBe
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
fun <E, T : Iterable<E>> IterableContains.CheckerOption<E, T, InAnyOrderSearchBehaviour>.values(
|
||||
fun <E, T : Iterable<E>> CheckerOption<E, T, InAnyOrderSearchBehaviour>.values(
|
||||
expected: E,
|
||||
vararg otherExpected: E
|
||||
): Expect<T> = addAssertion(ExpectImpl.iterable.contains.valuesInAnyOrder(this, expected glue otherExpected))
|
||||
@@ -61,7 +61,7 @@ fun <E, T : Iterable<E>> IterableContains.CheckerOption<E, T, InAnyOrderSearchBe
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
fun <E : Any, T : Iterable<E?>> IterableContains.CheckerOption<E?, T, InAnyOrderSearchBehaviour>.entry(
|
||||
fun <E : Any, T : Iterable<E?>> CheckerOption<E?, T, InAnyOrderSearchBehaviour>.entry(
|
||||
assertionCreatorOrNull: (Expect<E>.() -> Unit)?
|
||||
): Expect<T> = entries(assertionCreatorOrNull)
|
||||
|
||||
@@ -80,7 +80,7 @@ fun <E : Any, T : Iterable<E?>> IterableContains.CheckerOption<E?, T, InAnyOrder
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
fun <E : Any, T : Iterable<E?>> IterableContains.CheckerOption<E?, T, InAnyOrderSearchBehaviour>.entries(
|
||||
fun <E : Any, T : Iterable<E?>> CheckerOption<E?, T, InAnyOrderSearchBehaviour>.entries(
|
||||
assertionCreatorOrNull: (Expect<E>.() -> Unit)?,
|
||||
vararg otherAssertionCreatorsOrNulls: (Expect<E>.() -> Unit)?
|
||||
): Expect<T> = addAssertion(
|
||||
@@ -105,7 +105,7 @@ fun <E : Any, T : Iterable<E?>> IterableContains.CheckerOption<E?, T, InAnyOrder
|
||||
*
|
||||
* @since 0.9.0
|
||||
*/
|
||||
inline fun <reified E, T : Iterable<E>> IterableContains.CheckerOption<E, T, InAnyOrderSearchBehaviour>.elementsOf(
|
||||
inline fun <reified E, T : Iterable<E>> CheckerOption<E, T, InAnyOrderSearchBehaviour>.elementsOf(
|
||||
expectedIterable: Iterable<E>
|
||||
): Expect<T> {
|
||||
val (first, rest) = toVarArg(expectedIterable)
|
||||
|
||||
@@ -4,7 +4,7 @@ import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.domain.builders.ExpectImpl
|
||||
import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion
|
||||
import ch.tutteli.atrium.domain.builders.utils.toVarArg
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains.Builder
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderOnlySearchBehaviour
|
||||
import ch.tutteli.kbox.glue
|
||||
|
||||
@@ -23,7 +23,7 @@ import ch.tutteli.kbox.glue
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
fun <E, T : Iterable<E>> IterableContains.Builder<E, T, InAnyOrderOnlySearchBehaviour>.value(expected: E): Expect<T> =
|
||||
fun <E, T : Iterable<E>> Builder<E, T, InAnyOrderOnlySearchBehaviour>.value(expected: E): Expect<T> =
|
||||
values(expected)
|
||||
|
||||
/**
|
||||
@@ -42,7 +42,7 @@ fun <E, T : Iterable<E>> IterableContains.Builder<E, T, InAnyOrderOnlySearchBeha
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
fun <E, T : Iterable<E>> IterableContains.Builder<E, T, InAnyOrderOnlySearchBehaviour>.values(
|
||||
fun <E, T : Iterable<E>> Builder<E, T, InAnyOrderOnlySearchBehaviour>.values(
|
||||
expected: E,
|
||||
vararg otherExpected: E
|
||||
): Expect<T> = addAssertion(ExpectImpl.iterable.contains.valuesInAnyOrderOnly(this, expected glue otherExpected))
|
||||
@@ -65,7 +65,7 @@ fun <E, T : Iterable<E>> IterableContains.Builder<E, T, InAnyOrderOnlySearchBeha
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
fun <E : Any, T : Iterable<E?>> IterableContains.Builder<E?, T, InAnyOrderOnlySearchBehaviour>.entry(
|
||||
fun <E : Any, T : Iterable<E?>> Builder<E?, T, InAnyOrderOnlySearchBehaviour>.entry(
|
||||
assertionCreatorOrNull: (Expect<E>.() -> Unit)?
|
||||
): Expect<T> = entries(assertionCreatorOrNull)
|
||||
|
||||
@@ -97,7 +97,7 @@ fun <E : Any, T : Iterable<E?>> IterableContains.Builder<E?, T, InAnyOrderOnlySe
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
fun <E : Any, T : Iterable<E?>> IterableContains.Builder<E?, T, InAnyOrderOnlySearchBehaviour>.entries(
|
||||
fun <E : Any, T : Iterable<E?>> Builder<E?, T, InAnyOrderOnlySearchBehaviour>.entries(
|
||||
assertionCreatorOrNull: (Expect<E>.() -> Unit)?,
|
||||
vararg otherAssertionCreatorsOrNulls: (Expect<E>.() -> Unit)?
|
||||
): Expect<T> = addAssertion(
|
||||
@@ -126,7 +126,7 @@ fun <E : Any, T : Iterable<E?>> IterableContains.Builder<E?, T, InAnyOrderOnlySe
|
||||
*
|
||||
* @since 0.9.0
|
||||
*/
|
||||
inline fun <reified E, T : Iterable<E>> IterableContains.Builder<E, T, InAnyOrderOnlySearchBehaviour>.elementsOf(
|
||||
inline fun <reified E, T : Iterable<E>> Builder<E, T, InAnyOrderOnlySearchBehaviour>.elementsOf(
|
||||
expectedIterable: Iterable<E>
|
||||
): Expect<T> {
|
||||
val (first, rest) = toVarArg(expectedIterable)
|
||||
|
||||
@@ -4,7 +4,7 @@ import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.domain.builders.ExpectImpl
|
||||
import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion
|
||||
import ch.tutteli.atrium.domain.builders.utils.toVarArg
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains.Builder
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InOrderOnlySearchBehaviour
|
||||
import ch.tutteli.kbox.glue
|
||||
|
||||
@@ -23,7 +23,7 @@ import ch.tutteli.kbox.glue
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
fun <E, T : Iterable<E>> IterableContains.Builder<E, T, InOrderOnlySearchBehaviour>.value(expected: E): Expect<T> =
|
||||
fun <E, T : Iterable<E>> Builder<E, T, InOrderOnlySearchBehaviour>.value(expected: E): Expect<T> =
|
||||
values(expected)
|
||||
|
||||
/**
|
||||
@@ -41,7 +41,7 @@ fun <E, T : Iterable<E>> IterableContains.Builder<E, T, InOrderOnlySearchBehavio
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
fun <E, T : Iterable<E>> IterableContains.Builder<E, T, InOrderOnlySearchBehaviour>.values(
|
||||
fun <E, T : Iterable<E>> Builder<E, T, InOrderOnlySearchBehaviour>.values(
|
||||
expected: E,
|
||||
vararg otherExpected: E
|
||||
): Expect<T> = addAssertion(ExpectImpl.iterable.contains.valuesInOrderOnly(this, expected glue otherExpected))
|
||||
@@ -64,7 +64,7 @@ fun <E, T : Iterable<E>> IterableContains.Builder<E, T, InOrderOnlySearchBehavio
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
fun <E : Any, T : Iterable<E?>> IterableContains.Builder<E?, T, InOrderOnlySearchBehaviour>.entry(
|
||||
fun <E : Any, T : Iterable<E?>> Builder<E?, T, InOrderOnlySearchBehaviour>.entry(
|
||||
assertionCreatorOrNull: (Expect<E>.() -> Unit)?
|
||||
): Expect<T> = entries(assertionCreatorOrNull)
|
||||
|
||||
@@ -87,7 +87,7 @@ fun <E : Any, T : Iterable<E?>> IterableContains.Builder<E?, T, InOrderOnlySearc
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
fun <E : Any, T : Iterable<E?>> IterableContains.Builder<E?, T, InOrderOnlySearchBehaviour>.entries(
|
||||
fun <E : Any, T : Iterable<E?>> Builder<E?, T, InOrderOnlySearchBehaviour>.entries(
|
||||
assertionCreatorOrNull: (Expect<E>.() -> Unit)?,
|
||||
vararg otherAssertionCreatorsOrNulls: (Expect<E>.() -> Unit)?
|
||||
): Expect<T> = addAssertion(
|
||||
@@ -116,7 +116,7 @@ fun <E : Any, T : Iterable<E?>> IterableContains.Builder<E?, T, InOrderOnlySearc
|
||||
*
|
||||
* @since 0.9.0
|
||||
*/
|
||||
inline fun <reified E, T : Iterable<E>> IterableContains.Builder<E, T, InOrderOnlySearchBehaviour>.elementsOf(
|
||||
inline fun <reified E, T : Iterable<E>> Builder<E, T, InOrderOnlySearchBehaviour>.elementsOf(
|
||||
expectedIterable: Iterable<E>
|
||||
): Expect<T> {
|
||||
val (first, rest) = toVarArg(expectedIterable)
|
||||
|
||||
@@ -5,7 +5,7 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl
|
||||
import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion
|
||||
import ch.tutteli.atrium.domain.builders.utils.Group
|
||||
import ch.tutteli.atrium.domain.builders.utils.groupsToList
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains.Builder
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InOrderOnlyGroupedWithinSearchBehaviour
|
||||
import kotlin.jvm.JvmName
|
||||
|
||||
@@ -22,7 +22,7 @@ import kotlin.jvm.JvmName
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
fun <E, T : Iterable<E>> IterableContains.Builder<E, T, InOrderOnlyGroupedWithinSearchBehaviour>.inAnyOrder(
|
||||
fun <E, T : Iterable<E>> Builder<E, T, InOrderOnlyGroupedWithinSearchBehaviour>.inAnyOrder(
|
||||
firstGroup: Group<E>,
|
||||
secondGroup: Group<E>,
|
||||
vararg otherExpectedGroups: Group<E>
|
||||
@@ -52,7 +52,7 @@ fun <E, T : Iterable<E>> IterableContains.Builder<E, T, InOrderOnlyGroupedWithin
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
@JvmName("inAnyOrderEntries")
|
||||
fun <E : Any, T : Iterable<E?>> IterableContains.Builder<E?, T, InOrderOnlyGroupedWithinSearchBehaviour>.inAnyOrder(
|
||||
fun <E : Any, T : Iterable<E?>> Builder<E?, T, InOrderOnlyGroupedWithinSearchBehaviour>.inAnyOrder(
|
||||
firstGroup: Group<(Expect<E>.() -> Unit)?>,
|
||||
secondGroup: Group<(Expect<E>.() -> Unit)?>,
|
||||
vararg otherExpectedGroups: Group<(Expect<E>.() -> Unit)?>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package ch.tutteli.atrium.api.fluent.en_GB
|
||||
|
||||
import ch.tutteli.atrium.domain.builders.ExpectImpl
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains.Builder
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.*
|
||||
import kotlin.jvm.JvmName
|
||||
|
||||
@@ -11,7 +11,7 @@ import kotlin.jvm.JvmName
|
||||
*
|
||||
* @return The newly created builder.
|
||||
*/
|
||||
val <E, T : Iterable<E>> IterableContains.Builder<E, T, NoOpSearchBehaviour>.inAnyOrder
|
||||
val <E, T : Iterable<E>> Builder<E, T, NoOpSearchBehaviour>.inAnyOrder
|
||||
get() = ExpectImpl.iterable.contains.searchBehaviours.inAnyOrder(this)
|
||||
|
||||
/**
|
||||
@@ -20,7 +20,7 @@ val <E, T : Iterable<E>> IterableContains.Builder<E, T, NoOpSearchBehaviour>.inA
|
||||
*
|
||||
* @return The newly created builder.
|
||||
*/
|
||||
val <E, T : Iterable<E>> IterableContains.Builder<E, T, InAnyOrderSearchBehaviour>.only
|
||||
val <E, T : Iterable<E>> Builder<E, T, InAnyOrderSearchBehaviour>.only
|
||||
@JvmName("butOnly")
|
||||
get() = ExpectImpl.iterable.contains.searchBehaviours.inAnyOrderOnly(this)
|
||||
|
||||
@@ -31,7 +31,7 @@ val <E, T : Iterable<E>> IterableContains.Builder<E, T, InAnyOrderSearchBehaviou
|
||||
*
|
||||
* @return The newly created builder.
|
||||
*/
|
||||
val <E, T : Iterable<E>> IterableContains.Builder<E, T, NoOpSearchBehaviour>.inOrder
|
||||
val <E, T : Iterable<E>> Builder<E, T, NoOpSearchBehaviour>.inOrder
|
||||
get() = ExpectImpl.iterable.contains.searchBehaviours.inOrder(this)
|
||||
|
||||
/**
|
||||
@@ -40,7 +40,7 @@ val <E, T : Iterable<E>> IterableContains.Builder<E, T, NoOpSearchBehaviour>.inO
|
||||
*
|
||||
* @return The newly created builder.
|
||||
*/
|
||||
val <E, T : Iterable<E>> IterableContains.Builder<E, T, InOrderSearchBehaviour>.only
|
||||
val <E, T : Iterable<E>> Builder<E, T, InOrderSearchBehaviour>.only
|
||||
@JvmName("andOnly")
|
||||
get() = ExpectImpl.iterable.contains.searchBehaviours.inOrderOnly(this)
|
||||
|
||||
@@ -50,7 +50,7 @@ val <E, T : Iterable<E>> IterableContains.Builder<E, T, InOrderSearchBehaviour>.
|
||||
*
|
||||
* @return The newly created builder.
|
||||
*/
|
||||
val <E, T : Iterable<E>> IterableContains.Builder<E, T, InOrderOnlySearchBehaviour>.grouped
|
||||
val <E, T : Iterable<E>> Builder<E, T, InOrderOnlySearchBehaviour>.grouped
|
||||
get() = ExpectImpl.iterable.contains.searchBehaviours.inOrderOnlyGrouped(this)
|
||||
|
||||
/**
|
||||
@@ -58,5 +58,5 @@ val <E, T : Iterable<E>> IterableContains.Builder<E, T, InOrderOnlySearchBehavio
|
||||
*
|
||||
* @return The newly created builder.
|
||||
*/
|
||||
val <E, T : Iterable<E>> IterableContains.Builder<E, T, InOrderOnlyGroupedSearchBehaviour>.within
|
||||
val <E, T : Iterable<E>> Builder<E, T, InOrderOnlyGroupedSearchBehaviour>.within
|
||||
get() = ExpectImpl.iterable.contains.searchBehaviours.inOrderOnlyGroupedWithin(this)
|
||||
|
||||
@@ -53,7 +53,7 @@ abstract class CharSequenceContainsSpecBase {
|
||||
a1.contains.ignoringCase.values("a", 'b')
|
||||
a1.contains.ignoringCase.regex("a")
|
||||
a1.contains.ignoringCase.regex("a", "bl")
|
||||
//TODO add (also to infix API)
|
||||
// a1.contains.ignoringCase.elementsOf(listOf(1, 2))("a", "bl")
|
||||
//TODO #422 uncomment
|
||||
//a1.contains.ignoringCase.elementsOf(listOf("a", 2))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,10 +12,10 @@ object IterableAllAssertionsSpec : ch.tutteli.atrium.specs.integration.IterableA
|
||||
) {
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
private fun ambiguityTest() {
|
||||
var a1: Expect<Iterable<Double>> = notImplemented()
|
||||
var a1b: Expect<Iterable<Double?>> = notImplemented()
|
||||
var a1: Expect<List<Double>> = notImplemented()
|
||||
var a1b: Expect<Set<Double?>> = notImplemented()
|
||||
|
||||
var star: Expect<Iterable<*>> = notImplemented()
|
||||
var star: Expect<Collection<*>> = notImplemented()
|
||||
|
||||
a1 = a1.all {}
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ import ch.tutteli.atrium.specs.notImplemented
|
||||
import ch.tutteli.atrium.specs.withNullableSuffix
|
||||
import org.spekframework.spek2.Spek
|
||||
import kotlin.reflect.KFunction2
|
||||
import kotlin.reflect.KFunction3
|
||||
|
||||
class IterableAnyAssertionsSpec : Spek({
|
||||
include(PredicateSpec)
|
||||
@@ -45,47 +44,47 @@ class IterableAnyAssertionsSpec : Spek({
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
fun getContainsPair() =
|
||||
"$contains.$inAnyOrder.$atLeast(1).$inAnyOrderEntries" to Companion::containsInAnyOrderEntries
|
||||
"$contains.$inAnyOrder.$atLeast(1).$inAnyOrderEntries" to Companion::containsInAnyOrderEntry
|
||||
|
||||
private fun containsInAnyOrderEntries(expect: Expect<Iterable<Double>>, a: Expect<Double>.() -> Unit) =
|
||||
private fun containsInAnyOrderEntry(expect: Expect<Iterable<Double>>, a: Expect<Double>.() -> Unit) =
|
||||
expect.contains.inAnyOrder.atLeast(1).entry(a)
|
||||
|
||||
fun getContainsNullablePair() =
|
||||
"$contains.$inAnyOrder.$atLeast(1).$inAnyOrderEntries" to Companion::containsNullableEntries
|
||||
"$contains.$inAnyOrder.$atLeast(1).$inAnyOrderEntries" to Companion::containsNullableEntry
|
||||
|
||||
private fun containsNullableEntries(expect: Expect<Iterable<Double?>>, a: (Expect<Double>.() -> Unit)?) =
|
||||
private fun containsNullableEntry(expect: Expect<Iterable<Double?>>, a: (Expect<Double>.() -> Unit)?) =
|
||||
expect.contains.inAnyOrder.atLeast(1).entry(a)
|
||||
|
||||
private val containsShortcutFun: KFunction3<Expect<Iterable<Double>>, Expect<Double>.() -> Unit, Array<out Expect<Double>.() -> Unit>, Expect<Iterable<Double>>> =
|
||||
private val containsShortcutFun: KFunction2<Expect<Iterable<Double>>, Expect<Double>.() -> Unit, Expect<Iterable<Double>>> =
|
||||
Expect<Iterable<Double>>::contains
|
||||
|
||||
fun getContainsShortcutPair() = containsShortcutFun.name to Companion::containsInAnyOrderEntriesShortcut
|
||||
fun getContainsShortcutPair() = containsShortcutFun.name to Companion::containsInAnyOrderEntryShortcut
|
||||
|
||||
private fun containsInAnyOrderEntriesShortcut(expect: Expect<Iterable<Double>>, a: Expect<Double>.() -> Unit) =
|
||||
private fun containsInAnyOrderEntryShortcut(expect: Expect<Iterable<Double>>, a: Expect<Double>.() -> Unit) =
|
||||
expect.contains(a)
|
||||
|
||||
private val containsShortcutNullableFun: KFunction2<Expect<Iterable<Double?>>, (Expect<Double>.() -> Unit)?, Expect<Iterable<Double?>>> =
|
||||
Expect<Iterable<Double?>>::contains
|
||||
|
||||
fun getContainsNullableShortcutPair() =
|
||||
containsShortcutNullableFun.name to Companion::containsNullableEntriesShortcut
|
||||
containsShortcutNullableFun.name to Companion::containsNullableEntryShortcut
|
||||
|
||||
private fun containsNullableEntriesShortcut(
|
||||
private fun containsNullableEntryShortcut(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: (Expect<Double>.() -> Unit)?
|
||||
) = expect.contains(a)
|
||||
|
||||
|
||||
private fun getContainsSequencePair() =
|
||||
"asSequence().${Sequence<*>::asIterable.name}().${containsShortcutFun.name}" to Companion::containsInAnyOrderEntriesSequence
|
||||
"asSequence().${Sequence<*>::asIterable.name}().${containsShortcutFun.name}" to Companion::containsInAnyOrderEntrySequence
|
||||
|
||||
private fun containsInAnyOrderEntriesSequence(expect: Expect<Iterable<Double>>, a: Expect<Double>.() -> Unit) =
|
||||
private fun containsInAnyOrderEntrySequence(expect: Expect<Iterable<Double>>, a: Expect<Double>.() -> Unit) =
|
||||
ExpectImpl.changeSubject(expect).unreported { it.asSequence() }.asIterable().contains(a)
|
||||
|
||||
fun getContainsNullableSequencePair() =
|
||||
"asSequence().${Sequence<*>::asIterable.name}().${containsShortcutNullableFun.name}" to Companion::containsNullableEntriesSequence
|
||||
"asSequence().${Sequence<*>::asIterable.name}().${containsShortcutNullableFun.name}" to Companion::containsNullableEntrySequence
|
||||
|
||||
private fun containsNullableEntriesSequence(
|
||||
private fun containsNullableEntrySequence(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: (Expect<Double>.() -> Unit)?
|
||||
) = ExpectImpl.changeSubject(expect).unreported { it.asSequence() }.asIterable().contains(a)
|
||||
@@ -93,10 +92,10 @@ class IterableAnyAssertionsSpec : Spek({
|
||||
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
private fun ambiguityTest() {
|
||||
var a1: Expect<Iterable<Double>> = notImplemented()
|
||||
var a1b: Expect<Iterable<Double?>> = notImplemented()
|
||||
var a1: Expect<List<Double>> = notImplemented()
|
||||
var a1b: Expect<Set<Double?>> = notImplemented()
|
||||
|
||||
var star: Expect<Iterable<*>> = notImplemented()
|
||||
var star: Expect<Collection<*>> = notImplemented()
|
||||
|
||||
a1 = a1.any {}
|
||||
a1 = a1.contains {}
|
||||
|
||||
@@ -11,10 +11,9 @@ object IterableAssertionsSpec : ch.tutteli.atrium.specs.integration.IterableAsse
|
||||
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
private fun ambiguityTest() {
|
||||
var a1: Expect<Iterable<Double>> = notImplemented()
|
||||
var a1b: Expect<Iterable<Double?>> = notImplemented()
|
||||
|
||||
var star: Expect<Iterable<*>> = notImplemented()
|
||||
var a1: Expect<List<Double>> = notImplemented()
|
||||
var a1b: Expect<Set<Double?>> = notImplemented()
|
||||
var star: Expect<Collection<*>> = notImplemented()
|
||||
|
||||
a1 = a1.hasNext()
|
||||
a1 = a1.hasNotNext()
|
||||
|
||||
@@ -59,7 +59,7 @@ class IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec : Spek({
|
||||
else expect.contains(a, *aX)
|
||||
|
||||
|
||||
private val containsNullableFun: KFunction3<Expect<Iterable<Double?>>, Double, Array<out Double?>, Expect<Iterable<Double?>>> =
|
||||
private val containsNullableFun: KFunction3<Expect<Iterable<Double?>>, Double?, Array<out Double?>, Expect<Iterable<Double?>>> =
|
||||
Expect<Iterable<Double?>>::contains
|
||||
|
||||
fun getContainsNullableShortcutPair() = containsNullableFun.name to Companion::containsNullableValuesShortcut
|
||||
|
||||
@@ -43,30 +43,69 @@ abstract class IterableContainsSpecBase {
|
||||
@Suppress("unused")
|
||||
private fun ambiguityTest() {
|
||||
val list: Expect<List<Number>> = notImplemented()
|
||||
val nullableList: Expect<List<Number?>> = notImplemented()
|
||||
val nullableList: Expect<Set<Number?>> = notImplemented()
|
||||
val subList: Expect<ArrayList<out Number>> = notImplemented()
|
||||
val star: Expect<Collection<*>> = notImplemented()
|
||||
|
||||
list.contains(1)
|
||||
list.contains(1f)
|
||||
list.contains(1, 2)
|
||||
list.contains(1, 2f)
|
||||
list.contains {}
|
||||
list.contains({}, {})
|
||||
list.containsNot(1)
|
||||
list.containsNot(1f)
|
||||
list.containsNot(1, 2f)
|
||||
list.containsNot.entry {}
|
||||
list.containsNot.entries({}, {})
|
||||
|
||||
subList.contains(1)
|
||||
subList.contains(1f)
|
||||
subList.contains(1, 2)
|
||||
subList.contains(1, 2f)
|
||||
subList.contains {}
|
||||
subList.contains({}, {})
|
||||
subList.containsNot(1)
|
||||
subList.containsNot(1f)
|
||||
subList.containsNot(1, 2f)
|
||||
subList.containsNot.entry {}
|
||||
subList.containsNot.entries({}, {})
|
||||
|
||||
nullableList.contains(1)
|
||||
nullableList.contains(1f)
|
||||
nullableList.contains(1, 2)
|
||||
nullableList.contains(1, 2f)
|
||||
nullableList.contains {}
|
||||
nullableList.contains({}, {})
|
||||
nullableList.containsNot(1)
|
||||
nullableList.containsNot(1f)
|
||||
nullableList.containsNot(1, 2f)
|
||||
nullableList.containsNot.entry {}
|
||||
nullableList.containsNot.entries({}, {})
|
||||
nullableList.contains(null)
|
||||
nullableList.contains({}, null)
|
||||
nullableList.contains({}, {})
|
||||
nullableList.contains(null, {})
|
||||
nullableList.contains(null, null)
|
||||
nullableList.containsNot(null)
|
||||
nullableList.containsNot.entries({}, null)
|
||||
nullableList.containsNot.entries(null, {})
|
||||
nullableList.containsNot.entries(null, null)
|
||||
|
||||
star.contains(1)
|
||||
star.contains(1f)
|
||||
star.contains(1, 2f)
|
||||
star.contains {}
|
||||
star.contains({}, {})
|
||||
star.containsNot(1)
|
||||
star.containsNot(1f)
|
||||
star.containsNot(1, 2f)
|
||||
star.containsNot.entry {}
|
||||
star.containsNot.entries({}, {})
|
||||
star.contains(null)
|
||||
star.contains({}, null)
|
||||
star.contains(null, {})
|
||||
star.contains(null, null)
|
||||
star.containsNot(null)
|
||||
star.containsNot.entries({}, null)
|
||||
star.containsNot.entries(null, {})
|
||||
star.containsNot.entries(null, null)
|
||||
|
||||
list.containsExactly(1)
|
||||
list.containsExactly(1, 2f)
|
||||
@@ -85,67 +124,162 @@ abstract class IterableContainsSpecBase {
|
||||
nullableList.containsExactly(null, {})
|
||||
|
||||
list.contains.inAnyOrder.atLeast(1).value(1)
|
||||
list.contains.inAnyOrder.atLeast(1).value(null)
|
||||
list.contains.inAnyOrder.atLeast(1).values(2, 1)
|
||||
list.contains.inAnyOrder.atLeast(1).entry {}
|
||||
list.contains.inAnyOrder.atLeast(1).entry(null)
|
||||
list.contains.inAnyOrder.atLeast(1).entries({}, {})
|
||||
list.contains.inAnyOrder.atLeast(1).elementsOf(listOf(1, 2))
|
||||
subList.contains.inAnyOrder.atLeast(1).value(1)
|
||||
subList.contains.inAnyOrder.atLeast(1).value(null)
|
||||
subList.contains.inAnyOrder.atLeast(1).values(2, 1)
|
||||
subList.contains.inAnyOrder.atLeast(1).entry {}
|
||||
subList.contains.inAnyOrder.atLeast(1).entry(null)
|
||||
subList.contains.inAnyOrder.atLeast(1).entries({}, {})
|
||||
subList.contains.inAnyOrder.atLeast(1).elementsOf(listOf(1, 2))
|
||||
nullableList.contains.inAnyOrder.atLeast(1).value(1)
|
||||
nullableList.contains.inAnyOrder.atLeast(1).values(2, 1)
|
||||
nullableList.contains.inAnyOrder.atLeast(1).entry {}
|
||||
nullableList.contains.inAnyOrder.atLeast(1).entries({}, {})
|
||||
nullableList.contains.inAnyOrder.atLeast(1).elementsOf(listOf(1, 2))
|
||||
nullableList.contains.inAnyOrder.atLeast(1).value(null)
|
||||
nullableList.contains.inAnyOrder.atLeast(1).values(null, 1)
|
||||
nullableList.contains.inAnyOrder.atLeast(1).values(2, null)
|
||||
nullableList.contains.inAnyOrder.atLeast(1).values(null, null)
|
||||
nullableList.contains.inAnyOrder.atLeast(1).entry(null)
|
||||
nullableList.contains.inAnyOrder.atLeast(1).entries(null, {})
|
||||
nullableList.contains.inAnyOrder.atLeast(1).entries({}, null)
|
||||
nullableList.contains.inAnyOrder.atLeast(1).entries(null, null)
|
||||
star.contains.inAnyOrder.atLeast(1).value(1)
|
||||
star.contains.inAnyOrder.atLeast(1).values(2, 1)
|
||||
star.contains.inAnyOrder.atLeast(1).entry {}
|
||||
star.contains.inAnyOrder.atLeast(1).entries({}, {})
|
||||
star.contains.inAnyOrder.atLeast(1).elementsOf(listOf(1, 2))
|
||||
star.contains.inAnyOrder.atLeast(1).value(null)
|
||||
star.contains.inAnyOrder.atLeast(1).values(null, 1)
|
||||
star.contains.inAnyOrder.atLeast(1).values(2, null)
|
||||
star.contains.inAnyOrder.atLeast(1).values(null, null)
|
||||
star.contains.inAnyOrder.atLeast(1).entry(null)
|
||||
star.contains.inAnyOrder.atLeast(1).entries(null, {})
|
||||
star.contains.inAnyOrder.atLeast(1).entries({}, null)
|
||||
star.contains.inAnyOrder.atLeast(1).entries(null, null)
|
||||
|
||||
list.contains.inAnyOrder.only.value(1)
|
||||
list.contains.inAnyOrder.only.value(null)
|
||||
list.contains.inAnyOrder.only.values(2, 1)
|
||||
list.contains.inAnyOrder.only.entry {}
|
||||
list.contains.inAnyOrder.only.entry(null)
|
||||
list.contains.inAnyOrder.only.entries({}, {})
|
||||
list.contains.inAnyOrder.only.elementsOf(listOf(1, 2))
|
||||
subList.contains.inAnyOrder.only.value(1)
|
||||
subList.contains.inAnyOrder.only.value(null)
|
||||
subList.contains.inAnyOrder.only.values(2, 1)
|
||||
subList.contains.inAnyOrder.only.entry {}
|
||||
subList.contains.inAnyOrder.only.entry(null)
|
||||
subList.contains.inAnyOrder.only.entries({}, {})
|
||||
subList.contains.inAnyOrder.only.elementsOf(listOf(1, 2))
|
||||
nullableList.contains.inAnyOrder.only.value(1)
|
||||
nullableList.contains.inAnyOrder.only.values(2, 1)
|
||||
nullableList.contains.inAnyOrder.only.entry {}
|
||||
nullableList.contains.inAnyOrder.only.entries({}, {})
|
||||
nullableList.contains.inAnyOrder.only.elementsOf(listOf(1, 2))
|
||||
nullableList.contains.inAnyOrder.only.value(null)
|
||||
nullableList.contains.inAnyOrder.only.values(null, 1)
|
||||
nullableList.contains.inAnyOrder.only.values(2, null)
|
||||
nullableList.contains.inAnyOrder.only.values(null, null)
|
||||
nullableList.contains.inAnyOrder.only.entry(null)
|
||||
nullableList.contains.inAnyOrder.only.entries(null, {})
|
||||
nullableList.contains.inAnyOrder.only.entries({}, null)
|
||||
nullableList.contains.inAnyOrder.only.entries(null, null)
|
||||
star.contains.inAnyOrder.only.value(1)
|
||||
star.contains.inAnyOrder.only.values(2, 1)
|
||||
star.contains.inAnyOrder.only.entry {}
|
||||
star.contains.inAnyOrder.only.entries({}, {})
|
||||
star.contains.inAnyOrder.only.elementsOf(listOf(1, 2))
|
||||
star.contains.inAnyOrder.only.value(null)
|
||||
star.contains.inAnyOrder.only.values(null, 1)
|
||||
star.contains.inAnyOrder.only.values(2, null)
|
||||
star.contains.inAnyOrder.only.values(null, null)
|
||||
star.contains.inAnyOrder.only.entry(null)
|
||||
star.contains.inAnyOrder.only.entries(null, {})
|
||||
star.contains.inAnyOrder.only.entries({}, null)
|
||||
star.contains.inAnyOrder.only.entries(null, null)
|
||||
|
||||
list.contains.inOrder.only.value(1)
|
||||
list.contains.inOrder.only.value(null)
|
||||
list.contains.inOrder.only.values(2, 1)
|
||||
list.contains.inOrder.only.entry {}
|
||||
list.contains.inOrder.only.entry(null)
|
||||
list.contains.inOrder.only.entries({}, {})
|
||||
list.contains.inOrder.only.elementsOf(listOf(1, 2))
|
||||
subList.contains.inOrder.only.value(1)
|
||||
subList.contains.inOrder.only.value(null)
|
||||
subList.contains.inOrder.only.values(2, 1)
|
||||
subList.contains.inOrder.only.entry {}
|
||||
subList.contains.inOrder.only.entry(null)
|
||||
|
||||
subList.contains.inOrder.only.entries({}, {})
|
||||
subList.contains.inOrder.only.elementsOf(listOf(1, 2))
|
||||
nullableList.contains.inOrder.only.value(1)
|
||||
nullableList.contains.inOrder.only.values(2, 1)
|
||||
nullableList.contains.inOrder.only.entry {}
|
||||
nullableList.contains.inOrder.only.entries({}, {})
|
||||
nullableList.contains.inOrder.only.elementsOf(listOf(1, 2))
|
||||
nullableList.contains.inOrder.only.value(null)
|
||||
nullableList.contains.inOrder.only.values(null, 1)
|
||||
nullableList.contains.inOrder.only.values(2, null)
|
||||
nullableList.contains.inOrder.only.values(null, null)
|
||||
nullableList.contains.inOrder.only.entry(null)
|
||||
nullableList.contains.inOrder.only.entries(null, {})
|
||||
nullableList.contains.inOrder.only.entries({}, null)
|
||||
nullableList.contains.inOrder.only.entries(null, null)
|
||||
star.contains.inOrder.only.value(1)
|
||||
star.contains.inOrder.only.values(2, 1)
|
||||
star.contains.inOrder.only.entry {}
|
||||
star.contains.inOrder.only.entries({}, {})
|
||||
star.contains.inOrder.only.elementsOf(listOf(1, 2))
|
||||
star.contains.inOrder.only.value(null)
|
||||
star.contains.inOrder.only.values(null, 1)
|
||||
star.contains.inOrder.only.values(2, null)
|
||||
star.contains.inOrder.only.values(null, null)
|
||||
star.contains.inOrder.only.entry(null)
|
||||
star.contains.inOrder.only.entries(null, {})
|
||||
star.contains.inOrder.only.entries({}, null)
|
||||
star.contains.inOrder.only.entries(null, null)
|
||||
|
||||
list.contains.inOrder.only.grouped.within.inAnyOrder(
|
||||
Value(1),
|
||||
Value(null),
|
||||
Values(1f),
|
||||
Values(null),
|
||||
Values(1f, 1),
|
||||
Values(1, null),
|
||||
Values(null, null)
|
||||
Values(1f, 1)
|
||||
)
|
||||
subList.contains.inOrder.only.grouped.within.inAnyOrder(
|
||||
Value(1),
|
||||
Value(null),
|
||||
Values(1f),
|
||||
Values(1f, 1)
|
||||
)
|
||||
nullableList.contains.inOrder.only.grouped.within.inAnyOrder(
|
||||
Value(null),
|
||||
Values(null),
|
||||
Values(1f, 1),
|
||||
Values(null, 2),
|
||||
Values(1, null),
|
||||
Values(null, null)
|
||||
)
|
||||
star.contains.inOrder.only.grouped.within.inAnyOrder(
|
||||
Value(null),
|
||||
Values(null),
|
||||
Values(null, 2),
|
||||
Values(1, null),
|
||||
Values(null, null)
|
||||
)
|
||||
|
||||
list.contains.inOrder.only.grouped.within.inAnyOrder(
|
||||
Entry {},
|
||||
Entry(null),
|
||||
Entries({}),
|
||||
Entries({}, {})
|
||||
)
|
||||
subList.contains.inOrder.only.grouped.within.inAnyOrder(
|
||||
Entry {},
|
||||
Entries({}),
|
||||
Entries({}, {})
|
||||
)
|
||||
nullableList.contains.inOrder.only.grouped.within.inAnyOrder(
|
||||
Entry(null),
|
||||
Entries(null),
|
||||
Entries({}, {}),
|
||||
Entries(null, {}),
|
||||
Entries({}, null),
|
||||
Entries(null, null)
|
||||
)
|
||||
subList.contains.inOrder.only.grouped.within.inAnyOrder(
|
||||
Entry {},
|
||||
star.contains.inOrder.only.grouped.within.inAnyOrder(
|
||||
Entry(null),
|
||||
Entries({}),
|
||||
Entries(null),
|
||||
Entries({}, {}),
|
||||
Entries(null, {}),
|
||||
Entries({}, null),
|
||||
Entries(null, null)
|
||||
)
|
||||
|
||||
@@ -13,7 +13,7 @@ class IterableFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.Iterab
|
||||
) {
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
private fun ambiguityTest() {
|
||||
var a1: Expect<Iterable<Int>> = notImplemented()
|
||||
var a1: Expect<List<Int>> = notImplemented()
|
||||
//nullable not supported by min/max or rather T : Comparable<T> does not exist for T? (one cannot implement an interface for the nullable type)
|
||||
//same for Iterable<*>
|
||||
|
||||
|
||||
@@ -41,10 +41,10 @@ class IterableNoneAssertionsSpec : Spek({
|
||||
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
private fun ambiguityTest() {
|
||||
var a1: Expect<Iterable<Double>> = notImplemented()
|
||||
var a1b: Expect<Iterable<Double?>> = notImplemented()
|
||||
var a1: Expect<List<Double>> = notImplemented()
|
||||
var a1b: Expect<Set<Double?>> = notImplemented()
|
||||
|
||||
var star: Expect<Iterable<*>> = notImplemented()
|
||||
var star: Expect<Collection<*>> = notImplemented()
|
||||
|
||||
a1 = a1.none {}
|
||||
a1 = a1.containsNot.entry {}
|
||||
|
||||
@@ -2,6 +2,7 @@ package ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builder
|
||||
|
||||
import ch.tutteli.atrium.api.infix.en_GB.atLeast
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.AtLeastCheckerOption
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl.StaticName.nameContainsNotValuesFun
|
||||
import ch.tutteli.atrium.domain.builders.creating.charsequence.contains.builders.AtLeastCheckerOptionBase
|
||||
import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains
|
||||
|
||||
@@ -24,6 +25,6 @@ internal class AtLeastCheckerOptionImpl<out T : CharSequence, out S : CharSequen
|
||||
) : AtLeastCheckerOptionBase<T, S>(
|
||||
times,
|
||||
containsBuilder,
|
||||
nameContainsNotValuesFun(),
|
||||
nameContainsNotValuesFun,
|
||||
{ "`${containsBuilder::atLeast.name} $it`" }
|
||||
), AtLeastCheckerOption<T, S>
|
||||
|
||||
@@ -3,6 +3,7 @@ package ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builder
|
||||
import ch.tutteli.atrium.api.infix.en_GB.atLeast
|
||||
import ch.tutteli.atrium.api.infix.en_GB.atMost
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.AtMostCheckerOption
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl.StaticName.nameContainsNotValuesFun
|
||||
import ch.tutteli.atrium.api.infix.en_GB.exactly
|
||||
import ch.tutteli.atrium.domain.builders.creating.charsequence.contains.builders.AtMostCheckerOptionBase
|
||||
import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains
|
||||
@@ -26,7 +27,7 @@ internal class AtMostCheckerOptionImpl<out T : CharSequence, out S : CharSequenc
|
||||
) : AtMostCheckerOptionBase<T, S>(
|
||||
times,
|
||||
containsBuilder,
|
||||
nameContainsNotValuesFun(),
|
||||
nameContainsNotValuesFun,
|
||||
{ "`${containsBuilder::atMost.name} $it`" },
|
||||
{ "`${containsBuilder::atLeast.name} $it`" },
|
||||
{ "`${containsBuilder::exactly.name} $it`" }
|
||||
|
||||
@@ -5,6 +5,7 @@ import ch.tutteli.atrium.api.infix.en_GB.atMost
|
||||
import ch.tutteli.atrium.api.infix.en_GB.butAtMost
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.AtLeastCheckerOption
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.ButAtMostCheckerOption
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl.StaticName.nameContainsNotValuesFun
|
||||
import ch.tutteli.atrium.api.infix.en_GB.exactly
|
||||
import ch.tutteli.atrium.domain.builders.creating.charsequence.contains.builders.ButAtMostCheckerOptionBase
|
||||
import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains
|
||||
@@ -30,7 +31,7 @@ internal class ButAtMostCheckerOptionImpl<out T : CharSequence, out S : CharSequ
|
||||
times,
|
||||
atLeastBuilder,
|
||||
containsBuilder,
|
||||
nameContainsNotValuesFun(),
|
||||
nameContainsNotValuesFun,
|
||||
{ l, u -> "`${containsBuilder::atLeast.name} $l ${atLeastBuilder::butAtMost.name} $u`" },
|
||||
{ "`${containsBuilder::atMost.name} $it`" },
|
||||
{ "`${containsBuilder::atLeast.name} $it`" },
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl
|
||||
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.ExactlyCheckerOption
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl.StaticName.nameContainsNotValuesFun
|
||||
import ch.tutteli.atrium.api.infix.en_GB.exactly
|
||||
import ch.tutteli.atrium.domain.builders.creating.charsequence.contains.builders.ExactlyCheckerOptionBase
|
||||
import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains
|
||||
@@ -24,6 +25,6 @@ internal class ExactlyCheckerOptionImpl<out T : CharSequence, out S : CharSequen
|
||||
) : ExactlyCheckerOptionBase<T, S>(
|
||||
times,
|
||||
containsBuilder,
|
||||
nameContainsNotValuesFun(),
|
||||
nameContainsNotValuesFun,
|
||||
{ "`${containsBuilder::exactly.name} $it`" }
|
||||
), ExactlyCheckerOption<T, S>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl
|
||||
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.NotOrAtMostCheckerOption
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.charsequence.contains.builders.impl.StaticName.nameContainsNotValuesFun
|
||||
import ch.tutteli.atrium.api.infix.en_GB.notOrAtMost
|
||||
import ch.tutteli.atrium.domain.builders.creating.charsequence.contains.builders.NotOrAtMostCheckerOptionBase
|
||||
import ch.tutteli.atrium.domain.creating.charsequence.contains.CharSequenceContains
|
||||
@@ -24,6 +25,6 @@ internal class NotOrAtMostCheckerOptionImpl<out T : CharSequence, out S : CharSe
|
||||
) : NotOrAtMostCheckerOptionBase<T, S>(
|
||||
times,
|
||||
containsBuilder,
|
||||
nameContainsNotValuesFun(),
|
||||
nameContainsNotValuesFun,
|
||||
{ "`${containsBuilder::notOrAtMost.name} $it`" }
|
||||
), NotOrAtMostCheckerOption<T, S>
|
||||
|
||||
@@ -5,7 +5,8 @@ import ch.tutteli.atrium.api.infix.en_GB.containsNot
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import kotlin.reflect.KFunction2
|
||||
|
||||
internal fun nameContainsNotValuesFun(): String {
|
||||
val f: KFunction2<Expect<CharSequence>, Values<Any>, Expect<CharSequence>> = Expect<CharSequence>::containsNot
|
||||
return "`${f.name} ${Values::class.simpleName}`"
|
||||
internal object StaticName {
|
||||
private val f: KFunction2<Expect<CharSequence>, Values<Any>, Expect<CharSequence>> =
|
||||
Expect<CharSequence>::containsNot
|
||||
val nameContainsNotValuesFun = "`${f.name} ${Values::class.simpleName}`"
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders
|
||||
|
||||
import ch.tutteli.atrium.domain.builders.creating.iterable.contains.builders.WithTimesCheckerOption
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains
|
||||
|
||||
/**
|
||||
* Represents the extension point for another option after a `contains at least`-check within a sophisticated
|
||||
* `contains` assertion building process for [Iterable].
|
||||
*
|
||||
* @param T The input type of the search.
|
||||
* @param S The search behaviour which should be applied for the input of the search.
|
||||
*/
|
||||
interface AtLeastCheckerOption<out E, out T : Iterable<E>, out S : IterableContains.SearchBehaviour>
|
||||
: WithTimesCheckerOption<E, T, S>
|
||||
@@ -0,0 +1,14 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders
|
||||
|
||||
import ch.tutteli.atrium.domain.builders.creating.iterable.contains.builders.WithTimesCheckerOption
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains
|
||||
|
||||
/**
|
||||
* Represents the extension point for another option after a `contains at least once but at most`-check within
|
||||
* a sophisticated `contains` assertion building process for [Iterable].
|
||||
*
|
||||
* @param T The input type of the search.
|
||||
* @param S The search behaviour which should be applied for the input of the search.
|
||||
*/
|
||||
interface AtMostCheckerOption<out E, out T : Iterable<E>, out S : IterableContains.SearchBehaviour>
|
||||
: WithTimesCheckerOption<E, T, S>
|
||||
@@ -0,0 +1,14 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders
|
||||
|
||||
import ch.tutteli.atrium.domain.builders.creating.iterable.contains.builders.WithTimesCheckerOption
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains
|
||||
|
||||
/**
|
||||
* Represents the extension point for another option after a `contains at least but at most`-check within a
|
||||
* sophisticated `contains` assertion building process for [Iterable].
|
||||
*
|
||||
* @param T The input type of the search.
|
||||
* @param S The search behaviour which should be applied for the input of the search.
|
||||
*/
|
||||
interface ButAtMostCheckerOption<out E, out T : Iterable<E>, out S : IterableContains.SearchBehaviour>
|
||||
: WithTimesCheckerOption<E, T, S>
|
||||
@@ -0,0 +1,14 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders
|
||||
|
||||
import ch.tutteli.atrium.domain.builders.creating.iterable.contains.builders.WithTimesCheckerOption
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains
|
||||
|
||||
/**
|
||||
* Represents the extension point for another option after a `contains exactly`-check within
|
||||
* a sophisticated `contains` assertion building process for [Iterable].
|
||||
*
|
||||
* @param T The input type of the search.
|
||||
* @param S The search behaviour which should be applied for the input of the search.
|
||||
*/
|
||||
interface ExactlyCheckerOption<out E, out T : Iterable<E>, out S : IterableContains.SearchBehaviour>
|
||||
: WithTimesCheckerOption<E, T, S>
|
||||
@@ -0,0 +1,13 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders
|
||||
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains
|
||||
|
||||
/**
|
||||
* Represents the extension point for another option after a `contains not at all`-check within
|
||||
* a sophisticated `contains` assertion building process for [Iterable].
|
||||
*
|
||||
* @param T The input type of the search.
|
||||
* @param S The search behaviour which should be applied for the input of the search.
|
||||
*/
|
||||
interface NotCheckerOption<out E, out T : Iterable<E>, out S : IterableContains.SearchBehaviour>
|
||||
: IterableContains.CheckerOption<E, T, S>
|
||||
@@ -0,0 +1,14 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders
|
||||
|
||||
import ch.tutteli.atrium.domain.builders.creating.iterable.contains.builders.WithTimesCheckerOption
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains
|
||||
|
||||
/**
|
||||
* Represents the extension point for another option after a `contains not or at most`-check within
|
||||
* a sophisticated `contains` assertion building process for [Iterable].
|
||||
*
|
||||
* @param T The input type of the search.
|
||||
* @param S The search behaviour which should be applied for the input of the search.
|
||||
*/
|
||||
interface NotOrAtMostCheckerOption<out E, out T : Iterable<E>, out S : IterableContains.SearchBehaviour>
|
||||
: WithTimesCheckerOption<E, T, S>
|
||||
@@ -0,0 +1,30 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl
|
||||
|
||||
import ch.tutteli.atrium.api.infix.en_GB.atLeast
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.AtLeastCheckerOption
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl.StaticName.nameContainsNotValuesFun
|
||||
import ch.tutteli.atrium.domain.builders.creating.iterable.contains.builders.AtLeastCheckerOptionBase
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderSearchBehaviour
|
||||
|
||||
/**
|
||||
* Represents the builder of a `contains at least` check within the fluent API of a sophisticated
|
||||
* `contains` assertion for [Iterable].
|
||||
*
|
||||
* @param T The input type of the search.
|
||||
*
|
||||
* @constructor Represents the builder of a `contains at least` check within the fluent API of a sophisticated
|
||||
* `contains` assertion for [Iterable].
|
||||
* @param times The number which the check will compare against the actual number of times an expected entry is
|
||||
* found in the [Iterable].
|
||||
* @param containsBuilder The previously used [IterableContains.Builder].
|
||||
*/
|
||||
internal class AtLeastCheckerOptionImpl<out E, out T : Iterable<E>, out S : InAnyOrderSearchBehaviour>(
|
||||
times: Int,
|
||||
containsBuilder: IterableContains.Builder<E, T, S>
|
||||
) : AtLeastCheckerOptionBase<E, T, S>(
|
||||
times,
|
||||
containsBuilder,
|
||||
nameContainsNotValuesFun,
|
||||
{ "`${containsBuilder::atLeast.name} $it`" }
|
||||
), AtLeastCheckerOption<E, T, S>
|
||||
@@ -0,0 +1,34 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl
|
||||
|
||||
import ch.tutteli.atrium.api.infix.en_GB.atLeast
|
||||
import ch.tutteli.atrium.api.infix.en_GB.atMost
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.AtMostCheckerOption
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl.StaticName.nameContainsNotValuesFun
|
||||
import ch.tutteli.atrium.api.infix.en_GB.exactly
|
||||
import ch.tutteli.atrium.domain.builders.creating.iterable.contains.builders.AtMostCheckerOptionBase
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderSearchBehaviour
|
||||
|
||||
/**
|
||||
* Represents the builder of a `contains at least once but at most` check within the fluent API of a
|
||||
* sophisticated `contains` assertion for [Iterable].
|
||||
*
|
||||
* @param T The input type of the search.
|
||||
*
|
||||
* @constructor Represents the builder of a `contains at least once but at most` check within the fluent API of a
|
||||
* sophisticated `contains` assertion for [Iterable].
|
||||
* @param times The number which the check will compare against the actual number of times an expected entry is
|
||||
* found in the [Iterable].
|
||||
* @param containsBuilder The previously used [IterableContains.Builder].
|
||||
*/
|
||||
internal class AtMostCheckerOptionImpl<out E, out T : Iterable<E>, out S : InAnyOrderSearchBehaviour>(
|
||||
times: Int,
|
||||
containsBuilder: IterableContains.Builder<E, T, S>
|
||||
) : AtMostCheckerOptionBase<E, T, S>(
|
||||
times,
|
||||
containsBuilder,
|
||||
nameContainsNotValuesFun,
|
||||
{ "`${containsBuilder::atMost.name} $it`" },
|
||||
{ "`${containsBuilder::atLeast.name} $it`" },
|
||||
{ "`${containsBuilder::exactly.name} $it`" }
|
||||
), AtMostCheckerOption<E, T, S>
|
||||
@@ -0,0 +1,40 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl
|
||||
|
||||
import ch.tutteli.atrium.api.infix.en_GB.atLeast
|
||||
import ch.tutteli.atrium.api.infix.en_GB.atMost
|
||||
import ch.tutteli.atrium.api.infix.en_GB.butAtMost
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.AtLeastCheckerOption
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.ButAtMostCheckerOption
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl.StaticName.nameContainsNotValuesFun
|
||||
import ch.tutteli.atrium.api.infix.en_GB.exactly
|
||||
import ch.tutteli.atrium.domain.builders.creating.iterable.contains.builders.ButAtMostCheckerOptionBase
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderSearchBehaviour
|
||||
|
||||
/**
|
||||
* Represents the builder of the second step of a `contains at least but at most` check within the
|
||||
* fluent API of a sophisticated `contains` assertion for [Iterable].
|
||||
*
|
||||
* @param T The input type of the search.
|
||||
*
|
||||
* @constructor Represents the builder of the second step of a `contains at least but at most` check within the
|
||||
* fluent API of a sophisticated `contains` assertion for [Iterable].
|
||||
* @param times The number which the check will compare against the actual number of times an expected entry is
|
||||
* found in the [Iterable].
|
||||
* @param containsBuilder The previously used [IterableContains.Builder].
|
||||
*/
|
||||
internal class ButAtMostCheckerOptionImpl<out E, out T : Iterable<E>, out S : InAnyOrderSearchBehaviour>(
|
||||
times: Int,
|
||||
atLeastBuilder: AtLeastCheckerOption<E, T, S>,
|
||||
containsBuilder: IterableContains.Builder<E, T, S>
|
||||
) : ButAtMostCheckerOptionBase<E, T, S>(
|
||||
times,
|
||||
atLeastBuilder,
|
||||
containsBuilder,
|
||||
nameContainsNotValuesFun,
|
||||
{ l, u -> "`${containsBuilder::atLeast.name} $l ${atLeastBuilder::butAtMost.name} $u`" },
|
||||
{ "`${containsBuilder::atMost.name} $it`" },
|
||||
{ "`${containsBuilder::atLeast.name} $it`" },
|
||||
{ "`${atLeastBuilder::butAtMost.name} $it`" },
|
||||
{ "`${containsBuilder::exactly.name} $it`" }
|
||||
), ButAtMostCheckerOption<E, T, S>
|
||||
@@ -0,0 +1,30 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl
|
||||
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.ExactlyCheckerOption
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl.StaticName.nameContainsNotValuesFun
|
||||
import ch.tutteli.atrium.api.infix.en_GB.exactly
|
||||
import ch.tutteli.atrium.domain.builders.creating.iterable.contains.builders.ExactlyCheckerOptionBase
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderSearchBehaviour
|
||||
|
||||
/**
|
||||
* Represents the builder of a `contains exactly` check within the fluent API of a sophisticated
|
||||
* `contains` assertion for [Iterable].
|
||||
*
|
||||
* @param T The input type of the search.
|
||||
*
|
||||
* @constructor Represents the builder of a `contains exactly` check within the fluent API of a sophisticated
|
||||
* `contains` assertion for [Iterable].
|
||||
* @param times The number which the check will compare against the actual number of times an expected entry is
|
||||
* found in the [Iterable].
|
||||
* @param containsBuilder The previously used [IterableContains.Builder].
|
||||
*/
|
||||
internal class ExactlyCheckerOptionImpl<out E, out T : Iterable<E>, out S : InAnyOrderSearchBehaviour>(
|
||||
times: Int,
|
||||
containsBuilder: IterableContains.Builder<E, T, S>
|
||||
) : ExactlyCheckerOptionBase<E, T, S>(
|
||||
times,
|
||||
containsBuilder,
|
||||
nameContainsNotValuesFun,
|
||||
{ "`${containsBuilder::exactly.name} $it`" }
|
||||
), ExactlyCheckerOption<E, T, S>
|
||||
@@ -0,0 +1,22 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl
|
||||
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.NotCheckerOption
|
||||
import ch.tutteli.atrium.domain.builders.creating.iterable.contains.builders.NotCheckerOptionBase
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderSearchBehaviour
|
||||
|
||||
/**
|
||||
* Represents the builder of a `contains not at all` check within the fluent API of a sophisticated
|
||||
* `contains` assertion for [Iterable].
|
||||
*
|
||||
* @param T The input type of the search.
|
||||
* @param S The search behaviour which should be applied for the input of the search.
|
||||
*
|
||||
* @constructor Represents the builder of a `contains not at all` check within the fluent API of a sophisticated
|
||||
* `contains not` assertion for [Iterable].
|
||||
* @param containsBuilder The previously used [IterableContains.Builder].
|
||||
*/
|
||||
internal class NotCheckerOptionImpl<out E, out T : Iterable<E>, out S : InAnyOrderSearchBehaviour>(
|
||||
containsBuilder: IterableContains.Builder<E, T, S>
|
||||
) : NotCheckerOptionBase<E, T, S>(containsBuilder),
|
||||
NotCheckerOption<E, T, S>
|
||||
@@ -0,0 +1,30 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl
|
||||
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.NotOrAtMostCheckerOption
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl.StaticName.nameContainsNotValuesFun
|
||||
import ch.tutteli.atrium.api.infix.en_GB.notOrAtMost
|
||||
import ch.tutteli.atrium.domain.builders.creating.iterable.contains.builders.NotOrAtMostCheckerOptionBase
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderSearchBehaviour
|
||||
|
||||
/**
|
||||
* Represents the builder of a `contains not or at most` check within the fluent API of a
|
||||
* sophisticated `contains` assertion for [Iterable].
|
||||
*
|
||||
* @param T The input type of the search.
|
||||
*
|
||||
* @constructor Represents the builder of a `contains at least once but at most` check within the fluent API of a
|
||||
* sophisticated `contains` assertion for [Iterable].
|
||||
* @param times The number which the check will compare against the actual number of times an expected entry is
|
||||
* found in the [Iterable].
|
||||
* @param containsBuilder The previously used [IterableContains.Builder].
|
||||
*/
|
||||
internal class NotOrAtMostCheckerOptionImpl<out E, out T : Iterable<E>, out S : InAnyOrderSearchBehaviour>(
|
||||
times: Int,
|
||||
containsBuilder: IterableContains.Builder<E, T, S>
|
||||
) : NotOrAtMostCheckerOptionBase<E, T, S>(
|
||||
times,
|
||||
containsBuilder,
|
||||
nameContainsNotValuesFun,
|
||||
{ "`${containsBuilder::notOrAtMost.name} $it`" }
|
||||
), NotOrAtMostCheckerOption<E, T, S>
|
||||
@@ -0,0 +1,23 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl
|
||||
|
||||
import ch.tutteli.atrium.api.infix.en_GB.Values
|
||||
import ch.tutteli.atrium.api.infix.en_GB.containsNot
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.NotCheckerOption
|
||||
import ch.tutteli.atrium.api.infix.en_GB.o
|
||||
import ch.tutteli.atrium.api.infix.en_GB.the
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderSearchBehaviour
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.NotSearchBehaviour
|
||||
import kotlin.reflect.KFunction2
|
||||
|
||||
internal object StaticName {
|
||||
private val f: KFunction2<Expect<Iterable<Double>>, o, NotCheckerOption<Double, Iterable<Double>, NotSearchBehaviour>> =
|
||||
Expect<Iterable<Double>>::containsNot
|
||||
private val fThe: KFunction2<
|
||||
IterableContains.CheckerOption<Double, Iterable<Double>, InAnyOrderSearchBehaviour>,
|
||||
Values<Double>,
|
||||
Expect<Iterable<Double>>
|
||||
> = IterableContains.CheckerOption<Double, Iterable<Double>, InAnyOrderSearchBehaviour>::the
|
||||
val nameContainsNotValuesFun = "`${f.name} ${o::class.simpleName} ${fThe.name} ${Values::class.simpleName}`"
|
||||
}
|
||||
@@ -1,7 +1,275 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.NotCheckerOption
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl.NotCheckerOptionImpl
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.creating.SubjectProvider
|
||||
import ch.tutteli.atrium.domain.builders.ExpectImpl
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.NoOpSearchBehaviour
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.NotSearchBehaviour
|
||||
|
||||
/**
|
||||
* Creates an [IterableContains.Builder] based on this [Expect] which allows to define
|
||||
* more sophisticated `contains` assertions.
|
||||
*
|
||||
* @param o The filler object [o].
|
||||
*
|
||||
* @return The newly created builder.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.contains(
|
||||
@Suppress("UNUSED_PARAMETER") o: o
|
||||
): IterableContains.Builder<E, T, NoOpSearchBehaviour> = ExpectImpl.iterable.containsBuilder(this)
|
||||
|
||||
/**
|
||||
* Creates an [IterableContains.Builder] based on this [Expect] which allows to define
|
||||
* more sophisticated `contains not` assertions.
|
||||
*
|
||||
* @param o The filler object [o].
|
||||
*
|
||||
* @return The newly created builder.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.containsNot(
|
||||
@Suppress("UNUSED_PARAMETER") o: o
|
||||
): NotCheckerOption<E, T, NotSearchBehaviour> = NotCheckerOptionImpl(ExpectImpl.iterable.containsNotBuilder(this))
|
||||
|
||||
/**
|
||||
* Creates an [Expect] for the result of calling `min()` on the subject of the assertion,
|
||||
* so that further fluent calls are assertions about it.
|
||||
*
|
||||
* @param o The filler object [o].
|
||||
*
|
||||
* @return The newly created [Expect] for the extracted feature.
|
||||
*
|
||||
* @since 0.11.0
|
||||
*/
|
||||
infix fun <E : Comparable<E>, T : Iterable<E>> Expect<T>.min(@Suppress("UNUSED_PARAMETER") o: o): Expect<E> =
|
||||
ExpectImpl.iterable.min(this).getExpectOfFeature()
|
||||
|
||||
/**
|
||||
* Expects that the result of calling `min()` on the subject of the assertion
|
||||
* holds all assertions the given [assertionCreator] creates for it and
|
||||
* returns an [Expect] for the current subject of the assertion.
|
||||
*
|
||||
* @return An [Expect] for the current subject of the assertion.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*
|
||||
* @since 0.11.0
|
||||
*/
|
||||
infix fun <E : Comparable<E>, T : Iterable<E>> Expect<T>.min(assertionCreator: Expect<E>.() -> Unit): Expect<T> =
|
||||
ExpectImpl.iterable.min(this).addToInitial(assertionCreator)
|
||||
|
||||
|
||||
/**
|
||||
* Creates an [Expect] for the result of calling `max()` on the subject of the assertion,
|
||||
* so that further fluent calls are assertions about it.
|
||||
*
|
||||
* @param o The filler object [o].
|
||||
*
|
||||
* @return The newly created [Expect] for the extracted feature.
|
||||
*
|
||||
* @since 0.11.0
|
||||
*/
|
||||
infix fun <E : Comparable<E>, T : Iterable<E>> Expect<T>.max(@Suppress("UNUSED_PARAMETER") o: o): Expect<E> =
|
||||
ExpectImpl.iterable.max(this).getExpectOfFeature()
|
||||
|
||||
/**
|
||||
* Expects that the result of calling `max()` on the subject of the assertion
|
||||
* holds all assertions the given [assertionCreator] creates for it and
|
||||
* returns an [Expect] for the current subject of the assertion.
|
||||
*
|
||||
* @return An [Expect] for the current subject of the assertion.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*
|
||||
* @since 0.11.0
|
||||
*/
|
||||
infix fun <E : Comparable<E>, T : Iterable<E>> Expect<T>.max(assertionCreator: Expect<E>.() -> Unit): Expect<T> =
|
||||
ExpectImpl.iterable.max(this).addToInitial(assertionCreator)
|
||||
|
||||
/**
|
||||
* Expects that the subject of the assertion (an [Iterable]) contains the [expected] value.
|
||||
*
|
||||
* It is a shortcut for `contains o inAny order atLeast 1 value expected`
|
||||
*
|
||||
* @return An [Expect] for the current subject of the assertion.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.contains(expected: E) =
|
||||
it contains o inAny order atLeast 1 value expected
|
||||
|
||||
/**
|
||||
* Expects that the subject of the assertion (an [Iterable]) contains the expected [values].
|
||||
*
|
||||
* It is a shortcut for `contains o inAny order atLeast 1 the Values(...)`
|
||||
*
|
||||
* Notice, that it does not search for unique matches. Meaning, if the iterable is `setOf('a', 'b')` and
|
||||
* [values].[expected][Values.expected] is defined as `'a'` and
|
||||
* one [values].[otherExpected][Values.otherExpected] is defined as `'a'` as well, then both match,
|
||||
* even though they match the same entry. Use an option such as [atLeast], [atMost] and [exactly] to control the
|
||||
* number of occurrences you expect.
|
||||
*
|
||||
* Meaning you might want to use:
|
||||
* contains o inAny order exactly 2 value 'a'`
|
||||
* instead of:
|
||||
* `contains Values('a', 'a')`
|
||||
*
|
||||
* @return An [Expect] for the current subject of the assertion.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.contains(values: Values<E>): Expect<T> =
|
||||
it contains o inAny order atLeast 1 the values
|
||||
|
||||
/**
|
||||
* Expects that the subject of the assertion (an [Iterable]) contains an entry holding the
|
||||
* assertions created by [assertionCreatorOrNull] or an entry which is `null` in case [assertionCreatorOrNull]
|
||||
* is defined as `null`.
|
||||
*
|
||||
* It is a shortcut for `contains o inAny order atLeast 1 entry assertionCreatorOrNull`
|
||||
*
|
||||
* @param assertionCreatorOrNull The identification lambda which creates the assertions which the entry we are looking
|
||||
* for has to hold; or in other words, the function which defines whether an entry is the one we are looking for
|
||||
* or not. In case it is defined as `null`, then an entry is identified if it is `null` as well.
|
||||
*
|
||||
* @return An [Expect] for the current subject of the assertion.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
infix fun <E : Any, T : Iterable<E?>> Expect<T>.contains(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
|
||||
it contains o inAny order atLeast 1 entry assertionCreatorOrNull
|
||||
|
||||
/**
|
||||
* Makes the assertion that the [Assert.subject][SubjectProvider.subject] contains an entry holding the
|
||||
* assertions created by [entries].[assertionCreatorOrNull][Entries.assertionCreatorOrNull] or an entry
|
||||
* which is `null` in case [entries].[assertionCreatorOrNull][Entries.assertionCreatorOrNull]
|
||||
* is defined as `null` -- likewise an entry (can be the same) is searched for each of the
|
||||
* [entries].[otherAssertionCreatorsOrNulls][Entries.otherAssertionCreatorsOrNulls].
|
||||
*
|
||||
* It is a shortcut for `contains o inAny order atLeast 1 the Entries(...)`
|
||||
*
|
||||
* @return An [Expect] for the current subject of the assertion.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
infix fun <E : Any, T : Iterable<E?>> Expect<T>.contains(
|
||||
entries: Entries<E>
|
||||
): Expect<T> = it contains o inAny order atLeast 1 the entries
|
||||
|
||||
/**
|
||||
* Expects that the subject of the assertion (an [Iterable]) contains only
|
||||
* the [expected] value.
|
||||
*
|
||||
* It is a shortcut for `contains o inGiven order and only value expected`
|
||||
|
||||
* @return An [Expect] for the current subject of the assertion.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.containsExactly(expected: E): Expect<T> =
|
||||
it contains o inGiven order and only value expected
|
||||
|
||||
/**
|
||||
* Expects that the subject of the assertion (an [Iterable]) contains only
|
||||
* the expected [values] in the defined order.
|
||||
*
|
||||
* It is a shortcut for `contains o inGiven order and only the Values(...)`
|
||||
*
|
||||
* Note that we might change the signature of this function with the next version
|
||||
* which will cause a binary backward compatibility break (see
|
||||
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
|
||||
*
|
||||
* @return An [Expect] for the current subject of the assertion.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.containsExactly(values: Values<E>): Expect<T> =
|
||||
it contains o inGiven order and only the values
|
||||
|
||||
/**
|
||||
* Expects that the subject of the assertion (an [Iterable]) contains only an entry holding
|
||||
* the assertions created by [assertionCreatorOrNull] or only one entry which is `null` in case [assertionCreatorOrNull]
|
||||
* is defined as `null`.
|
||||
*
|
||||
* It is a shortcut for `contains o inGiven order and only entry assertionCreatorOrNull`
|
||||
*
|
||||
* Note that we might change the signature of this function with the next version
|
||||
* which will cause a binary backward compatibility break (see
|
||||
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
|
||||
*
|
||||
* @param assertionCreatorOrNull The identification lambda which creates the assertions which the entry we are looking
|
||||
* for has to hold; or in other words, the function which defines whether an entry is the one we are looking for
|
||||
* or not. In case it is defined as `null`, then an entry is identified if it is `null` as well.
|
||||
*
|
||||
* @return An [Expect] for the current subject of the assertion.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
infix fun <E : Any, T : Iterable<E?>> Expect<T>.containsExactly(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
|
||||
it contains o inGiven order and only entry assertionCreatorOrNull
|
||||
|
||||
/**
|
||||
* Expects that the subject of the assertion (an [Iterable]) contains only an entry holding
|
||||
* the assertions created by [entries].[assertionCreatorOrNull][Entries.assertionCreatorOrNull] or
|
||||
* `null` in case [entries].[assertionCreatorOrNull][Entries.assertionCreatorOrNull] is defined as `null`
|
||||
* and likewise an additional entry for each
|
||||
* [entries].[otherAssertionCreatorsOrNulls][Entries.otherAssertionCreatorsOrNulls] (if given)
|
||||
* whereas the entries have to appear in the defined order.
|
||||
*
|
||||
* It is a shortcut for `contains o inGiven order and only the Entries(...)`
|
||||
*
|
||||
* Note that we might change the signature of this function with the next version
|
||||
* which will cause a binary backward compatibility break (see
|
||||
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
|
||||
*
|
||||
* @return An [Expect] for the current subject of the assertion.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
infix fun <E : Any, T : Iterable<E?>> Expect<T>.containsExactly(entries: Entries<E>): Expect<T> =
|
||||
it contains o inGiven order and only the entries
|
||||
|
||||
/**
|
||||
* Expects that the subject of the assertion (an [Iterable]) does not contain the [expected] value.
|
||||
*
|
||||
* It is a shortcut for `containsNot o value expected`
|
||||
*
|
||||
* @return An [Expect] for the current subject of the assertion.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.containsNot(expected: E): Expect<T> =
|
||||
it containsNot o value expected
|
||||
|
||||
/**
|
||||
* Expects that the subject of the assertion (an [Iterable]) does not contain the expected [values].
|
||||
*
|
||||
* It is a shortcut for `containsNot o the Values(...)`
|
||||
*
|
||||
* @return An [Expect] for the current subject of the assertion.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.containsNot(values: Values<E>): Expect<T> =
|
||||
it containsNot o the values
|
||||
|
||||
|
||||
/**
|
||||
* Expects that the subject of the assertion (an [Iterable]) contains an entry holding
|
||||
* the assertions created by [assertionCreatorOrNull] or an entry which is `null` in case [assertionCreatorOrNull]
|
||||
* is defined as `null`.
|
||||
*
|
||||
* It is a shortcut for `contains o inAny order atLeast 1 entry assertionCreatorOrNull`
|
||||
*
|
||||
* @return An [Expect] for the current subject of the assertion.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
infix fun <E : Any, T : Iterable<E?>> Expect<T>.any(assertionCreatorOrNull: (Expect<E>.() -> Unit)?): Expect<T> =
|
||||
it contains o inAny order atLeast 1 entry assertionCreatorOrNull
|
||||
|
||||
|
||||
/**
|
||||
* Expects that the subject of the assertion (an [Iterable]) does not contain a single entry
|
||||
* which holds all assertions created by [assertionCreatorOrNull] or does not contain a single entry which is `null`
|
||||
* in case [assertionCreatorOrNull] is defined as `null`.
|
||||
*
|
||||
* It is a shortcut for `containsNot o entry assertionCreatorOrNull`
|
||||
*
|
||||
* @return An [Expect] for the current subject of the assertion.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
infix fun <E : Any, T : Iterable<E?>> Expect<T>.none(assertionCreatorOrNull: (Expect<E>.() -> Unit)?) =
|
||||
it containsNot o entry assertionCreatorOrNull
|
||||
|
||||
/**
|
||||
* Expects that the subject of the assertion (an [Iterable]) has at least one element and
|
||||
@@ -13,3 +281,25 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl
|
||||
*/
|
||||
infix fun <E : Any, T : Iterable<E?>> Expect<T>.all(assertionCreatorOrNull: (Expect<E>.() -> Unit)?) =
|
||||
addAssertion(ExpectImpl.iterable.all(this, assertionCreatorOrNull))
|
||||
|
||||
/**
|
||||
* Expects that the subject of the assertion (an [Iterable]) has at least one element.
|
||||
*
|
||||
* @return An [Expect] for the current subject of the assertion.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*
|
||||
* @since 0.11.0
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.has(@Suppress("UNUSED_PARAMETER") next: next) =
|
||||
addAssertion(ExpectImpl.iterable.hasNext(this))
|
||||
|
||||
/**
|
||||
* Expects that the subject of the assertion (an [Iterable]) does not have next element.
|
||||
*
|
||||
* @return An [Expect] for the current subject of the assertion.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*
|
||||
* @since 0.11.0
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Expect<T>.hasNot(@Suppress("UNUSED_PARAMETER") next: next) =
|
||||
addAssertion(ExpectImpl.iterable.hasNotNext(this))
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.*
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.impl.*
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderSearchBehaviour
|
||||
|
||||
/**
|
||||
* Restricts a `contains` assertion by specifying that the number of occurrences of the entry which we are looking
|
||||
* for occurs `at least` number of [times] within the [Iterable].
|
||||
*
|
||||
* @param times The number which the check will compare against the actual number of times an expected entry is
|
||||
* found in the [Iterable].
|
||||
*
|
||||
* @return The newly created builder.
|
||||
* @throws IllegalArgumentException In case [times] is smaller than zero.
|
||||
* @throws IllegalArgumentException In case [times] equals to zero; use [containsNot] instead.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>, S : InAnyOrderSearchBehaviour> IterableContains.Builder<E, T, S>.atLeast(
|
||||
times: Int
|
||||
): AtLeastCheckerOption<E, T, S> = AtLeastCheckerOptionImpl(times, this)
|
||||
|
||||
/**
|
||||
* Restricts a `contains at least` assertion by specifying that the number of occurrences of the entry which we
|
||||
* are looking for occurs `at most` number of [times] within the [Iterable].
|
||||
*
|
||||
* The resulting restriction will be a `contains at least but at most` assertion.
|
||||
*
|
||||
* @param times The number which the check will compare against the actual number of times an expected entry is
|
||||
* found in the [Iterable].
|
||||
*
|
||||
* @return The newly created builder.
|
||||
* @throws IllegalArgumentException In case [times] is smaller than zero.
|
||||
* @throws IllegalArgumentException In case [times] equals to zero; use [containsNot] instead.
|
||||
* @throws IllegalArgumentException In case [times] of this `at most` restriction equals to the number of the
|
||||
* `at least` restriction; use the [exactly] restriction instead.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>, S : InAnyOrderSearchBehaviour> AtLeastCheckerOption<E, T, S>.butAtMost(
|
||||
times: Int
|
||||
): ButAtMostCheckerOption<E, T, S> = ButAtMostCheckerOptionImpl(times, this, containsBuilder)
|
||||
|
||||
/**
|
||||
* Restricts a `contains` assertion by specifying that the number of occurrences of the entry which we
|
||||
* are looking for occurs `exactly` number of [times] within the [Iterable].
|
||||
*
|
||||
* @param times The number which the check will compare against the actual number of times an expected entry is
|
||||
* found in the [Iterable].
|
||||
*
|
||||
* @return The newly created builder.
|
||||
* @throws IllegalArgumentException In case [times] is smaller than zero.
|
||||
* @throws IllegalArgumentException In case [times] equals to zero; use [containsNot] instead.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>, S : InAnyOrderSearchBehaviour> IterableContains.Builder<E, T, S>.exactly(
|
||||
times: Int
|
||||
): ExactlyCheckerOption<E, T, S> = ExactlyCheckerOptionImpl(times, this)
|
||||
|
||||
/**
|
||||
* Restricts a `contains` assertion by specifying that the number of occurrences of the entry which we
|
||||
* are looking for occurs `at least` once but `at most` number of [times] within the [Iterable].
|
||||
*
|
||||
* If you want to use a higher lower bound than one, then use `atLeast(2).butAtMost(3)` instead of `atMost(3)`.
|
||||
* And in case you want to state that it is either not contained at all or at most a certain number of times,
|
||||
* then use `notOrAstMost(2)` instead.
|
||||
*
|
||||
* @param times The number which the check will compare against the actual number of times an expected entry is
|
||||
* found in the [Iterable].
|
||||
*
|
||||
* @return The newly created builder.
|
||||
* @throws IllegalArgumentException In case [times] is smaller than zero.
|
||||
* @throws IllegalArgumentException In case [times] equals to zero; use [containsNot] instead.
|
||||
* @throws IllegalArgumentException In case [times] equals to one; use [exactly] instead.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>, S : InAnyOrderSearchBehaviour> IterableContains.Builder<E, T, S>.atMost(
|
||||
times: Int
|
||||
): AtMostCheckerOption<E, T, S> = AtMostCheckerOptionImpl(times, this)
|
||||
|
||||
/**
|
||||
* Restricts a `contains` assertion by specifying that the number of occurrences of the entry which we
|
||||
* are looking for occurs `not at all or at most` number of [times] within the [Iterable].
|
||||
*
|
||||
* @param times The number which the check will compare against the actual number of times an expected entry is
|
||||
* found in the [Iterable].
|
||||
*
|
||||
* @return The newly created builder.
|
||||
* @throws IllegalArgumentException In case [times] is smaller than zero.
|
||||
* @throws IllegalArgumentException In case [times] equals to zero; use [containsNot] instead.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>, S : InAnyOrderSearchBehaviour> IterableContains.Builder<E, T, S>.notOrAtMost(
|
||||
times: Int
|
||||
): NotOrAtMostCheckerOption<E, T, S> = NotOrAtMostCheckerOptionImpl(times, this)
|
||||
@@ -0,0 +1,102 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.AssertionPlant
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.domain.builders.ExpectImpl
|
||||
import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion
|
||||
import ch.tutteli.atrium.domain.builders.utils.toVarArg
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains.CheckerOption
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderSearchBehaviour
|
||||
|
||||
/**
|
||||
* Finishes the specification of the sophisticated `contains` assertion where the [expected]
|
||||
* value shall be searched within the [Iterable].
|
||||
*
|
||||
* Delegates to [values].
|
||||
*
|
||||
* @param expected The value which is expected to be contained within this [Iterable].
|
||||
*
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> CheckerOption<E, T, InAnyOrderSearchBehaviour>.value(expected: E): Expect<T> =
|
||||
this the Values(expected)
|
||||
|
||||
/**
|
||||
* Finishes the specification of the sophisticated `contains` assertion where the expected [values]
|
||||
* shall be searched within the [Iterable].
|
||||
*
|
||||
* Notice, that it does not search for unique matches. Meaning, if the iterable is `setOf('a', 'b')` and
|
||||
* [values].[expected][Values.expected] is defined as `'a'` and one
|
||||
* [values].[otherExpected][Values.otherExpected] is defined as `'a'` as well, then both match,
|
||||
* even though they match the same entry. Use an option such as [atLeast], [atMost] and [exactly] to control the
|
||||
* number of occurrences you expect.
|
||||
*
|
||||
* Meaning you might want to use:
|
||||
* `to contain inAny order exactly 2 value 'a'`
|
||||
* instead of:
|
||||
* `to contain inAny order exactly 1 the Values('a', 'a')`
|
||||
*
|
||||
* @param values The values which are expected to be contained within the [Iterable].
|
||||
*
|
||||
* @return The [AssertionPlant] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> CheckerOption<E, T, InAnyOrderSearchBehaviour>.the(values: Values<E>): Expect<T> =
|
||||
addAssertion(ExpectImpl.iterable.contains.valuesInAnyOrder(this, values.toList()))
|
||||
|
||||
/**
|
||||
* Finishes the specification of the sophisticated `contains` assertion where an entry shall be searched which either
|
||||
* holds all assertions [assertionCreatorOrNull] creates or needs to be `null` in case [assertionCreatorOrNull]
|
||||
* is defined as `null`.
|
||||
*
|
||||
* Delegates to [entries].
|
||||
*
|
||||
* @param assertionCreatorOrNull The identification lambda which creates the assertions which the entry we are looking
|
||||
* for has to hold; or in other words, the function which defines whether an entry is the one we are looking for
|
||||
* or not. In case it is defined as `null`, then an entry is identified if it is `null` as well.
|
||||
*
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
infix fun <E : Any, T : Iterable<E?>> CheckerOption<E?, T, InAnyOrderSearchBehaviour>.entry(
|
||||
assertionCreatorOrNull: (Expect<E>.() -> Unit)?
|
||||
): Expect<T> = this the Entries(assertionCreatorOrNull)
|
||||
|
||||
/**
|
||||
* Finishes the specification of the sophisticated `contains` assertion where an entry shall be searched which either
|
||||
* holds all assertions [entries].[assertionCreatorOrNull][Entries.assertionCreatorOrNull] might create or
|
||||
* needs to be `null` in case [entries].[assertionCreatorOrNull][Entries.otherAssertionCreatorsOrNulls]
|
||||
* is defined as `null` -- likewise an entry (can be the same) is searched for each of
|
||||
* the [entries].[otherAssertionCreatorsOrNulls][Entries.otherAssertionCreatorsOrNulls].
|
||||
*
|
||||
* @param entries The parameter object which contains the identification lambdas.
|
||||
*
|
||||
* @return The [AssertionPlant] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
infix fun <E : Any, T : Iterable<E?>> CheckerOption<E?, T, InAnyOrderSearchBehaviour>.the(
|
||||
entries: Entries<E>
|
||||
): Expect<T> = addAssertion(ExpectImpl.iterable.contains.entriesInAnyOrder(this, entries.toList()))
|
||||
|
||||
/**
|
||||
* Finishes the specification of the sophisticated `contains` assertion where all elements of the [expectedIterable]
|
||||
* shall be searched within the [Iterable].
|
||||
*
|
||||
* Delegates to [values] which also means that it does not search for unique matches
|
||||
* (see [values] for more information).
|
||||
*
|
||||
* @param expectedIterable The [Iterable] whose elements are expected to be contained within this [Iterable].
|
||||
*
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
* @throws IllegalArgumentException in case the given [expectedIterable] does not have elements (is empty).
|
||||
*
|
||||
* @since 0.11.0
|
||||
*/
|
||||
inline infix fun <reified E, T : Iterable<E>> CheckerOption<E, T, InAnyOrderSearchBehaviour>.elementsOf(
|
||||
expectedIterable: Iterable<E>
|
||||
): Expect<T> {
|
||||
val (first, rest) = toVarArg(expectedIterable)
|
||||
return this the Values(first, *rest)
|
||||
}
|
||||
@@ -0,0 +1,121 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.domain.builders.ExpectImpl
|
||||
import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion
|
||||
import ch.tutteli.atrium.domain.builders.utils.toVarArg
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains.Builder
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InAnyOrderOnlySearchBehaviour
|
||||
|
||||
/**
|
||||
* Finishes the specification of the sophisticated `contains` assertion where the [Iterable] needs to contain only the
|
||||
* [expected] value.
|
||||
*
|
||||
* Delegates to [values].
|
||||
*
|
||||
* Note that we might change the signature of this function with the next version
|
||||
* which will cause a binary backward compatibility break (see
|
||||
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
|
||||
*
|
||||
* @param expected The value which is expected to be contained within the [Iterable].
|
||||
*
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Builder<E, T, InAnyOrderOnlySearchBehaviour>.value(expected: E): Expect<T> =
|
||||
this the Values(expected)
|
||||
|
||||
/**
|
||||
* Finishes the specification of the sophisticated `contains` assertion where the expected [values]
|
||||
* must be contained in [Iterable] but it does not matter in which order.
|
||||
*
|
||||
* Note that we might change the signature of this function with the next version
|
||||
* which will cause a binary backward compatibility break (see
|
||||
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
|
||||
*
|
||||
* @param values The values which are expected to be contained within the [Iterable].
|
||||
*
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Builder<E, T, InAnyOrderOnlySearchBehaviour>.the(
|
||||
values: Values<E>
|
||||
): Expect<T> = addAssertion(ExpectImpl.iterable.contains.valuesInAnyOrderOnly(this, values.toList()))
|
||||
|
||||
/**
|
||||
* Finishes the specification of the sophisticated `contains` assertion where the [Iterable] needs to contain only one
|
||||
* entry which holds all assertions created by the given [assertionCreatorOrNull] or is `null` in case
|
||||
* [assertionCreatorOrNull] is defined as `null`.
|
||||
*
|
||||
* Delegates to [entries].
|
||||
*
|
||||
* Note that we might change the signature of this function with the next version
|
||||
* which will cause a binary backward compatibility break (see
|
||||
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
|
||||
*
|
||||
* @param assertionCreatorOrNull The identification lambda which creates the assertions which the entry we are looking
|
||||
* for has to hold; or in other words, the function which defines whether an entry is the one we are looking for
|
||||
* or not. In case it is defined as `null`, then an entry is identified if it is `null` as well.
|
||||
*
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
infix fun <E : Any, T : Iterable<E?>> Builder<E?, T, InAnyOrderOnlySearchBehaviour>.entry(
|
||||
assertionCreatorOrNull: (Expect<E>.() -> Unit)?
|
||||
): Expect<T> = this the Entries(assertionCreatorOrNull)
|
||||
|
||||
/**
|
||||
* Finishes the specification of the sophisticated `contains` assertion where an entry needs to be contained in the
|
||||
* [Iterable] which holds all assertions [entries].[assertionCreatorOrNull][Entries.assertionCreatorOrNull]
|
||||
* might create or it needs to be `null` in case
|
||||
* [entries].[assertionCreatorOrNull][Entries.assertionCreatorOrNull] is defined as `null` -- likewise an
|
||||
* entry for each [entries].[otherAssertionCreatorsOrNulls][Entries.otherAssertionCreatorsOrNulls] needs to
|
||||
* be contained in the [Iterable] where it does not matter in which order the entries appear but only as many entries
|
||||
* should be returned by the [Iterable] as assertion creators are defined.
|
||||
*
|
||||
* Notice, that a first-wins strategy applies which means your assertion creator lambdas -- which kind of serve as
|
||||
* identification lambdas -- should be ordered in such a way that the most specific identification lambda appears
|
||||
* first, not that a less specific lambda wins. For instance, given a `setOf(1, 2)` you should not search for
|
||||
* `Entries({ isGreaterThan(0) }, { toBe(1) })` but for `Entries({ toBe(1) }, { isGreaterThan(0) })`
|
||||
* otherwise `isGreaterThan(0)` matches `1` before `toBe(1)` would match it. As a consequence `toBe(1)` could
|
||||
* only match the entry which is left -- in this case `2` -- and of course this would fail.
|
||||
*
|
||||
* Note that we might change the signature of this function with the next version
|
||||
* which will cause a binary backward compatibility break (see
|
||||
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
|
||||
*
|
||||
* @param entries The parameter object containing the identification lambdas.
|
||||
*
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
|
||||
infix fun <E : Any, T : Iterable<E?>> Builder<E?, T, InAnyOrderOnlySearchBehaviour>.the(
|
||||
entries: Entries<E>
|
||||
): Expect<T> = addAssertion(ExpectImpl.iterable.contains.entriesInAnyOrderOnly(this, entries.toList()))
|
||||
|
||||
/**
|
||||
* Finishes the specification of the sophisticated `contains` assertion where all elements in
|
||||
* [expectedIterable] need to be contained in [Iterable] where it does not matter in which order but only as
|
||||
* many entries should be returned by the [Iterable] as values defined.
|
||||
*
|
||||
* Delegates to [values].
|
||||
*
|
||||
* Note that we might change the signature of this function with the next version
|
||||
* which will cause a binary backward compatibility break (see
|
||||
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
|
||||
*
|
||||
* @param expectedIterable The [Iterable] whose elements are expected to be contained within this [Iterable]
|
||||
*
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
* @throws IllegalArgumentException in case the given [expectedIterable] does not have elements (is empty).
|
||||
*
|
||||
* @since 0.11.0
|
||||
*/
|
||||
inline infix fun <reified E, T : Iterable<E>> Builder<E, T, InAnyOrderOnlySearchBehaviour>.elementsOf(
|
||||
expectedIterable: Iterable<E>
|
||||
): Expect<T> {
|
||||
val (first, rest) = toVarArg(expectedIterable)
|
||||
return this the Values(first, *rest)
|
||||
}
|
||||
@@ -0,0 +1,112 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.AssertionPlant
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.domain.builders.ExpectImpl
|
||||
import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion
|
||||
import ch.tutteli.atrium.domain.builders.utils.toVarArg
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains.Builder
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InOrderOnlySearchBehaviour
|
||||
|
||||
/**
|
||||
* Finishes the specification of the sophisticated `contains` assertion where the [Iterable] needs to contain only the
|
||||
* [expected] value.
|
||||
*
|
||||
* Delegates to [values].
|
||||
*
|
||||
* Note that we might change the signature of this function with the next version
|
||||
* which will cause a binary backward compatibility break (see
|
||||
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
|
||||
*
|
||||
* @param expected The value which is expected to be contained within the [Iterable].
|
||||
*
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Builder<E, T, InOrderOnlySearchBehaviour>.value(expected: E): Expect<T> =
|
||||
this the Values(expected)
|
||||
|
||||
/**
|
||||
* Finishes the specification of the sophisticated `contains` assertion where the [Iterable] needs to contain only the
|
||||
* expected [values] in the specified order.
|
||||
*
|
||||
* Note that we might change the signature of this function with the next version
|
||||
* which will cause a binary backward compatibility break (see
|
||||
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
|
||||
*
|
||||
* @param values The nullable values which are expected to be contained within the [Iterable].
|
||||
*
|
||||
* @return The [AssertionPlant] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Builder<E, T, InOrderOnlySearchBehaviour>.the(values: Values<E>): Expect<T> =
|
||||
addAssertion(ExpectImpl.iterable.contains.valuesInOrderOnly(this, values.toList()))
|
||||
|
||||
/**
|
||||
* Finishes the specification of the sophisticated `contains` assertion where the [Iterable] needs to contain only a
|
||||
* single entry which holds all assertions created by the given [assertionCreatorOrNull] or needs to be `null`
|
||||
* in case [assertionCreatorOrNull] is defined as `null`.
|
||||
*
|
||||
* Delegates to `entries(assertionCreatorOrNull)`.
|
||||
*
|
||||
* Note that we might change the signature of this function with the next version
|
||||
* which will cause a binary backward compatibility break (see
|
||||
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
|
||||
*
|
||||
* @param assertionCreatorOrNull The identification lambda which creates the assertions which the entry we are looking
|
||||
* for has to hold; or in other words, the function which defines whether an entry is the one we are looking for
|
||||
* or not. In case it is defined as `null`, then an entry is identified if it is `null` as well.
|
||||
*
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
infix fun <E : Any, T : Iterable<E?>> Builder<E?, T, InOrderOnlySearchBehaviour>.entry(
|
||||
assertionCreatorOrNull: (Expect<E>.() -> Unit)?
|
||||
): Expect<T> = this the Entries(assertionCreatorOrNull)
|
||||
|
||||
/**
|
||||
* Finishes the specification of the sophisticated `contains` assertion where the [Iterable] needs to contain only an
|
||||
* entry which holds all assertions [entries].[assertionCreatorOrNull][Entries.assertionCreatorOrNull]
|
||||
* might create or is `null` in case [entries].[assertionCreatorOrNull][Entries.otherAssertionCreatorsOrNulls]
|
||||
* is defined as `null` and likewise a further entry for each
|
||||
* [entries].[otherAssertionCreatorsOrNulls][Entries.otherAssertionCreatorsOrNulls]
|
||||
* (if given) whereas the entries have to appear in the specified order.
|
||||
*
|
||||
* Note that we might change the signature of this function with the next version
|
||||
* which will cause a binary backward compatibility break (see
|
||||
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
|
||||
*
|
||||
* @param entries The parameter object containing the identification lambdas.
|
||||
*
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
infix fun <E : Any, T : Iterable<E?>> Builder<E?, T, InOrderOnlySearchBehaviour>.the(
|
||||
entries: Entries<E>
|
||||
): Expect<T> = addAssertion(ExpectImpl.iterable.contains.entriesInOrderOnly(this, entries.toList()))
|
||||
|
||||
/**
|
||||
* Finishes the specification of the sophisticated `contains` assertion where all elements of the [expectedIterable]
|
||||
* shall be searched within the [Iterable]
|
||||
* (if given) in the specified order.
|
||||
*
|
||||
* Delegates to [values].
|
||||
*
|
||||
* Note that we might change the signature of this function with the next version
|
||||
* which will cause a binary backward compatibility break (see
|
||||
* [#292](https://github.com/robstoll/atrium/issues/292) for more information)
|
||||
*
|
||||
* @param expectedIterable The [Iterable] whose elements are expected to be contained within this [Iterable].
|
||||
*
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
* @throws IllegalArgumentException in case the given [expectedIterable] does not have elements (is empty).
|
||||
*
|
||||
* @since 0.11.0
|
||||
*/
|
||||
inline infix fun <reified E, T : Iterable<E>> Builder<E, T, InOrderOnlySearchBehaviour>.elementsOf(
|
||||
expectedIterable: Iterable<E>
|
||||
): Expect<T> {
|
||||
val (first, rest) = toVarArg(expectedIterable)
|
||||
return this the Values(first, *rest)
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.domain.builders.ExpectImpl
|
||||
import ch.tutteli.atrium.domain.builders.creating.basic.contains.addAssertion
|
||||
import ch.tutteli.atrium.domain.builders.utils.Group
|
||||
import ch.tutteli.atrium.domain.builders.utils.groupsToList
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains.Builder
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.InOrderOnlyGroupedWithinSearchBehaviour
|
||||
import kotlin.jvm.JvmName
|
||||
|
||||
/**
|
||||
* Finishes the specification of the sophisticated `contains` assertion where the expected [Order.firstGroup] as well as
|
||||
* the [Order.secondGroup] and optionally [Order.otherExpectedGroups] of values need to be
|
||||
* contained in [Iterable] in the specified order whereas the values within the groups can occur in any order.
|
||||
*
|
||||
* @param order A parameter object containing the different groups which have to appear in order in the [Iterable].
|
||||
*
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Builder<E, T, InOrderOnlyGroupedWithinSearchBehaviour>.inAny(
|
||||
order: Order<E, Group<E>>
|
||||
): Expect<T> = addAssertion(
|
||||
ExpectImpl.iterable.contains.valuesInOrderOnlyGrouped(
|
||||
this,
|
||||
groupsToList(order.firstGroup, order.secondGroup, order.otherExpectedGroups)
|
||||
)
|
||||
)
|
||||
|
||||
/**
|
||||
* Finishes the specification of the sophisticated `contains` assertion where the expected [Order.firstGroup] as well as
|
||||
* the [Order.secondGroup] and optionally [Order.otherExpectedGroups] of identification lambdas, identifying an entry,
|
||||
* need to be contained in [Iterable] in the specified order whereas the identification lambdas within the groups
|
||||
* can occur in any order.
|
||||
*
|
||||
* An identification lambda can also be defined as `null` in which case it matches an entry which is `null` as well.
|
||||
*
|
||||
* @param order A parameter object containing the different groups which have to appear in order in the [Iterable].
|
||||
*
|
||||
* @return The [Expect] for which the assertion was built to support a fluent API.
|
||||
* @throws AssertionError Might throw an [AssertionError] if the assertion made is not correct.
|
||||
*/
|
||||
@JvmName("inAnyOrderEntries")
|
||||
infix fun <E : Any, T : Iterable<E?>> Builder<E?, T, InOrderOnlyGroupedWithinSearchBehaviour>.inAny(
|
||||
order: Order<(Expect<E>.() -> Unit)?, Group<(Expect<E>.() -> Unit)?>>
|
||||
): Expect<T> = addAssertion(
|
||||
ExpectImpl.iterable.contains.entriesInOrderOnlyGrouped(
|
||||
this,
|
||||
groupsToList(order.firstGroup, order.secondGroup, order.otherExpectedGroups)
|
||||
)
|
||||
)
|
||||
@@ -0,0 +1,60 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.domain.builders.ExpectImpl
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains.Builder
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.*
|
||||
|
||||
/**
|
||||
* Defines that the search behaviour "find entries `in any order` in the [Iterable]" shall be applied to this
|
||||
* sophisticated `contains` in [Iterable] assertion.
|
||||
*
|
||||
* @return The newly created builder.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Builder<E, T, NoOpSearchBehaviour>.inAny(@Suppress("UNUSED_PARAMETER") order: order) =
|
||||
ExpectImpl.iterable.contains.searchBehaviours.inAnyOrder(this)
|
||||
|
||||
/**
|
||||
* Defines that the constraint "`only` the specified entries exist in the [Iterable]" shall be applied to this
|
||||
* sophisticated `contains` [Iterable] assertion.
|
||||
*
|
||||
* @return The newly created builder.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Builder<E, T, InAnyOrderSearchBehaviour>.but(@Suppress("UNUSED_PARAMETER") only: only) =
|
||||
ExpectImpl.iterable.contains.searchBehaviours.inAnyOrderOnly(this)
|
||||
|
||||
|
||||
/**
|
||||
* Defines that the search behaviour "find entries `in order` in the [Iterable]" shall be applied to this
|
||||
* sophisticated `contains` in [Iterable] assertion.
|
||||
*
|
||||
* @return The newly created builder.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Builder<E, T, NoOpSearchBehaviour>.inGiven(@Suppress("UNUSED_PARAMETER") order: order) =
|
||||
ExpectImpl.iterable.contains.searchBehaviours.inOrder(this)
|
||||
|
||||
/**
|
||||
* Defines that the constraint "`only` the specified entries exist in the [Iterable]" shall be applied to this
|
||||
* sophisticated `contains in order` [Iterable] assertion.
|
||||
*
|
||||
* @return The newly created builder.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Builder<E, T, InOrderSearchBehaviour>.and(@Suppress("UNUSED_PARAMETER") only: only) =
|
||||
ExpectImpl.iterable.contains.searchBehaviours.inOrderOnly(this)
|
||||
|
||||
/**
|
||||
* Defines that the [Iterable] contains `in order only` groups of entries
|
||||
* whereas the order within the group is specified as next step.
|
||||
*
|
||||
* @return The newly created builder.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Builder<E, T, InOrderOnlySearchBehaviour>.grouped(@Suppress("UNUSED_PARAMETER") entries: entries) =
|
||||
ExpectImpl.iterable.contains.searchBehaviours.inOrderOnlyGrouped(this)
|
||||
|
||||
/**
|
||||
* A filler word to emphasis that the next step defines the order within expected groups of values.
|
||||
*
|
||||
* @return The newly created builder.
|
||||
*/
|
||||
infix fun <E, T : Iterable<E>> Builder<E, T, InOrderOnlyGroupedSearchBehaviour>.within(@Suppress("UNUSED_PARAMETER") group: group) =
|
||||
ExpectImpl.iterable.contains.searchBehaviours.inOrderOnlyGroupedWithin(this)
|
||||
|
||||
@@ -59,12 +59,12 @@ object entries : Keyword
|
||||
object group : Keyword
|
||||
|
||||
/**
|
||||
* Represents the pseudo keyword `not` as in [contains] `not`.
|
||||
* Represents the pseudo keyword `next` as in [has] `next`.
|
||||
* It can be used for a parameter less function so that it has one parameter and thus can be used as infix function.
|
||||
*
|
||||
* @since 0.11.0
|
||||
*/
|
||||
object not : Keyword
|
||||
object next : Keyword
|
||||
|
||||
/**
|
||||
* Represents a filler, a pseudo keyword where there isn't really a good keyword.
|
||||
|
||||
@@ -1,17 +1,60 @@
|
||||
@file:Suppress("DEPRECATION" /** TODO remove suppress with 1.0.0 */)
|
||||
@file:Suppress("DEPRECATION" /* TODO remove suppress with 1.0.0 */)
|
||||
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.assertions.Assertion
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.domain.builders.utils.Group
|
||||
import ch.tutteli.atrium.domain.builders.utils.GroupWithNullableEntries
|
||||
import ch.tutteli.atrium.domain.builders.utils.GroupWithoutNullableEntries
|
||||
import ch.tutteli.atrium.domain.builders.utils.VarArgHelper
|
||||
import ch.tutteli.kbox.glue
|
||||
|
||||
/**
|
||||
* Parameter object to express `T, vararg T`.
|
||||
*/
|
||||
class All<out T>(override val expected: T, override vararg val otherExpected: T) : VarArgHelper<T>
|
||||
|
||||
/**
|
||||
* Parameter object to express a [Group] with a single identification lambda.
|
||||
*
|
||||
* In case `null` is used for the identification lambda then it is expected that the corresponding entry
|
||||
* is `null` as well.
|
||||
*
|
||||
* @param assertionCreatorOrNull The identification lambda identifying the entry where an entry is considered
|
||||
* to be identified if it holds all [Assertion]s the lambda creates.
|
||||
* In case it is defined as `null`, then an entry is identified if it is `null` as well.
|
||||
*/
|
||||
class Entry<T : Any>(
|
||||
val assertionCreatorOrNull: (Expect<T>.() -> Unit)?
|
||||
) : GroupWithoutNullableEntries<(Expect<T>.() -> Unit)?>, GroupWithNullableEntries<(Expect<T>.() -> Unit)?> {
|
||||
override fun toList(): List<(Expect<T>.() -> Unit)?> = listOf(assertionCreatorOrNull)
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameter object to express a [Group] of identification lambdas.
|
||||
*
|
||||
* It is also used to express `(Expect<T>.() -> Unit)?, vararg (Expect<T>.() -> Unit)?` at other places the infix-api.
|
||||
*
|
||||
* In case `null` is used for an identification lambda then it is expected that the corresponding entry
|
||||
* is `null` as well.
|
||||
*
|
||||
* @param assertionCreatorOrNull The identification lambda identifying the entry where an entry is considered
|
||||
* to be identified if it holds all [Assertion]s the lambda might create.
|
||||
* In case it is defined as `null`, then an entry is identified if it is `null` as well.
|
||||
* @param otherAssertionCreatorsOrNulls A variable amount of additional identification lambdas or `null`s.
|
||||
*/
|
||||
class Entries<T>(
|
||||
val assertionCreatorOrNull: (Expect<T>.() -> Unit)?,
|
||||
vararg val otherAssertionCreatorsOrNulls: (Expect<T>.() -> Unit)?
|
||||
) : GroupWithoutNullableEntries<(Expect<T>.() -> Unit)?>, GroupWithNullableEntries<(Expect<T>.() -> Unit)?>,
|
||||
VarArgHelper<(Expect<T>.() -> Unit)?> {
|
||||
override val expected get() = assertionCreatorOrNull
|
||||
override val otherExpected get() = otherAssertionCreatorsOrNulls
|
||||
|
||||
override fun toList(): List<(Expect<T>.() -> Unit)?> = assertionCreatorOrNull glue otherAssertionCreatorsOrNulls
|
||||
}
|
||||
|
||||
/**
|
||||
* Parameter object to express a key/value [Pair] whose value type is a nullable lambda with an
|
||||
* [Expect] receiver, which means one can either pass a lambda or `null`.
|
||||
@@ -22,6 +65,18 @@ data class KeyValue<out K, V : Any>(val key: K, val valueAssertionCreatorOrNull:
|
||||
"KeyValue(key=$key, value=${if (valueAssertionCreatorOrNull == null) "null" else "lambda"})"
|
||||
}
|
||||
|
||||
//TODO #63 move to iterable and introduce function instead
|
||||
/**
|
||||
* Parameter object to express `Group<T>, Group<T>, vararg Group<T>` in the infix-api.
|
||||
*
|
||||
* Notice, most probably the type parameter G will be removed in the future, will be fixed to [Group].
|
||||
*/
|
||||
class Order<out T, out G : Group<T>>(
|
||||
val firstGroup: G,
|
||||
val secondGroup: G,
|
||||
vararg val otherExpectedGroups: G
|
||||
)
|
||||
|
||||
/**
|
||||
* Parameter object to express `Pair<K, V>, vararg Pair<K, V>`.
|
||||
*/
|
||||
@@ -38,6 +93,13 @@ class RegexPatterns(pattern: String, vararg otherPatterns: String) : VarArgHelpe
|
||||
override val otherExpected = otherPatterns
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a [Group] with a single value.
|
||||
*/
|
||||
data class Value<T>(val expected: T) : GroupWithNullableEntries<T>, GroupWithoutNullableEntries<T> {
|
||||
override fun toList() = listOf(expected)
|
||||
}
|
||||
|
||||
/**
|
||||
* Represents a [Group] of multiple values.
|
||||
*
|
||||
|
||||
@@ -11,6 +11,7 @@ import ch.tutteli.atrium.domain.builders.ExpectImpl.changeSubject
|
||||
*
|
||||
* @return The newly created [Expect] for the transformed subject.
|
||||
*/
|
||||
//TODO #63 use parameter o
|
||||
fun <E, T : Sequence<E>> Expect<T>.asIterable(): Expect<Iterable<E>> =
|
||||
changeSubject(this).unreported { it.asIterable() }
|
||||
|
||||
|
||||
@@ -48,7 +48,12 @@ abstract class CharSequenceContainsSpecBase : WithAsciiReporter() {
|
||||
a1 contains o atLeast 2 matchFor Regex("bla")
|
||||
a1 contains o atLeast 2 matchFor All(Regex("bla"), Regex("b"))
|
||||
a1 contains o atLeast 2 elementsOf listOf(1, 2)
|
||||
a1 containsNot o
|
||||
|
||||
a1 containsNot o value "a"
|
||||
a1 containsNot o the Values("a", 'b')
|
||||
a1 containsNot o regex "a"
|
||||
a1 containsNot o the RegexPatterns("a", "bl")
|
||||
a1 containsNot o elementsOf listOf(1, 2)
|
||||
|
||||
a1 contains o ignoring case atLeast 1 value "a"
|
||||
a1 contains o ignoring case atLeast 1 the Values("a", 'b')
|
||||
@@ -56,13 +61,19 @@ abstract class CharSequenceContainsSpecBase : WithAsciiReporter() {
|
||||
a1 contains o ignoring case atLeast 1 the RegexPatterns("a", "bl")
|
||||
a1 contains o ignoring case atLeast 1 elementsOf listOf(1, 2)
|
||||
|
||||
a1 containsNot o ignoring case value "a"
|
||||
a1 containsNot o ignoring case the Values("a", 'b')
|
||||
a1 containsNot o ignoring case regex "a"
|
||||
a1 containsNot o ignoring case the RegexPatterns("a", "bl")
|
||||
a1 containsNot o ignoring case elementsOf listOf(1, 2)
|
||||
|
||||
// skip atLeast
|
||||
a1 contains o ignoring case value "a"
|
||||
a1 contains o ignoring case the Values("a", 'b')
|
||||
a1 contains o ignoring case regex "a"
|
||||
a1 contains o ignoring case the RegexPatterns("a", "bl")
|
||||
//TODO add to infix as well as fluent
|
||||
//a1 contains o ignoring case elementsOf listOf(1, 2)
|
||||
//TODO #422 uncomment
|
||||
//a1 contains o ignoring case elementsOf listOf("a", 2)
|
||||
|
||||
a1 and { it contains o atLeast 1 value 1 }
|
||||
a1 and { it contains o atMost 2 the Values("a", 1) }
|
||||
|
||||
@@ -0,0 +1,111 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.domain.builders.ExpectImpl
|
||||
import ch.tutteli.atrium.specs.fun1
|
||||
import ch.tutteli.atrium.specs.notImplemented
|
||||
import ch.tutteli.atrium.specs.withNullableSuffix
|
||||
import org.spekframework.spek2.Spek
|
||||
import kotlin.reflect.KFunction2
|
||||
|
||||
class IterableAnyAssertionsSpec : Spek({
|
||||
include(PredicateSpec)
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
include(SequenceSpec)
|
||||
}) {
|
||||
object PredicateSpec : ch.tutteli.atrium.specs.integration.IterableAnyAssertionsSpec(
|
||||
fun1(Expect<Iterable<Double>>::any),
|
||||
fun1(Expect<Iterable<Double?>>::any).withNullableSuffix(),
|
||||
"* ",
|
||||
"[Atrium][Predicate] "
|
||||
)
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableAnyAssertionsSpec(
|
||||
getContainsPair(),
|
||||
getContainsNullablePair().withNullableSuffix(),
|
||||
"* ",
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableAnyAssertionsSpec(
|
||||
getContainsShortcutPair(),
|
||||
getContainsNullableShortcutPair().withNullableSuffix(),
|
||||
"* ",
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
object SequenceSpec : ch.tutteli.atrium.specs.integration.IterableAnyAssertionsSpec(
|
||||
getContainsSequencePair(),
|
||||
getContainsNullableSequencePair().withNullableSuffix(),
|
||||
"* ",
|
||||
"[Atrium][Sequence] "
|
||||
)
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
fun getContainsPair() =
|
||||
"$contains $filler $inAnyOrder $atLeast 1 entry" to Companion::containsInAnyOrderEntry
|
||||
|
||||
private fun containsInAnyOrderEntry(expect: Expect<Iterable<Double>>, a: Expect<Double>.() -> Unit) =
|
||||
expect contains o inAny order atLeast 1 entry a
|
||||
|
||||
fun getContainsNullablePair() =
|
||||
"$contains $filler $inAnyOrder $atLeast 1 entry" to Companion::containsNullableEntry
|
||||
|
||||
private fun containsNullableEntry(expect: Expect<Iterable<Double?>>, a: (Expect<Double>.() -> Unit)?) =
|
||||
expect contains o inAny order atLeast 1 entry a
|
||||
|
||||
private val containsShortcutFun: KFunction2<Expect<Iterable<Double>>, Expect<Double>.() -> Unit, Expect<Iterable<Double>>> =
|
||||
Expect<Iterable<Double>>::contains
|
||||
|
||||
fun getContainsShortcutPair() = containsShortcutFun.name to Companion::containsInAnyOrderEntryShortcut
|
||||
|
||||
private fun containsInAnyOrderEntryShortcut(expect: Expect<Iterable<Double>>, a: Expect<Double>.() -> Unit) =
|
||||
expect contains a
|
||||
|
||||
private val containsShortcutNullableFun: KFunction2<Expect<Iterable<Double?>>, (Expect<Double>.() -> Unit)?, Expect<Iterable<Double?>>> =
|
||||
Expect<Iterable<Double?>>::contains
|
||||
|
||||
fun getContainsNullableShortcutPair() =
|
||||
containsShortcutNullableFun.name to Companion::containsNullableEntryShortcut
|
||||
|
||||
private fun containsNullableEntryShortcut(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: (Expect<Double>.() -> Unit)?
|
||||
) = expect contains a
|
||||
|
||||
|
||||
private fun getContainsSequencePair() =
|
||||
"asSequence().${Sequence<*>::asIterable.name}() ${containsShortcutFun.name}" to Companion::containsInAnyOrderEntrySequence
|
||||
|
||||
private fun containsInAnyOrderEntrySequence(expect: Expect<Iterable<Double>>, a: Expect<Double>.() -> Unit) =
|
||||
ExpectImpl.changeSubject(expect).unreported { it.asSequence() }.asIterable() contains a
|
||||
|
||||
fun getContainsNullableSequencePair() =
|
||||
"asSequence().${Sequence<*>::asIterable.name}() ${containsShortcutNullableFun.name}" to Companion::containsNullableEntrySequence
|
||||
|
||||
private fun containsNullableEntrySequence(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: (Expect<Double>.() -> Unit)?
|
||||
) = ExpectImpl.changeSubject(expect).unreported { it.asSequence() }.asIterable() contains a
|
||||
}
|
||||
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
private fun ambiguityTest() {
|
||||
var a1: Expect<List<Double>> = notImplemented()
|
||||
var a1b: Expect<Set<Double?>> = notImplemented()
|
||||
|
||||
var star: Expect<Collection<*>> = notImplemented()
|
||||
|
||||
a1 = a1 any {}
|
||||
a1 = a1 contains {}
|
||||
|
||||
a1b = a1b any {}
|
||||
a1b = a1b any null
|
||||
a1b = a1b contains {}
|
||||
a1b = a1b contains (null as Double?)
|
||||
|
||||
star = star any {}
|
||||
star = star contains {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,39 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.specs.notImplemented
|
||||
import ch.tutteli.atrium.specs.testutils.WithAsciiReporter
|
||||
import kotlin.reflect.KFunction2
|
||||
|
||||
class IterableAssertionsSpec : ch.tutteli.atrium.specs.integration.IterableAssertionsSpec(
|
||||
getHasNextPair(),
|
||||
getHasNotNextPair()
|
||||
) {
|
||||
companion object : WithAsciiReporter() {
|
||||
private val has: KFunction2<Expect<Iterable<Int>>, next, Expect<Iterable<Int>>> = Expect<Iterable<Int>>::has
|
||||
private fun getHasNextPair() = "${has.name} ${next::class.simpleName}" to Companion::hasNext
|
||||
private fun hasNext(expect: Expect<Iterable<Int>>) = expect has next
|
||||
|
||||
private val hasNot: KFunction2<Expect<Iterable<Int>>, next, Expect<Iterable<Int>>> =
|
||||
Expect<Iterable<Int>>::hasNot
|
||||
|
||||
private fun getHasNotNextPair() = "${hasNot.name} ${next::class.simpleName}" to Companion::hasNotNext
|
||||
private fun hasNotNext(expect: Expect<Iterable<Int>>) = expect hasNot next
|
||||
}
|
||||
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
private fun ambiguityTest() {
|
||||
var a1: Expect<List<Double>> = notImplemented()
|
||||
var a1b: Expect<Set<Double?>> = notImplemented()
|
||||
var star: Expect<Collection<*>> = notImplemented()
|
||||
|
||||
a1 = a1 has next
|
||||
a1 = a1 hasNot next
|
||||
|
||||
a1b = a1b has next
|
||||
a1b = a1b hasNot next
|
||||
|
||||
star = star has next
|
||||
star = star hasNot next
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.api.verbs.internal.expect
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import org.spekframework.spek2.Spek
|
||||
import org.spekframework.spek2.style.specification.describe
|
||||
|
||||
class IterableContainsInAnyOrderAtLeast1ElementsOfAssertionsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
|
||||
describe("elementsOf") {
|
||||
it("passing an empty iterable throws an IllegalArgumentException") {
|
||||
expect {
|
||||
expect(listOf(1, 2)) contains o inAny order atLeast 1 elementsOf listOf()
|
||||
}.toThrow<IllegalArgumentException>()
|
||||
}
|
||||
}
|
||||
}) {
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec(
|
||||
getContainsPair(),
|
||||
getContainsNullablePair(),
|
||||
"* ",
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
fun getContainsPair() =
|
||||
"$contains $filler $inAnyOrder $atLeast 1 $inAnyOrderElementsOf" to Companion::containsValues
|
||||
|
||||
private fun containsValues(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
): Expect<Iterable<Double>> = expect contains o inAny order atLeast 1 elementsOf listOf(a, *aX)
|
||||
|
||||
fun getContainsNullablePair() =
|
||||
"$contains $filler $inAnyOrder $atLeast 1 $inAnyOrderElementsOf" to Companion::containsNullableValues
|
||||
|
||||
private fun containsNullableValues(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: Double?,
|
||||
aX: Array<out Double?>
|
||||
): Expect<Iterable<Double?>> = expect contains o inAny order atLeast 1 elementsOf listOf(a, *aX)
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,75 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import org.spekframework.spek2.Spek
|
||||
import kotlin.reflect.KFunction2
|
||||
|
||||
class IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
}) {
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec(
|
||||
getContainsPair(),
|
||||
getContainsNullablePair(),
|
||||
"* ",
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableContainsInAnyOrderAtLeast1EntriesAssertionsSpec(
|
||||
getContainsShortcutPair(),
|
||||
getContainsNullableShortcutPair(),
|
||||
"* ",
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
fun getContainsPair() =
|
||||
"$contains $filler $inAnyOrder $atLeast 1 $inAnyOrderEntries" to Companion::containsInAnyOrderEntries
|
||||
|
||||
private fun containsInAnyOrderEntries(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Expect<Double>.() -> Unit,
|
||||
aX: Array<out Expect<Double>.() -> Unit>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect contains o inAny order atLeast 1 entry a
|
||||
else expect contains o inAny order atLeast 1 the Entries(a, *aX)
|
||||
|
||||
fun getContainsNullablePair() =
|
||||
"$contains $filler $inAnyOrder $atLeast 1 $inAnyOrderEntries" to Companion::containsNullableEntries
|
||||
|
||||
private fun containsNullableEntries(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: (Expect<Double>.() -> Unit)?,
|
||||
aX: Array<out (Expect<Double>.() -> Unit)?>
|
||||
): Expect<Iterable<Double?>> =
|
||||
if (aX.isEmpty()) expect contains o inAny order atLeast 1 entry a
|
||||
else expect contains o inAny order atLeast 1 the Entries(a, *aX)
|
||||
|
||||
|
||||
private val containsShortcutFun: KFunction2<Expect<Iterable<Double>>, Expect<Double>.() -> Unit, Expect<Iterable<Double>>> =
|
||||
Expect<Iterable<Double>>::contains
|
||||
|
||||
fun getContainsShortcutPair() = containsShortcutFun.name to Companion::containsInAnyOrderEntriesShortcut
|
||||
|
||||
private fun containsInAnyOrderEntriesShortcut(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Expect<Double>.() -> Unit,
|
||||
aX: Array<out Expect<Double>.() -> Unit>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect contains a
|
||||
else expect contains Entries(a, *aX)
|
||||
|
||||
private val containsEntriesFun: KFunction2<Expect<Iterable<Double?>>, (Expect<Double>.() -> Unit)?, Expect<Iterable<Double?>>> =
|
||||
Expect<Iterable<Double?>>::contains
|
||||
|
||||
fun getContainsNullableShortcutPair() = containsEntriesFun.name to Companion::containsNullableEntriesShortcut
|
||||
|
||||
private fun containsNullableEntriesShortcut(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: (Expect<Double>.() -> Unit)?,
|
||||
aX: Array<out (Expect<Double>.() -> Unit)?>
|
||||
): Expect<Iterable<Double?>> =
|
||||
if (aX.isEmpty()) expect contains a
|
||||
else expect contains Entries(a, *aX)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import org.spekframework.spek2.Spek
|
||||
import kotlin.reflect.KFunction2
|
||||
|
||||
class IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
}) {
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec(
|
||||
getContainsPair(),
|
||||
getContainsNullablePair(),
|
||||
"* ",
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableContainsInAnyOrderAtLeast1ValuesAssertionsSpec(
|
||||
getContainsShortcutPair(),
|
||||
getContainsNullableShortcutPair(),
|
||||
"* ",
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
fun getContainsPair() =
|
||||
"$contains $filler $inAnyOrder $atLeast 1 $inAnyOrderValues" to Companion::containsValues
|
||||
|
||||
private fun containsValues(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect contains o inAny order atLeast 1 value a
|
||||
else expect contains o inAny order atLeast 1 the Values(a, *aX)
|
||||
|
||||
fun getContainsNullablePair() =
|
||||
"$contains $filler $inAnyOrder $atLeast 1 $inAnyOrderValues" to Companion::containsNullableValues
|
||||
|
||||
private fun containsNullableValues(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: Double?,
|
||||
aX: Array<out Double?>
|
||||
): Expect<Iterable<Double?>> =
|
||||
if (aX.isEmpty()) expect contains o inAny order atLeast 1 value a
|
||||
else expect contains o inAny order atLeast 1 the Values(a, *aX)
|
||||
|
||||
|
||||
private val containsFun: KFunction2<Expect<Iterable<Double>>, Double, Expect<Iterable<Double>>> =
|
||||
Expect<Iterable<Double>>::contains
|
||||
|
||||
fun getContainsShortcutPair() = containsFun.name to Companion::containsValuesShortcut
|
||||
|
||||
private fun containsValuesShortcut(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect contains a
|
||||
else expect contains Values(a, *aX)
|
||||
|
||||
|
||||
private val containsNullableFun: KFunction2<Expect<Iterable<Double?>>, Double?, Expect<Iterable<Double?>>> =
|
||||
Expect<Iterable<Double?>>::contains
|
||||
|
||||
fun getContainsNullableShortcutPair() = containsNullableFun.name to Companion::containsNullableValuesShortcut
|
||||
|
||||
private fun containsNullableValuesShortcut(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: Double?,
|
||||
aX: Array<out Double?>
|
||||
): Expect<Iterable<Double?>> =
|
||||
if (aX.isEmpty()) expect contains a
|
||||
else expect contains Values(a, *aX)
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
|
||||
class IterableContainsInAnyOrderAtLeastValuesAssertionsSpec :
|
||||
ch.tutteli.atrium.specs.integration.IterableContainsInAnyOrderAtLeastValuesAssertionSpec(
|
||||
getAtLeastTriple(),
|
||||
getAtLeastButAtMostTriple(),
|
||||
getContainsNotPair(),
|
||||
getExactlyPair(),
|
||||
Companion::getErrorMsgAtLeastButAtMost,
|
||||
"* "
|
||||
) {
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
|
||||
internal fun getAtLeastTriple() =
|
||||
{ what: String, times: String -> "$contains $what in any order $atLeast $times" } to
|
||||
("$contains $filler $inAnyOrder $atLeast" to Companion::containsAtLeast)
|
||||
|
||||
private fun containsAtLeast(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
atLeast: Int,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect contains o inAny order atLeast atLeast value a
|
||||
else expect contains o inAny order atLeast atLeast the Values(a, *aX)
|
||||
|
||||
|
||||
private fun getAtLeastButAtMostTriple() =
|
||||
{ what: String, timesAtLeast: String, timesAtMost: String -> "$contains $what $atLeast $timesAtLeast $butAtMost $timesAtMost" } to
|
||||
("$contains $filler $atLeast $butAtMost" to Companion::containsAtLeastButAtMost)
|
||||
|
||||
private fun containsAtLeastButAtMost(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
atLeast: Int,
|
||||
butAtMost: Int,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
) = expect contains o inAny order atLeast atLeast butAtMost butAtMost the Values(a, *aX)
|
||||
|
||||
private fun getContainsNotPair() = containsNot to Companion::getErrorMsgContainsNot
|
||||
|
||||
private fun getErrorMsgContainsNot(times: Int) = "use `$containsNot` instead of `$atLeast $times`"
|
||||
|
||||
private fun getExactlyPair() = exactly to Companion::getErrorMsgExactly
|
||||
|
||||
private fun getErrorMsgExactly(times: Int) =
|
||||
"use `$exactly $times` instead of `$atLeast $times $butAtMost $times`"
|
||||
|
||||
internal fun getErrorMsgAtLeastButAtMost(timesAtLeast: Int, timesButAtMost: Int) =
|
||||
"specifying `$butAtMost $timesButAtMost` does not make sense if `$atLeast $timesAtLeast` was used before"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
|
||||
class IterableContainsInAnyOrderAtMostValuesAssertionsSpec :
|
||||
ch.tutteli.atrium.specs.integration.IterableContainsInAnyOrderAtMostValuesAssertionSpec(
|
||||
getAtMostTriple(),
|
||||
getContainsNotPair(),
|
||||
getExactlyPair(),
|
||||
"* "
|
||||
) {
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
|
||||
private fun getAtMostTriple() =
|
||||
{ what: String, times: String -> "$contains $what $atMost $times" } to
|
||||
("$contains $filler $inAnyOrder $atMost" to Companion::containsAtMost)
|
||||
|
||||
private fun containsAtMost(expect: Expect<Iterable<Double>>, atMost: Int, a: Double, aX: Array<out Double>) =
|
||||
if(aX.isEmpty()) expect contains o inAny order atMost atMost value a
|
||||
else expect contains o inAny order atMost atMost the Values(a, *aX)
|
||||
|
||||
|
||||
private fun getContainsNotPair() = containsNot to Companion::getErrorMsgContainsNot
|
||||
|
||||
private fun getErrorMsgContainsNot(times: Int) = "use `$containsNot` instead of `$atMost $times`"
|
||||
|
||||
private fun getExactlyPair() = exactly to Companion::getErrorMsgExactly
|
||||
|
||||
private fun getErrorMsgExactly(times: Int) =
|
||||
"use `$exactly $times` instead of `$atMost $times`; `$atMost $times` defines implicitly `$atLeast $times` as well"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
|
||||
class IterableContainsInAnyOrderExactlyValuesAssertionsSpec :
|
||||
ch.tutteli.atrium.specs.integration.IterableContainsInAnyOrderExactlyValuesAssertionsSpec(
|
||||
getExactlyTriple(),
|
||||
getContainsNotPair(),
|
||||
"* "
|
||||
) {
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
|
||||
private fun getExactlyTriple() =
|
||||
{ what: String, times: String -> "$contains $what $exactly $times" } to
|
||||
("$contains $filler $inAnyOrder $exactly" to Companion::containsExactly)
|
||||
|
||||
private fun containsExactly(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
exactly: Int,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect contains o inAny order exactly exactly value a
|
||||
else expect contains o inAny order exactly exactly the Values(a, *aX)
|
||||
|
||||
private fun getContainsNotPair() = containsNot to Companion::getErrorMsgContainsNot
|
||||
|
||||
private fun getErrorMsgContainsNot(times: Int) = "use `$containsNot` instead of `$exactly $times`"
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
|
||||
class IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec :
|
||||
ch.tutteli.atrium.specs.integration.IterableContainsInAnyOrderNotOrAtMostValuesAssertionsSpec(
|
||||
getNotOrAtMostTriple(),
|
||||
getContainsNotPair(),
|
||||
"* "
|
||||
) {
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
|
||||
private fun getNotOrAtMostTriple() =
|
||||
{ what: String, times: String -> "$contains $what $notOrAtMost $times" } to
|
||||
("$contains $filler $notOrAtMost" to Companion::containsNotOrAtMost)
|
||||
|
||||
private fun containsNotOrAtMost(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
atMost: Int,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
) =
|
||||
if (aX.isEmpty()) expect contains o inAny order notOrAtMost atMost value a
|
||||
else expect contains o inAny order notOrAtMost atMost the Values(a, *aX)
|
||||
|
||||
private fun getContainsNotPair() = containsNot to Companion::getErrorMsgContainsNot
|
||||
|
||||
private fun getErrorMsgContainsNot(times: Int) = "use `$containsNot` instead of `$notOrAtMost $times`"
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.api.verbs.internal.expect
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import org.spekframework.spek2.Spek
|
||||
import org.spekframework.spek2.style.specification.describe
|
||||
|
||||
class IterableContainsInAnyOrderOnlyElementsOfAssertionSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
|
||||
describe("elementsOf") {
|
||||
it("passing an empty iterable throws an IllegalArgumentException") {
|
||||
expect {
|
||||
expect(listOf(1, 2)) contains o inAny order but only elementsOf listOf()
|
||||
}.toThrow<IllegalArgumentException>()
|
||||
}
|
||||
}
|
||||
}) {
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableContainsInAnyOrderOnlyValuesAssertionsSpec(
|
||||
getContainsPair(),
|
||||
getContainsNullablePair(),
|
||||
"* ", "(/) ", "(x) ", "(!) ", "- ", "» "
|
||||
)
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
fun getContainsPair() =
|
||||
"$contains $filler $inAnyOrder $butOnly $inAnyOrderOnlyElementsOf" to Companion::getContainsValues
|
||||
|
||||
private fun getContainsValues(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
): Expect<Iterable<Double>> = expect contains o inAny order but only elementsOf listOf(a, *aX)
|
||||
|
||||
fun getContainsNullablePair() =
|
||||
"$contains $filler $inAnyOrder $butOnly $inAnyOrderOnlyElementsOf" to Companion::getContainsNullableValues
|
||||
|
||||
private fun getContainsNullableValues(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: Double?,
|
||||
aX: Array<out Double?>
|
||||
): Expect<Iterable<Double?>> = expect contains o inAny order but only elementsOf listOf(a, *aX)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
|
||||
class IterableContainsInAnyOrderOnlyEntriesAssertionsSpec :
|
||||
ch.tutteli.atrium.specs.integration.IterableContainsInAnyOrderOnlyEntriesAssertionsSpec(
|
||||
getContainsPair(),
|
||||
getContainsNullablePair(),
|
||||
"* ", "(/) ", "(x) ", "(!) ", "- ", "» "
|
||||
) {
|
||||
companion object : IterableContainsSpecBase() {
|
||||
fun getContainsPair() =
|
||||
"$contains $filler $inAnyOrder $butOnly $inAnyOrderOnlyEntries" to Companion::containsInAnyOrderOnlyEntries
|
||||
|
||||
private fun containsInAnyOrderOnlyEntries(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Expect<Double>.() -> Unit,
|
||||
aX: Array<out Expect<Double>.() -> Unit>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect contains o inAny order but only entry a
|
||||
else expect contains o inAny order but only the Entries(a, *aX)
|
||||
|
||||
|
||||
fun getContainsNullablePair() =
|
||||
"$contains $filler $inAnyOrder $butOnly $inAnyOrderOnlyEntries" to Companion::containsInAnyOrderOnlyNullableEntries
|
||||
|
||||
private fun containsInAnyOrderOnlyNullableEntries(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: (Expect<Double>.() -> Unit)?,
|
||||
aX: Array<out (Expect<Double>.() -> Unit)?>
|
||||
): Expect<Iterable<Double?>> =
|
||||
if (aX.isEmpty()) expect contains o inAny order but only entry a
|
||||
else expect contains o inAny order but only the Entries(a, *aX)
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
|
||||
class IterableContainsInAnyOrderOnlyValuesAssertionsSpec :
|
||||
ch.tutteli.atrium.specs.integration.IterableContainsInAnyOrderOnlyValuesAssertionsSpec(
|
||||
getContainsPair(),
|
||||
getContainsNullablePair(),
|
||||
"* ", "(/) ", "(x) ", "(!) ", "- "
|
||||
) {
|
||||
companion object : IterableContainsSpecBase() {
|
||||
fun getContainsPair() =
|
||||
"$contains $filler $inAnyOrder $butOnly $inAnyOrderOnlyValues" to Companion::containsInAnyOrderOnlyValues
|
||||
|
||||
private fun containsInAnyOrderOnlyValues(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect contains o inAny order but only value a
|
||||
else expect contains o inAny order but only the Values(a, *aX)
|
||||
|
||||
|
||||
fun getContainsNullablePair() =
|
||||
"$contains $filler $inAnyOrder $butOnly $inAnyOrderOnlyValues" to Companion::containsInAnyOrderOnlyNullableValues
|
||||
|
||||
private fun containsInAnyOrderOnlyNullableValues(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: Double?,
|
||||
aX: Array<out Double?>
|
||||
): Expect<Iterable<Double?>> =
|
||||
if (aX.isEmpty()) expect contains o inAny order but only value a
|
||||
else expect contains o inAny order but only the Values(a, *aX)
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import org.spekframework.spek2.Spek
|
||||
|
||||
class IterableContainsInOrderOnlyElementsOfAssertionSpec : Spek({
|
||||
include(BuilderSpec)
|
||||
}) {
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableContainsInOrderOnlyValuesAssertionsSpec(
|
||||
getContainsPair(),
|
||||
getContainsNullablePair(),
|
||||
"* ", "(/) ", "(x) ", "(!) ", "- ", ">> ", "=> ",
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
fun getContainsPair() =
|
||||
"$contains $filler $inOrder $andOnly $inOrderElementsOf" to Companion::containsInOrderOnlyValues
|
||||
|
||||
private fun containsInOrderOnlyValues(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
): Expect<Iterable<Double>> = expect contains o inGiven order and only elementsOf listOf(a, *aX)
|
||||
|
||||
fun getContainsNullablePair() =
|
||||
"$contains $filler $inOrder $andOnly $inOrderElementsOf" to Companion::containsInOrderOnlyNullableValues
|
||||
|
||||
private fun containsInOrderOnlyNullableValues(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: Double?,
|
||||
aX: Array<out Double?>
|
||||
): Expect<Iterable<Double?>> = expect contains o inGiven order and only elementsOf listOf(a, *aX)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import org.spekframework.spek2.Spek
|
||||
import kotlin.reflect.KFunction2
|
||||
|
||||
class IterableContainsInOrderOnlyEntriesAssertionsSpec : Spek({
|
||||
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
|
||||
}) {
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableContainsInOrderOnlyEntriesAssertionsSpec(
|
||||
getContainsPair(),
|
||||
getContainsNullablePair(),
|
||||
"* ", "(/) ", "(x) ", "(!) ", "- ", "» ", ">> ", "=> ",
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableContainsInOrderOnlyEntriesAssertionsSpec(
|
||||
getContainsShortcutPair(),
|
||||
getContainsNullableShortcutPair(),
|
||||
"* ", "(/) ", "(x) ", "(!) ", "- ", "» ", ">> ", "=> ",
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
fun getContainsPair() =
|
||||
"$contains $filler $inOrder $andOnly $inOrderOnlyEntries" to Companion::containsInOrderOnly
|
||||
|
||||
private fun containsInOrderOnly(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Expect<Double>.() -> Unit,
|
||||
aX: Array<out Expect<Double>.() -> Unit>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect contains o inGiven order and only entry a
|
||||
else expect contains o inGiven order and only the Entries(a, *aX)
|
||||
|
||||
fun getContainsNullablePair() =
|
||||
"$contains $filler $inOrder $andOnly $inOrderOnlyEntries" to Companion::containsInOrderOnlyNullableEntriesPair
|
||||
|
||||
private fun containsInOrderOnlyNullableEntriesPair(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: (Expect<Double>.() -> Unit)?,
|
||||
aX: Array<out (Expect<Double>.() -> Unit)?>
|
||||
): Expect<Iterable<Double?>> =
|
||||
if (aX.isEmpty()) expect contains o inGiven order and only entry a
|
||||
else expect contains o inGiven order and only the Entries(a, *aX)
|
||||
|
||||
private val containsShortcutFun: KFunction2<Expect<Iterable<Double>>, Expect<Double>.() -> Unit, Expect<Iterable<Double>>> =
|
||||
Expect<Iterable<Double>>::containsExactly
|
||||
|
||||
fun getContainsShortcutPair() = containsShortcutFun.name to Companion::containsInOrderOnlyEntriesShortcut
|
||||
|
||||
private fun containsInOrderOnlyEntriesShortcut(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Expect<Double>.() -> Unit,
|
||||
aX: Array<out Expect<Double>.() -> Unit>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect containsExactly { a() }
|
||||
else expect containsExactly Entries(a, *aX)
|
||||
|
||||
private val containsNullableShortcutFun: KFunction2<Expect<Iterable<Double?>>, (Expect<Double>.() -> Unit)?, Expect<Iterable<Double?>>> =
|
||||
Expect<Iterable<Double?>>::containsExactly
|
||||
|
||||
fun getContainsNullableShortcutPair() =
|
||||
containsNullableShortcutFun.name to Companion::containsInOrderOnlyNullableEntriesShortcut
|
||||
|
||||
private fun containsInOrderOnlyNullableEntriesShortcut(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: (Expect<Double>.() -> Unit)?,
|
||||
aX: Array<out (Expect<Double>.() -> Unit)?>
|
||||
): Expect<Iterable<Double?>> =
|
||||
if (aX.isEmpty()) {
|
||||
//TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4)
|
||||
if (a == null) expect containsExactly a as Double?
|
||||
else expect containsExactly { a() }
|
||||
} else {
|
||||
expect containsExactly Entries(a, *aX)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.domain.builders.utils.Group
|
||||
|
||||
class IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec :
|
||||
ch.tutteli.atrium.specs.integration.IterableContainsInOrderOnlyGroupedEntriesAssertionsSpec(
|
||||
getContainsPair(),
|
||||
Companion::groupFactory,
|
||||
"* ", "(/) ", "(x) ", "(!) ", "- ", "» ", ">> ", "=> ",
|
||||
"[Atrium][Builder] "
|
||||
) {
|
||||
companion object : IterableContainsSpecBase() {
|
||||
fun getContainsPair() =
|
||||
"$contains $filler $inOrder $andOnly $grouped $within $withinInAnyOrder" to Companion::containsInOrderOnlyGroupedInAnyOrderEntries
|
||||
|
||||
private fun containsInOrderOnlyGroupedInAnyOrderEntries(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a1: Group<(Expect<Double>.() -> Unit)?>,
|
||||
a2: Group<(Expect<Double>.() -> Unit)?>,
|
||||
aX: Array<out Group<(Expect<Double>.() -> Unit)?>>
|
||||
): Expect<Iterable<Double?>> =
|
||||
expect contains o inGiven order and only grouped entries within group inAny Order(a1, a2, *aX)
|
||||
|
||||
private fun groupFactory(groups: Array<out (Expect<Double>.() -> Unit)?>) =
|
||||
when (groups.size) {
|
||||
0 -> object : Group<(Expect<Double>.() -> Unit)?> {
|
||||
override fun toList() = listOf<Expect<Double>.() -> Unit>()
|
||||
}
|
||||
1 -> Entry(groups[0])
|
||||
else -> Entries(groups[0], *groups.drop(1).toTypedArray())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.domain.builders.utils.Group
|
||||
|
||||
class IterableContainsInOrderOnlyGroupedValuesAssertionsSpec :
|
||||
ch.tutteli.atrium.specs.integration.IterableContainsInOrderOnlyGroupedValuesAssertionsSpec(
|
||||
getContainsPair(),
|
||||
Companion::groupFactory,
|
||||
getContainsNullablePair(),
|
||||
Companion::nullableGroupFactory,
|
||||
"* ", "(/) ", "(x) ", "(!) ", "- ", ">> ", "=> ",
|
||||
"[Atrium][Builder] "
|
||||
) {
|
||||
companion object : IterableContainsSpecBase() {
|
||||
fun getContainsPair() =
|
||||
"$contains $filler $inOrder $andOnly $grouped $within $withinInAnyOrder" to Companion::containsInOrderOnlyGroupedInAnyOrderValues
|
||||
|
||||
private fun containsInOrderOnlyGroupedInAnyOrderValues(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a1: Group<Double>,
|
||||
a2: Group<Double>,
|
||||
aX: Array<out Group<Double>>
|
||||
): Expect<Iterable<Double>> {
|
||||
return expect contains o inGiven order and only grouped entries within group inAny Order(a1, a2, *aX)
|
||||
}
|
||||
|
||||
private fun groupFactory(groups: Array<out Double>): Group<Double> =
|
||||
when (groups.size) {
|
||||
0 -> object : Group<Double> {
|
||||
override fun toList() = listOf<Double>()
|
||||
}
|
||||
1 -> Value(groups[0])
|
||||
else -> Values(groups[0], *groups.drop(1).toTypedArray())
|
||||
}
|
||||
|
||||
|
||||
fun getContainsNullablePair() =
|
||||
"$contains $filler $inOrder $andOnly $grouped $within $withinInAnyOrder" to Companion::containsInOrderOnlyGroupedInAnyOrderNullableValues
|
||||
|
||||
private fun containsInOrderOnlyGroupedInAnyOrderNullableValues(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a1: Group<Double?>,
|
||||
a2: Group<Double?>,
|
||||
aX: Array<out Group<Double?>>
|
||||
): Expect<Iterable<Double?>> {
|
||||
return expect contains o inGiven order and only grouped entries within group inAny Order(a1, a2, *aX)
|
||||
}
|
||||
|
||||
private fun nullableGroupFactory(groups: Array<out Double?>): Group<Double?> =
|
||||
when (groups.size) {
|
||||
0 -> object : Group<Double?> {
|
||||
override fun toList() = listOf<Double>()
|
||||
}
|
||||
1 -> Value(groups[0])
|
||||
else -> Values(groups[0], *groups.drop(1).toTypedArray())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import org.spekframework.spek2.Spek
|
||||
import kotlin.reflect.KFunction2
|
||||
|
||||
class IterableContainsInOrderOnlyValuesAssertionsSpec : Spek({
|
||||
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
|
||||
}) {
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableContainsInOrderOnlyValuesAssertionsSpec(
|
||||
getContainsPair(),
|
||||
getContainsNullablePair(),
|
||||
"* ", "(/) ", "(x) ", "(!) ", "- ", ">> ", "=> ",
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableContainsInOrderOnlyValuesAssertionsSpec(
|
||||
getContainsShortcutPair(),
|
||||
getContainsNullableShortcutPair(),
|
||||
"* ", "(/) ", "(x) ", "(!) ", "- ", ">> ", "=> ",
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
fun getContainsPair() = "$contains $filler $inOrder $andOnly $inOrderOnlyValues" to Companion::containsInOrderOnlyValues
|
||||
|
||||
private fun containsInOrderOnlyValues(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect contains o inGiven order and only value a
|
||||
else expect contains o inGiven order and only the Values(a, *aX)
|
||||
|
||||
fun getContainsNullablePair() =
|
||||
"$contains $filler $inOrder $andOnly $inOrderOnlyValues" to Companion::containsInOrderOnlyNullableValues
|
||||
|
||||
private fun containsInOrderOnlyNullableValues(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: Double?,
|
||||
aX: Array<out Double?>
|
||||
): Expect<Iterable<Double?>> =
|
||||
if (aX.isEmpty()) expect contains o inGiven order and only value a
|
||||
else expect contains o inGiven order and only the Values(a, *aX)
|
||||
|
||||
private val containsShortcutFun: KFunction2<Expect<Iterable<Double>>, Double, Expect<Iterable<Double>>> =
|
||||
Expect<Iterable<Double>>::containsExactly
|
||||
|
||||
fun getContainsShortcutPair() = containsShortcutFun.name to Companion::containsInOrderOnlyValuesShortcut
|
||||
|
||||
private fun containsInOrderOnlyValuesShortcut(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect containsExactly a
|
||||
else expect containsExactly Values(a, *aX)
|
||||
|
||||
private val containsNullableShortcutFun: KFunction2<Expect<Iterable<Double?>>, Double?, Expect<Iterable<Double?>>> =
|
||||
Expect<Iterable<Double?>>::containsExactly
|
||||
|
||||
fun getContainsNullableShortcutPair() =
|
||||
containsNullableShortcutFun.name to Companion::containsInOrderOnlyNullableValuesShortcut
|
||||
|
||||
private fun containsInOrderOnlyNullableValuesShortcut(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: Double?,
|
||||
aX: Array<out Double?>
|
||||
): Expect<Iterable<Double?>> =
|
||||
if (aX.isEmpty()) expect containsExactly a
|
||||
else expect containsExactly Values(a, *aX)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.specs.withNullableSuffix
|
||||
|
||||
class IterableContainsNotEntriesAssertionsSpec :
|
||||
ch.tutteli.atrium.specs.integration.IterableContainsNotEntriesAssertionsSpec(
|
||||
getContainsNotPair(),
|
||||
getContainsNotNullablePair().withNullableSuffix(),
|
||||
"* ", "(/) ", "(x) ", "- ", "» ", ">> ", "=> ",
|
||||
"[Atrium][Builder] "
|
||||
) {
|
||||
companion object : IterableContainsSpecBase() {
|
||||
|
||||
private fun getContainsNotPair() = containsNot to Companion::containsNotFun
|
||||
|
||||
private fun containsNotFun(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Expect<Double>.() -> Unit,
|
||||
aX: Array<out Expect<Double>.() -> Unit>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect containsNot o entry a
|
||||
else expect containsNot o the Entries(a, *aX)
|
||||
|
||||
private fun getContainsNotNullablePair() = containsNot to Companion::containsNotNullableFun
|
||||
|
||||
private fun containsNotNullableFun(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: (Expect<Double>.() -> Unit)?,
|
||||
aX: Array<out (Expect<Double>.() -> Unit)?>
|
||||
): Expect<Iterable<Double?>> =
|
||||
if (aX.isEmpty()) expect containsNot o entry a
|
||||
else expect containsNot o the Entries(a, *aX)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import org.spekframework.spek2.Spek
|
||||
import kotlin.reflect.KFunction2
|
||||
|
||||
class IterableContainsNotValuesAssertionsSpec : Spek({
|
||||
|
||||
include(BuilderSpec)
|
||||
include(ShortcutSpec)
|
||||
|
||||
}) {
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableContainsNotValuesAssertionsSpec(
|
||||
getContainsNotPair(),
|
||||
getContainsNotNullablePair(),
|
||||
"* ", "(/) ", "(x) ", "- ", ">> ", "=> ",
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
object ShortcutSpec : ch.tutteli.atrium.specs.integration.IterableContainsNotValuesAssertionsSpec(
|
||||
getContainsNotShortcutPair(),
|
||||
getContainsNotNullablePair(),
|
||||
"* ", "(/) ", "(x) ", "- ", ">> ", "=> ",
|
||||
"[Atrium][Shortcut] "
|
||||
)
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
|
||||
private fun getContainsNotPair() = containsNot to Companion::containsNotFun
|
||||
|
||||
private fun containsNotFun(
|
||||
expect: Expect<Iterable<Double>>,
|
||||
a: Double,
|
||||
aX: Array<out Double>
|
||||
): Expect<Iterable<Double>> =
|
||||
if (aX.isEmpty()) expect containsNot o value a
|
||||
else expect containsNot o the Values(a, *aX)
|
||||
|
||||
private fun getContainsNotNullablePair() = containsNot to Companion::containsNotNullableFun
|
||||
|
||||
private fun containsNotNullableFun(
|
||||
expect: Expect<Iterable<Double?>>,
|
||||
a: Double?,
|
||||
aX: Array<out Double?>
|
||||
): Expect<Iterable<Double?>> =
|
||||
if (aX.isEmpty()) expect containsNot o value a
|
||||
else expect containsNot o the Values(a, *aX)
|
||||
|
||||
private val containsNotShortcutFun: KFunction2<Expect<Iterable<Double>>, Double, Expect<Iterable<Double>>> =
|
||||
Expect<Iterable<Double>>::containsNot
|
||||
|
||||
private fun getContainsNotShortcutPair() = containsNotShortcutFun.name to Companion::containsNotShortcut
|
||||
|
||||
private fun containsNotShortcut(expect: Expect<Iterable<Double>>, a: Double, aX: Array<out Double>) =
|
||||
if (aX.isEmpty()) expect containsNot a
|
||||
else expect containsNot Values(a, *aX)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,324 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.AtLeastCheckerOption
|
||||
import ch.tutteli.atrium.api.infix.en_GB.creating.iterable.contains.builders.NotCheckerOption
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.domain.builders.utils.Group
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.IterableContains
|
||||
import ch.tutteli.atrium.domain.creating.iterable.contains.searchbehaviours.*
|
||||
import ch.tutteli.atrium.specs.notImplemented
|
||||
import ch.tutteli.atrium.specs.testutils.WithAsciiReporter
|
||||
import kotlin.reflect.KFunction2
|
||||
|
||||
abstract class IterableContainsSpecBase : WithAsciiReporter() {
|
||||
protected val Values = Values::class.simpleName
|
||||
private val Entries = Entries::class.simpleName
|
||||
|
||||
//@formatter:off
|
||||
protected val atLeast = IterableContains.Builder<*, *, InAnyOrderSearchBehaviour>::atLeast.name
|
||||
protected val butAtMost = AtLeastCheckerOption<*, *, InAnyOrderSearchBehaviour>::butAtMost.name
|
||||
protected val exactly = IterableContains.Builder<*, *, InAnyOrderSearchBehaviour>::exactly.name
|
||||
protected val atMost = IterableContains.Builder<*, *, InAnyOrderSearchBehaviour>::atMost.name
|
||||
protected val notOrAtMost = IterableContains.Builder<*, *, InAnyOrderSearchBehaviour>::notOrAtMost.name
|
||||
protected val inAnyOrder = "${IterableContains.Builder<*, Iterable<*>, NoOpSearchBehaviour>::inAny.name} ${order::class.simpleName}"
|
||||
protected val butOnly = "${IterableContains.Builder<Int, Iterable<Int>, InAnyOrderSearchBehaviour>::but.name} ${only::class.simpleName}"
|
||||
private val theInAnyOrderFun: KFunction2<IterableContains.CheckerOption<Int, Iterable<Int>, InAnyOrderSearchBehaviour>, Values<Int>, Expect<Iterable<Int>>>
|
||||
= IterableContains.CheckerOption<Int, Iterable<Int>, InAnyOrderSearchBehaviour>::the
|
||||
private val theInAnyOrder = theInAnyOrderFun.name
|
||||
protected val inAnyOrderEntries = "$theInAnyOrder $Entries"
|
||||
protected val inAnyOrderValues = "$theInAnyOrder $Values"
|
||||
protected val inAnyOrderElementsOf = IterableContains.CheckerOption<Int, Iterable<Int>, InAnyOrderSearchBehaviour>::elementsOf.name
|
||||
|
||||
private val theInAnyOrderOnlyFun: KFunction2<IterableContains.Builder<Int, Iterable<Int>, InAnyOrderOnlySearchBehaviour>, Values<Int>, Expect<Iterable<Int>>>
|
||||
= IterableContains.Builder<Int, Iterable<Int>, InAnyOrderOnlySearchBehaviour>::the
|
||||
private val theInAnyOrderOnly = theInAnyOrderOnlyFun.name
|
||||
protected val inAnyOrderOnlyValues = "$theInAnyOrderOnly $Values"
|
||||
protected val inAnyOrderOnlyEntries = "$theInAnyOrderOnly $Entries"
|
||||
protected val inAnyOrderOnlyElementsOf = IterableContains.Builder<Int, Iterable<Int>, InAnyOrderOnlySearchBehaviour>::elementsOf.name
|
||||
|
||||
protected val inOrder = "${IterableContains.Builder<*, Iterable<*>, NoOpSearchBehaviour>::inGiven.name} ${order::class.simpleName}"
|
||||
protected val andOnly = "${IterableContains.Builder<Int, Iterable<Int>, InOrderSearchBehaviour>::and.name} ${only::class.simpleName}"
|
||||
private val theInOrderOnlyFun: KFunction2<IterableContains.Builder<Int, Iterable<Int>, InOrderOnlySearchBehaviour>, Values<Int>, Expect<Iterable<Int>>>
|
||||
= IterableContains.Builder<Int, Iterable<Int>, InOrderOnlySearchBehaviour>::the
|
||||
private val theInOrderOnly = theInOrderOnlyFun.name
|
||||
protected val inOrderOnlyValues = "$theInOrderOnly $Values"
|
||||
protected val inOrderOnlyEntries = "$theInOrderOnly $Entries"
|
||||
protected val inOrderElementsOf = IterableContains.Builder<Int, Iterable<Int>, InOrderOnlySearchBehaviour>::elementsOf.name
|
||||
protected val grouped = "${IterableContains.Builder<*, *, InOrderOnlySearchBehaviour>::grouped.name} ${entries::class.simpleName}"
|
||||
protected val within = IterableContains.Builder<*, *, InOrderOnlyGroupedSearchBehaviour>::within.name
|
||||
private val withinInAnyOrderFun : KFunction2<IterableContains.Builder<Int, Iterable<Int>, InOrderOnlyGroupedWithinSearchBehaviour>, Order<Int, Group<Int>>, Expect<Iterable<Int>>>
|
||||
= IterableContains.Builder<Int, Iterable<Int>, InOrderOnlyGroupedWithinSearchBehaviour>::inAny
|
||||
protected val withinInAnyOrder = withinInAnyOrderFun.name
|
||||
//@formatter:on
|
||||
|
||||
protected val filler = o::class.simpleName
|
||||
private val containsProp: KFunction2<Expect<Iterable<Int>>, o, IterableContains.Builder<Int, Iterable<Int>, NoOpSearchBehaviour>> =
|
||||
Expect<Iterable<Int>>::contains
|
||||
protected val contains = containsProp.name
|
||||
private val containsNotProp: KFunction2<Expect<Iterable<Int>>, o, NotCheckerOption<Int, Iterable<Int>, NotSearchBehaviour>> =
|
||||
Expect<Iterable<Int>>::containsNot
|
||||
protected val containsNot = "${containsNotProp.name} $filler $inAnyOrderValues"
|
||||
|
||||
@Suppress("unused")
|
||||
private fun ambiguityTest() {
|
||||
val list: Expect<List<Number>> = notImplemented()
|
||||
val nullableList: Expect<Set<Number?>> = notImplemented()
|
||||
val subList: Expect<ArrayList<out Number>> = notImplemented()
|
||||
val star: Expect<Collection<*>> = notImplemented()
|
||||
|
||||
list contains 1
|
||||
list contains 1f
|
||||
list contains Values(1, 2f)
|
||||
list contains {}
|
||||
list contains Entries({}, {})
|
||||
list containsNot 1
|
||||
list containsNot 1f
|
||||
list containsNot Values(1, 2f)
|
||||
list containsNot o entry {}
|
||||
list containsNot o the Entries({}, {})
|
||||
|
||||
subList contains 1
|
||||
subList contains 1f
|
||||
subList contains Values(1, 2f)
|
||||
subList contains {}
|
||||
subList contains Entries({}, {})
|
||||
subList containsNot 1
|
||||
subList containsNot 1f
|
||||
subList containsNot Values(1, 2f)
|
||||
subList containsNot o entry {}
|
||||
subList containsNot o the Entries({}, {})
|
||||
|
||||
nullableList contains 1
|
||||
nullableList contains 1f
|
||||
nullableList contains Values(1, 2f)
|
||||
nullableList contains {}
|
||||
nullableList contains Entries({}, {})
|
||||
nullableList containsNot 1
|
||||
nullableList containsNot 1f
|
||||
nullableList containsNot Values(1, 2f)
|
||||
nullableList containsNot o entry {}
|
||||
nullableList containsNot o the Entries({}, {})
|
||||
//TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4)
|
||||
nullableList contains null as Number?
|
||||
nullableList contains Entries(null, {})
|
||||
nullableList contains Entries({}, null)
|
||||
nullableList contains Entries(null, null)
|
||||
//TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4)
|
||||
nullableList containsNot null as Number?
|
||||
nullableList containsNot o the Entries(null, {})
|
||||
nullableList containsNot o the Entries({}, null)
|
||||
nullableList containsNot o the Entries(null, null)
|
||||
|
||||
star contains 1
|
||||
star contains 1f
|
||||
star contains Values(1, 2f)
|
||||
star contains {}
|
||||
star contains Entries({}, {})
|
||||
star containsNot 1
|
||||
star containsNot 1f
|
||||
star containsNot Values(1, 2f)
|
||||
star containsNot o entry {}
|
||||
star containsNot o the Entries({}, {})
|
||||
//TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4)
|
||||
star contains (null as Number?)
|
||||
star contains Entries(null, {})
|
||||
star contains Entries({}, null)
|
||||
star contains Entries(null, null)
|
||||
//TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4)
|
||||
star containsNot (null as Number?)
|
||||
star containsNot o the Entries(null, {})
|
||||
star containsNot o the Entries({}, null)
|
||||
star containsNot o the Entries(null, null)
|
||||
|
||||
list containsExactly 1
|
||||
list containsExactly Values(1, 2f)
|
||||
list containsExactly {}
|
||||
list containsExactly Entries({}, {})
|
||||
|
||||
subList containsExactly 1
|
||||
subList containsExactly Values(1, 2f)
|
||||
subList containsExactly {}
|
||||
subList containsExactly Entries({}, {})
|
||||
|
||||
nullableList containsExactly 1
|
||||
nullableList containsExactly Values(1, 2f)
|
||||
nullableList containsExactly {}
|
||||
nullableList containsExactly Entries({}, {})
|
||||
//TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4)
|
||||
nullableList containsExactly (null as (Expect<Number>.() -> Unit)?)
|
||||
nullableList containsExactly Entries({}, null)
|
||||
nullableList containsExactly Entries(null, {})
|
||||
nullableList containsExactly Entries(null, null)
|
||||
|
||||
star containsExactly 1
|
||||
star containsExactly Values(1, 2f)
|
||||
star containsExactly {}
|
||||
star containsExactly Entries({}, {})
|
||||
//TODO should work without cast, remove as soon as KT-6591 is fixed - (with Kotlin 1.4)
|
||||
star containsExactly (null as (Expect<Number>.() -> Unit)?)
|
||||
star containsExactly Entries({}, null)
|
||||
star containsExactly Entries(null, {})
|
||||
star containsExactly Entries(null, null)
|
||||
|
||||
list contains o inAny order atLeast 1 value 1
|
||||
list contains o inAny order atLeast 1 the Values(2, 1)
|
||||
list contains o inAny order atLeast 1 entry {}
|
||||
list contains o inAny order atLeast 1 the Entries({}, {})
|
||||
list contains o inAny order atLeast 1 elementsOf listOf(1, 2)
|
||||
subList contains o inAny order atLeast 1 value 1
|
||||
subList contains o inAny order atLeast 1 the Values(2, 1)
|
||||
subList contains o inAny order atLeast 1 entry {}
|
||||
subList contains o inAny order atLeast 1 the Entries({}, {})
|
||||
subList contains o inAny order atLeast 1 elementsOf listOf(1, 2)
|
||||
nullableList contains o inAny order atLeast 1 value 1
|
||||
nullableList contains o inAny order atLeast 1 the Values(2, 1)
|
||||
nullableList contains o inAny order atLeast 1 entry {}
|
||||
nullableList contains o inAny order atLeast 1 the Entries({}, {})
|
||||
nullableList contains o inAny order atLeast 1 elementsOf listOf(1, 2)
|
||||
nullableList contains o inAny order atLeast 1 value null
|
||||
nullableList contains o inAny order atLeast 1 the Values(null, 1)
|
||||
nullableList contains o inAny order atLeast 1 the Values(2, null)
|
||||
nullableList contains o inAny order atLeast 1 the Values(null, null)
|
||||
nullableList contains o inAny order atLeast 1 entry null
|
||||
nullableList contains o inAny order atLeast 1 the Entries(null, {})
|
||||
nullableList contains o inAny order atLeast 1 the Entries({}, null)
|
||||
nullableList contains o inAny order atLeast 1 the Entries(null, null)
|
||||
star contains o inAny order atLeast 1 value 1
|
||||
star contains o inAny order atLeast 1 the Values(2, 1)
|
||||
star contains o inAny order atLeast 1 entry {}
|
||||
star contains o inAny order atLeast 1 the Entries({}, {})
|
||||
star contains o inAny order atLeast 1 elementsOf listOf(1, 2)
|
||||
star contains o inAny order atLeast 1 value null
|
||||
star contains o inAny order atLeast 1 the Values(null, 1)
|
||||
star contains o inAny order atLeast 1 the Values(2, null)
|
||||
star contains o inAny order atLeast 1 the Values(null, null)
|
||||
star contains o inAny order atLeast 1 entry null
|
||||
star contains o inAny order atLeast 1 the Entries(null, {})
|
||||
star contains o inAny order atLeast 1 the Entries({}, null)
|
||||
star contains o inAny order atLeast 1 the Entries(null, null)
|
||||
|
||||
list contains o inAny order but only value 1
|
||||
list contains o inAny order but only the Values(2, 1)
|
||||
list contains o inAny order but only entry {}
|
||||
list contains o inAny order but only the Entries({}, {})
|
||||
list contains o inAny order but only elementsOf listOf(1, 2)
|
||||
subList contains o inAny order but only value 1
|
||||
subList contains o inAny order but only the Values(2, 1)
|
||||
subList contains o inAny order but only entry {}
|
||||
subList contains o inAny order but only the Entries({}, {})
|
||||
subList contains o inAny order but only elementsOf listOf(1, 2)
|
||||
nullableList contains o inAny order but only value 1
|
||||
nullableList contains o inAny order but only the Values(2, 1)
|
||||
nullableList contains o inAny order but only entry {}
|
||||
nullableList contains o inAny order but only the Entries({}, {})
|
||||
nullableList contains o inAny order but only elementsOf listOf(1, 2)
|
||||
nullableList contains o inAny order but only value null
|
||||
nullableList contains o inAny order but only the Values(null, 1)
|
||||
nullableList contains o inAny order but only the Values(2, null)
|
||||
nullableList contains o inAny order but only the Values(null, null)
|
||||
nullableList contains o inAny order but only entry null
|
||||
nullableList contains o inAny order but only the Entries(null, {})
|
||||
nullableList contains o inAny order but only the Entries({}, null)
|
||||
nullableList contains o inAny order but only the Entries(null, null)
|
||||
star contains o inAny order but only value 1
|
||||
star contains o inAny order but only the Values(2, 1)
|
||||
star contains o inAny order but only entry {}
|
||||
star contains o inAny order but only the Entries({}, {})
|
||||
star contains o inAny order but only elementsOf listOf(1, 2)
|
||||
star contains o inAny order but only value null
|
||||
star contains o inAny order but only the Values(null, 1)
|
||||
star contains o inAny order but only the Values(2, null)
|
||||
star contains o inAny order but only the Values(null, null)
|
||||
star contains o inAny order but only entry null
|
||||
star contains o inAny order but only the Entries(null, {})
|
||||
star contains o inAny order but only the Entries({}, null)
|
||||
star contains o inAny order but only the Entries(null, null)
|
||||
|
||||
list contains o inGiven order and only value 1
|
||||
list contains o inGiven order and only the Values(2, 1)
|
||||
list contains o inGiven order and only entry {}
|
||||
list contains o inGiven order and only the Entries({}, {})
|
||||
list contains o inGiven order and only elementsOf listOf(1, 2)
|
||||
subList contains o inGiven order and only value 1
|
||||
subList contains o inGiven order and only the Values(2, 1)
|
||||
subList contains o inGiven order and only entry {}
|
||||
subList contains o inGiven order and only the Entries({}, {})
|
||||
subList contains o inGiven order and only elementsOf listOf(1, 2)
|
||||
nullableList contains o inGiven order and only value 1
|
||||
nullableList contains o inGiven order and only the Values(2, 1)
|
||||
nullableList contains o inGiven order and only entry {}
|
||||
nullableList contains o inGiven order and only the Entries({}, {})
|
||||
nullableList contains o inGiven order and only elementsOf listOf(1, 2)
|
||||
nullableList contains o inGiven order and only value null
|
||||
nullableList contains o inGiven order and only the Values(null, 1)
|
||||
nullableList contains o inGiven order and only the Values(2, null)
|
||||
nullableList contains o inGiven order and only the Values(null, null)
|
||||
nullableList contains o inGiven order and only entry null
|
||||
nullableList contains o inGiven order and only the Entries(null, {})
|
||||
nullableList contains o inGiven order and only the Entries({}, null)
|
||||
nullableList contains o inGiven order and only the Entries(null, null)
|
||||
star contains o inGiven order and only value 1
|
||||
star contains o inGiven order and only the Values(2, 1)
|
||||
star contains o inGiven order and only entry {}
|
||||
star contains o inGiven order and only the Entries({}, {})
|
||||
star contains o inGiven order and only elementsOf listOf(1, 2)
|
||||
star contains o inGiven order and only value null
|
||||
star contains o inGiven order and only the Values(null, 1)
|
||||
star contains o inGiven order and only the Values(2, null)
|
||||
star contains o inGiven order and only the Values(null, null)
|
||||
star contains o inGiven order and only entry null
|
||||
star contains o inGiven order and only the Entries(null, {})
|
||||
star contains o inGiven order and only the Entries({}, null)
|
||||
star contains o inGiven order and only the Entries(null, null)
|
||||
|
||||
list contains o inGiven order and only grouped entries within group inAny Order(
|
||||
Value(1),
|
||||
Values(1f),
|
||||
Values(1f, 1)
|
||||
)
|
||||
subList contains o inGiven order and only grouped entries within group inAny Order(
|
||||
Value(1),
|
||||
Values(1f),
|
||||
Values(1f, 1)
|
||||
)
|
||||
nullableList contains o inGiven order and only grouped entries within group inAny Order(
|
||||
Value(null),
|
||||
Values(null),
|
||||
Values(null, 2),
|
||||
Values(1, null),
|
||||
Values(null, null)
|
||||
)
|
||||
star contains o inGiven order and only grouped entries within group inAny Order(
|
||||
Value(null),
|
||||
Values(null),
|
||||
Values(null, 2),
|
||||
Values(1, null),
|
||||
Values(null, null)
|
||||
)
|
||||
|
||||
list contains o inGiven order and only grouped entries within group inAny Order(
|
||||
Entry {},
|
||||
Entries({}),
|
||||
Entries({}, {})
|
||||
)
|
||||
subList contains o inGiven order and only grouped entries within group inAny Order(
|
||||
Entry {},
|
||||
Entries({}),
|
||||
Entries({}, {})
|
||||
)
|
||||
nullableList contains o inGiven order and only grouped entries within group inAny Order(
|
||||
Entry(null),
|
||||
Entries(null),
|
||||
Entries(null, {}),
|
||||
Entries({}, null),
|
||||
Entries(null, null)
|
||||
)
|
||||
star contains o inGiven order and only grouped entries within group inAny Order(
|
||||
Entry(null),
|
||||
Entries(null),
|
||||
Entries(null, {}),
|
||||
Entries({}, null),
|
||||
Entries(null, null)
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.specs.feature1
|
||||
import ch.tutteli.atrium.specs.fun1
|
||||
import ch.tutteli.atrium.specs.name
|
||||
import ch.tutteli.atrium.specs.notImplemented
|
||||
import ch.tutteli.atrium.specs.testutils.WithAsciiReporter
|
||||
|
||||
class IterableFeatureAssertionsSpec : ch.tutteli.atrium.specs.integration.IterableFeatureAssertionsSpec(
|
||||
minFeaturePair(),
|
||||
fun1<Iterable<Int>, Expect<Int>.() -> Unit>(Expect<Iterable<Int>>::min),
|
||||
maxFeaturePair(),
|
||||
fun1<Iterable<Int>, Expect<Int>.() -> Unit>(Expect<Iterable<Int>>::max)
|
||||
) {
|
||||
companion object : WithAsciiReporter() {
|
||||
private fun minFeaturePair() = feature1<Iterable<Int>, o, Int>(Expect<Iterable<Int>>::min).name to ::minFeature
|
||||
private fun minFeature(expect: Expect<Iterable<Int>>) = expect min o
|
||||
|
||||
private fun maxFeaturePair() = feature1<Iterable<Int>, o, Int>(Expect<Iterable<Int>>::min).name to ::maxFeature
|
||||
private fun maxFeature(expect: Expect<Iterable<Int>>) = expect max o
|
||||
}
|
||||
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
private fun ambiguityTest() {
|
||||
var a1: Expect<List<Int>> = notImplemented()
|
||||
//nullable not supported by min/max or rather T : Comparable<T> does not exist for T? (one cannot implement an interface for the nullable type)
|
||||
//same for Iterable<*>
|
||||
|
||||
a1 min o toBe 2
|
||||
a1 max o toBe 3
|
||||
|
||||
a1 = a1 min { }
|
||||
a1 = a1 max { }
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package ch.tutteli.atrium.api.infix.en_GB
|
||||
|
||||
import ch.tutteli.atrium.creating.Expect
|
||||
import ch.tutteli.atrium.specs.fun1
|
||||
import ch.tutteli.atrium.specs.notImplemented
|
||||
import ch.tutteli.atrium.specs.withNullableSuffix
|
||||
import org.spekframework.spek2.Spek
|
||||
|
||||
class IterableNoneAssertionsSpec : Spek({
|
||||
|
||||
include(PredicateSpec)
|
||||
include(BuilderSpec)
|
||||
|
||||
}) {
|
||||
object PredicateSpec : ch.tutteli.atrium.specs.integration.IterableNoneAssertionsSpec(
|
||||
fun1(Expect<Iterable<Double>>::none),
|
||||
fun1(Expect<Iterable<Double?>>::none).withNullableSuffix(),
|
||||
"* ", "(/) ", "(x) ", "- ", "» ", ">> ", "=> ",
|
||||
"[Atrium][Predicate] "
|
||||
)
|
||||
|
||||
object BuilderSpec : ch.tutteli.atrium.specs.integration.IterableNoneAssertionsSpec(
|
||||
getContainsNotPair(),
|
||||
getContainsNotNullablePair().withNullableSuffix(),
|
||||
"* ", "(/) ", "(x) ", "- ", "» ", ">> ", "=> ",
|
||||
"[Atrium][Builder] "
|
||||
)
|
||||
|
||||
companion object : IterableContainsSpecBase() {
|
||||
|
||||
private fun getContainsNotPair() = containsNot to Companion::containsNotFun
|
||||
|
||||
private fun containsNotFun(expect: Expect<Iterable<Double>>, a: Expect<Double>.() -> Unit) =
|
||||
expect containsNot o entry a
|
||||
|
||||
private fun getContainsNotNullablePair() = containsNot to Companion::containsNotNullableFun
|
||||
|
||||
private fun containsNotNullableFun(expect: Expect<Iterable<Double?>>, a: (Expect<Double>.() -> Unit)?) =
|
||||
expect containsNot o entry a
|
||||
}
|
||||
|
||||
@Suppress("unused", "UNUSED_VALUE")
|
||||
private fun ambiguityTest() {
|
||||
var a1: Expect<List<Double>> = notImplemented()
|
||||
var a1b: Expect<Set<Double?>> = notImplemented()
|
||||
|
||||
var star: Expect<Collection<*>> = notImplemented()
|
||||
|
||||
a1 = a1.none {}
|
||||
a1 = a1 containsNot o entry {}
|
||||
|
||||
a1b = a1b.none {}
|
||||
a1b = a1b.none(null)
|
||||
a1b = a1b containsNot o entry {}
|
||||
a1b = a1b containsNot o entry (null)
|
||||
|
||||
star = star.none {}
|
||||
star = star containsNot o entry {}
|
||||
}
|
||||
}
|
||||
@@ -11,6 +11,7 @@ interface VarArgHelper<out T> {
|
||||
* The first argument in the argument list `T, vararg T`
|
||||
*/
|
||||
val expected: T
|
||||
|
||||
/**
|
||||
* The second argument in the argument list `T, vararg T`
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user