Skip to content

Commit

Permalink
Boolean isTrue / isFalse
Browse files Browse the repository at this point in the history
Issue #29
  • Loading branch information
robfletcher committed May 29, 2018
1 parent 650ddd6 commit 20c92cf
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
9 changes: 9 additions & 0 deletions strikt-core/src/main/kotlin/strikt/assertions/Boolean.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package strikt.assertions

import strikt.api.Assertion

fun Assertion<Boolean>.isTrue() =
passesIf("is true") { this }

fun Assertion<Boolean>.isFalse() =
passesIf("is false") { !this }
33 changes: 33 additions & 0 deletions strikt-core/src/test/kotlin/strikt/assertions/BooleanAssertions.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package strikt.assertions

import org.jetbrains.spek.api.Spek
import org.jetbrains.spek.api.dsl.describe
import org.jetbrains.spek.api.dsl.it
import strikt.api.expect
import strikt.fails

@Suppress("SimplifyBooleanWithConstants")
internal object BooleanAssertions : Spek({
describe("assertions on ${Boolean::class.simpleName}") {
describe("isTrue assertion") {
it("passes when the subject is true") {
expect("a" == "a").isTrue()
}
it("fails when the subject is false") {
fails {
expect("a" == "A").isTrue()
}
}
}
describe("isFalse assertion") {
it("passes when the subject is false") {
expect("a" == "A").isFalse()
}
it("fails when the subject is false") {
fails {
expect("a" == "a").isFalse()
}
}
}
}
})

0 comments on commit 20c92cf

Please sign in to comment.