Skip to content
Merged
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
Expand Up @@ -14,6 +14,7 @@ object NumberStatements {
override val failureMessage: String
get() = "The subject is less than or equal to $value"
}

fun <T:Number> isAtMost(value: T) = object: Statement<T> {
override fun evaluate(subject: T): Boolean {
return subject.toDouble() <= value.toDouble()
Expand All @@ -22,4 +23,49 @@ object NumberStatements {
override val failureMessage: String
get() = "The subject is greater than $value"
}

fun <T:Number> isLessThan(other: T) = object: Statement<T> {
override val failureMessage: String
get() = "The subject is greater than or equal to $other."

override fun evaluate(subject: T): Boolean {
return subject.toDouble() < other.toDouble()
}
}

fun <T:Number> isAtLeast(value: T) = object: Statement<T> {
override fun evaluate(subject: T): Boolean {
return subject.toDouble() >= value.toDouble()
}

override val failureMessage: String
get() = "The subject is less than $value"
}

fun isEven() = object: Statement<Int> {
override val failureMessage: String
get() = "Subject is not even."

override fun evaluate(subject: Int): Boolean {
return subject % 2 == 0
}
}

fun isOdd() = object: Statement<Int> {
override val failureMessage: String
get() = "Subject is not odd."

override fun evaluate(subject: Int): Boolean {
return subject % 2 != 0
}
}

fun isDividedBy(divisor: Int) = object: Statement<Int> {
override val failureMessage: String
get() = "Subject is not evenly divided by $divisor."

override fun evaluate(subject: Int): Boolean {
return subject % divisor == 0
}
}
}
23 changes: 1 addition & 22 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,38 +1,17 @@
[versions]
agp = "8.3.0"
androidx-compose = "1.8.2"
compose = "1.5.12"
dokka = "1.9.20"
jupiter = "5.10.2"
kass = "0.3.1"
koin = "3.5.3"
koin-bom = "3.5.3"
kass = "0.4.0"
kotlin = "2.0.0"
kotlinx-datetime = "0.4.0"
kotlinx-coroutines = "1.8.0"
mockk = "1.12.0"
truth = "1.1.3"

[libraries]
androidx-activityCompose = { module = "androidx.activity:activity-compose", version.ref = "androidx-compose" }
jupiter = { module = "org.junit.jupiter:junit-jupiter", version.ref = "jupiter" }
koin-android = { module = "io.insert-koin:koin-android", version.ref = "koin" }
koin-bom = { module = "io.insert-koin:koin-bom", version.ref = "koin-bom" }
koin-core = { module = "io.insert-koin:koin-core", version.ref = "koin" }
koin-compose = { module = "io.insert-koin:koin-androidx-compose", version.ref = "koin" }
koin-ktor = { module = "io.insert-koin:koin-ktor" }
koin-test = { module = "io.insert-koin:koin-test", version.ref = "koin" }
kotlin-test = { module = "org.jetbrains.kotlin:kotlin-test", version.ref = "kotlin" }
kotlinx-dateTime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.ref = "kotlinx-datetime" }
kotlinx-coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "kotlinx-coroutines" }
mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
truth = { module = "com.google.truth:truth", version.ref = "truth" }

[plugins]
androidApplication = { id = "com.android.application", version.ref = "agp" }
androidLibrary = { id = "com.android.library", version.ref = "agp" }
composeMultiplatform = { id = "org.jetbrains.compose", version.ref = "compose" }
dokka = { id = "org.jetbrains.dokka", version.ref = "dokka" }
kotlinAndroid = { id = "org.jetbrains.kotlin.android", version.ref = "kotlin" }
kotlinJvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" }
kotlinMultiplatform = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
Loading