Added shouldBeZero and shouldNotBeZero matcher for number types (#819)#848
Merged
sksamuel merged 6 commits intoJun 23, 2019
Merged
Conversation
hjJunior
approved these changes
Jun 21, 2019
hjJunior
left a comment
There was a problem hiding this comment.
It looks great, just give another look about new line at end of file
sksamuel
requested changes
Jun 21, 2019
sksamuel
left a comment
Member
There was a problem hiding this comment.
The zero stuff is awesome and can be merged.
The float stuff needs change as per request.
Thanks!
Member
|
Yes definitely.
…On Fri, 21 Jun 2019, 11:55 Gustavo Fão Valvassori, ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In
kotlintest-assertions/src/main/kotlin/io/kotlintest/matchers/FloatMatchers.kt
<#848 (comment)>:
>
infix fun Float.plusOrMinus(tolerance: Float): FloatToleranceMatcher = FloatToleranceMatcher(this, tolerance)
fun exactly(d: Float): Matcher<Float> = object : Matcher<Float> {
override fun test(value: Float) = Result(value == d, "$value is not equal to expected value $d", "$value should not be equal to $d")
}
+fun lt(x: Float) = beLessThan(x)
+fun beLessThan(x: Float) = object : Matcher<Float> {
+ override fun test(value: Float) = Result(value < x, "$value should be < $x", "$value should not be < $x")
+}
+
+fun lte(x: Float) = beLessThanOrEqualTo(x)
Só, it's preferable to keep these rules in the floats package?
—
You are receiving this because your review was requested.
Reply to this email directly, view it on GitHub
<#848>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAFVSGRN23OJ4H6RTVIRCR3P3UBWPANCNFSM4H2C4DAA>
.
|
Contributor
Author
|
@sksamuel can you see if it's ok now? |
Member
|
👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #819
I've also added the same matcher for floats (idn if it was necessary, because if it was not described on the task).
Also, there was a matcher file with just a couple of rules on the
numericspackage, so I joined with the existing one with more rules. Did the same with floats with to keep the same pattern from other numerics.