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

Adding CharSequenceToContainCheckerSamples.kt infix style #1558

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
package ch.tutteli.atrium.api.infix.en_GB.samples

import ch.tutteli.atrium.api.infix.en_GB.*
import ch.tutteli.atrium.api.verbs.expect
import kotlin.test.Test

class CharSequenceToContainCheckerSamples {

@Test
fun atLeast() {
expect("ABBC") toContain o atLeast 2 value "B"

fails {
expect("ABB") toContain o atLeast 2 value "A"
}
}

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

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

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

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

@Test
fun butAtMost() {
expect("ABBC") toContain o atLeast 1 butAtMost 2 value "B"

fails {
expect("ABBBBCD") toContain o atLeast 2 butAtMost 3 value "B"
}
}

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

fails {
expect("ABBBBCD") toContain o exactly 3 value "B"
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
package ch.tutteli.atrium.api.infix.en_GB.samples

import ch.tutteli.atrium.api.infix.en_GB.*
import ch.tutteli.atrium.api.verbs.expect
import kotlin.test.Test

class CharSequenceToContainCreatorSamples {

@Test
fun value() {
expect("ABC") toContain exactly(1) value "A"
expect("ABBBC") toContain atLeast(2) value "B"

fails {
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) the values("A", "B", "C")
expect("AAABC") toContain atMost(3) the values("A", "B", "C")
expect("ABBBCD") toContain atLeast(1) the values("A", "B", "C", "D")

fails {
expect("AAAAAABBBB") toContain atMost(3) the values("A", "B")
}
fails {
expect("AAABBBB") toContain exactly(3) the values("A", "B")
}
fails {
expect("AAAAAABBBB") toContain atLeast(3) the values("A", "B", "C")
}
}

@Test
fun valuesIgnoringCase() {
expect("AbC") toContain ignoringCase the values("A", "B", "c")

fails {
expect("aabaabbb") toContain ignoringCase the values("A", "B", "C")
}
}

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

fails {
expect("AAAAAABBBB") toContain ignoringCase atMost(3) the values("a", "b")
}
fails {
expect("AAABBBB") toContain ignoringCase exactly(3) the values("A", "b")
}
fails {
expect("AAAAAABBBB") toContain ignoringCase atLeast(3) the values("a", "b", "C")
}
}

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

fails {
expect("AAAAAABBBB") toContain atMost(3) matchFor "A", "B"
}
fails {
expect("AAABBBB") toContain exactly(3) matchFor "A", "B"
}
fails {
expect("AAAAAABBBB") toContain atLeast(3) matchFor "A", "B", "C"
}
}

@Test
fun regexIgnoringCase() {
expect("AbC") toContain ignoringCase matchFor "A", "B", "c"

fails {
expect("aabaabbb") toContain ignoringCase matchFor "A", "B", "C"
}
}

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

fails {
expect("AAAAAABBBB") toContain ignoringCase atMost(3) matchFor "a", "b"
}
fails {
expect("AAABBBB") toContain ignoringCase exactly(3) matchFor "A", "b"
}
fails {
expect("AAAAAABBBB") toContain ignoringCase atLeast(3) matchFor "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) the elementsOf listOf("A", "B", "C")
expect("AAABC") toContain atMost(3) the elementsOf listOf("A", "B", "C")
expect("ABBBCD") toContain atLeast(1) the elementsOf listOf("A", "B", "C", "D")

fails {
expect("AAAAAABBBB") toContain atMost(3) the elementsOf listOf("A", "B")
}
fails {
expect("AAABBBB") toContain exactly(3) the elementsOf listOf("A", "B")
}
fails {
expect("AAAAAABBBB") toContain atLeast(3) the elementsOf listOf("A", "B", "C")
}
}

@Test
fun elementsOfIgnoreCase() {
expect("AbC") toContain ignoringCase the elementsOf listOf("A", "B", "c")

fails {
expect("aabaabbb") toContain ignoringCase the elementsOf listOf("A", "B", "C")
}
}

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

fails {
expect("AAAAAABBBB") toContain ignoringCase atMost(3) the elementsOf listOf("a", "b")
}
fails {
expect("AAABBBB") toContain ignoringCase exactly(3) the elementsOf listOf("A", "b")
}
fails {
expect("AAAAAABBBB") toContain ignoringCase atLeast(3) the elementsOf listOf("a", "b", "C")
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
package ch.tutteli.atrium.api.infix.en_GB.samples

import ch.tutteli.atrium.api.infix.en_GB.*
import ch.tutteli.atrium.api.verbs.expect
import kotlin.test.Test

class CharSequenceToContainSearchBehaviourSamples {

@Test
fun ignoringCase() {
expect("ABC") containsIgnoringCase exactly 1 value "a"
expect("ABbC") containsIgnoringCase atLeast 2 value "b"

fails {
expect("AAAaaa") containsIgnoringCase atMost 3 value "a"
}
}
}