How to use decreasing class of io.kotest.matchers.collections package

Best Kotest code snippet using io.kotest.matchers.collections.decreasing

CollectionMatchersTest.kt

Source:CollectionMatchersTest.kt Github

copy

Full Screen

...232 listOf(5, 6).shouldNotBeStrictlyIncreasingWith(comparator)233 }234 }235 "shouldBeDecreasing" should {236 "test that a collection is monotonically decreasing" {237 listOf(3, 2, 2, -4) shouldBe monotonicallyDecreasing<Int>()238 listOf(5, 6) shouldNotBe monotonicallyDecreasing<Int>()239 listOf(3, 2, 2, -4).shouldBeMonotonicallyDecreasing()240 listOf(5, 6).shouldNotBeMonotonicallyDecreasing()241 }242 "test that a collection is monotonically decreasing according to comparator" {243 val comparator = Comparator(desc)244 listOf(-4, 2, 2, 3) shouldBe monotonicallyDecreasingWith(comparator)245 listOf(6, 5) shouldNotBe monotonicallyDecreasingWith(comparator)246 listOf(-4, 2, 2, 3).shouldBeMonotonicallyDecreasingWith(comparator)247 listOf(6, 5).shouldNotBeMonotonicallyDecreasingWith(comparator)248 }249 "test that a collection is strictly decreasing" {250 listOf(3, 2, -4) shouldBe strictlyDecreasing<Int>()251 listOf(3, 2, 2, -4) shouldNotBe strictlyDecreasing<Int>()252 listOf(5, 6) shouldNotBe strictlyDecreasing<Int>()253 listOf(3, 2, -4).shouldBeStrictlyDecreasing()254 listOf(3, 2, 2, -4).shouldNotBeStrictlyDecreasing()255 listOf(5, 6).shouldNotBeStrictlyDecreasing()256 }257 "test that a collection is strictly decreasing according to comparator" {258 val comparator = Comparator(desc)259 listOf(-4, 2, 3) shouldBe strictlyDecreasingWith(comparator)260 listOf(-4, 2, 2, 3) shouldNotBe strictlyDecreasingWith(comparator)261 listOf(6, 5) shouldNotBe strictlyDecreasingWith(comparator)262 listOf(-4, 2, 3).shouldBeStrictlyDecreasingWith(comparator)263 listOf(-4, 2, 2, 3).shouldNotBeStrictlyDecreasingWith(comparator)264 listOf(6, 5).shouldNotBeStrictlyDecreasingWith(comparator)265 }266 }267 "haveDuplicates" should {268 "test that a collection is unique" {269 listOf(1, 2, 3, 3) should containDuplicates()270 listOf(1, 2, 3, 4) shouldNot containDuplicates()271 listOf(1, 2, 3, 3).shouldContainDuplicates()...

Full Screen

Full Screen

RGATest.kt

Source:RGATest.kt Github

copy

Full Screen

...282 }283 /**284 * This test evaluates the scenario: insert at 0 twice || insert at 0 twice, merge, get/iterator.285 * Call to get should return an array containing the four values. Values should be ordered286 * according to decreasing order of their associated timestamp.287 * Call to get at 0 should return the second value inserted in replica 2.288 * Call to get at 1 should return the second value inserted in replica 1.289 * Call to get at 2 should return the first value inserted in replica 2.290 * Call to get at 3 should return the first value inserted in replica 1.291 * Call to iterator should return an iterator containing the four values.292 */293 "R1: insert at 0, insert at 0; R2: insert at 0, insert at 0, merge, get/iterator" {294 val rga1 = RGA(client1)295 val rga2 = RGA(client2)296 rga1.insertAt(0, "D")297 rga1.insertAt(0, "B")298 rga2.insertAt(0, "C")299 rga2.insertAt(0, "A")300 rga2.merge(rga1)...

Full Screen

Full Screen

matchers.kt

Source:matchers.kt Github

copy

Full Screen

1package io.kotest.matchers.collections2import io.kotest.assertions.show.show3import io.kotest.matchers.Matcher4import io.kotest.matchers.MatcherResult5import io.kotest.matchers.neverNullMatcher6import io.kotest.matchers.should7import io.kotest.matchers.shouldHave8import io.kotest.matchers.shouldNot9import kotlin.jvm.JvmName10fun <T> Iterable<T>.shouldContainOnlyNulls() = toList().shouldContainOnlyNulls()11fun <T> Array<T>.shouldContainOnlyNulls() = asList().shouldContainOnlyNulls()12fun <T> Collection<T>.shouldContainOnlyNulls() = this should containOnlyNulls()13fun <T> Iterable<T>.shouldNotContainOnlyNulls() = toList().shouldNotContainOnlyNulls()14fun <T> Array<T>.shouldNotContainOnlyNulls() = asList().shouldNotContainOnlyNulls()15fun <T> Collection<T>.shouldNotContainOnlyNulls() = this shouldNot containOnlyNulls()16fun <T> containOnlyNulls() = object : Matcher<Collection<T>> {17 override fun test(value: Collection<T>) =18 MatcherResult(19 value.all { it == null },20 "Collection should contain only nulls",21 "Collection should not contain only nulls"22 )23}24fun <T> Iterable<T>.shouldContainNull() = toList().shouldContainNull()25fun <T> Array<T>.shouldContainNull() = asList().shouldContainNull()26fun <T> Collection<T>.shouldContainNull() = this should containNull()27fun <T> Iterable<T>.shouldNotContainNull() = toList().shouldNotContainNull()28fun <T> Array<T>.shouldNotContainNull() = asList().shouldNotContainNull()29fun <T> Collection<T>.shouldNotContainNull() = this shouldNot containNull()30fun <T> containNull() = object : Matcher<Collection<T>> {31 override fun test(value: Collection<T>) =32 MatcherResult(33 value.any { it == null },34 "Collection should contain at least one null",35 "Collection should not contain any nulls"36 )37}38fun <T> Iterable<T>.shouldHaveElementAt(index: Int, element: T) = toList().shouldHaveElementAt(index, element)39fun <T> Array<T>.shouldHaveElementAt(index: Int, element: T) = asList().shouldHaveElementAt(index, element)40fun <T> List<T>.shouldHaveElementAt(index: Int, element: T) = this should haveElementAt(index, element)41fun <T> Iterable<T>.shouldNotHaveElementAt(index: Int, element: T) = toList().shouldNotHaveElementAt(index, element)42fun <T> Array<T>.shouldNotHaveElementAt(index: Int, element: T) = asList().shouldNotHaveElementAt(index, element)43fun <T> List<T>.shouldNotHaveElementAt(index: Int, element: T) = this shouldNot haveElementAt(index, element)44fun <T, L : List<T>> haveElementAt(index: Int, element: T) = object : Matcher<L> {45 override fun test(value: L) =46 MatcherResult(47 value[index] == element,48 { "Collection should contain ${element.show().value} at index $index" },49 { "Collection should not contain ${element.show().value} at index $index" }50 )51}52fun <T> Iterable<T>.shouldContainNoNulls() = toList().shouldContainNoNulls()53fun <T> Array<T>.shouldContainNoNulls() = asList().shouldContainNoNulls()54fun <T> Collection<T>.shouldContainNoNulls() = this should containNoNulls()55fun <T> Iterable<T>.shouldNotContainNoNulls() = toList().shouldNotContainNoNulls()56fun <T> Array<T>.shouldNotContainNoNulls() = asList().shouldNotContainNoNulls()57fun <T> Collection<T>.shouldNotContainNoNulls() = this shouldNot containNoNulls()58fun <T> containNoNulls() = object : Matcher<Collection<T>> {59 override fun test(value: Collection<T>) =60 MatcherResult(61 value.all { it != null },62 { "Collection should not contain nulls" },63 { "Collection should have at least one null" }64 )65}66infix fun <T> Array<T>.shouldNotContainExactlyInAnyOrder(expected: Array<T>) =67 asList().shouldNotContainExactlyInAnyOrder(expected.asList())68infix fun <T, C : Collection<T>> C?.shouldNotContainExactlyInAnyOrder(expected: C) =69 this shouldNot containExactlyInAnyOrder(expected)70fun <T, C : Collection<T>> C?.shouldNotContainExactlyInAnyOrder(vararg expected: T) =71 this shouldNot containExactlyInAnyOrder(*expected)72infix fun <T> Array<T>.shouldContainExactlyInAnyOrder(expected: Array<T>) =73 asList().shouldContainExactlyInAnyOrder(expected.asList())74infix fun <T, C : Collection<T>> C?.shouldContainExactlyInAnyOrder(expected: C) =75 this should containExactlyInAnyOrder(expected)76fun <T, C : Collection<T>> C?.shouldContainExactlyInAnyOrder(vararg expected: T) =77 this should containExactlyInAnyOrder(*expected)78fun <T> containExactlyInAnyOrder(vararg expected: T): Matcher<Collection<T>?> =79 containExactlyInAnyOrder(expected.asList())80/** Assert that a collection contains exactly the given values and nothing else, in any order. */81fun <T, C : Collection<T>> containExactlyInAnyOrder(expected: C): Matcher<C?> = neverNullMatcher { value ->82 val valueGroupedCounts: Map<T, Int> = value.groupBy { it }.mapValues { it.value.size }83 val expectedGroupedCounts: Map<T, Int> = expected.groupBy { it }.mapValues { it.value.size }84 val passed = expectedGroupedCounts.size == valueGroupedCounts.size85 && expectedGroupedCounts.all { valueGroupedCounts[it.key] == it.value }86 MatcherResult(87 passed,88 "Collection should contain ${expected.show().value} in any order, but was ${value.show().value}",89 "Collection should not contain exactly ${expected.show().value} in any order"90 )91}92infix fun <T : Comparable<T>> Iterable<T>.shouldHaveUpperBound(t: T) = toList().shouldHaveUpperBound(t)93infix fun <T : Comparable<T>> Array<T>.shouldHaveUpperBound(t: T) = asList().shouldHaveUpperBound(t)94infix fun <T : Comparable<T>, C : Collection<T>> C.shouldHaveUpperBound(t: T) = this should haveUpperBound(t)95fun <T : Comparable<T>, C : Collection<T>> haveUpperBound(t: T) = object : Matcher<C> {96 override fun test(value: C) = MatcherResult(97 value.all { it <= t },98 "Collection should have upper bound $t",99 "Collection should not have upper bound $t"100 )101}102infix fun <T : Comparable<T>> Iterable<T>.shouldHaveLowerBound(t: T) = toList().shouldHaveLowerBound(t)103infix fun <T : Comparable<T>> Array<T>.shouldHaveLowerBound(t: T) = asList().shouldHaveLowerBound(t)104infix fun <T : Comparable<T>, C : Collection<T>> C.shouldHaveLowerBound(t: T) = this should haveLowerBound(t)105fun <T : Comparable<T>, C : Collection<T>> haveLowerBound(t: T) = object : Matcher<C> {106 override fun test(value: C) = MatcherResult(107 value.all { t <= it },108 "Collection should have lower bound $t",109 "Collection should not have lower bound $t"110 )111}112fun <T> Iterable<T>.shouldBeUnique() = toList().shouldBeUnique()113fun <T> Array<T>.shouldBeUnique() = asList().shouldBeUnique()114fun <T> Collection<T>.shouldBeUnique() = this should beUnique()115fun <T> Iterable<T>.shouldNotBeUnique() = toList().shouldNotBeUnique()116fun <T> Array<T>.shouldNotBeUnique() = asList().shouldNotBeUnique()117fun <T> Collection<T>.shouldNotBeUnique() = this shouldNot beUnique()118fun <T> beUnique() = object : Matcher<Collection<T>> {119 override fun test(value: Collection<T>) = MatcherResult(120 value.toSet().size == value.size,121 "Collection should be Unique",122 "Collection should contain at least one duplicate element"123 )124}125fun <T> Iterable<T>.shouldContainDuplicates() = toList().shouldContainDuplicates()126fun <T> Array<T>.shouldContainDuplicates() = asList().shouldContainDuplicates()127fun <T> Collection<T>.shouldContainDuplicates() = this should containDuplicates()128fun <T> Iterable<T>.shouldNotContainDuplicates() = toList().shouldNotContainDuplicates()129fun <T> Array<T>.shouldNotContainDuplicates() = asList().shouldNotContainDuplicates()130fun <T> Collection<T>.shouldNotContainDuplicates() = this shouldNot containDuplicates()131fun <T> containDuplicates() = object : Matcher<Collection<T>> {132 override fun test(value: Collection<T>) = MatcherResult(133 value.toSet().size < value.size,134 "Collection should contain duplicates",135 "Collection should not contain duplicates"136 )137}138fun <T> beSortedWith(comparator: Comparator<in T>): Matcher<List<T>> = sortedWith(comparator)139fun <T> beSortedWith(cmp: (T, T) -> Int): Matcher<List<T>> = sortedWith(cmp)140fun <T> sortedWith(comparator: Comparator<in T>): Matcher<List<T>> = sortedWith { a, b ->141 comparator.compare(a, b)142}143fun <T> sortedWith(cmp: (T, T) -> Int): Matcher<List<T>> = object : Matcher<List<T>> {144 override fun test(value: List<T>): MatcherResult {145 val failure = value.withIndex().firstOrNull { (i, it) -> i != value.lastIndex && cmp(it, value[i + 1]) > 0 }146 val snippet = value.joinToString(",", limit = 10)147 val elementMessage = when (failure) {148 null -> ""149 else -> ". Element ${failure.value} at index ${failure.index} shouldn't precede element ${value[failure.index + 1]}"150 }151 return MatcherResult(152 failure == null,153 "List [$snippet] should be sorted$elementMessage",154 "List [$snippet] should not be sorted"155 )156 }157}158fun <T : Comparable<T>> Iterable<T>.shouldBeSorted() = toList().shouldBeSorted()159fun <T : Comparable<T>> Array<T>.shouldBeSorted() = asList().shouldBeSorted()160fun <T : Comparable<T>> List<T>.shouldBeSorted() = this should beSorted<T>()161fun <T : Comparable<T>> Iterable<T>.shouldNotBeSorted() = toList().shouldNotBeSorted()162fun <T : Comparable<T>> Array<T>.shouldNotBeSorted() = asList().shouldNotBeSorted()163fun <T : Comparable<T>> List<T>.shouldNotBeSorted() = this shouldNot beSorted<T>()164infix fun <T> Iterable<T>.shouldBeSortedWith(comparator: Comparator<in T>) = toList().shouldBeSortedWith(comparator)165infix fun <T> Array<T>.shouldBeSortedWith(comparator: Comparator<in T>) = asList().shouldBeSortedWith(comparator)166infix fun <T> List<T>.shouldBeSortedWith(comparator: Comparator<in T>) = this should beSortedWith(comparator)167infix fun <T> Iterable<T>.shouldNotBeSortedWith(comparator: Comparator<in T>) = toList().shouldNotBeSortedWith(comparator)168infix fun <T> Array<T>.shouldNotBeSortedWith(comparator: Comparator<in T>) = asList().shouldNotBeSortedWith(comparator)169infix fun <T> List<T>.shouldNotBeSortedWith(comparator: Comparator<in T>) = this shouldNot beSortedWith(comparator)170infix fun <T> Iterable<T>.shouldBeSortedWith(cmp: (T, T) -> Int) = toList().shouldBeSortedWith(cmp)171infix fun <T> Array<T>.shouldBeSortedWith(cmp: (T, T) -> Int) = asList().shouldBeSortedWith(cmp)172infix fun <T> List<T>.shouldBeSortedWith(cmp: (T, T) -> Int) = this should beSortedWith(cmp)173infix fun <T> Iterable<T>.shouldNotBeSortedWith(cmp: (T, T) -> Int) = toList().shouldNotBeSortedWith(cmp)174infix fun <T> Array<T>.shouldNotBeSortedWith(cmp: (T, T) -> Int) = asList().shouldNotBeSortedWith(cmp)175infix fun <T> List<T>.shouldNotBeSortedWith(cmp: (T, T) -> Int) = this shouldNot beSortedWith(cmp)176fun <T : Comparable<T>> Iterable<T>.shouldBeMonotonicallyIncreasing() = toList().shouldBeMonotonicallyIncreasing()177fun <T : Comparable<T>> Array<T>.shouldBeMonotonicallyIncreasing() = asList().shouldBeMonotonicallyIncreasing()178fun <T : Comparable<T>> List<T>.shouldBeMonotonicallyIncreasing() = this should beMonotonicallyIncreasing<T>()179fun <T : Comparable<T>> Iterable<T>.shouldNotBeMonotonicallyIncreasing() = toList().shouldNotBeMonotonicallyIncreasing()180fun <T : Comparable<T>> Array<T>.shouldNotBeMonotonicallyIncreasing() = asList().shouldNotBeMonotonicallyIncreasing()181fun <T : Comparable<T>> List<T>.shouldNotBeMonotonicallyIncreasing() = this shouldNot beMonotonicallyIncreasing<T>()182fun <T> List<T>.shouldBeMonotonicallyIncreasingWith(comparator: Comparator<in T>) =183 this should beMonotonicallyIncreasingWith(comparator)184fun <T> Iterable<T>.shouldBeMonotonicallyIncreasingWith(comparator: Comparator<in T>) =185 toList().shouldBeMonotonicallyIncreasingWith(comparator)186fun <T> Array<T>.shouldBeMonotonicallyIncreasingWith(comparator: Comparator<in T>) =187 asList().shouldBeMonotonicallyIncreasingWith(comparator)188fun <T> List<T>.shouldNotBeMonotonicallyIncreasingWith(comparator: Comparator<in T>) =189 this shouldNot beMonotonicallyIncreasingWith(comparator)190fun <T> Iterable<T>.shouldNotBeMonotonicallyIncreasingWith(comparator: Comparator<in T>) =191 toList().shouldNotBeMonotonicallyIncreasingWith(comparator)192fun <T> Array<T>.shouldNotBeMonotonicallyIncreasingWith(comparator: Comparator<in T>) =193 asList().shouldNotBeMonotonicallyIncreasingWith(comparator)194fun <T : Comparable<T>> Iterable<T>.shouldBeMonotonicallyDecreasing() = toList().shouldBeMonotonicallyDecreasing()195fun <T : Comparable<T>> Array<T>.shouldBeMonotonicallyDecreasing() = asList().shouldBeMonotonicallyDecreasing()196fun <T : Comparable<T>> List<T>.shouldBeMonotonicallyDecreasing() = this should beMonotonicallyDecreasing<T>()197fun <T : Comparable<T>> Iterable<T>.shouldNotBeMonotonicallyDecreasing() = toList().shouldNotBeMonotonicallyDecreasing()198fun <T : Comparable<T>> Array<T>.shouldNotBeMonotonicallyDecreasing() = asList().shouldNotBeMonotonicallyDecreasing()199fun <T : Comparable<T>> List<T>.shouldNotBeMonotonicallyDecreasing() = this shouldNot beMonotonicallyDecreasing<T>()200fun <T> List<T>.shouldBeMonotonicallyDecreasingWith(comparator: Comparator<in T>) =201 this should beMonotonicallyDecreasingWith(comparator)202fun <T> Iterable<T>.shouldBeMonotonicallyDecreasingWith(comparator: Comparator<in T>) =203 toList().shouldBeMonotonicallyDecreasingWith(comparator)204fun <T> Array<T>.shouldBeMonotonicallyDecreasingWith(comparator: Comparator<in T>) =205 asList().shouldBeMonotonicallyDecreasingWith(comparator)206fun <T> List<T>.shouldNotBeMonotonicallyDecreasingWith(comparator: Comparator<in T>) =207 this shouldNot beMonotonicallyDecreasingWith(comparator)208fun <T> Iterable<T>.shouldNotBeMonotonicallyDecreasingWith(comparator: Comparator<in T>) =209 toList().shouldNotBeMonotonicallyDecreasingWith(comparator)210fun <T> Array<T>.shouldNotBeMonotonicallyDecreasingWith(comparator: Comparator<in T>) =211 asList().shouldNotBeMonotonicallyDecreasingWith(comparator)212fun <T : Comparable<T>> Iterable<T>.shouldBeStrictlyIncreasing() = toList().shouldBeStrictlyIncreasing()213fun <T : Comparable<T>> Array<T>.shouldBeStrictlyIncreasing() = asList().shouldBeStrictlyIncreasing()214fun <T : Comparable<T>> List<T>.shouldBeStrictlyIncreasing() = this should beStrictlyIncreasing<T>()215fun <T : Comparable<T>> Iterable<T>.shouldNotBeStrictlyIncreasing() = toList().shouldNotBeStrictlyIncreasing()216fun <T : Comparable<T>> Array<T>.shouldNotBeStrictlyIncreasing() = asList().shouldNotBeStrictlyIncreasing()217fun <T : Comparable<T>> List<T>.shouldNotBeStrictlyIncreasing() = this shouldNot beStrictlyIncreasing<T>()218fun <T> List<T>.shouldBeStrictlyIncreasingWith(comparator: Comparator<in T>) =219 this should beStrictlyIncreasingWith(comparator)220fun <T> Iterable<T>.shouldBeStrictlyIncreasingWith(comparator: Comparator<in T>) =221 toList().shouldBeStrictlyIncreasingWith(comparator)222fun <T> Array<T>.shouldBeStrictlyIncreasingWith(comparator: Comparator<in T>) =223 asList().shouldBeStrictlyIncreasingWith(comparator)224fun <T> List<T>.shouldNotBeStrictlyIncreasingWith(comparator: Comparator<in T>) =225 this shouldNot beStrictlyIncreasingWith(comparator)226fun <T> Iterable<T>.shouldNotBeStrictlyIncreasingWith(comparator: Comparator<in T>) =227 toList().shouldNotBeStrictlyIncreasingWith(comparator)228fun <T> Array<T>.shouldNotBeStrictlyIncreasingWith(comparator: Comparator<in T>) =229 asList().shouldNotBeStrictlyIncreasingWith(comparator)230fun <T : Comparable<T>> Iterable<T>.shouldBeStrictlyDecreasing() = toList().shouldBeStrictlyDecreasing()231fun <T : Comparable<T>> List<T>.shouldBeStrictlyDecreasing() = this should beStrictlyDecreasing<T>()232fun <T : Comparable<T>> Iterable<T>.shouldNotBeStrictlyDecreasing() = toList().shouldNotBeStrictlyDecreasing()233fun <T : Comparable<T>> List<T>.shouldNotBeStrictlyDecreasing() = this shouldNot beStrictlyDecreasing<T>()234fun <T> List<T>.shouldBeStrictlyDecreasingWith(comparator: Comparator<in T>) =235 this should beStrictlyDecreasingWith(comparator)236fun <T> Iterable<T>.shouldBeStrictlyDecreasingWith(comparator: Comparator<in T>) =237 toList().shouldBeStrictlyDecreasingWith(comparator)238fun <T> Array<T>.shouldBeStrictlyDecreasingWith(comparator: Comparator<in T>) =239 asList().shouldBeStrictlyDecreasingWith(comparator)240fun <T> List<T>.shouldNotBeStrictlyDecreasingWith(comparator: Comparator<in T>) =241 this shouldNot beStrictlyDecreasingWith(comparator)242fun <T> Iterable<T>.shouldNotBeStrictlyDecreasingWith(comparator: Comparator<in T>) =243 toList().shouldNotBeStrictlyDecreasingWith(comparator)244fun <T> Array<T>.shouldNotBeStrictlyDecreasingWith(comparator: Comparator<in T>) =245 asList().shouldNotBeStrictlyDecreasingWith(comparator)246infix fun <T> Iterable<T>.shouldHaveSingleElement(t: T) = toList().shouldHaveSingleElement(t)247infix fun <T> Array<T>.shouldHaveSingleElement(t: T) = asList().shouldHaveSingleElement(t)248infix fun <T> Iterable<T>.shouldHaveSingleElement(p: (T) -> Boolean) = toList().shouldHaveSingleElement(p)249infix fun <T> Array<T>.shouldHaveSingleElement(p: (T) -> Boolean) = asList().shouldHaveSingleElement(p)250infix fun <T> Collection<T>.shouldHaveSingleElement(t: T) = this should singleElement(t)251infix fun <T> Collection<T>.shouldHaveSingleElement(p: (T) -> Boolean) = this should singleElement(p)252infix fun <T> Iterable<T>.shouldNotHaveSingleElement(t: T) = toList().shouldNotHaveSingleElement(t)253infix fun <T> Array<T>.shouldNotHaveSingleElement(t: T) = asList().shouldNotHaveSingleElement(t)254infix fun <T> Collection<T>.shouldNotHaveSingleElement(t: T) = this shouldNot singleElement(t)255infix fun <T> Iterable<T>.shouldHaveSize(size: Int) = toList().shouldHaveSize(size)256infix fun <T> Array<T>.shouldHaveSize(size: Int) = asList().shouldHaveSize(size)257infix fun <T> Collection<T>.shouldHaveSize(size: Int) = this should haveSize(size = size)258infix fun <T> Iterable<T>.shouldNotHaveSize(size: Int) = toList().shouldNotHaveSize(size)259infix fun <T> Array<T>.shouldNotHaveSize(size: Int) = asList().shouldNotHaveSize(size)260infix fun <T> Collection<T>.shouldNotHaveSize(size: Int) = this shouldNot haveSize(size)261/**262 * Verifies this collection contains only one element263 *264 * This assertion is an alias to `collection shouldHaveSize 1`. This will pass if the collection have exactly one element265 * (definition of a Singleton Collection)266 *267 * ```268 * listOf(1).shouldBeSingleton() // Assertion passes269 * listOf(1, 2).shouldBeSingleton() // Assertion fails270 * ```271 *272 * @see [shouldHaveSize]273 * @see [shouldNotBeSingleton]274 * @see [shouldHaveSingleElement]275 */276fun <T> Collection<T>.shouldBeSingleton() = this shouldHaveSize 1277fun <T> Iterable<T>.shouldBeSingleton() = toList().shouldBeSingleton()278fun <T> Array<T>.shouldBeSingleton() = asList().shouldBeSingleton()279inline fun <T> Collection<T>.shouldBeSingleton(fn: (T) -> Unit) {280 this.shouldBeSingleton()281 fn(this.first())282}283inline fun <T> Iterable<T>.shouldBeSingleton(fn: (T) -> Unit) {284 toList().shouldBeSingleton(fn)285}286inline fun <T> Array<T>.shouldBeSingleton(fn: (T) -> Unit) {287 asList().shouldBeSingleton(fn)288}289/**290 * Verifies this collection doesn't contain only one element291 *292 * This assertion is an alias to `collection shouldNotHaveSize 1`. This will pass if the collection doesn't have exactly one element293 * (definition of a Singleton Collection)294 *295 * ```296 * listOf(1, 2).shouldNotBeSingleton() // Assertion passes297 * listOf<Int>().shouldNotBeSingleton() // Assertion passes298 * listOf(1).shouldNotBeSingleton() // Assertion fails299 * ```300 *301 * @see [shouldNotHaveSize]302 * @see [shouldBeSingleton]303 * @see [shouldNotHaveSingleElement]304 */305fun <T> Collection<T>.shouldNotBeSingleton() = this shouldNotHaveSize 1306fun <T> Iterable<T>.shouldNotBeSingleton() = toList().shouldNotBeSingleton()307fun <T> Array<T>.shouldNotBeSingleton() = asList().shouldNotBeSingleton()308infix fun <T, U> Iterable<T>.shouldBeLargerThan(other: Collection<U>) = toList().shouldBeLargerThan(other)309infix fun <T, U> Array<T>.shouldBeLargerThan(other: Collection<U>) = asList().shouldBeLargerThan(other)310infix fun <T, U> Iterable<T>.shouldBeLargerThan(other: Iterable<U>) = toList().shouldBeLargerThan(other.toList())311infix fun <T, U> Array<T>.shouldBeLargerThan(other: Array<U>) = asList().shouldBeLargerThan(other.asList())312infix fun <T, U> Collection<T>.shouldBeLargerThan(other: Collection<U>) = this should beLargerThan(other)313fun <T, U> beLargerThan(other: Collection<U>) = object : Matcher<Collection<T>> {314 override fun test(value: Collection<T>) = MatcherResult(315 value.size > other.size,316 "Collection of size ${value.size} should be larger than collection of size ${other.size}",317 "Collection of size ${value.size} should not be larger than collection of size ${other.size}"318 )319}320infix fun <T, U> Iterable<T>.shouldBeSmallerThan(other: Collection<U>) = toList().shouldBeSmallerThan(other)321infix fun <T, U> Array<T>.shouldBeSmallerThan(other: Collection<U>) = asList().shouldBeSmallerThan(other)322infix fun <T, U> Iterable<T>.shouldBeSmallerThan(other: Iterable<U>) = toList().shouldBeSmallerThan(other.toList())323infix fun <T, U> Array<T>.shouldBeSmallerThan(other: Array<U>) = asList().shouldBeSmallerThan(other.asList())324infix fun <T, U> Collection<T>.shouldBeSmallerThan(other: Collection<U>) = this should beSmallerThan(other)325fun <T, U> beSmallerThan(other: Collection<U>) = object : Matcher<Collection<T>> {326 override fun test(value: Collection<T>) = MatcherResult(327 value.size < other.size,328 "Collection of size ${value.size} should be smaller than collection of size ${other.size}",329 "Collection of size ${value.size} should not be smaller than collection of size ${other.size}"330 )331}332infix fun <T, U> Iterable<T>.shouldBeSameSizeAs(other: Collection<U>) = toList().shouldBeSameSizeAs(other)333infix fun <T, U> Array<T>.shouldBeSameSizeAs(other: Collection<U>) = asList().shouldBeSameSizeAs(other)334infix fun <T, U> Iterable<T>.shouldBeSameSizeAs(other: Iterable<U>) = toList().shouldBeSameSizeAs(other.toList())335infix fun <T, U> Array<T>.shouldBeSameSizeAs(other: Array<U>) = asList().shouldBeSameSizeAs(other.asList())336infix fun <T, U> Collection<T>.shouldBeSameSizeAs(other: Collection<U>) = this should beSameSizeAs(other)337fun <T, U> beSameSizeAs(other: Collection<U>) = object : Matcher<Collection<T>> {338 override fun test(value: Collection<T>) = MatcherResult(339 value.size == other.size,340 "Collection of size ${value.size} should be the same size as collection of size ${other.size}",341 "Collection of size ${value.size} should not be the same size as collection of size ${other.size}"342 )343}344infix fun <T> Iterable<T>.shouldHaveAtLeastSize(n: Int) = toList().shouldHaveAtLeastSize(n)345infix fun <T> Array<T>.shouldHaveAtLeastSize(n: Int) = asList().shouldHaveAtLeastSize(n)346infix fun <T> Collection<T>.shouldHaveAtLeastSize(n: Int) = this shouldHave atLeastSize(n)347fun <T> atLeastSize(n: Int) = object : Matcher<Collection<T>> {348 override fun test(value: Collection<T>) = MatcherResult(349 value.size >= n,350 "Collection should contain at least $n elements",351 "Collection should contain less than $n elements"352 )353}354infix fun <T> Iterable<T>.shouldHaveAtMostSize(n: Int) = toList().shouldHaveAtMostSize(n)355infix fun <T> Array<T>.shouldHaveAtMostSize(n: Int) = asList().shouldHaveAtMostSize(n)356infix fun <T> Collection<T>.shouldHaveAtMostSize(n: Int) = this shouldHave atMostSize(n)357fun <T> atMostSize(n: Int) = object : Matcher<Collection<T>> {358 override fun test(value: Collection<T>) = MatcherResult(359 value.size <= n,360 "Collection should contain at most $n elements",361 "Collection should contain more than $n elements"362 )363}364infix fun <T> Iterable<T>.shouldExist(p: (T) -> Boolean) = toList().shouldExist(p)365infix fun <T> Array<T>.shouldExist(p: (T) -> Boolean) = asList().shouldExist(p)366infix fun <T> Collection<T>.shouldExist(p: (T) -> Boolean) = this should exist(p)367fun <T> exist(p: (T) -> Boolean) = object : Matcher<Collection<T>> {368 override fun test(value: Collection<T>) = MatcherResult(369 value.any { p(it) },370 "Collection should contain an element that matches the predicate $p",371 "Collection should not contain an element that matches the predicate $p"372 )373}374fun <T> Iterable<T>.shouldExistInOrder(vararg ps: (T) -> Boolean) = toList().shouldExistInOrder(ps.toList())375fun <T> Array<T>.shouldExistInOrder(vararg ps: (T) -> Boolean) = asList().shouldExistInOrder(ps.toList())376fun <T> List<T>.shouldExistInOrder(vararg ps: (T) -> Boolean) = this.shouldExistInOrder(ps.toList())377infix fun <T> Iterable<T>.shouldExistInOrder(expected: List<(T) -> Boolean>) = toList().shouldExistInOrder(expected)378infix fun <T> Array<T>.shouldExistInOrder(expected: List<(T) -> Boolean>) = asList().shouldExistInOrder(expected)379infix fun <T> List<T>.shouldExistInOrder(expected: List<(T) -> Boolean>) = this should existInOrder(expected)380infix fun <T> Iterable<T>.shouldNotExistInOrder(expected: Iterable<(T) -> Boolean>) = toList().shouldNotExistInOrder(expected.toList())381infix fun <T> Array<T>.shouldNotExistInOrder(expected: Array<(T) -> Boolean>) = asList().shouldNotExistInOrder(expected.asList())382infix fun <T> Iterable<T>.shouldNotExistInOrder(expected: List<(T) -> Boolean>) = toList().shouldNotExistInOrder(expected)383infix fun <T> Array<T>.shouldNotExistInOrder(expected: List<(T) -> Boolean>) = asList().shouldNotExistInOrder(expected)384infix fun <T> List<T>.shouldNotExistInOrder(expected: List<(T) -> Boolean>) = this shouldNot existInOrder(expected)385fun <T> Iterable<T>.shouldBeEmpty() = toList().shouldBeEmpty()386fun <T> Array<T>.shouldBeEmpty() = asList().shouldBeEmpty()387fun <T> Collection<T>.shouldBeEmpty() = this should beEmpty()388fun <T> Iterable<T>.shouldNotBeEmpty() = toList().shouldNotBeEmpty()389fun <T> Array<T>.shouldNotBeEmpty() = asList().shouldNotBeEmpty()390fun <T> Collection<T>.shouldNotBeEmpty() = this shouldNot beEmpty()391fun <T> Iterable<T>.shouldContainAnyOf(vararg ts: T) = toList().shouldContainAnyOf(ts)392fun <T> Array<T>.shouldContainAnyOf(vararg ts: T) = asList().shouldContainAnyOf(ts)393fun <T> Collection<T>.shouldContainAnyOf(vararg ts: T) = this should containAnyOf(ts.asList())394fun <T> Iterable<T>.shouldNotContainAnyOf(vararg ts: T) = toList().shouldNotContainAnyOf(ts)395fun <T> Array<T>.shouldNotContainAnyOf(vararg ts: T) = asList().shouldNotContainAnyOf(ts)396fun <T> Collection<T>.shouldNotContainAnyOf(vararg ts: T) = this shouldNot containAnyOf(ts.asList())397infix fun <T> Iterable<T>.shouldContainAnyOf(ts: Collection<T>) = toList().shouldContainAnyOf(ts)398infix fun <T> Array<T>.shouldContainAnyOf(ts: Collection<T>) = asList().shouldContainAnyOf(ts)399infix fun <T> Collection<T>.shouldContainAnyOf(ts: Collection<T>) = this should containAnyOf(ts)400infix fun <T> Iterable<T>.shouldNotContainAnyOf(ts: Collection<T>) = toList().shouldNotContainAnyOf(ts)401infix fun <T> Array<T>.shouldNotContainAnyOf(ts: Collection<T>) = asList().shouldNotContainAnyOf(ts)402infix fun <T> Collection<T>.shouldNotContainAnyOf(ts: Collection<T>) = this shouldNot containAnyOf(ts)403fun <T> containAnyOf(ts: Collection<T>) = object : Matcher<Collection<T>> {404 override fun test(value: Collection<T>): MatcherResult {405 if (ts.isEmpty()) throwEmptyCollectionError()406 return MatcherResult(407 ts.any { it in value },408 { "Collection should contain any of ${ts.joinToString(separator = ", ", limit = 10) { it.show().value }}" },409 { "Collection should not contain any of ${ts.joinToString(separator = ", ", limit = 10) { it.show().value }}" }410 )411 }412}413/**414 * Verifies that this instance is in [collection]415 *416 * Assertion to check that this instance is in [collection]. This assertion checks by reference, and not by value,417 * therefore the exact instance must be in [collection], or this will fail.418 *419 * An empty collection will always fail. If you need to check for empty collection, use [Collection.shouldBeEmpty]420 *421 * @see [shouldNotBeOneOf]422 * @see [beOneOf]423 */424infix fun <T> T.shouldBeOneOf(collection: Collection<T>) = this should beOneOf(collection)425/**426 * Verifies that this instance is NOT in [collection]427 *428 * Assertion to check that this instance is not in [collection]. This assertion checks by reference, and not by value,429 * therefore the exact instance must not be in [collection], or this will fail.430 *431 * An empty collection will always fail. If you need to check for empty collection, use [Collection.shouldBeEmpty]432 *433 * @see [shouldBeOneOf]434 * @see [beOneOf]435 */436infix fun <T> T.shouldNotBeOneOf(collection: Collection<T>) = this shouldNot beOneOf(collection)437/**438 * Verifies that this instance is any of [any]439 *440 * Assertion to check that this instance is any of [any]. This assertion checks by reference, and not by value,441 * therefore the exact instance must be in [any], or this will fail.442 *443 * An empty collection will always fail. If you need to check for empty collection, use [Collection.shouldBeEmpty]444 *445 * @see [shouldNotBeOneOf]446 * @see [beOneOf]447 */448fun <T> T.shouldBeOneOf(vararg any: T) = this should beOneOf(any.toList())449/**450 * Verifies that this instance is NOT any of [any]451 *452 * Assertion to check that this instance is not any of [any]. This assertion checks by reference, and not by value,453 * therefore the exact instance must not be in [any], or this will fail.454 *455 * An empty collection will always fail. If you need to check for empty collection, use [Collection.shouldBeEmpty]456 *457 * @see [shouldNotBeOneOf]458 * @see [beOneOf]459 */460fun <T> T.shouldNotBeOneOf(vararg any: T) = this shouldNot beOneOf(any.toList())461/**462 * Matcher that verifies that this instance is in [collection]463 *464 * Assertion to check that this instance is in [collection]. This matcher checks by reference, and not by value,465 * therefore the exact instance must be in [collection], or this will fail.466 *467 * An empty collection will always fail. If you need to check for empty collection, use [Collection.shouldBeEmpty]468 *469 * @see [shouldBeOneOf]470 * @see [shouldNotBeOneOf]471 */472fun <T> beOneOf(collection: Collection<T>) = object : Matcher<T> {473 override fun test(value: T): MatcherResult {474 if (collection.isEmpty()) throwEmptyCollectionError()475 val match = collection.any { it === value }476 return MatcherResult(477 match,478 "Collection should contain the instance of value, but doesn't.",479 "Collection should not contain the instance of value, but does."480 )481 }482}483/**484 * Verifies that this element is in [collection] by comparing value485 *486 * Assertion to check that this element is in [collection]. This assertion checks by value, and not by reference,487 * therefore even if the exact instance is not in [collection] but another instance with same value is present, the488 * test will pass.489 *490 * An empty collection will always fail. If you need to check for empty collection, use [Collection.shouldBeEmpty]491 *492 * @see [shouldNotBeIn]493 * @see [beIn]494 */495infix fun <T> T.shouldBeIn(collection: Collection<T>) = this should beIn(collection)496/**497 * Verifies that this element is NOT any of [collection]498 *499 * Assertion to check that this element is not any of [collection]. This assertion checks by value, and not by reference,500 * therefore any instance with same value must not be in [collection], or this will fail.501 *502 * An empty collection will always fail. If you need to check for empty collection, use [Collection.shouldBeEmpty]503 *504 * @see [shouldNotBeIn]505 * @see [beIn]506 */507infix fun <T> T.shouldNotBeIn(collection: Collection<T>) = this shouldNot beIn(collection.toList())508/**509 * Verifies that this element is any of [any] by comparing value510 *511 * Assertion to check that this element is any of [any]. This assertion checks by value, and not by reference,512 * therefore even if the exact instance is not any of [any] but another instance with same value is present, the513 * test will pass.514 *515 * An empty collection will always fail. If you need to check for empty collection, use [Collection.shouldBeEmpty]516 *517 * @see [shouldNotBeIn]518 * @see [beIn]519 */520fun <T> T.shouldBeIn(vararg any: T) = this should beIn(any.toList())521/**522 * Verifies that this element is NOT any of [any]523 *524 * Assertion to check that this element is not any of [any]. This assertion checks by value, and not by reference,525 * therefore any instance with same value must not be in [any], or this will fail.526 *527 * An empty collection will always fail. If you need to check for empty collection, use [Collection.shouldBeEmpty]528 *529 * @see [shouldNotBeIn]530 * @see [beIn]531 */532fun <T> T.shouldNotBeIn(vararg any: T) = this shouldNot beIn(any.toList())533/**534 * Verifies that this element is in [array] by comparing value535 *536 * Assertion to check that this element is in [array]. This assertion checks by value, and not by reference,537 * therefore even if the exact instance is not in [array] but another instance with same value is present, the538 * test will pass.539 *540 * An empty array will always fail. If you need to check for empty array, use [Array.shouldBeEmpty]541 *542 * @see [shouldNotBeIn]543 * @see [beIn]544 */545@JvmName("shouldBeInArray")546infix fun <T> T.shouldBeIn(array: Array<T>) = this should beIn(array.toList())547/**548 * Verifies that this element is NOT any of [array]549 *550 * Assertion to check that this element is not any of [array]. This assertion checks by value, and not by reference,551 * therefore any instance with same value must not be in [array], or this will fail.552 *553 * An empty array will always fail. If you need to check for empty array, use [Array.shouldBeEmpty]554 *555 * @see [shouldNotBeIn]556 * @see [beIn]557 */558@JvmName("shouldNotBeInArray")559infix fun <T> T.shouldNotBeIn(array: Array<T>) = this shouldNot beIn(array.toList())560/**561 * Matcher that verifies that this element is in [collection] by comparing value562 *563 * Assertion to check that this element is in [collection]. This assertion checks by value, and not by reference,564 * therefore even if the exact instance is not in [collection] but another instance with same value is present, the565 * test will pass.566 *567 * An empty collection will always fail. If you need to check for empty collection, use [Collection.shouldBeEmpty]568 *569 * @see [shouldBeOneOf]570 * @see [shouldNotBeOneOf]571 */572fun <T> beIn(collection: Collection<T>) = object : Matcher<T> {573 override fun test(value: T): MatcherResult {574 if (collection.isEmpty()) throwEmptyCollectionError()575 val match = value in collection576 return MatcherResult(577 match,578 "Collection should contain ${value.show().value}, but doesn't. Possible values: ${collection.show().value}",579 "Collection should not contain ${value.show().value}, but does. Forbidden values: ${collection.show().value}"580 )581 }582}583private fun throwEmptyCollectionError(): Nothing {584 throw AssertionError("Asserting content on empty collection. Use Collection.shouldBeEmpty() instead.")585}...

Full Screen

Full Screen

RateLimitedDispatcherTest.kt

Source:RateLimitedDispatcherTest.kt Github

copy

Full Screen

...259 }260 trackableDispatcher.completeAllAndClose();261 }262 @Test263 fun `decreasing window size reduces limit`() {264 val trackableDispatcher = TrackableDispatcher()265 trackableDispatcher.windowProperty.set(10)266 trackableDispatcher.submitTasks(1..10)267 sleep(4000)268 trackableDispatcher.isSubmittedTaskInvoked(1..10).shouldBeTrue()269 trackableDispatcher.completeTasks(1..10)270 trackableDispatcher.windowProperty.set(4)271 trackableDispatcher.submitTasks(11..15)272 sleep(4000)273 trackableDispatcher.isSubmittedTaskInvoked(11..14).shouldBeTrue()274 trackableDispatcher.isSubmittedTaskInvoked(15).shouldBeFalse()275 trackableDispatcher.completeTask(11)276 await().atMost(Duration.ofSeconds(10)).until {277 trackableDispatcher.isSubmittedTaskInvoked(15)...

Full Screen

Full Screen

CollectionMatchers.kt

Source:CollectionMatchers.kt Github

copy

Full Screen

...118 else -> ". Element ${failure.value.second} at index ${failure.index + 1} was not monotonically decreased from previous element."119 }120 return MatcherResult(121 failure == null,122 { "List [$snippet] should be monotonically decreasing$elementMessage" },123 { "List [$snippet] should not be monotonically decreasing" }124 )125}126fun <T : Comparable<T>> beStrictlyIncreasing(): Matcher<List<T>> = strictlyIncreasing()127fun <T : Comparable<T>> strictlyIncreasing(): Matcher<List<T>> = object : Matcher<List<T>> {128 override fun test(value: List<T>): MatcherResult {129 return testStrictlyIncreasingWith(value, Comparator { a, b -> a.compareTo(b) })130 }131}132fun <T> beStrictlyIncreasingWith(comparator: Comparator<in T>): Matcher<List<T>> = strictlyIncreasingWith(133 comparator)134fun <T> strictlyIncreasingWith(comparator: Comparator<in T>): Matcher<List<T>> = object : Matcher<List<T>> {135 override fun test(value: List<T>): MatcherResult {136 return testStrictlyIncreasingWith(value, comparator)137 }138}139private fun <T> testStrictlyIncreasingWith(value: List<T>, comparator: Comparator<in T>): MatcherResult {140 val failure = value.zipWithNext().withIndex().find { (_, pair) -> comparator.compare(pair.first, pair.second) >= 0 }141 val snippet = value.show().value142 val elementMessage = when (failure) {143 null -> ""144 else -> ". Element ${failure.value.second} at index ${failure.index + 1} was not strictly increased from previous element."145 }146 return MatcherResult(147 failure == null,148 { "List [$snippet] should be strictly increasing$elementMessage" },149 { "List [$snippet] should not be strictly increasing" }150 )151}152fun <T : Comparable<T>> beStrictlyDecreasing(): Matcher<List<T>> = strictlyDecreasing()153fun <T : Comparable<T>> strictlyDecreasing(): Matcher<List<T>> = object : Matcher<List<T>> {154 override fun test(value: List<T>): MatcherResult {155 return testStrictlyDecreasingWith(value, Comparator { a, b -> a.compareTo(b) })156 }157}158fun <T> beStrictlyDecreasingWith(comparator: Comparator<in T>): Matcher<List<T>> = strictlyDecreasingWith(159 comparator)160fun <T> strictlyDecreasingWith(comparator: Comparator<in T>): Matcher<List<T>> = object : Matcher<List<T>> {161 override fun test(value: List<T>): MatcherResult {162 return testStrictlyDecreasingWith(value, comparator)163 }164}165private fun <T> testStrictlyDecreasingWith(value: List<T>, comparator: Comparator<in T>): MatcherResult {166 val failure = value.zipWithNext().withIndex().find { (_, pair) -> comparator.compare(pair.first, pair.second) <= 0 }167 val snippet = value.show().value168 val elementMessage = when (failure) {169 null -> ""170 else -> ". Element ${failure.value.second} at index ${failure.index + 1} was not strictly decreased from previous element."171 }172 return MatcherResult(173 failure == null,174 { "List [$snippet] should be strictly decreasing$elementMessage" },175 { "List [$snippet] should not be strictly decreasing" }176 )177}...

Full Screen

Full Screen

decreasing.kt

Source:decreasing.kt Github

copy

Full Screen

...91 else -> ". Element ${failure.value.second} at index ${failure.index + 1} was not monotonically decreased from previous element."92 }93 return MatcherResult(94 failure == null,95 { "List [$snippet] should be monotonically decreasing$elementMessage" },96 { "List [$snippet] should not be monotonically decreasing" }97 )98}99fun <T : Comparable<T>> beStrictlyDecreasing(): Matcher<List<T>> = strictlyDecreasing()100fun <T : Comparable<T>> strictlyDecreasing(): Matcher<List<T>> = object : Matcher<List<T>> {101 override fun test(value: List<T>): MatcherResult {102 return testStrictlyDecreasingWith(value) { a, b -> a.compareTo(b) }103 }104}105fun <T> beStrictlyDecreasingWith(comparator: Comparator<in T>): Matcher<List<T>> =106 strictlyDecreasingWith(comparator)107fun <T> strictlyDecreasingWith(comparator: Comparator<in T>): Matcher<List<T>> = object : Matcher<List<T>> {108 override fun test(value: List<T>): MatcherResult {109 return testStrictlyDecreasingWith(value, comparator)110 }111}112private fun <T> testStrictlyDecreasingWith(value: List<T>, comparator: Comparator<in T>): MatcherResult {113 val failure = value.zipWithNext().withIndex().find { (_, pair) -> comparator.compare(pair.first, pair.second) <= 0 }114 val snippet = value.print().value115 val elementMessage = when (failure) {116 null -> ""117 else -> ". Element ${failure.value.second} at index ${failure.index + 1} was not strictly decreased from previous element."118 }119 return MatcherResult(120 failure == null,121 { "List [$snippet] should be strictly decreasing$elementMessage" },122 { "List [$snippet] should not be strictly decreasing" }123 )124}...

Full Screen

Full Screen

LineTest.kt

Source:LineTest.kt Github

copy

Full Screen

1package day052import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder3import org.junit.jupiter.api.Test4internal class LineTest {5 @Test6 fun create__success__horizontalIncreasingNumbersOnly() {7 val definition = LineDefinition(Position(3, 5), Position(5, 5))8 val line = Line(definition)9 line.positions shouldContainExactlyInAnyOrder listOf(Position(3, 5), Position(4, 5), Position(5, 5))10 }11 @Test12 fun create__success__verticalDecreasingX() {13 val definition = LineDefinition(Position(3, 5), Position(3, 3))14 val line = Line(definition)15 line.positions shouldContainExactlyInAnyOrder listOf(Position(3, 3), Position(3, 4), Position(3, 5))16 }17 @Test18 fun create__success__diagonalDecreasingY() {19 val definition = LineDefinition(Position(3, 3), Position(6, 0))20 val line = Line(definition)21 line.positions shouldContainExactlyInAnyOrder listOf(22 Position(3, 3),23 Position(4, 2),24 Position(5, 1),25 Position(6, 0)26 )27 }28}...

Full Screen

Full Screen

decreasing

Using AI Code Generation

copy

Full Screen

1val list = listOf(1, 2, 3)2list should haveSize(3)3list should haveSize(greaterThan(2))4list should haveSize(greaterThanOrEqual(3))5list should haveSize(lessThan(4))6list should haveSize(lessThanOrEqual(3))7list should haveSize(inRange(1..3))8list should haveSize(inRange(2..4))9list should haveSize(not(1))10list should haveSize(not(greaterThan(3)))11list should haveSize(not(greaterThanOrEqual(4)))12list should haveSize(not(lessThan(3)))13list should haveSize(not(lessThanOrEqual(2)))14list should haveSize(not(inRange(1..2)))15list should haveSize(not(inRange(4..5)))16val list = listOf(1, 2, 3)17list should haveSize(3)18list should haveSize(greaterThan(2))19list should haveSize(greaterThanOrEqual(3))20list should haveSize(lessThan(4))21list should haveSize(lessThanOrEqual(3))22list should haveSize(inRange(1..3))23list should haveSize(inRange(2..4))24list should haveSize(not(1))25list should haveSize(not(greaterThan(3)))26list should haveSize(not(greaterThanOrEqual(4)))27list should haveSize(not(lessThan(3)))28list should haveSize(not(lessThanOrEqual(2)))29list should haveSize(not(inRange(1..2)))30list should haveSize(not(inRange(4..5)))31val list = listOf(1, 2, 3)32list should haveSize(3)33list should haveSize(greaterThan(2))34list should haveSize(greaterThanOrEqual(3))35list should haveSize(lessThan(4))36list should haveSize(lessThanOrEqual(3))37list should haveSize(inRange(1..3))38list should haveSize(inRange(2..4))39list should haveSize(not(1))40list should haveSize(not(greaterThan(3)))41list should haveSize(not(greaterThanOrEqual(4)))42list should haveSize(not(lessThan(3)))43list should haveSize(not(lessThanOrEqual(2)))

Full Screen

Full Screen

decreasing

Using AI Code Generation

copy

Full Screen

1val list = listOf(1, 2, 3, 4, 5)2list.shouldHaveSize(5)3list.shouldHaveSingleElement(1)4list.shouldHaveAtLeastOneElement(1)5list.shouldHaveAtLeastOneElement(2)6list.shouldHaveAtLeastOneElement(3)7list.shouldHaveAtLeastOneElement(4)8list.shouldHaveAtLeastOneElement(5)9list.shouldHaveAtLeastOneElement(6)10list.shouldHaveAtLeastOneElement(7)11list.shouldHaveAtLeastOneElement(8)12list.shouldHaveAtLeastOneElement(9)13list.shouldHaveAtLeastOneElement(10)14list.shouldHaveAtLeastOneElement(11)15list.shouldHaveAtLeastOneElement(12)16list.shouldHaveAtLeastOneElement(13)17list.shouldHaveAtLeastOneElement(14)18list.shouldHaveAtLeastOneElement(15)19list.shouldHaveAtLeastOneElement(16)20list.shouldHaveAtLeastOneElement(17)21list.shouldHaveAtLeastOneElement(18)22list.shouldHaveAtLeastOneElement(19)23list.shouldHaveAtLeastOneElement(20)24list.shouldHaveAtLeastOneElement(21)25list.shouldHaveAtLeastOneElement(22)26list.shouldHaveAtLeastOneElement(23)27list.shouldHaveAtLeastOneElement(24)28list.shouldHaveAtLeastOneElement(25)29list.shouldHaveAtLeastOneElement(26)30list.shouldHaveAtLeastOneElement(27)31list.shouldHaveAtLeastOneElement(28)32list.shouldHaveAtLeastOneElement(29)33list.shouldHaveAtLeastOneElement(30)34list.shouldHaveAtLeastOneElement(31)35list.shouldHaveAtLeastOneElement(32)36list.shouldHaveAtLeastOneElement(33)37list.shouldHaveAtLeastOneElement(34)38list.shouldHaveAtLeastOneElement(35)39list.shouldHaveAtLeastOneElement(36)40list.shouldHaveAtLeastOneElement(37)41list.shouldHaveAtLeastOneElement(38)42list.shouldHaveAtLeastOneElement(39)43list.shouldHaveAtLeastOneElement(40)44list.shouldHaveAtLeastOneElement(41)45list.shouldHaveAtLeastOneElement(42)46list.shouldHaveAtLeastOneElement(43)47list.shouldHaveAtLeastOneElement(44)48list.shouldHaveAtLeastOneElement(45)49list.shouldHaveAtLeastOneElement(46)

Full Screen

Full Screen

decreasing

Using AI Code Generation

copy

Full Screen

1@Test fun `should not contain`() { val numbers = listOf(1, 2, 3, 4, 5) numbers shouldNotContain 6 } Enter fullscreen mode Exit fullscreen mode2@Test fun `should contain all`() { val numbers = listOf("one", "two", "three") numbers shouldContainAll listOf("one", "three") } Enter fullscreen mode Exit fullscreen mode3@Test fun `should contain exactly`() { val numbers = listOf("one", "two", "three") numbers shouldContainExactly listOf("one", "two", "three") } Enter fullscreen mode Exit fullscreen mode4@Test fun `should contain none`() { val numbers = listOf("one", "two", "three") numbers shouldContainNone listOf("four", "five") } Enter fullscreen mode Exit fullscreen mode5@Test fun `should contain any of`() { val numbers = listOf("one", "two", "three") numbers shouldContainAnyOf listOf("three", "five") } Enter fullscreen mode Exit fullscreen mode6@Test fun `should contain none of`() { val numbers = listOf("one", "two", "three") numbers shouldContainNoneOf listOf("four", "five") } Enter fullscreen mode Exit fullscreen mode7@Test fun `should contain in order`() { val

Full Screen

Full Screen

Automation Testing Tutorials

Learn to execute automation testing from scratch with LambdaTest Learning Hub. Right from setting up the prerequisites to run your first automation test, to following best practices and diving deeper into advanced test scenarios. LambdaTest Learning Hubs compile a list of step-by-step guides to help you be proficient with different test automation frameworks i.e. Selenium, Cypress, TestNG etc.

LambdaTest Learning Hubs:

YouTube

You could also refer to video tutorials over LambdaTest YouTube channel to get step by step demonstration from industry experts.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful