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

Double should have oppostive matchers for shouldBePositive and shouldBeNegative #435

Closed
LeoColman opened this issue Oct 9, 2018 · 2 comments
Labels
enhancement ✨ Suggestions for adding new features or improving existing ones.
Milestone

Comments

@LeoColman
Copy link
Member

Most of the matchers have a opposite matcher. For example

Double.shouldBeLessThan
Double.shouldNotBeLessThan

This behavior should be added to the shouldBePositive and shouldBeNegative matchers.

A use case for this, is for example matching the number 0.0;

Zero is not positive, and it should match shouldNotBePositive. However, the opposite of this is not shouldBeNegative, as it won't match 0.0 (zero is also not negative).


I propose that we add the following matchers to the Double Matchers:

Double.shouldNotBePositive
Double.shouldNotBeNegative

ATTENTION: These matchers might also be useful for Int, Float, Short.... But I didn't take a look at them for now. It's a point to be kept in the radar!

@sksamuel sksamuel added the enhancement ✨ Suggestions for adding new features or improving existing ones. label Oct 9, 2018
@sksamuel sksamuel added this to the 3.2 milestone Oct 9, 2018
@raverona
Copy link
Contributor

raverona commented Oct 10, 2018

I created a pull request to fix this issue, it also creates a DoubleMatchersTest.kt on a new com.sksamuel.kotlintest.matchers.doubles package inside the kotlintest-tests/kotlintest-tests-core module as I talked with @Kerooker beforehand and it's the aproach he is taking for these tests

@raverona
Copy link
Contributor

Let me know if you guys think more test cases are necessary for this feature

sksamuel pushed a commit that referenced this issue Oct 11, 2018
#437)

* Add unit tests for new matchers 'shouldNotBePositive', 'shouldNotBeNegative' and unit tests for both

Fixes: #435

* Fix package name for "DoubleMatchersTest.kt"

* Add documentation for the following double matchers: 'shouldBePositive', 'shouldNotBePositive', 'shouldBeNegative' and 'shouldNotBeNegative'

* Change the order of the 'shouldNotBePositive' and 'shouldNotBeNegative' tests to make it consistent through every test

* Fix unit tests implementation for matchers "shouldNotBePositive" and "shouldNotBeNegative"

the tests for cases where the implementation should fail were done all inside a "shouldThrow" block, this is not a correct approach since after the first thrown exception the subsequent tests will not execute and the test will pass without asserting all test cases

* Correct documentation for matchers "shouldNotBePositive" and "shouldNotBeNegative"

the documentation said:
- "shouldBeNotPositive" when the correct is "shouldNotBePositive"
- "shouldBeNotNegative" when the correct is "shouldNotBeNegative"
@sksamuel sksamuel mentioned this issue Dec 3, 2018
17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement ✨ Suggestions for adding new features or improving existing ones.
Projects
None yet
Development

No branches or pull requests

3 participants