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

Implement Is between functionality #320

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

elirehema
Copy link

FIX Add functionality to compare if a decimal value is between two decimals #319

FIX Add functionality to compare if a decimal value is between two decimals shopspring#319
Copy link
Member

@mwoss mwoss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for the late review and thanks a lot for your contribution!

@@ -900,12 +895,18 @@ func (d Decimal) LessThanOrEqual(d2 Decimal) bool {
return cmp == -1 || cmp == 0
}

// Betwee (LTE) return true when d is between d1 and d2 inclusive
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Go doc should start with the method name, so I'd suggest:
IsBetween returns true when d is between (inclusive) d1 and d2, otherwise false.

@@ -2542,6 +2542,13 @@ func TestDecimal_Equalities(t *testing.T) {
if c.LessThanOrEqual(b) {
t.Errorf("%q should not be less than or equal %q", a, b)
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you add a separate test case for IsBetween where you verify the correctness of left and right bound inclusiveness?

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.

None yet

2 participants