Skip to content

Add unit tests for RTSPHeader.SplitHeaders line folding#1657

Merged
sipsorcery merged 1 commit into
masterfrom
tests/rtsp-splitheaders-folding
Jun 1, 2026
Merged

Add unit tests for RTSPHeader.SplitHeaders line folding#1657
sipsorcery merged 1 commit into
masterfrom
tests/rtsp-splitheaders-folding

Conversation

@sipsorcery
Copy link
Copy Markdown
Member

Summary

RTSPHeader.SplitHeaders performs RTSP header line folding (collapsing continuation lines that begin with whitespace onto the previous line) and normalises malformed \r (CR + space) line endings. Despite being non-trivial parsing logic, it had no direct test coverage — it was only exercised indirectly through well-formed round-trip messages.

This PR adds four characterisation tests for it:

  • basic CRLF-separated splitting
  • a continuation line folded with a leading space
  • a continuation line folded with a leading tab
  • a lone "\r " (CR + space) treated as a proper line break

Why now

#1654 rewrites SplitHeaders to replace the Regex calls with a hand-rolled span-based normaliser. That's the kind of change where a behavioural regression could slip through silently, since the only existing RTSP test uses well-formed input that never folds.

I verified these tests pass against both:

…which confirms the two implementations are equivalent for these cases. The tests are written against master so they guard the behaviour regardless of whether/when #1654 lands.

Test plan

dotnet test test/unit/SIPSorcery.UnitTests.csproj --filter "FullyQualifiedName~RTSPHeaderUnitTest"

Passed: 4/4 on both branches.

🤖 Generated with Claude Code

SplitHeaders performs RTSP header line-folding (collapsing continuation
lines that begin with whitespace) and normalisation of malformed
carriage-return line endings, but had no direct test coverage; it was
only exercised indirectly via well-formed round-trip messages.

These characterisation tests lock in the existing behaviour:
- basic CRLF-separated splitting
- continuation line folded with a leading space
- continuation line folded with a leading tab
- lone "\r " (CR + space) treated as a line break

Verified to pass against both the current regex-based implementation and
the span-based rewrite in #1654, confirming the two are equivalent.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@sipsorcery sipsorcery merged commit 6f49ffa into master Jun 1, 2026
7 checks passed
@sipsorcery sipsorcery deleted the tests/rtsp-splitheaders-folding branch June 1, 2026 13:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant