test(diffguard-lsp): cover text.rs edge cases#1608
Conversation
Adds unit tests for split_lines empty input, build_synthetic_diff edge cases (line 0 skip, out-of-range lines, no-change header), incremental change handling (no-range full replace, invalid start/end positions, start-after-end error), byte_offset_at_position end-of-text and past-line boundaries plus multibyte UTF-16 handling, and utf16_length surrogate-pair counting. Pure test-only additions — no behavior change. Closes a 26-region coverage gap in diffguard-lsp/src/text.rs (was 86.93% region coverage).
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Rate limit exceeded
You’ve run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After the wait time has elapsed, a review can be triggered using the 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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout. Please see our FAQ for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Organization UI Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
Inline 'diffguard: ignore' on the .expect("apply") used in
apply_incremental_change_with_no_range_replaces_whole_text. The line is
in a #[cfg(test)] module so the rule's intent does not apply, but the
diff lint cannot distinguish test modules from src/ files.
Refs #1609.
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Summary
Closes the largest coverage gap in
crates/diffguard-lsp/src/text.rs(was 86.93% region coverage, 26 uncovered regions). Pure test-only additions — no behavior change.Closes #1609 (tracked alongside sibling PRs).
New unit tests cover:
split_lineswith empty input and single-line inputchanged_lines_betweenfor identical inputs and truncation boundarybuild_synthetic_diffskipping line 0 and out-of-range lines, and header-only output when no lines changeapply_incremental_changewith no range (full replace), invalid start position, invalid end position, and start-after-end errorsbyte_offset_at_positionend-of-text, past-end, past-last-line, character beyond line length, and multibyte (surrogate-pair) handlingutf16_lengthsurrogate-pair countingThe one
.expect("apply")line uses an inline// diffguard: ignore rust.no_unwrapsuppression — it's inside#[cfg(test)]and matches the same idiom used by the pre-existing test on line 159, but the diff lint can't distinguish test modules from production code insrc/.Test plan
cargo test -p diffguard-lsp text::— 20/20 passcargo clippy -p diffguard-lsp --all-targets -- -D warnings— cleancargo fmt -p diffguard-lsp -- --check