Skip to content

test: add recorder coverage tests#237

Merged
sudip-mondal-2002 merged 3 commits into
sudip-mondal-2002:mainfrom
shreyarani01:test-recorder-coverage
May 26, 2026
Merged

test: add recorder coverage tests#237
sudip-mondal-2002 merged 3 commits into
sudip-mondal-2002:mainfrom
shreyarani01:test-recorder-coverage

Conversation

@shreyarani01

@shreyarani01 shreyarani01 commented May 25, 2026

Copy link
Copy Markdown
Contributor

Added recorder coverage tests for #181 based on the current src/audio implementation.
Covered:

  • pause/resume behavior
  • paused writes being ignored
  • duration checks
  • peak tracking
  • write-after-stop behavior
  • empty WAV header validation
  • waveform updates after writing samples
    Local test result: 233 passed, 0 failed.

Note: I checked for RecorderSession, RecorderWav, RecorderIO::flush(), and write_metadata_chunk, but these APIs are not present separately in the current src/ code, so the tests target the existing Recorder flow.

Summary by CodeRabbit

  • Tests
    • Expanded test coverage for Recorder functionality including pause/resume operations, peak tracking, duration measurement, and waveform buffer retrieval.

Review Change Stack

@coderabbitai

coderabbitai Bot commented May 25, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

@sudip-mondal-2002, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 43 minutes and 4 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d6429faf-546c-40a7-af8c-fb02aa77ce8b

📥 Commits

Reviewing files that changed from the base of the PR and between 5f01b9e and 0d116d7.

📒 Files selected for processing (1)
  • tests/test_recorder.cpp
📝 Walkthrough

Walkthrough

This PR adds seven new unit tests to tests/test_recorder.cpp that extend coverage of the Recorder class beyond start/stop and basic writing. The tests validate pause/resume state management, metric tracking (peak value and duration), stop-write semantics, WAV file format correctness for empty recordings, and waveform buffer population.

Changes

Recorder unit test coverage expansion

Layer / File(s) Summary
Pause/resume state preservation
tests/test_recorder.cpp
Tests verify that pause() and resume() preserve sample counts written across pause boundaries, prevent sample increments during pause, and correctly update is_paused state.
Recording metrics and stop semantics
tests/test_recorder.cpp
Tests assert peak tracking via get_current_peak(), duration near-zero for empty recordings, and that write_samples() after stop() is a no-op that does not increment samples_written.
WAV file format and waveform retrieval
tests/test_recorder.cpp
Tests validate that empty recordings (start then immediate stop) produce valid WAV files with correct RIFF/WAVE and data chunk headers, and that get_waveform() returns non-empty sample buffers after writes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related issues

  • sudip-mondal-2002/Amplitron#181: New tests target the same RecorderSession/RecorderWav functions (pause/resume, get_duration, get_current_peak, and empty WAV handling) described in this issue.

Possibly related PRs

  • sudip-mondal-2002/Amplitron#219: Both PRs extend tests/test_recorder.cpp with unit tests that validate Recorder's WAV header correctness including the data chunk and RIFF-related fields.

Suggested labels

Audio Processing, type:testing, level:intermediate

Suggested reviewers

  • sudip-mondal-2002

Poem

🐰 A rabbit hops through tests so fine,
Pause and resume in perfect line,
Peak and waveform dance in place,
WAV files bloom—the test suite's grace!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'test: add recorder coverage tests' accurately and concisely summarizes the main change: adding test coverage for the Recorder component with new test cases covering pause/resume, peak tracking, duration, and waveform behavior.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions

Copy link
Copy Markdown
Contributor

Code Coverage Report 📊

Line Coverage: 82.2%

✅ Coverage meets threshold: 82.2% >= 60%

Full Coverage Summary
Summary coverage rate:
  lines......: 82.2% (3457 of 4206 lines)
  functions..: 92.5% (490 of 530 functions)
  branches...: no data found

@github-actions

github-actions Bot commented May 26, 2026

Copy link
Copy Markdown
Contributor

PR Preview Removed

The GitHub Pages preview for this PR has been removed because the PR was closed.

@sudip-mondal-2002 sudip-mondal-2002 added gssoc:approved GSSoC 2026 contribution level:intermediate Intermediate task · 25 GSSoC points type:testing Unit tests, integration tests, or test coverage quality:clean labels May 26, 2026
@sudip-mondal-2002 sudip-mondal-2002 merged commit 32faa27 into sudip-mondal-2002:main May 26, 2026
9 checks passed
github-actions Bot added a commit that referenced this pull request May 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gssoc:approved GSSoC 2026 contribution level:intermediate Intermediate task · 25 GSSoC points mentor:sudip-mondal-2002 quality:clean type:testing Unit tests, integration tests, or test coverage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

test: Cover recorder module gaps — recorder_session.cpp (48%) and recorder_wav.cpp (40%)

2 participants