Skip to content

Fix Fix() and Remove(); improve tests #1

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 6 commits into
base: master
Choose a base branch
from

Conversation

thepaul
Copy link

@thepaul thepaul commented Apr 3, 2025

There is a bug causing minmax heap invariants to be violated in certain conditions when using Remove() or Fix().

I also added a lot to the test suite to aid in debugging and visualizing the problem.

thepaul added 6 commits April 2, 2025 20:36
Rather than relying on Seed(0), try things in a different order every
time. The seed is logged so that if something fails, the problem can be
reproduced using the -seed flag.
Removes elements from a larger minmax heap in a random order, making
sure all elements were yielded and no non-elements were yielded.
This can be used when a test fails unexpectedly to show the structure of
the tree and where values are.

Perhaps this is overkill, but I found it very useful.
This now checks that grandchildren have the correct relationship to
nodes. Without this, it was possible for an invalid tree to pass
verify().
This appears to fix all of the ordering problems I have been
experiencing so far.
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.

1 participant