Skip to content

Commit

Permalink
Merge pull request #830 from mai2412/#676-add-samples-comparable-asse…
Browse files Browse the repository at this point in the history
…rtions-infix

Resolved #676
  • Loading branch information
robstoll authored Mar 5, 2021
2 parents 810fb6f + 2b31018 commit a9f8776
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import ch.tutteli.atrium.logic.*
* The comparison is carried out with [Comparable.compareTo].
*
* @return an [Expect] for the subject of `this` expectation.
*
* @sample ch.tutteli.atrium.api.infix.en_GB.samples.deprecated.ComparableAssertionSamples.isLessThan
*/
infix fun <T : Comparable<T>> Expect<T>.isLessThan(expected: T): Expect<T> =
_logicAppend { isLessThan(expected) }
Expand All @@ -17,6 +19,8 @@ infix fun <T : Comparable<T>> Expect<T>.isLessThan(expected: T): Expect<T> =
* The comparison is carried out with [Comparable.compareTo].
*
* @return an [Expect] for the subject of `this` expectation.
*
* @sample ch.tutteli.atrium.api.infix.en_GB.samples.deprecated.ComparableAssertionSamples.isLessThanOrEqual
*/
infix fun <T : Comparable<T>> Expect<T>.isLessThanOrEqual(expected: T): Expect<T> =
_logicAppend { isLessThanOrEqual(expected) }
Expand All @@ -26,6 +30,8 @@ infix fun <T : Comparable<T>> Expect<T>.isLessThanOrEqual(expected: T): Expect<T
* The comparison is carried out with [Comparable.compareTo].
*
* @return an [Expect] for the subject of `this` expectation.
*
* @sample ch.tutteli.atrium.api.infix.en_GB.samples.deprecated.ComparableAssertionSamples.isGreaterThan
*/
infix fun <T : Comparable<T>> Expect<T>.isGreaterThan(expected: T): Expect<T> =
_logicAppend { isGreaterThan(expected) }
Expand All @@ -35,6 +41,8 @@ infix fun <T : Comparable<T>> Expect<T>.isGreaterThan(expected: T): Expect<T> =
* The comparison is carried out with [Comparable.compareTo].
*
* @return an [Expect] for the subject of `this` expectation.
*
* @sample ch.tutteli.atrium.api.infix.en_GB.samples.deprecated.ComparableAssertionSamples.isGreaterThanOrEqual
*/
infix fun <T : Comparable<T>> Expect<T>.isGreaterThanOrEqual(expected: T): Expect<T> =
_logicAppend { isGreaterThanOrEqual(expected) }
Expand All @@ -46,6 +54,8 @@ infix fun <T : Comparable<T>> Expect<T>.isGreaterThanOrEqual(expected: T): Expec
* @return an [Expect] for the subject of `this` expectation.
*
* @since 0.13.0
*
* @sample ch.tutteli.atrium.api.infix.en_GB.samples.deprecated.ComparableAssertionSamples.isEqualComparingTo
*/
infix fun <T : Comparable<T>> Expect<T>.isEqualComparingTo(expected: T): Expect<T> =
_logicAppend { isEqualComparingTo(expected) }
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
//TODO remove file with 1.0.0
@file:Suppress("DEPRECATION")

package ch.tutteli.atrium.api.infix.en_GB.samples.deprecated

import ch.tutteli.atrium.api.infix.en_GB.isEqualComparingTo
import ch.tutteli.atrium.api.infix.en_GB.isGreaterThan
import ch.tutteli.atrium.api.infix.en_GB.isLessThan
import ch.tutteli.atrium.api.infix.en_GB.isLessThanOrEqual
import ch.tutteli.atrium.api.infix.en_GB.samples.fails
import ch.tutteli.atrium.api.verbs.internal.expect
import kotlin.test.Test

class ComparableAssertionSamples {

@Test
fun isLessThan() {
expect(1) isLessThan 2

fails {
expect(2) isLessThan 1
}
}

@Test
fun isLessThanOrEqual() {
expect(1) isLessThanOrEqual 2
expect(2) isLessThanOrEqual 2

fails {
expect(2) isLessThanOrEqual 1
}
}

@Test
fun isGreaterThan() {
expect(2) isGreaterThan 1

fails {
expect(2) isGreaterThan 2
}
}

@Test
fun isGreaterThanOrEqual() {
expect(2) isEqualComparingTo 2

fails {
expect(1) isEqualComparingTo 2
expect(2) isEqualComparingTo 1
}
}

@Test
fun isEqualComparingTo() {
expect(2) isEqualComparingTo 2

fails {
expect(1) isEqualComparingTo 2
expect(2) isEqualComparingTo 1
}
}
}

0 comments on commit a9f8776

Please sign in to comment.