value
Finishes the specification of the sophisticated to contain expectation where the expected object shall be searched, using a non-disjoint search.
Delegates to the values(expected).
Notice that a runtime check applies which assures that only CharSequence, Number and Char are passed. This function expects CharSequenceOrNumberOrChar (which is a typealias for Any) for your convenience, so that you can mix String and Int for instance.
By non-disjoint is meant that "aa" in "aaaa" is found three times and not only two times.
Return
an Expect for the subject of this expectation.
Parameters
The value which is expected to be contained within the input of the search.
Throws
in case expected is not a CharSequence, Number or Char.
Samples
// `value` is a final step in the CharSequence.toContain expectation-building process and can be used with
// various checkers (see CharSequenceToContainCheckerSamples)
expect("ABC") toContain o exactly 1 value "A"
expect("ABBBC") toContain o atLeast 2 value "B"
fails {
expect("AAAAAA") toContain o atMost 3 value "A"
}Finishes the specification of the sophisticated to contain expectation where the expected value shall be searched (ignoring case), using a non-disjoint search.
Delegates to the values(expected).
Notice that a runtime check applies which assures that only CharSequence, Number and Char are passed. This function expects CharSequenceOrNumberOrChar (which is a typealias for Any) for your convenience, so that you can mix String and Int for instance.
By non-disjoint is meant that "aa" in "aaaa" is found three times and not only two times.
Return
an Expect for the subject of this expectation.
Parameters
The value which is expected to be contained within the input of the search.
Throws
in case expected is not a CharSequence, Number or Char.
Samples
expect("ABC") toContain o ignoring case value "a"
expect("AbbbC") toContain o ignoring case value "B"
fails {
expect("AAAAAA") toContain o ignoring case value "B"
}Finishes the specification of the sophisticated to contain expectation where the expected value shall be searched (ignoring case), using a non-disjoint search where it needs to be contained at least once.
Delegates to atLeast 1 value expected.
Notice that a runtime check applies which assures that only CharSequence, Number and Char are passed. This function expects CharSequenceOrNumberOrChar (which is a typealias for Any) for your convenience, so that you can mix String and Int for instance.
By non-disjoint is meant that "aa" in "aaaa" is found three times and not only two times.
Return
an Expect for the subject of this expectation.
Parameters
The value which is expected to be contained within the input of the search.
Throws
in case expected is not a CharSequence, Number or Char.
Samples
// `value` is a final step in the CharSequence.toContain expectation-building process and can be used with
// various checkers (see CharSequenceToContainCheckerSamples)
expect("ABC") toContain o ignoring case exactly 1 value "A"
expect("AAABBC") toContain o ignoring case atMost 3 value "b"
expect("aBBBCD") toContain o ignoring case atLeast 1 value "A"
fails {
expect("AAAAAABBBB") toContain o ignoring case atMost 3 value "A"
}
fails {
expect("AAABBBb") toContain o ignoring case exactly 3 value "b"
}
fails {
expect("AAAAAABBBB") toContain o ignoring case atLeast 3 value "D"
}Helper function to create a Value based on the given value.
Finishes the specification of the sophisticated to contain expectation where the subject (an IterableLike) needs to contain the expected value.
Delegates to the values(expected).
Return
an Expect for the subject of this expectation.
Since
0.14.0 -- API existed for Iterable but not for IterableLike.
Parameters
The value which is expected to be contained within this IterableLike.
Samples
expect(listOf("A", "B")) toContain o inAny order exactly 1 value "A"
expect(listOf("A", "B", "A", "B")) toContain o inAny order atLeast 2 value ("A")
expect(listOf("A", "B", "B")) toContain o inAny order atMost 2 value "B"
fails {
expect(listOf("A", "B")) toContain o inAny order exactly 2 value "A"
expect(listOf("A", "B", "A", "B")) toContain o inAny order atLeast 3 value "A"
expect(listOf("A", "B", "B", "B")) toContain o inAny order atMost 2 value "B"
}Finishes the specification of the sophisticated to contain expectation where the subject (an IterableLike) needs to contain only the expected value.
Delegates to the values(expected).
Return
an Expect for the subject of this expectation.
Parameters
The value which is expected to be contained within the IterableLike.
Samples
expect(listOf("A")) toContain o inAny order but only value "A"
fails { // because the List does not contain expected value
expect(listOf("B")) toContain o inAny order but only value "A"
}
fails { // because the List contains multiple elements
expect(listOf("A", "A")) toContain o inAny order but only value "A"
}Finishes the specification of the sophisticated to contain expectation where the subject (an IterableLike) needs to contain only the expected value.
Delegates to the values(expected).
Return
an Expect for the subject of this expectation.
Since
0.14.0 -- API existed for Iterable but not for IterableLike.
Parameters
The value which is expected to be contained within the IterableLike.
Samples
expect(listOf("A")) toContain o inGiven order and only value "A"
fails { // because the List does not contain expected value
expect(listOf("B")) toContain o inGiven order and only value "A"
}
fails { // because the List contains multiple elements
expect(listOf("A", "A")) toContain o inGiven order and only value "A"
}Expects that the property Map.Entry.value of the subject of this expectation holds all assertions the given assertionCreator creates for it and returns an Expect for the current subject of this expectation.
Return
an Expect for the subject of this expectation.
Samples
val entry = mapOf(1 to "a").entries.first()
expect(entry) value { // subject inside this expectation-group is of type String (actually "a")
it toEqual "a"
} // subject here is back to type Map.Entry<Int, String>
fails { // because "a" is not equal to "b"
// all expectations are evaluated inside an expectation-group block; for more details:
// https://github.com/robstoll/atrium#define-single-expectations-or-an-expectation-group
expect(entry) value {
it toEqual "b" // fails
it toEqual "c" // stil evaluated
}
}Creates an Expect for the property Map.Entry.value of the subject of this expectation, so that further fluent calls are assertions about it.
Return
The newly created Expect for the extracted feature.
Samples
val entry = mapOf(1 to "a").entries.first()
expect(entry).value toEqual "a"
// | | subject here is of type String (actually "a")
// | subject here is of type Map.Entry<Int, String>
fails { // because "a" is not equal to "b"
expect(entry).value toEqual "b"
// | | subject here is of type String (actually "a")
// | subject here is of type Map.Entry<Int, String>
}