Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce numerical comparisons #18

Merged
merged 11 commits into from
Jan 6, 2017
94 changes: 94 additions & 0 deletions src/main/kotlin/org/amshove/kluent/Assertions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,100 @@ infix fun CharSequence.shouldNotContain(theOther: CharSequence) = this `should n
infix fun CharSequence.shouldNotMatch(regex: String) = this `should not match` regex
infix fun CharSequence.shouldNotMatch(regex: Regex) = this `should not match` regex

infix fun Byte.shouldBeGreaterThan(theOther: Byte) = this `should be greater than` theOther
infix fun Short.shouldBeGreaterThan(theOther: Short) = this `should be greater than` theOther
infix fun Int.shouldBeGreaterThan(theOther: Int) = this `should be greater than` theOther
infix fun Long.shouldBeGreaterThan(theOther: Long) = this `should be greater than` theOther
infix fun Float.shouldBeGreaterThan(theOther: Float) = this `should be greater than` theOther
infix fun Double.shouldBeGreaterThan(theOther: Double) = this `should be greater than` theOther

infix fun Byte.shouldNotBeGreaterThan(theOther: Byte) = this `should not be greater than` theOther
infix fun Short.shouldNotBeGreaterThan(theOther: Short) = this `should not be greater than` theOther
infix fun Int.shouldNotBeGreaterThan(theOther: Int) = this `should not be greater than` theOther
infix fun Long.shouldNotBeGreaterThan(theOther: Long) = this `should not be greater than` theOther
infix fun Float.shouldNotBeGreaterThan(theOther: Float) = this `should not be greater than` theOther
infix fun Double.shouldNotBeGreaterThan(theOther: Double) = this `should not be greater than` theOther

infix fun Byte.shouldBeGreaterOrEqualTo(theOther: Byte) = this `should be greater or equal to` theOther
infix fun Short.shouldBeGreaterOrEqualTo(theOther: Short) = this `should be greater or equal to` theOther
infix fun Int.shouldBeGreaterOrEqualTo(theOther: Int) = this `should be greater or equal to` theOther
infix fun Long.shouldBeGreaterOrEqualTo(theOther: Long) = this `should be greater or equal to` theOther
infix fun Float.shouldBeGreaterOrEqualTo(theOther: Float) = this `should be greater or equal to` theOther
infix fun Double.shouldBeGreaterOrEqualTo(theOther: Double) = this `should be greater or equal to` theOther

infix fun Byte.shouldNotBeGreaterOrEqualTo(theOther: Byte) = this `should not be greater or equal to` theOther
infix fun Short.shouldNotBeGreaterOrEqualTo(theOther: Short) = this `should not be greater or equal to` theOther
infix fun Int.shouldNotBeGreaterOrEqualTo(theOther: Int) = this `should not be greater or equal to` theOther
infix fun Long.shouldNotBeGreaterOrEqualTo(theOther: Long) = this `should not be greater or equal to` theOther
infix fun Float.shouldNotBeGreaterOrEqualTo(theOther: Float) = this `should not be greater or equal to` theOther
infix fun Double.shouldNotBeGreaterOrEqualTo(theOther: Double) = this `should not be greater or equal to` theOther

infix fun Byte.shouldBeLessThan(theOther: Byte) = this `should be less than` theOther
infix fun Short.shouldBeLessThan(theOther: Short) = this `should be less than` theOther
infix fun Int.shouldBeLessThan(theOther: Int) = this `should be less than` theOther
infix fun Long.shouldBeLessThan(theOther: Long) = this `should be less than` theOther
infix fun Float.shouldBeLessThan(theOther: Float) = this `should be less than` theOther
infix fun Double.shouldBeLessThan(theOther: Double) = this `should be less than` theOther

infix fun Byte.shouldNotBeLessThan(theOther: Byte) = this `should not be less than` theOther
infix fun Short.shouldNotBeLessThan(theOther: Short) = this `should not be less than` theOther
infix fun Int.shouldNotBeLessThan(theOther: Int) = this `should not be less than` theOther
infix fun Long.shouldNotBeLessThan(theOther: Long) = this `should not be less than` theOther
infix fun Float.shouldNotBeLessThan(theOther: Float) = this `should not be less than` theOther
infix fun Double.shouldNotBeLessThan(theOther: Double) = this `should not be less than` theOther

infix fun Byte.shouldBeLessOrEqualTo(theOther: Byte) = this `should be less or equal to` theOther
infix fun Short.shouldBeLessOrEqualTo(theOther: Short) = this `should be less or equal to` theOther
infix fun Int.shouldBeLessOrEqualTo(theOther: Int) = this `should be less or equal to` theOther
infix fun Long.shouldBeLessOrEqualTo(theOther: Long) = this `should be less or equal to` theOther
infix fun Float.shouldBeLessOrEqualTo(theOther: Float) = this `should be less or equal to` theOther
infix fun Double.shouldBeLessOrEqualTo(theOther: Double) = this `should be less or equal to` theOther

infix fun Byte.shouldNotBeLessOrEqualTo(theOther: Byte) = this `should not be less or equal to` theOther
infix fun Short.shouldNotBeLessOrEqualTo(theOther: Short) = this `should not be less or equal to` theOther
infix fun Int.shouldNotBeLessOrEqualTo(theOther: Int) = this `should not be less or equal to` theOther
infix fun Long.shouldNotBeLessOrEqualTo(theOther: Long) = this `should not be less or equal to` theOther
infix fun Float.shouldNotBeLessOrEqualTo(theOther: Float) = this `should not be less or equal to` theOther
infix fun Double.shouldNotBeLessOrEqualTo(theOther: Double) = this `should not be less or equal to` theOther

fun Byte.shouldBePositive() = this.`should be positive`()
fun Short.shouldBePositive() = this.`should be positive`()
fun Int.shouldBePositive() = this.`should be positive`()
fun Long.shouldBePositive() = this.`should be positive`()
fun Float.shouldBePositive() = this.`should be positive`()
fun Double.shouldBePositive() = this.`should be positive`()

fun Byte.shouldBeNegative() = this.`should be negative`()
fun Short.shouldBeNegative() = this.`should be negative`()
fun Int.shouldBeNegative() = this.`should be negative`()
fun Long.shouldBeNegative() = this.`should be negative`()
fun Float.shouldBeNegative() = this.`should be negative`()
fun Double.shouldBeNegative() = this.`should be negative`()

fun Byte.shouldBeInRange(lowerBound: Byte, upperBound: Byte) = this.`should be in range`(lowerBound, upperBound)
fun Short.shouldBeInRange(lowerBound: Short, upperBound: Short) = this.`should be in range`(lowerBound, upperBound)
fun Int.shouldBeInRange(lowerBound: Int, upperBound: Int) = this.`should be in range`(lowerBound, upperBound)
fun Long.shouldBeInRange(lowerBound: Long, upperBound: Long) = this.`should be in range`(lowerBound, upperBound)
fun Float.shouldBeInRange(lowerBound: Float, upperBound: Float) = this.`should be in range`(lowerBound, upperBound)
fun Double.shouldBeInRange(lowerBound: Double, upperBound: Double) = this.`should be in range`(lowerBound, upperBound)

fun Byte.shouldNotBeInRange(lowerBound: Byte, upperBound: Byte) = this.`should not be in range`(lowerBound, upperBound)
fun Short.shouldNotBeInRange(lowerBound: Short, upperBound: Short) = this.`should not be in range`(lowerBound, upperBound)
fun Int.shouldNotBeInRange(lowerBound: Int, upperBound: Int) = this.`should not be in range`(lowerBound, upperBound)
fun Long.shouldNotBeInRange(lowerBound: Long, upperBound: Long) = this.`should not be in range`(lowerBound, upperBound)
fun Float.shouldNotBeInRange(lowerBound: Float, upperBound: Float) = this.`should not be in range`(lowerBound, upperBound)
fun Double.shouldNotBeInRange(lowerBound: Double, upperBound: Double) = this.`should not be in range`(lowerBound, upperBound)

infix fun Byte.shouldBeInRange(range: IntRange) = this.`should be in range`(range)
infix fun Short.shouldBeInRange(range: IntRange) = this.`should be in range`(range)
infix fun Int.shouldBeInRange(range: IntRange) = this.`should be in range`(range)
infix fun Long.shouldBeInRange(range: LongRange) = this.`should be in range`(range)

infix fun Byte.shouldNotBeInRange(range: IntRange) = this.`should not be in range`(range)
infix fun Short.shouldNotBeInRange(range: IntRange) = this.`should not be in range`(range)
infix fun Int.shouldNotBeInRange(range: IntRange) = this.`should not be in range`(range)
infix fun Long.shouldNotBeInRange(range: LongRange) = this.`should not be in range`(range)

infix fun <T> Array<T>?.shouldEqual(theOther: Array<T>?) = this `should equal` theOther
infix fun <T> Iterable<T>?.shouldEqual(theOther: Iterable<T>?) = this `should equal` theOther

Expand Down
Loading