-
Notifications
You must be signed in to change notification settings - Fork 623
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
`containDuplicates` should list duplicates that violate the assumption, for instance: ``` shouldThrowAny { listOf(1, 2, 3, 4, 2, 1) shouldNot containDuplicates() }.shouldHaveMessage("Collection should not contain duplicates, but has some: [1, 2]") ```
- Loading branch information
1 parent
77db319
commit f524b62
Showing
3 changed files
with
44 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...rtions-core/src/jvmTest/kotlin/com/sksamuel/kotest/matchers/collections/DuplicatesTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
package com.sksamuel.kotest.matchers.collections | ||
|
||
import io.kotest.core.spec.style.StringSpec | ||
import io.kotest.matchers.collections.duplicates | ||
import io.kotest.matchers.collections.shouldBeEmpty | ||
import io.kotest.matchers.collections.shouldContainExactlyInAnyOrder | ||
|
||
class DuplicatesTest : StringSpec(){ | ||
init { | ||
"return empty list" { | ||
listOf(1, 2, 3, 4, null).duplicates().shouldBeEmpty() | ||
} | ||
|
||
"return not null duplicates" { | ||
listOf(1, 2, 3, 4, 3, 2).duplicates() shouldContainExactlyInAnyOrder listOf(2, 3) | ||
} | ||
|
||
"return null duplicates" { | ||
listOf(1, 2, 3, null, 4, 3, null, 2).duplicates() shouldContainExactlyInAnyOrder listOf(2, 3, null) | ||
} | ||
} | ||
} |