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

Suggestion: Add BigDecimal.shouldBeCloseTo #155

Closed
ChristianIvicevic opened this issue Sep 9, 2019 · 3 comments
Closed

Suggestion: Add BigDecimal.shouldBeCloseTo #155

ChristianIvicevic opened this issue Sep 9, 2019 · 3 comments

Comments

@ChristianIvicevic
Copy link
Contributor

I ran into a scenario wherein I'd like to assert a BigDecimal to be within range of a target value with a specified error margin. Thus I added the following custom extension:

fun BigDecimal.shouldBeCloseTo(
    target: BigDecimal,
    error: BigDecimal
) = shouldBeInRange(target - error, target + error)

I expected this to already be a part of the library, but it wasn't. Have you considered adding this to the library?

@MarkusAmshove
Copy link
Owner

That would be a great addition and I will gladly merge a PR if you're willing to contribute :-)

@ChristianIvicevic
Copy link
Contributor Author

I'll be looking into it, it will take slightly more work for the other numerical types to make it possibly generic if possible, but I'd like to contribute nonetheless once I find the time.

@MarkusAmshove
Copy link
Owner

Thank you for the contribution. I've just released it as v1.55 :-)

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

No branches or pull requests

2 participants