Cysharp/Utf8StreamReader

Buffer Boundary CRLF

EnsignPayton opened this issue · 0 comments

If the buffer boundary falls in the middle of a CRLF, the CR will be left on to the end of the line preceding the buffer boundary.

For example, the following test fails:

[Fact]
public async Task NewLineTrimmedAtBufferBoundary()
{
    // Buffer 1: aaa....\r\nasdf\r
    // Buffer 2: \nasdf
    var ms2 = CreateStringStream(
        new string('a', 1017) +
        "\r\nasdf" +
        "\r\nasdf");

    var actual = await Utf8StreamReaderResultAsync(ms2, 1024);

    string[] expected =
    [
        new string('a', 1017),
        "asdf",
        "asdf",
    ];

    actual[1].Should().Be(expected[1]);
    actual.Should().Equal(expected);
}