-
Notifications
You must be signed in to change notification settings - Fork 0
Feat/#5/map collections #11
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
Merged
Merged
Changes from all commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
c29edbd
#5 - initialize tests for map collections
maciej-sz e984026
#5 - map functionality wip
maciej-sz 85334a0
#5 - map functionality wip
maciej-sz da5dfcf
#5 - map functionality wip
maciej-sz d6e7e64
#5 - map functionality wip
maciej-sz efced07
#5 - finished comfyMap impl
maciej-sz f36da30
#5 - introduced internal interfaces
maciej-sz 295445e
#5 - introduced extractors for underlying structures in tests
maciej-sz 9993d50
#5 - reorganize fold/reduce to only use underlying slices
maciej-sz 841e830
#5 - initial mapcmp is ready; introduced BasePairs interface; extract…
maciej-sz d0a92ed
#5 - all `map` cases covered also for `mapcmp`
maciej-sz aca7ec5
#7 - remove `ToSlice` and `ToMap` test coupling for map and cmpmap
maciej-sz 869476e
#5 - non-mutable cmp tests done
maciej-sz b88a9f4
#5 - Complete cmp tests, add mutable sort, and refactor test builders
maciej-sz f808c31
#10 - added conditional valuesCounter tests to cmpMap
maciej-sz e75d25b
#9, #10 - Implement value counting and use nil slices for empty colle…
maciej-sz a801d76
#7, #5 - remove test coupling; some fixes; full coverage of methods
maciej-sz 08cdbe4
#5 - fix linter errors
maciej-sz 6cc8677
#5 - cr fixes
maciej-sz 22ca276
#5 - valuesCounter optimize; add tests
maciej-sz cc006e7
#5 - valuesCounter test update
maciej-sz File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| package coll | ||
|
|
||
| import "cmp" | ||
|
|
||
| type valuesCounter[V cmp.Ordered] struct { | ||
| counter map[V]int | ||
| } | ||
|
|
||
| func newValuesCounter[V cmp.Ordered]() *valuesCounter[V] { | ||
| return &valuesCounter[V]{ | ||
| counter: make(map[V]int), | ||
| } | ||
| } | ||
|
|
||
| func (c *valuesCounter[V]) Count(v V) int { | ||
| return c.counter[v] | ||
| } | ||
|
|
||
| func (c *valuesCounter[V]) Increment(v V) { | ||
| c.counter[v]++ | ||
| } | ||
|
|
||
| func (c *valuesCounter[V]) Decrement(v V) { | ||
| count, exists := c.counter[v] | ||
| if !exists { | ||
| return | ||
| } | ||
| if count == 1 { | ||
| delete(c.counter, v) | ||
| } else { | ||
| c.counter[v]-- | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
❓ Verification inconclusive
Add test coverage for the non-existent key case in Decrement.
The implementation correctly checks for key existence before attempting to decrement, which addresses the issue raised in the previous review. However, static analysis indicates that lines 33-34 (the early return when a key doesn't exist) aren't covered by tests.
Please add test cases that verify the behavior when attempting to decrement a non-existent key to ensure complete test coverage.
🏁 Script executed:
Length of output: 46
Action Required: Add Test Case for Non-Existent Key in Decrement
The
Decrementmethod incmp.go(lines 30–40) handles the non-existent key case by returning early when the key isn't found. However, our repository lacks tests covering this branch (as indicated by the absence of test output for references toDecrementin*_test.gofiles). Please add a unit test that callsDecrementon a key not present in the counter to verify that it exits gracefully without modifying the counter.🧰 Tools
🪛 GitHub Check: codecov/patch
[warning] 33-34: cmp.go#L33-L34
Added lines #L33 - L34 were not covered by tests