Add some missing unit tests #76
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Hi,
Thanks for your time to review this PR.
By examining the existing code, we found that some tests can be added to improve the repo's overall test coverage. The tests we submitted have been carefully curated by us to ensure their behavior and effectiveness.
The code region we covered is:
strsim-rs/src/lib.rs
Lines 360 to 364 in 43d4443
strsim-rs/src/lib.rs
Lines 486 to 488 in 43d4443
strsim-rs/src/lib.rs
Lines 528 to 530 in 43d4443
strsim-rs/src/lib.rs
Lines 534 to 565 in 43d4443
And I found that after creating a GrowingHashmapChar instance via GrowingHashmapChar::default(), the self.mask value is -1. If the grow() method is called directly without initializing the map (via allocate() or get_mut()), the following loop will run indefinitely:
strsim-rs/src/lib.rs
Lines 535 to 538 in 43d4443
While current internal usage (e.g., get_mut() always initializes the map via allocate()) prevents this scenario, but it's never good that such situations exist. So I added a debug_assert for it.
Thanks again for reviewing.