From 44367d6b163b894417db9e71ef21bae9cc1e85da Mon Sep 17 00:00:00 2001 From: Tim Acosta Date: Sun, 7 Nov 2021 17:10:46 +0000 Subject: [PATCH] re-done based on comments in PR https://github.com/robstoll/atrium/pull/1031 --- .../samples/OptionalExpectationSamples.kt | 38 +++++++++---------- 1 file changed, 17 insertions(+), 21 deletions(-) diff --git a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/OptionalExpectationSamples.kt b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/OptionalExpectationSamples.kt index b1bac2ee32..997654dae9 100644 --- a/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/OptionalExpectationSamples.kt +++ b/apis/fluent-en_GB/atrium-api-fluent-en_GB-jvm/src/test/kotlin/ch/tutteli/atrium/api/fluent/en_GB/samples/OptionalExpectationSamples.kt @@ -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) + } + } } - - }