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

decimal: impement Sum and Prod functions #54

Merged
merged 3 commits into from
Nov 16, 2024
Merged

decimal: impement Sum and Prod functions #54

merged 3 commits into from
Nov 16, 2024

Conversation

eapenkin
Copy link
Collaborator

No description provided.

@eapenkin eapenkin merged commit addadd5 into main Nov 16, 2024
7 checks passed
@eapenkin eapenkin deleted the sum-prod-methods branch November 16, 2024 13:42
func(t *testing.T, dneg bool, dscale int, dcoef uint64, eneg bool, escale int, ecoef uint64) {
d, err := newSafe(dneg, fint(dcoef), dscale)
if err != nil {
t.Skip()

Choose a reason for hiding this comment

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

Why skipping?

Add a comment if it's normal, otherwise please fix it

It it's something you consider as a prerequisites condition before testing something else, it should fail

}
e, err := newSafe(eneg, fint(ecoef), escale)
if err != nil {
t.Skip()

Choose a reason for hiding this comment

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

Same?


got, err := d.Mul(e)
if err != nil {
t.Skip()

Choose a reason for hiding this comment

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

Same?


got, err := d.Add(e)
if err != nil {
t.Skip()

Choose a reason for hiding this comment

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

Same?

}
e, err := newSafe(eneg, fint(ecoef), escale)
if err != nil {
t.Skip()

Choose a reason for hiding this comment

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

Same?

func(t *testing.T, dneg bool, dscale int, dcoef uint64, eneg bool, escale int, ecoef uint64) {
d, err := newSafe(dneg, fint(dcoef), dscale)
if err != nil {
t.Skip()

Choose a reason for hiding this comment

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

Same?

@eapenkin
Copy link
Collaborator Author

@ccoVeille, there could be two situations:

  1. function returns an error when it is not supposed to (aka false positive);
  2. function does not return an error when it is supposed to (aka false negative).

The case of false positive is relatively safe. There is logging and monitoring in place to detect such cases. Eventually, the function will be fixed and unit tests will be added to prevent this from happening in the future.

The case of false negative is much more dangerous. It can lead to data corruption, financial loss, etc. And this is what tested by fuzz tests. If function returns an error we don't care about it, but if it returns some result then this result MUST satisfy some property: be equal to the result of the reference implementation, be in some range, etc.

@ccoVeille
Copy link

Thanks for your reply.

Your explanation is good,it makes sense

Maybe you could add a method to call skip, then document the reason you do that

something like

// fuzzSkipError blah blah
func(t *testing.T) fuzzSkipError(err error) {
  t.Helper()

  t.Skipf("skipping error in fuzzy mode: %s", err)
}

@@ -3697,7 +3866,7 @@ func TestDecimal_Min(t *testing.T) {
}
}

//nolint:predeclared
//nolint:revive

Choose a reason for hiding this comment

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

You are disabling a whole linter here. You should add a comment.

You should consider adding nolintlint linter and add require-specific and require-explanation

https://golangci-lint.run/usage/linters/#nolintlint

Also, does this directive have to be applied to the whole function? Can't it be move somewhat only where it's needed?

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