Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1516 1522 add samples for uncovered functions #1532

Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ fun <T : CharSequence, S : SearchBehaviour> AtLeastCheckerStep<T, S>.butAtMost(
* @return The newly created builder.
* @throws IllegalArgumentException In case [times] is smaller than zero.
* @throws IllegalArgumentException In case [times] is zero; use [notToContain] instead.
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCheckerSamples.exactly
*
*/
fun <T : CharSequence, S : SearchBehaviour> CharSequenceContains.EntryPointStep<T, S>.exactly(
times: Int
Expand All @@ -85,6 +88,9 @@ fun <T : CharSequence, S : SearchBehaviour> CharSequenceContains.EntryPointStep<
* @throws IllegalArgumentException In case [times] is smaller than zero.
* @throws IllegalArgumentException In case [times] is zero; use [notToContain] instead.
* @throws IllegalArgumentException In case [times] equals to one; use [exactly] instead.
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCheckerSamples.atMost
*
*/
fun <T : CharSequence, S : SearchBehaviour> CharSequenceContains.EntryPointStep<T, S>.atMost(
times: Int
Expand All @@ -106,6 +112,9 @@ fun <T : CharSequence, S : SearchBehaviour> CharSequenceContains.EntryPointStep<
* @return The newly created builder.
* @throws IllegalArgumentException In case [times] is smaller than zero.
* @throws IllegalArgumentException In case [times] is zero; use [notToContain] instead.
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCheckerSamples.notOrAtMost
*
*/
fun <T : CharSequence, S : SearchBehaviour> CharSequenceContains.EntryPointStep<T, S>.notOrAtMost(
times: Int
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import kotlin.jvm.JvmName
* @throws IllegalArgumentException in case [expected] is not a [CharSequence], [Number] or [Char].
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCreatorSamples.value
*
*/
fun <T : CharSequence> CheckerStep<T, NoOpSearchBehaviour>.value(expected: CharSequenceOrNumberOrChar): Expect<T> =
values(expected)
Expand Down Expand Up @@ -64,6 +65,9 @@ fun <T : CharSequence> CheckerStep<T, NoOpSearchBehaviour>.value(expected: CharS
* @return an [Expect] for the subject of `this` expectation.
* @throws IllegalArgumentException in case [expected] or one of the [otherExpected] is not a
* [CharSequence], [Number] or [Char].
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCreatorSamples.values
*
*/
fun <T : CharSequence> CheckerStep<T, NoOpSearchBehaviour>.values(
expected: CharSequenceOrNumberOrChar,
Expand All @@ -87,6 +91,9 @@ fun <T : CharSequence> CheckerStep<T, NoOpSearchBehaviour>.values(
*
* @return an [Expect] for the subject of `this` expectation.
* @throws IllegalArgumentException in case [expected] is not a [CharSequence], [Number] or [Char].
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCreatorSamples.valueIgnoringCaseWithChecker
*
*/
@JvmName("valueIgnoringCase")
fun <T : CharSequence> CheckerStep<T, IgnoringCaseSearchBehaviour>.value(
Expand Down Expand Up @@ -118,6 +125,9 @@ fun <T : CharSequence> CheckerStep<T, IgnoringCaseSearchBehaviour>.value(
* @return an [Expect] for the subject of `this` expectation.
* @throws IllegalArgumentException in case [expected] or one of the [otherExpected] is not a
* [CharSequence], [Number] or [Char].
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCreatorSamples.valuesIgnoringCaseWithChecker
*
*/
@JvmName("valuesIgnoringCase")
fun <T : CharSequence> CheckerStep<T, IgnoringCaseSearchBehaviour>.values(
Expand All @@ -142,6 +152,9 @@ fun <T : CharSequence> CheckerStep<T, IgnoringCaseSearchBehaviour>.values(
*
* @return an [Expect] for the subject of `this` expectation.
* @throws IllegalArgumentException in case [expected] is not a [CharSequence], [Number] or [Char].
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCreatorSamples.valueIgnoringCase
*
*/
fun <T : CharSequence> EntryPointStep<T, IgnoringCaseSearchBehaviour>.value(
expected: CharSequenceOrNumberOrChar
Expand Down Expand Up @@ -169,6 +182,9 @@ fun <T : CharSequence> EntryPointStep<T, IgnoringCaseSearchBehaviour>.value(
* @return an [Expect] for the subject of `this` expectation.
* @throws IllegalArgumentException in case [expected] or one of the [otherExpected] is not a
* [CharSequence], [Number] or [Char].
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCreatorSamples.valuesIgnoringCase
*
*/
fun <T : CharSequence> EntryPointStep<T, IgnoringCaseSearchBehaviour>.values(
expected: CharSequenceOrNumberOrChar,
Expand All @@ -194,6 +210,9 @@ fun <T : CharSequence> EntryPointStep<T, IgnoringCaseSearchBehaviour>.values(
* @param otherPatterns Additional patterns which are expected to have a match against the input of the search.
*
* @return an [Expect] for the subject of `this` expectation.
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCreatorSamples.regex
*
*/
fun <T : CharSequence> CheckerStep<T, NoOpSearchBehaviour>.regex(
pattern: String,
Expand Down Expand Up @@ -252,6 +271,9 @@ fun <T : CharSequence> CheckerStep<T, NoOpSearchBehaviour>.regex(
* @return an [Expect] for the subject of `this` expectation.
*
* @since 1.1.0
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCreatorSamples.matchFor
*
*/
fun <T : CharSequence> CheckerStep<T, NoOpSearchBehaviour>.matchFor(
pattern: Regex,
Expand All @@ -277,6 +299,9 @@ fun <T : CharSequence> CheckerStep<T, NoOpSearchBehaviour>.matchFor(
* @param otherPatterns Additional patterns which are expected to have a match against the input of the search.
*
* @return an [Expect] for the subject of `this` expectation.
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCreatorSamples.regexIgnoringCaseWithChecker
*
*/
@JvmName("regexIgnoringCase")
fun <T : CharSequence> CheckerStep<T, IgnoringCaseSearchBehaviour>.regex(
Expand Down Expand Up @@ -306,6 +331,9 @@ fun <T : CharSequence> CheckerStep<T, IgnoringCaseSearchBehaviour>.regex(
* @param otherPatterns Additional patterns which are expected to have a match against the input of the search.
*
* @return an [Expect] for the subject of `this` expectation.
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCreatorSamples.regexIgnoringCase
*
*/
fun <T : CharSequence> EntryPointStep<T, IgnoringCaseSearchBehaviour>.regex(
pattern: String,
Expand All @@ -331,6 +359,9 @@ fun <T : CharSequence> EntryPointStep<T, IgnoringCaseSearchBehaviour>.regex(
* [expectedIterableLike] does not have elements (is empty).
*
* @since 0.13.0
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCreatorSamples.elementsOf
*
*/
fun <T : CharSequence> CheckerStep<T, NoOpSearchBehaviour>.elementsOf(
expectedIterableLike: IterableLike
Expand All @@ -357,6 +388,8 @@ fun <T : CharSequence> CheckerStep<T, NoOpSearchBehaviour>.elementsOf(
* @throws IllegalArgumentException in case [expectedIterableLike] is not an [Iterable], [Sequence] or one of the [Array] types or the given
* [expectedIterableLike] does not have elements (is empty).
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCreatorSamples.elementsOfIgnoringCaseWithChecker
*
* @since 0.13.0
*/
@JvmName("elementsOfIgnoringCase")
Expand Down Expand Up @@ -385,6 +418,9 @@ fun <T : CharSequence> CheckerStep<T, IgnoringCaseSearchBehaviour>.elementsOf(
* [expectedIterableLike] does not have elements (is empty).
*
* @since 0.13.0
*
* @sample ch.tutteli.atrium.api.fluent.en_GB.samples.CharSequenceToContainCreatorSamples.elementsOfIgnoreCase
*
*/
@JvmName("elementsOfIgnoringCase")
fun <T : CharSequence> EntryPointStep<T, IgnoringCaseSearchBehaviour>.elementsOf(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,25 @@ class CharSequenceToContainCheckerSamples {
}
}

@Test
fun atMost() {
expect("ABBC").toContain.atMost(2).value("B")

fails {
expect("AABBAA").toContain.atMost(3).value("A")
}
}

@Test
fun notOrAtMost() {
expect("ABBC").toContain.notOrAtMost(2).value("D")
expect("ABBC").toContain.notOrAtMost(2).value("B")

fails {
expect("AABBAA").toContain.notOrAtMost(3).value("A")
}
}

@Test
fun butAtMost() {
expect("ABBC").toContain.atLeast(1).butAtMost(2).value("B")
Expand All @@ -23,4 +42,13 @@ class CharSequenceToContainCheckerSamples {
expect("ABBBBCD").toContain.atLeast(2).butAtMost(3).value("B")
}
}

@Test
fun exactly() {
expect("ABCBAC").toContain.exactly(2).value("C")

fails {
expect("ABBBBCD").toContain.exactly(3).value("B")
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,183 @@ class CharSequenceToContainCreatorSamples {
expect("AAAAAA").toContain.atMost(3).value("A")
}
}

@Test
fun valueIgnoringCase() {
expect("ABC").toContain.ignoringCase.value("a")
expect("AbbbC").toContain.ignoringCase.value("B")

fails {
expect("AAAAAA").toContain.ignoringCase.value("B")
}
}

@Test
fun valueIgnoringCaseWithChecker() {
expect("ABC").toContain.ignoringCase.exactly(1).value("A")
expect("AAABBC").toContain.ignoringCase.atMost(3).value("b")
expect("aBBBCD").toContain.ignoringCase.atLeast(1).value("A")
fails {
expect("AAAAAABBBB").toContain.ignoringCase.atMost(3).value("A")
}

fails {
expect("AAABBBb").toContain.ignoringCase.exactly(3).value("b")
}

fails {
expect("AAAAAABBBB").toContain.ignoringCase.atLeast(3).value("D")
}
}

@Test
fun values() {
expect("ABC").toContain.exactly(1).values("A", "B", "C")
expect("AAABC").toContain.atMost(3).values("A", "B", "C")
expect("ABBBCD").toContain.atLeast(1).values("A", "B", "C", "D")
fails {
expect("AAAAAABBBB").toContain.atMost(3).values("A", "B")
}

fails {
expect("AAABBBB").toContain.exactly(3).values("A", "B")
}

fails {
expect("AAAAAABBBB").toContain.atLeast(3).values("A", "B", "C")
}
}

@Test
fun valuesIgnoringCase() {
expect("AbC").toContain.ignoringCase.values("A", "B", "c")
fails {
expect("aabaabbb").toContain.ignoringCase.values("A", "B", "C")
}
}

@Test
fun valuesIgnoringCaseWithChecker() {
expect("ABc").toContain.ignoringCase.exactly(1).values("A", "b", "C")
expect("AaaBC").toContain.ignoringCase.atMost(3).values("A", "B", "c")
expect("ABBBcD").toContain.ignoringCase.atLeast(1).values("a", "b", "C", "d")
fails {
expect("AAAAAABBBB").toContain.ignoringCase.atMost(3).values("a", "b")
}

fails {
expect("AAABBBB").toContain.ignoringCase.exactly(3).values("A", "b")
}

fails {
expect("AAAAAABBBB").toContain.ignoringCase.atLeast(3).values("a", "b", "C")
}
}

@Test
fun regex() {
expect("ABC").toContain.exactly(1).regex("A", "B", "C")
expect("AAABC").toContain.atMost(3).regex("A", "B", "C")
expect("ABBBCD").toContain.atLeast(1).regex("A", "B", "C", "D")
fails {
expect("AAAAAABBBB").toContain.atMost(3).regex("A", "B")
}

fails {
expect("AAABBBB").toContain.exactly(3).regex("A", "B")
}

fails {
expect("AAAAAABBBB").toContain.atLeast(3).regex("A", "B", "C")
}
}

@Test
fun regexIgnoringCase() {
expect("AbC").toContain.ignoringCase.regex("A", "B", "c")
fails {
expect("aabaabbb").toContain.ignoringCase.regex("A", "B", "C")
}
}

@Test
fun regexIgnoringCaseWithChecker() {
expect("ABc").toContain.ignoringCase.exactly(1).regex("A", "b", "C")
expect("AaaBC").toContain.ignoringCase.atMost(3).regex("A", "B", "c")
expect("ABBBcD").toContain.ignoringCase.atLeast(1).regex("a", "b", "C", "d")
fails {
expect("AAAAAABBBB").toContain.ignoringCase.atMost(3).regex("a", "b")
}

fails {
expect("AAABBBB").toContain.ignoringCase.exactly(3).regex("A", "b")
}

fails {
expect("AAAAAABBBB").toContain.ignoringCase.atLeast(3).regex("a", "b", "C")
}
}

@Test
fun matchFor() {
expect("ABC").toContain.exactly(1).matchFor(Regex("A"), Regex("B"), Regex("C"))
expect("AAABC").toContain.atMost(3).matchFor(Regex("A"), Regex("B"), Regex("C"))
expect("ABBBCD").toContain.atLeast(1).matchFor(Regex("A"), Regex("B"), Regex("C"), Regex("D"))
fails {
expect("AAAAAABBBB").toContain.atMost(3).matchFor(Regex("A"), Regex("B"))
}

fails {
expect("AAABBBB").toContain.exactly(3).matchFor(Regex("A"), Regex("B"))
}

fails {
expect("AAAAAABBBB").toContain.atLeast(3).matchFor(Regex("A"), Regex("B"), Regex("C"))
}
}


@Test
fun elementsOf() {
expect("ABC").toContain.exactly(1).elementsOf(listOf("A", "B", "C"))
expect("AAABC").toContain.atMost(3).elementsOf(listOf("A", "B", "C"))
expect("ABBBCD").toContain.atLeast(1).elementsOf(listOf("A", "B", "C", "D"))
fails {
expect("AAAAAABBBB").toContain.atMost(3).elementsOf(listOf("A", "B"))
}

fails {
expect("AAABBBB").toContain.exactly(3).elementsOf(listOf("A", "B"))
}

fails {
expect("AAAAAABBBB").toContain.atLeast(3).elementsOf(listOf("A", "B", "C"))
}
}

@Test
fun elementsOfIgnoreCase() {
expect("AbC").toContain.ignoringCase.elementsOf(listOf("A", "B", "c"))
fails {
expect("aabaabbb").toContain.ignoringCase.elementsOf(listOf("A", "B", "C"))
}
}

@Test
fun elementsOfIgnoringCaseWithChecker() {
expect("ABc").toContain.ignoringCase.exactly(1).elementsOf(listOf("A", "b", "C"))
expect("AaaBC").toContain.ignoringCase.atMost(3).elementsOf(listOf("A", "B", "c"))
expect("ABBBcD").toContain.ignoringCase.atLeast(1).elementsOf(listOf("a", "b", "C", "d"))
fails {
expect("AAAAAABBBB").toContain.ignoringCase.atMost(3).elementsOf(listOf("a", "b"))
}

fails {
expect("AAABBBB").toContain.ignoringCase.exactly(3).elementsOf(listOf("A", "b"))
}

fails {
expect("AAAAAABBBB").toContain.ignoringCase.atLeast(3).elementsOf(listOf("a", "b", "C"))
}
}
}
Loading