Closed grahamwren closed 4 years ago
We haven't come up with a way to externally validate that a rehash happened so haven't submitted a PR but wanted to know if you'd looked into it.
We tested our rehashing behavior by adding enough elements that a rehash should happen (we temporarily printed a statement when our helper was called so we knew it triggered) and then confirmed that all of our functionality still worked, especially on elements added before the rehash happened. If the test focuses on the public face of the implementation, what matters is that the Map
works the same before and after a rehash.
Because rehashing and the threshold is something of the implementation, it's difficult to make a test specifically to target rehashing. Still, it doesn't hurt to have a test with a large Map
(I figure ~35 elements should trigger most rehashes?). I can bang one out real quick and push it. If people want to pull it and/or update their commit hashes in their Makefiles to match, it'll be there.
We default to 1024 buckets with a max bucket size of 3 so would need closer to 500-2000 inserts. I can open a PR for that if it seems like a worthwhile test to you.
Oh wow, that's a big Map. I'm doing homework for some other classes at the moment, so if you know a good way to make a test like that, go right ahead. 👍 I don't want any of you to have rehashing bugs go unnoticed.
Glad we did this, found some bugs at the larger sizes ✌️PR incoming
Awesome, glad they were caught!
No specific opinion one way or the other, but did you consider adding a test for a very large map to try to exercise the rehash behavior requested in the assignment?