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
Merged

Conversation

MarkusAmshove
Copy link
Owner

@MarkusAmshove MarkusAmshove commented Jan 3, 2017

Issue: #17

  • shouldBeGreaterOrEqualTo
  • shouldBeGreaterThan
  • shouldBeLessOrEqualTo
  • shouldBeLessThan
  • shouldBePositive
  • shouldBeNegative
  • shouldBeInRange

@MarkusAmshove MarkusAmshove self-assigned this Jan 3, 2017
@MarkusAmshove
Copy link
Owner Author

I'm finished implementing those methods.

What do you think @goreRatzete ?

You can see those "in action" in the unittests:
https://github.com/MarkusAmshove/Kluent/tree/numerical-assertions/src/test/kotlin/org/amshove/kluent/tests/assertions/numerical

@AndreasVolkmann
Copy link
Collaborator

AndreasVolkmann commented Jan 5, 2017

Looking good!

What about something like this for ranges also ?

infix fun Number.shouldBeInRange(range: IntRange) = if (this in range) Unit else throw Exception()

@Test
fun shouldbe() {
    5 shouldBeInRange 4..10

    -100 shouldBeInRange -200..1000

}

@MarkusAmshove
Copy link
Owner Author

You're right, didn't know about that.

There seem to be a couple that we can use:

https://kotlinlang.org/api/latest/jvm/stdlib/kotlin.ranges/index.html

@AndreasVolkmann
Copy link
Collaborator

Looks good!

@MarkusAmshove MarkusAmshove merged commit 58311e8 into master Jan 6, 2017
@MarkusAmshove MarkusAmshove changed the title WIP: Introduce numerical comparisons Introduce numerical comparisons Jan 6, 2017
@MarkusAmshove MarkusAmshove deleted the numerical-assertions branch February 16, 2017 16:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants