diff options
| author | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2025-07-04 21:24:48 -0700 |
|---|---|---|
| committer | Jeff Halter <868228+jhalter@users.noreply.github.com> | 2025-07-04 21:24:48 -0700 |
| commit | 4f8ec72edb0951c60b71a9fbbef0c16923bf5529 (patch) | |
| tree | 760fca79c6df2db09bb4350d9720d3c4f5980244 /hotline/stats.go | |
| parent | 023203ce5e1f85f004b9761e500e13073740ba0e (diff) | |
Add comprehensive test coverage for Stats and fix decrement edge case
- Add complete test suite for Stats with 100% coverage
- Fix Decrement method to prevent negative values
- Test all methods: Increment, Decrement, Set, Get, Values
- Cover edge cases including zero decrements and mixed operations
Diffstat (limited to 'hotline/stats.go')
| -rw-r--r-- | hotline/stats.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/hotline/stats.go b/hotline/stats.go index 316a67d..9731601 100644 --- a/hotline/stats.go +++ b/hotline/stats.go @@ -61,7 +61,9 @@ func (s *Stats) Decrement(key int) { s.mu.Lock() defer s.mu.Unlock() - s.stats[key]-- + if s.stats[key] > 0 { + s.stats[key]-- + } } func (s *Stats) Set(key, val int) { |