Skip to content

Commit

Permalink
re-done based on comments in PR #1031
Browse files Browse the repository at this point in the history
  • Loading branch information
timacosta committed Nov 7, 2021
1 parent 3ea1c26 commit 44367d6
Showing 1 changed file with 17 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,39 +19,35 @@ class OptionalExpectationSamples {
}
}


@Test
fun toBePresentFeature() {
val notEmpty: String? = "toBePresentFeature"
val opt = Optional.ofNullable(notEmpty)

val opt = Optional.of(1)

expect(opt).toBePresent()
expect(opt)
.toBePresent() //subject is now of type Int

fails {
expect(opt).toBeEmpty()
expect(opt).toBeEmpty() //fails
}
}

}

@Test
fun toBePresent() {
val x = 10
val y = 5

val optX = Optional.ofNullable(x)
val optY = Optional.ofNullable(y)

expect(optX) {
val sum = optX.get() + optY.get()

feature("toBeLessThan") { sum }.toBeLessThan(20)
feature("toBeGreaterThan") { sum }.toBeGreaterThan(5)
feature("toBeGreaterThanOrEqualTo") { sum }.toBeGreaterThanOrEqualTo(15)

}.toBePresent()
val opt = Optional.of(10)

expect(opt).toBePresent() {
toBeGreaterThan(0)
toBeLessThan(11)
}

fails {
expect(opt).toBePresent() {
toBeGreaterThan(15)
toBeLessThan(9)
}
}
}


}

0 comments on commit 44367d6

Please sign in to comment.