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

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

UniqueDataProvierIT.kt

Source:UniqueDataProvierIT.kt Github

copy

Full Screen

...11import io.kotest.matchers.shouldNot12import io.kotest.matchers.shouldNotBe13@Suppress("UNCHECKED_CAST")14class UniqueDataProviderIT : DescribeSpec({15 describe("unique generation of values enabled for provider through configuration") {16 val config = FakerConfig.builder().create { uniqueGeneratorRetryLimit = 100 }17 // repeat 10 times to make sure values are not included in the collection18 repeat(10) {19 context("collection of values is generated #run$it") {20 val faker = Faker(config)21 faker.unique.configuration { enable(faker::address) }22 val countries = (0..18).map { faker.address.country() }23 val newCountries = (0..30).map { faker.address.country() }24 it("should have unique values") {25 assertSoftly {26 countries should beUnique()27 newCountries should beUnique()28 newCountries shouldNotContainAnyOf countries29 }30 }31 }32 }33 }34 describe("collection of values is used to exclude values from being generated for specific provider") {35 val config = FakerConfig.builder().create { uniqueGeneratorRetryLimit = 100 }36 // repeat 10 times to make sure values are not included in the collection37 repeat(10) {38 val faker = Faker(config)39 faker.unique.configuration { enable(faker::address) }40 val countries = (0..30).map { faker.address.country() }41 context("collection of unique values is generated run#$it") {42 val excludedCountries = listOf(43 "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra", "Angola"44 )45 faker.unique.configuration { excludeFromFunction(Address::country, excludedCountries) }46 val newCountries = (0..30).map { faker.address.country() }47 val moreExcludedCountries = listOf(48 "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands", "Central African Republic"49 )50 faker.unique.configuration { excludeFromProvider<Address>(moreExcludedCountries) }51 val moreCountries = (0..30).map { faker.address.country() }52 val excludedCountryCodes = listOf("AD", "AE", "AF", "AG", "AI", "AL", "AM", "AO", "AQ")53 faker.unique.configuration { excludeFromProvider<Address>(excludedCountryCodes) }54 val countryCodes = (0..30).map { faker.address.countryCode() }55 it("excluded values through config should not be included in the generation") {56 assertSoftly {57 newCountries shouldNotContainAnyOf excludedCountries58 moreCountries shouldNotContainAnyOf moreExcludedCountries59 countryCodes shouldNotContainAnyOf excludedCountryCodes60 }61 }62 it("already generated values through config should not be included in the generation") {63 assertSoftly {64 newCountries shouldNotContainAnyOf countries65 moreCountries shouldNotContainAnyOf newCountries66 moreCountries shouldNotContainAnyOf countries67 }68 }69 }70 }71 }72 describe("use collections to exclude values from being generated for all providers") {73 // repeat 10 times to make sure values are not included in the collection74 repeat(10) {75 val faker = Faker()76 val excludedCountries = listOf(77 "Afghanistan", "Albania", "Algeria", "American Samoa", "Andorra",78 "Angola", "Anguilla", "Antarctica (the territory South of 60 deg S)", "Antigua and Barbuda",79 "Argentina", "Armenia", "Aruba", "Australia", "Austria", "Azerbaijan", "Bahamas", "Bahrain",80 "Bangladesh", "Barbados", "Belarus", "Belgium", "Belize", "Benin", "Bermuda", "Bhutan", "Bolivia",81 "Bosnia and Herzegovina", "Botswana", "Bouvet Island (Bouvetoya)", "Brazil",82 "British Indian Ocean Territory (Chagos Archipelago)", "Brunei Darussalam", "Bulgaria",83 "Burkina Faso", "Burundi", "Cambodia", "Cameroon", "Canada", "Cape Verde", "Cayman Islands",84 "Central African Republic", "Chad", "Chile", "China", "Christmas Island", "Cocos (Keeling) Islands",85 "Colombia", "Comoros", "Congo", "Congo", "Cook Islands", "Costa Rica", "Cote d'Ivoire", "Croatia",86 "Cuba", "Cyprus", "Czech Republic",87 )88 val excludedNames = listOf(89 "Abbott", "Abernathy", "Abshire", "Adams", "Altenwerth", "Anderson", "Ankunding", "Armstrong", "Auer",90 "Aufderhar", "Bahringer", "Bailey", "Balistreri", "Barrows", "Bartell", "Bartoletti", "Barton",91 "Bashirian", "Batz", "Bauch", "Baumbach", "Bayer", "Beahan", "Beatty", "Bechtelar", "Becker", "Bednar",92 "Beer", "Beier", "Berge", "Bergnaum", "Bergstrom", "Bernhard", "Bernier", "Bins", "Blanda", "Blick",93 "Block", "Bode", "Boehm", "Bogan", "Bogisich", "Borer", "Bosco", "Botsford", "Boyer", "Boyle",94 "Bradtke", "Brakus", "Braun", "Breitenberg", "Brekke", "Brown", "Bruen", "Buckridge"95 )96 val excludedBicCodes = listOf(97 "AACCGB21", "AACNGB21", "AAFMGB21", "AAHOGB21", "AAHVGB21", "AANLGB21",98 "AANLGB2L", "AAOGGB21", "AAPEGB21", "AAPUGB21", "AAQIGB21", "ABBYGB2L",99 "BCYPGB2LCBB", "BCYPGB2LHGB", "BCYPGB2LHHB", "BCYPGB2LPGB", "BCYPGB2LSSB", "BCYPGB2LMBB"100 )101 val excludeAll = listOf(excludedCountries, excludedNames, excludedBicCodes).flatten()102 faker.unique.configuration {103 enable(faker::address)104 enable(faker::name)105 exclude(excludeAll)106 }107 context("collection of unique values is generated run#$it") {108 val countries = (0..30).map { faker.address.country() }109 val names = (0..30).map { faker.name.lastName() }110 // Unique generation not enabled for Bank111 val bicCodes = (0..30).map { faker.bank.swiftBic() }112 it("should not contain excluded values") {113 assertSoftly {114 countries shouldNotContainAnyOf excludeAll115 names shouldNotContainAnyOf excludeAll116 // Unique generation not enabled for Bank117 bicCodes shouldNot beUnique()118 bicCodes shouldContainAnyOf excludedBicCodes119 }120 }121 }122 }123 }124 describe("use regex patterns to exclude values from being generated for all providers") {125 repeat(10) {126 val faker = Faker()127 faker.unique.configuration {128 // Enable unique generation129 enable(faker::address)130 enable(faker::name)131 // Exclude all values starting with "A"132 exclude { listOf(Regex("^A")) }133 }134 it("should not contain values matching pattern run#$it") {135 val countries = (0..30).map { faker.address.country() }136 val names = (0..30).map { faker.name.lastName() }137 // Unique generation not enabled for Bank138 val bicCodes = (0..30).map { faker.bank.swiftBic() }139 assertSoftly {140 countries.none { s -> s.startsWith("A") } shouldBe true141 countries should beUnique()142 names.none { s -> s.startsWith("A") } shouldBe true143 names should beUnique()144 // Unique generation not enabled for Bank145 bicCodes.any { s -> s.startsWith("A") } shouldBe true146 bicCodes shouldNot beUnique()147 }148 }149 }150 }151 describe("use regex patterns to exclude values from being generated for specific provider") {152 repeat(10) {153 val faker = Faker()154 faker.unique.configuration {155 // Enable unique generation and exclude by patterns156 enable(faker::address) {157 excludeFromProvider<Address> { listOf(Regex("^A")) }158 excludeFromFunction(Address::country) { listOf(Regex("^B")) }159 }160 }161 it("excluded values by pattern should not be included in the generation for the provider run#$it") {162 val countries = (0..30).map { faker.address.country() }163 val cities = (0..30).map { faker.address.city() }164 assertSoftly {165 countries.none { s -> s.startsWith("A") } shouldBe true166 countries.none { s -> s.startsWith("B") } shouldBe true167 cities.none { s -> s.startsWith("A") } shouldBe true168 }169 }170 }171 }172 describe("unique generation of values for category") {173 val config = FakerConfig.builder().create { uniqueGeneratorRetryLimit = 100 }174 context("collection of values is generated") {175 val faker = Faker(config)176 faker.unique.enable(faker::address)177 faker.unique.enable(faker::ancient)178 val countries = (0..20).map { faker.address.country() }179 it("should not contain duplicates") {180 countries should beUnique()181 }182 }183 context("used values are cleared") {184 val faker = Faker(config).also {185 it.unique.enable(it::address)186 }187 val countries = (0..20).map { faker.address.country() }188 faker.unique.clear(faker::address)189 val newCountries = (0..20).map { faker.address.country() }190 it("new collection should not contain duplicates") {191 newCountries should beUnique()192 }193 it("new collection should not equal old collection") {194 newCountries shouldNotBe countries195 }196 }197 context("exclude values from being generated") {198 // repeat 10 times to make sure values are not included in the collection199 repeat(10) {200 val faker = Faker(config)201 faker.unique.enable(faker::address)202 val countries = (0..5).map { faker.address.country() }203 context("collection of values was marked for exclusion run#$it") {204 val excludedCountries = listOf(205 "Afghanistan",206 "Albania",207 "Algeria",208 "American Samoa",209 "Andorra",210 "Angola"211 )212 faker.unique.exclude<Address>("country", excludedCountries)213 val newCountries = (0..20).map { faker.address.country() }214 it("excluded values should not be included in the generation") {215 newCountries shouldNotContainAnyOf excludedCountries216 }217 it("already generated values should not be included in the generation") {218 newCountries shouldNotContainAnyOf countries219 }220 }221 }222 }223 context("unique generation is not enabled for category") {224 val faker = Faker(config)225 context("some values were marked for exclusion") {226 val excludedCountries = listOf(227 "Afghanistan",228 "Albania",229 "Algeria",230 "American Samoa",231 "Andorra",232 "Angola",233 "Anguilla",234 "Antarctica",235 "Antigua And Barbuda",236 "Argentina",237 "Armenia",238 "Aruba",239 "Australia",240 "Austria",241 "Aland Islands",242 "Azerbaijan",243 "Bahamas",244 "Bahrain",245 "Bangladesh",246 "Barbados",247 "Belarus",248 "Belgium",249 "Belize",250 "Benin",251 "Bermuda",252 "Bhutan",253 "Bolivia",254 "Bonaire",255 "Bosnia And Herzegovina",256 "Botswana",257 "Bouvet Island"258 )259 faker.unique.exclude<Address>("country", excludedCountries)260 val countries = (0..100).map { faker.address.country() }261 it("collection can have duplicates") {262 countries should containDuplicates()263 }264 it("collection can have excluded values") {265 countries.any { excludedCountries.contains(it) } shouldBe true266 }267 }268 }269 context("values are generated for another category that is not marked for unique generation") {270 val faker = Faker(config)271 faker.unique.enable(faker::address)272 val animalNames = (0..100).map { faker.animal.name() }273 it("collection can have duplicates") {274 animalNames shouldNot beUnique()275 }276 }277 context("unique generation for category is disabled") {278 val faker = Faker(config)279 faker.unique.enable(faker::address)280 (0..20).map { faker.address.country() }281 faker.unique.disable(faker::address)282 context("collection of values is generated") {283 val countries = (0..100).map { faker.address.country() }284 it("collection can have duplicates") {285 countries shouldNot beUnique()286 }287 }288 }289 context("unique generation is disabled for all categories") {290 val faker = Faker(config)291 faker.unique.enable(faker::address)292 faker.unique.enable(faker::ancient)293 faker.unique.disableAll()294 context("collections of values are generated") {295 val countries = (0..100).map { faker.address.country() }296 val gods = (0..100).map { faker.ancient.god() }297 it("collection can have duplicates") {298 assertSoftly {299 countries shouldNot beUnique()300 gods shouldNot beUnique()301 }302 }303 }304 context("unique generation for a category is re-enabled") {305 faker.unique.enable(faker::address)306 context("collection of values is generated") {307 val countries = (0..20).map { faker.address.country() }308 it("collection should not contain duplicates") {309 countries should beUnique()310 }311 }312 }313 }314 context("unique generation is cleared for all categories") {315 val faker = Faker(config)316 faker.unique.enable(faker::address)317 faker.unique.enable(faker::ancient)318 // Generate some values first319 (0..20).map { faker.address.country() }320 (0..20).map { faker.ancient.hero() }321 faker.unique.clearAll()322 context("collections of values are generated") {323 val countries = (0..20).map { faker.address.country() }324 val heroes = (0..20).map { faker.ancient.hero() }325 it("collections should be unique") {326 assertSoftly {327 countries should beUnique()328 heroes should beUnique()329 }330 }331 }332 }333 }334 describe("local unique generation") {335 val config = FakerConfig.builder().create {336 uniqueGeneratorRetryLimit = 100337 }338 val faker = Faker(config)339 context("unique property prefixes the category function invocation") {340 val countries = (0..20).map {341 faker.address.unique.country()342 }343 it("collection should not contain duplicates") {344 countries should beUnique()345 }346 it("other functions of the same category should not be marked as unique") {347 // This will produce an error if used with `unique` prefix348 // because there is only one value in the dictionary349 (0..10).map { faker.address.defaultCountry() }350 }351 context("values are cleared for the function name") {352 faker.address.unique.clear("country")353 val newCountries = (0..20).map {354 faker.address.unique.country()355 }356 it("collection should not contain duplicates") {357 newCountries should beUnique()358 }359 }360 context("values are cleared for all functions") {361 repeat(20) { faker.address.unique.country() }362 repeat(20) { faker.address.unique.state() }363 faker.address.unique.clearAll()364 it("re-generated collections should be unique") {365 val newCountries = (0..20).map { faker.address.unique.country() }366 val states = (0..20).map { faker.address.unique.state() }367 assertSoftly {368 newCountries should beUnique()369 states should beUnique()370 }371 }372 }373 }374 }375})...

Full Screen

Full Screen

Nel.kt

Source:Nel.kt Github

copy

Full Screen

1package io.kotest.assertions.arrow.core2import arrow.core.NonEmptyList3import io.kotest.matchers.collections.shouldBeSorted4import io.kotest.matchers.collections.shouldNotBeSorted5import io.kotest.matchers.collections.shouldBeUnique6import io.kotest.matchers.collections.shouldContain7import io.kotest.matchers.collections.shouldContainAll8import io.kotest.matchers.collections.shouldContainDuplicates9import io.kotest.matchers.collections.shouldContainNoNulls10import io.kotest.matchers.collections.shouldContainNull11import io.kotest.matchers.collections.shouldContainOnlyNulls12import io.kotest.matchers.collections.shouldHaveElementAt13import io.kotest.matchers.collections.shouldHaveSingleElement14import io.kotest.matchers.collections.shouldHaveSize15import io.kotest.matchers.collections.shouldNotHaveSize16import io.kotest.matchers.collections.shouldNotBeUnique17import io.kotest.matchers.collections.shouldNotContain18import io.kotest.matchers.collections.shouldNotContainAll19import io.kotest.matchers.collections.shouldNotContainDuplicates20import io.kotest.matchers.collections.shouldNotContainNoNulls21import io.kotest.matchers.collections.shouldNotContainNull22import io.kotest.matchers.collections.shouldNotContainOnlyNulls23import io.kotest.matchers.collections.shouldNotHaveElementAt24import io.kotest.matchers.collections.shouldNotHaveSingleElement25public fun <A> NonEmptyList<A>.shouldContainOnlyNulls(): NonEmptyList<A> =26 apply { all.shouldContainOnlyNulls() }27public fun <A> NonEmptyList<A>.shouldNotContainOnlyNulls(): NonEmptyList<A> =28 apply { all.shouldNotContainOnlyNulls() }29public fun <A> NonEmptyList<A>.shouldContainNull(): NonEmptyList<A> =30 apply { all.shouldContainNull() }31public fun <A> NonEmptyList<A>.shouldNotContainNull(): NonEmptyList<A> =32 apply { all.shouldNotContainNull() }33public fun <A> NonEmptyList<A>.shouldHaveElementAt(index: Int, element: A): Unit =34 all.shouldHaveElementAt(index, element)35public fun <A> NonEmptyList<A>.shouldNotHaveElementAt(index: Int, element: A): Unit =36 all.shouldNotHaveElementAt(index, element)37public fun <A> NonEmptyList<A>.shouldContainNoNulls(): NonEmptyList<A> =38 apply { all.shouldContainNoNulls() }39public fun <A> NonEmptyList<A>.shouldNotContainNoNulls(): NonEmptyList<A> =40 apply { all.shouldNotContainNoNulls() }41public infix fun <A> NonEmptyList<A>.shouldContain(a: A): Unit {42 all.shouldContain(a)43}44public infix fun <A> NonEmptyList<A>.shouldNotContain(a: A): Unit {45 all.shouldNotContain(a)46}47public fun <A> NonEmptyList<A>.shouldBeUnique(): NonEmptyList<A> =48 apply { all.shouldBeUnique() }49public fun <A> NonEmptyList<A>.shouldNotBeUnique(): NonEmptyList<A> =50 apply { all.shouldNotBeUnique() }51public fun <A> NonEmptyList<A>.shouldContainDuplicates(): NonEmptyList<A> =52 apply { all.shouldContainDuplicates() }53public fun <A> NonEmptyList<A>.shouldNotContainDuplicates(): NonEmptyList<A> =54 apply { all.shouldNotContainDuplicates() }55public fun <A> NonEmptyList<A>.shouldContainAll(vararg ts: A): Unit =56 all.shouldContainAll(*ts)57public fun <A> NonEmptyList<A>.shouldNotContainAll(vararg ts: A): Unit =58 all.shouldNotContainAll(*ts)59public infix fun <A> NonEmptyList<A>.shouldContainAll(ts: List<A>): Unit =60 all.shouldContainAll(ts)61public infix fun <A> NonEmptyList<A>.shouldNotContainAll(ts: List<A>): Unit =62 all.shouldNotContainAll(ts)63public infix fun <A> NonEmptyList<A>.shouldHaveSize(size: Int): NonEmptyList<A> =64 apply { all.shouldHaveSize(size) }65public infix fun <A> NonEmptyList<A>.shouldNotHaveSize(size: Int): NonEmptyList<A> =66 apply { all.shouldNotHaveSize(size) }67public infix fun <A> NonEmptyList<A>.shouldHaveSingleElement(a: A): Unit =68 all.shouldHaveSingleElement(a)69public infix fun <A> NonEmptyList<A>.shouldNotHaveSingleElement(a: A): Unit =70 all.shouldNotHaveSingleElement(a)71public fun <A : Comparable<A>> NonEmptyList<A>.shouldBeSorted(): NonEmptyList<A> =72 apply { all.shouldBeSorted() }73public fun <A : Comparable<A>> NonEmptyList<A>.shouldNotBeSorted(): NonEmptyList<A> =74 apply { all.shouldNotBeSorted() }...

Full Screen

Full Screen

PasswordGeneratorSpec.kt

Source:PasswordGeneratorSpec.kt Github

copy

Full Screen

1/*2 * Copyright 2022 Leonardo Colman Lopes, Luiz Neves Porto3 *4 * Licensed under the Apache License, Version 2.0 (the "License");5 * you may not use this file except in compliance with the License.6 * You may obtain a copy of the License at7 *8 * http://www.apache.org/licenses/LICENSE-2.09 *10 * Unless required by applicable law or agreed to in writing, software11 * distributed under the License is distributed on an "AS IS" BASIS,12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either press or implied.13 * See the License for the specific language governing permissions and14 * limitations under the License.15 */16package br.com.colman.password17import io.kotest.assertions.throwables.shouldNotThrowAny18import io.kotest.core.spec.style.FunSpec19import io.kotest.inspectors.forOne20import io.kotest.matchers.char.shouldBeInRange21import io.kotest.matchers.collections.shouldBeIn22import io.kotest.matchers.collections.shouldBeUnique23import io.kotest.matchers.shouldBe24import io.kotest.matchers.string.shouldHaveLength25import io.kotest.matchers.string.shouldMatch26import kotlin.random.Random27private val oracleAcceptedSpecialCharacters = """@%+\/'!#$^?:,(){?[]~`-_.""".toList()28class PasswordGeneratorSpec : FunSpec({29 val target = PasswordGenerator()30 test("Sanity check") {31 val myRandom = Random(19980209)32 val generator = PasswordGenerator(myRandom)33 generator.generate() shouldBe "9Lrwc'iy"34 generator.generate() shouldBe "f{uzP9pc"35 generator.generate() shouldBe "aQ)owQ1J"36 }37 context("Default generator") {38 val defaultGenerator = PasswordGenerator.Default39 test("Uses AZ az characters") {40 val pw = defaultGenerator.generate(includeSpecial = false, includeNumber = false)41 pw shouldMatch Regex("[a-zA-Z]+")42 }43 test("Includes a special characters") {44 val pw = defaultGenerator.generate(includeSpecial = true, includeNumber = false)45 shouldNotThrowAny {46 pw.single { it in oracleAcceptedSpecialCharacters }47 }48 }49 test("Includes a number") {50 val pw = defaultGenerator.generate(includeSpecial = false, includeNumber = true)51 pw.forOne { it shouldBeInRange '0'..'9' }52 }53 }54 test("Generates password with the desired size") {55 target.generate(size = 12) shouldHaveLength 1256 target.generate(size = 25) shouldHaveLength 2557 }58 test("Defaults to size 8") {59 target.generate() shouldHaveLength 860 }61 test("Generates random, different passwords") {62 val passwords = List(100) { target.generate() }63 passwords.shouldBeUnique()64 }65})...

Full Screen

Full Screen

FindPairWithSumSpec.kt

Source:FindPairWithSumSpec.kt Github

copy

Full Screen

...38 checkAll(rangeAtLeastTwoNumbersLong) { xs ->39 xs.pairPermutations.size shouldBe (xs.size - 1).seriesSum40 }41 }42 test("all pairs unique") {43 checkAll(rangeAtLeastTwoNumbersLong) { xs ->44 xs.pairPermutations.shouldBeUnique()45 }46 }47 test("all elements present") {48 forAll(rangeAtLeastTwoNumbersLong) { xs ->49 val permutations = xs.pairPermutations50 xs.all { x ->51 permutations.find { pair -> x == pair.first || x == pair.second } != null52 }53 }54 }55 }56 }...

Full Screen

Full Screen

CollectionsTest.kt

Source:CollectionsTest.kt Github

copy

Full Screen

...29 }30 @Test31 fun requiredIntSet() {32 every { source.getList(any()) } returns listOf("80", "8080")33 CollectionsConfig(source).uniqueIds shouldBe setOf(80, 8080)34 verifyAll { source.getList(keyWithName("uniqueIds")) }35 }36 @Test37 fun defaultIntSet() {38 every { source.getList(any()) } returns null andThen listOf("80", "8080")39 CollectionsConfig(source).uniqueIdsWithDefaults shouldBe setOf(1, 2, 3)40 CollectionsConfig(source).uniqueIdsWithDefaults shouldBe setOf(80, 8080)41 verify(exactly = 2) { source.getList(keyWithName("uniqueIdsWithDefaults")) }42 }43 @Test44 fun optionalIntSet() {45 every { source.getList(any()) } returns null andThen listOf("80", "8080")46 CollectionsConfig(source).optionalUniqueIds should beNull()47 CollectionsConfig(source).optionalUniqueIds shouldBe setOf(80, 8080)48 verify(exactly = 2) { source.getList(keyWithName("optionalUniqueIds")) }49 }50}...

Full Screen

Full Screen

DiscoveryRoundTripTest.kt

Source:DiscoveryRoundTripTest.kt Github

copy

Full Screen

...41 ns.ensureStopped()42 ns.isRunning.get().shouldBeFalse()43 }44 @Test45 fun `determine unique name`() {46 val name = "kernel"47 val uniqueName = NameServer.determineUniqueName(name, listOf(name))48 uniqueName.shouldStartWith(name)49 uniqueName.shouldNotBeEqualComparingTo(name)50 }51}...

Full Screen

Full Screen

DailyBalancesPropKotestTest.kt

Source:DailyBalancesPropKotestTest.kt Github

copy

Full Screen

1import io.kotest.core.spec.style.DescribeSpec2import io.kotest.matchers.booleans.shouldBeFalse3import io.kotest.matchers.collections.shouldBeStrictlyIncreasingWith4import io.kotest.matchers.collections.shouldContainAll5import io.kotest.matchers.shouldBe6import io.kotest.property.Arb7import io.kotest.property.PropTestConfig8import io.kotest.property.arbitrary.*9import io.kotest.property.checkAll10import java.time.LocalDate11class DailyBalancesPropKotestTest : DescribeSpec({12 describe("properties") {13 val arbBalance = Arb.bind(Arb.localDate(), Arb.bigDecimal()) { d, a -> Balance(d, a) }14 fun arbUniqueList(minLength: Int = 0) = Arb.list(arbBalance, minLength..100).map { it.distinctBy { it.date } }15 it("contains all original elements") {16 checkAll(PropTestConfig(outputClassifications = true), arbUniqueList()) { list ->17 val result = list.expandToDaily()18 result.shouldContainAll(list)19 }20 }21 it("result is strictly increasing by the balance date") {22 checkAll(arbUniqueList()) { list ->23 val result = list.expandToDaily()24 result.shouldBeStrictlyIncreasingWith(compareBy { it.date })25 }26 }27 it("returns the whole range") {28 checkAll(arbUniqueList(minLength = 1)) { list ->29 val result = list.expandToDaily()30 result.map { it.date } shouldBe wholeDateRange(result.minOf { it.date }, result.maxOf { it.date })31 }32 }33 }34})...

Full Screen

Full Screen

TokenCreatorTest.kt

Source:TokenCreatorTest.kt Github

copy

Full Screen

1package io.github.servb.eShop.auth2import io.github.servb.eShop.auth.util.TokenCreator3import io.github.servb.eShop.util.kotest.*4import io.github.servb.eShop.util.ktor.withTestApplication5import io.kotest.core.spec.style.BehaviorSpec6import io.kotest.core.spec.style.FreeSpec7import io.kotest.matchers.collections.shouldBeUnique8import io.kotest.matchers.shouldBe9import io.kotest.matchers.string.shouldEndWith10import io.kotest.matchers.string.shouldNotBeEmpty11import io.ktor.application.Application12import io.ktor.http.HttpMethod13import io.ktor.http.HttpStatusCode14import io.ktor.server.testing.handleRequest15class TokenCreatorTest : FreeSpec({16 "test token creator" - {17 "generated token should be non-empty" {18 TokenCreator.createToken().shouldNotBeEmpty()19 }20 "generated tokens should be different" {21 val tokens = (1..10000).map { TokenCreator.createToken() }22 tokens.shouldBeUnique()23 }24 }25})...

Full Screen

Full Screen

unique

Using AI Code Generation

copy

Full Screen

1 import io.kotest.matchers.collections.shouldContain2 import io.kotest.matchers.collections.shouldContainAll3 import io.kotest.matchers.collections.shouldContainAnyOf4 import io.kotest.matchers.collections.shouldContainNoneOf5 import io.kotest.matchers.collections.shouldContainOnly6 import io.kotest.matchers.collections.shouldContainExactly7 import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder8 import io.kotest.matchers.collections.shouldContainExactlyInAnyOrderOnly9 import io.kotest.matchers.collections.shouldContainExactlyInOrder10 import io.kotest.matchers.collections.shouldContainExactlyInOrderOnly11 import io.kotest.matchers.collections.shouldContainInAnyOrder12 import io.kotest.matchers.collections.shouldContainInOrder13 import io.kotest.matchers.collections.shouldHaveAtLeastOneElement14 import io.kotest.matchers.collections.shouldHaveAtLeastSize15 import io.kotest.matchers.collections.shouldHaveAtMostSize16 import io.kotest.matchers.collections.shouldHaveCount17 import io.kotest.matchers.collections.shouldHaveEmptySize18 import io.kotest.matchers.collections.shouldHaveSingleElement19 import io.kotest.matchers.collections.shouldHaveSize20 import io.kotest.matchers.collections.shouldNotContain21 import io.kotest.matchers.collections.shouldNotContainAll22 import io.kotest.matchers.collections.shouldNotContainAnyOf23 import io.kotest.matchers.collections.shouldNotContainNoneOf24 import io.kotest.matchers.collections.shouldNotContainOnly25 import io.kotest.matchers.collections.shouldNotContainExactly26 import io.kotest.matchers.collections.shouldNotContainExactlyInAnyOrder27 import io.kotest.matchers.collections.shouldNotContainExactlyInAnyOrderOnly28 import io.kotest.matchers.collections.shouldNotContainExactlyInOrder29 import io.kotest.matchers.collections.shouldNotContainExactlyInOrderOnly30 import io.kotest.matchers.collections.shouldNotContainInAnyOrder31 import io.kotest.matchers.collections.shouldNotContainInOrder32 import io.kotest.matchers.collections.shouldNotHaveAtLeastOneElement33 import io.kotest.matchers.collections.shouldNotHaveAtLeastSize34 import io.kotest.matchers.collections

Full Screen

Full Screen

unique

Using AI Code Generation

copy

Full Screen

1 import io.kotest.matchers.collections.*2 import io.kotest.matchers.string.*3 import io.kotest.matchers.numerics.*4 import io.kotest.matchers.comparables.*5 import io.kotest.matchers.maps.*6 import io.kotest.matchers.booleans.*7 import io.kotest.matchers.longs.*8 import io.kotest.matchers.floats.*9 import io.kotest.matchers.doubles.*10 import io.kotest.matchers.bytes.*11 import io.kotest.matchers.chars.*12 import io.kotest.matchers.ints.*13 import io.kotest.matchers.shorts.*14 import io.kotest.matchers.types.*15 import io.kotest.matchers.throwable.*16 import io.kotest.matchers.sequences.*17 import io.kotest.matchers.file.*

Full Screen

Full Screen

unique

Using AI Code Generation

copy

Full Screen

1import io.kotest.matchers.collections.shouldContain2import io.kotest.assertions.throwables.shouldThrow3import io.kotest.core.spec.style.StringSpec4import io.kotest.engine.spec.style.StringSpec5import io.kotest.property.Arb6import io.kotest.property.arbitrary.int7import io.kotest.matchers.string.shouldContain8import io.kotest.core.spec.style.StringSpec9import io.kotest.matchers.shouldBe10import io.kotest.core.spec.style.StringSpec11import io.kotest.matchers.shouldBe12import io.kotest.core.spec.style.StringSpec13import io.kotest.matchers.shouldBe14import io.kotest.core.spec.style.StringSpec15import io.kotest.matchers.shouldBe16import io.kotest.core.spec.style.StringSpec17import io.kotest.matchers.shouldBe18import io.kotest.core.spec.style.StringSpec19import io.kotest.matchers.shouldBe20import io.kotest.core.spec.style.StringSpec21import io.kotest.matchers.shouldBe22import io.kotest.core.spec.style.StringSpec23import io.kotest.matchers.shouldBe24import io.kotest.core.spec.style.StringSpec25import io.kotest.matchers.shouldBe26import

Full Screen

Full Screen

unique

Using AI Code Generation

copy

Full Screen

1class UniqueTest : FunSpec({2test("unique") {3val list = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10)4list should haveUniqueElements()5list should haveUniqueElements { it % 2 }6}7})8val list = listOf(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10)9list should haveUniqueElements()10list should haveUniqueElements(equals = { a, b -> a % 2 == b % 2 })

Full Screen

Full Screen

unique

Using AI Code Generation

copy

Full Screen

1import io.kotest.matchers.collections.shouldHaveSize2class MyTest : FunSpec({3 test("some test") {4 val list = listOf(1, 2, 3)5 }6})7import io.kotest.matchers.ints.shouldBeEven8class MyTest : FunSpec({9 test("some test") {10 }11})12import io.kotest.matchers.longs.shouldBeEven13class MyTest : FunSpec({14 test("some test") {15 }16})17import io.kotest.matchers.floats.shouldBeZero18class MyTest : FunSpec({19 test("some test") {20 }21})22import io.kotest.matchers.doubles.shouldBeZero23class MyTest : FunSpec({24 test("some test") {25 }26})27import io.kotest.matchers.booleans.shouldBeTrue28class MyTest : FunSpec({29 test("some test") {30 }31})32import io.kotest.matchers.chars.shouldBeDigit33class MyTest : FunSpec({34 test("some test") {35 }36})37import io.kotest.matchers.bytes.shouldBeEven38class MyTest : FunSpec({39 test("some test") {40 2.toByte() shouldBeEven41 }42})43import io.kotest.matchers.shorts.shouldBeEven44class MyTest : FunSpec({45 test("some test") {46 2.toShort() shouldBeEven47 }48})

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.

Run Kotest automation tests on LambdaTest cloud grid

Perform automation testing on 3000+ real desktop and mobile devices online.

Try LambdaTest Now !!

Get 100 minutes of automation test minutes FREE!!

Next-Gen App & Browser Testing Cloud

Was this article helpful?

Helpful

NotHelpful