Skip to content

Extend fuzz tests #196

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

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

Extend fuzz tests #196

wants to merge 2 commits into from

Conversation

panmari
Copy link
Collaborator

@panmari panmari commented Jul 4, 2025

Covering more methods for CellUnion and add a rudimentary fuzz test for polygon.

Covering more methods for CellUnion and add a rudimentary fuzz test for polygon.
if got := p.Area(); got < 0 {
t.Errorf("Area() = %v, want >= 0. Polygon: %v", got, p)
}
// TODO: Test more methods on Polygon.
Copy link
Collaborator

Choose a reason for hiding this comment

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

What's the rationale for

  1. one file with all fuzz tests (or all decoding related fuzz tests)?
  2. having monolithic FuzzFoo tests rather than testing properties independently?
    ?

http://go/unit-testing-practices?polyglot=go#behavior-testing-examples

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  1. That's mostly me being oldschool. In the past, I added fuzz tests to a project that supported earlier go versions that did not yet support fuzz testing, so the fuzz tests needed to be in a seperate file, where a minimum go version was enforced. In this project, we might want to move the fuzz tests to the respective type test, e.g. polygon_test.go. Do you have a preference?

  2. Not sure what you mean. The primary thing under test is Decode: Will it always create a valid X? The properties we check on the decoded object feel secondary, hence I feel checking them in FuzzDecodeX is approrpiate.

Copy link
Collaborator

Choose a reason for hiding this comment

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

  1. Seems better to keep all polygon tests together rather than all fuzz tests together.
  2. You're not testing a single property. You're testing forall bytes decode doesn't crash && forall polygons area non-negative && more in the future. This seems partially due to the limited set of types supported by fuzzing. Maybe it's also computationally efficient depending on how hard it is for the fuzzer to find valid polygons.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

  1. Done
  2. I think this is correct. With every pass, the fuzzer tries to find new interesting examples that execute more code paths. Having a large variety of code paths executed inside the fuzz test is preferable.

@panmari panmari requested a review from jmr July 10, 2025 20:11
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