mafintosh / mafintosh/nat-sampler

Missing test coverage on ring buffer's wrapping behavior

Open
#2 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
8
Forks
1
PR merge metrics
No merged PRs in 30d

Description

Tests for the NatSampler don't cover the case where the ring buffer wraps back to the beginning on line 23 - https://github.com/mafintosh/nat-sampler/blob/6ad6c9abdc07a8cb5dfde581df126f869e470560/index.js#L23.

This is the uncovered code. I've written tests for the equivalent Go code in my project and can confirm that the algorithm is correct.

```
} else {
if (this._top === 32) this._top = 0

const oa = this._samples[this._top]
this._samples[this._top++] = a
oa.hits--

const ob = this._samples[this._top]
this._samples[this._top++] = b
ob.hits--
}
```

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the wrapping branch in index.js at line 23 and inspect how NatSampler currently tests adjacent behavior. Add coverage for the ring buffer returning to the beginning after reaching the top, then run the existing test suite to confirm the wrapping path is exercised.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
testing
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.