diff options
| author | test@dangofactory.cos <you@example.com> | 2026-08-20 16:57:18 +0000 |
|---|---|---|
| committer | test@dangofactory.cos <you@example.com> | 2026-08-20 16:57:18 +0000 |
| commit | 50ce5d5e6cd0d720ff437d35eace545816848428 (patch) | |
| tree | b59af206a36265cf081945e434900b32b0c43edd /core/testing/src/main | |
| download | monocles_mail-50ce5d5e6cd0d720ff437d35eace545816848428.tar.gz monocles_mail-50ce5d5e6cd0d720ff437d35eace545816848428.tar.bz2 monocles_mail-50ce5d5e6cd0d720ff437d35eace545816848428.zip | |
Inital
Diffstat (limited to 'core/testing/src/main')
| -rw-r--r-- | core/testing/src/main/kotlin/app/k9mail/core/testing/TestClock.kt | 19 | ||||
| -rw-r--r-- | core/testing/src/main/kotlin/assertk/assertions/ListExtensions.kt | 13 |
2 files changed, 32 insertions, 0 deletions
diff --git a/core/testing/src/main/kotlin/app/k9mail/core/testing/TestClock.kt b/core/testing/src/main/kotlin/app/k9mail/core/testing/TestClock.kt new file mode 100644 index 0000000..508b2c4 --- /dev/null +++ b/core/testing/src/main/kotlin/app/k9mail/core/testing/TestClock.kt @@ -0,0 +1,19 @@ +package app.k9mail.core.testing + +import kotlin.time.Duration +import kotlinx.datetime.Clock +import kotlinx.datetime.Instant + +class TestClock( + private var currentTime: Instant = Clock.System.now(), +) : Clock { + override fun now(): Instant = currentTime + + fun changeTimeTo(time: Instant) { + currentTime = time + } + + fun advanceTimeBy(duration: Duration) { + currentTime += duration + } +} diff --git a/core/testing/src/main/kotlin/assertk/assertions/ListExtensions.kt b/core/testing/src/main/kotlin/assertk/assertions/ListExtensions.kt new file mode 100644 index 0000000..2ab42b2 --- /dev/null +++ b/core/testing/src/main/kotlin/assertk/assertions/ListExtensions.kt @@ -0,0 +1,13 @@ +package assertk.assertions + +import assertk.Assert +import assertk.assertions.support.expected +import assertk.assertions.support.show + +fun <T> Assert<List<T>>.containsNoDuplicates() = given { actual -> + val seen: MutableSet<T> = mutableSetOf() + val duplicates = actual.filter { !seen.add(it) } + if (duplicates.isNotEmpty()) { + expected("to contain no duplicates but found: ${show(duplicates)}") + } +} |
