Skip to content

Commit 823c419

Browse files
committed
test: assert buffer length after overflow trim
Identity check alone doesn't prove overflow path executed. Add length assertion to verify buffer is trimmed to max size.
1 parent 544bbbc commit 823c419

1 file changed

Lines changed: 6 additions & 0 deletions

File tree

tests/test_audio_stream_track.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,12 @@ async def test_buffer_overflow_does_not_reallocate(self):
360360
assert track._buffer is buffer_ref, (
361361
"overflow trim should modify buffer in-place, not create a new one"
362362
)
363+
max_buffer_seconds = 100 / 1000
364+
bytes_per_sample = 2
365+
expected_max_bytes = int(max_buffer_seconds * 48000) * bytes_per_sample
366+
assert len(track._buffer) == expected_max_bytes, (
367+
"buffer should be trimmed to configured max size"
368+
)
363369

364370
@pytest.mark.asyncio
365371
async def test_media_stream_error(self):

0 commit comments

Comments
 (0)