{
// Positive start and end index == ReadOnlySequenceSegment<T>
ReadOnlySequenceSegment<T> segment = (ReadOnlySequenceSegment<T>)startObject;
- next = new SequencePosition(segment.Next, 0);
first = segment.Memory.Span;
if (hasMultipleSegments)
{
first = first.Slice(startIndex);
+ next = new SequencePosition(segment.Next, 0);
}
else
{
Assert.Equal(i + 1, value);
}
}
+
+ [Fact]
+ public void TryReadTo_Span_At_Segments_Boundary()
+ {
+ Span<byte> delimiter = new byte[] { 13, 10 }; // \r\n
+ BufferSegment<byte> segment = new BufferSegment<byte>(Text.Encoding.ASCII.GetBytes("Hello\r"));
+ segment.Append(Text.Encoding.ASCII.GetBytes("\nWorld")); // add next segment
+ ReadOnlySequence<byte> inputSeq = new ReadOnlySequence<byte>(segment, 0, segment, 6); // span only the first segment!
+ SequenceReader<byte> sr = new SequenceReader<byte>(inputSeq);
+ bool r = sr.TryReadTo(out _, delimiter);
+ Assert.False(r);
+ }
}
}