public async Task JustHeadersAsync() { var config = (ConcreteBoundConfiguration <_JustHeaders>)Configuration.For <_JustHeaders>(Options.Default.NewBuilder().WithRowEnding(RowEndings.CarriageReturnLineFeed).Build()); // none { await RunAsyncReaderVariants <_Foo>( Options.Default, async (_, getReader) => { using (var str = getReader("fizz")) { using var charLookup = ReaderStateMachine.MakeCharacterLookup(config.MemoryPool, config.EscapedValueStartAndStop, config.ValueSeparator, config.EscapeValueEscapeChar, config.CommentChar); using var reader = new HeadersReader <_JustHeaders>(config, charLookup, str, new BufferWithPushback(MemoryPool <char> .Shared, 500)); var res = await reader.ReadAsync(CancellationToken.None); Assert.Collection(ToEnumerable(res.Headers), i => Assert.Equal("fizz", new string(i.Span))); Assert.False(res.IsHeader); } } ); } // one, exact { await RunAsyncReaderVariants <_Foo>( Options.Default, async (_, getReader) => { using (var str = getReader("Foo")) { using var charLookup = ReaderStateMachine.MakeCharacterLookup(config.MemoryPool, config.EscapedValueStartAndStop, config.ValueSeparator, config.EscapeValueEscapeChar, config.CommentChar); using var reader = new HeadersReader <_JustHeaders>(config, charLookup, str, new BufferWithPushback(MemoryPool <char> .Shared, 500)); var res = await reader.ReadAsync(CancellationToken.None); Assert.Collection(ToEnumerable(res.Headers), i => Assert.Equal("Foo", new string(i.Span))); Assert.True(res.IsHeader); } } ); } // one, inexact { await RunAsyncReaderVariants <_Foo>( Options.Default, async (_, getReader) => { using (var str = getReader("Foo,fizz")) { using var charLookup = ReaderStateMachine.MakeCharacterLookup(config.MemoryPool, config.EscapedValueStartAndStop, config.ValueSeparator, config.EscapeValueEscapeChar, config.CommentChar); using var reader = new HeadersReader <_JustHeaders>(config, charLookup, str, new BufferWithPushback(MemoryPool <char> .Shared, 500)); var res = await reader.ReadAsync(CancellationToken.None); Assert.Collection( ToEnumerable(res.Headers), i => Assert.Equal("Foo", new string(i.Span)), i => Assert.Equal("fizz", new string(i.Span)) ); Assert.True(res.IsHeader); } } ); await RunAsyncReaderVariants <_Foo>( Options.Default, async (_, getReader) => { using (var str = getReader("fizz,Bar")) { using var charLookup = ReaderStateMachine.MakeCharacterLookup(config.MemoryPool, config.EscapedValueStartAndStop, config.ValueSeparator, config.EscapeValueEscapeChar, config.CommentChar); using var reader = new HeadersReader <_JustHeaders>(config, charLookup, str, new BufferWithPushback(MemoryPool <char> .Shared, 500)); var res = await reader.ReadAsync(CancellationToken.None); Assert.Collection( ToEnumerable(res.Headers), i => Assert.Equal("fizz", new string(i.Span)), i => Assert.Equal("Bar", new string(i.Span)) ); Assert.True(res.IsHeader); } } ); } // two, exact { await RunAsyncReaderVariants <_Foo>( Options.Default, async (_, getReader) => { using (var str = getReader("Foo,Bar")) { using var charLookup = ReaderStateMachine.MakeCharacterLookup(config.MemoryPool, config.EscapedValueStartAndStop, config.ValueSeparator, config.EscapeValueEscapeChar, config.CommentChar); using var reader = new HeadersReader <_JustHeaders>(config, charLookup, str, new BufferWithPushback(MemoryPool <char> .Shared, 500)); var res = await reader.ReadAsync(CancellationToken.None); Assert.Collection( ToEnumerable(res.Headers), i => Assert.Equal("Foo", new string(i.Span)), i => Assert.Equal("Bar", new string(i.Span)) ); Assert.True(res.IsHeader); } } ); await RunAsyncReaderVariants <_Foo>( Options.Default, async (_, getReader) => { using (var str = getReader("Bar,Foo")) { using var charLookup = ReaderStateMachine.MakeCharacterLookup(config.MemoryPool, config.EscapedValueStartAndStop, config.ValueSeparator, config.EscapeValueEscapeChar, config.CommentChar); using var reader = new HeadersReader <_JustHeaders>(config, charLookup, str, new BufferWithPushback(MemoryPool <char> .Shared, 500)); var res = await reader.ReadAsync(CancellationToken.None); Assert.Collection( ToEnumerable(res.Headers), i => Assert.Equal("Bar", new string(i.Span)), i => Assert.Equal("Foo", new string(i.Span)) ); Assert.True(res.IsHeader); } } ); } // two, inexact { await RunAsyncReaderVariants <_Foo>( Options.Default, async (_, getReader) => { using (var str = getReader("Foo,Bar,Fizz")) { using var charLookup = ReaderStateMachine.MakeCharacterLookup(config.MemoryPool, config.EscapedValueStartAndStop, config.ValueSeparator, config.EscapeValueEscapeChar, config.CommentChar); using var reader = new HeadersReader <_JustHeaders>(config, charLookup, str, new BufferWithPushback(MemoryPool <char> .Shared, 500)); var res = await reader.ReadAsync(CancellationToken.None); Assert.Collection( ToEnumerable(res.Headers), i => Assert.Equal("Foo", new string(i.Span)), i => Assert.Equal("Bar", new string(i.Span)), i => Assert.Equal("Fizz", new string(i.Span)) ); Assert.True(res.IsHeader); } } ); await RunAsyncReaderVariants <_Foo>( Options.Default, async (_, getReader) => { using (var str = getReader("Bar,Fizz,Foo")) { using var charLookup = ReaderStateMachine.MakeCharacterLookup(config.MemoryPool, config.EscapedValueStartAndStop, config.ValueSeparator, config.EscapeValueEscapeChar, config.CommentChar); using var reader = new HeadersReader <_JustHeaders>(config, charLookup, str, new BufferWithPushback(MemoryPool <char> .Shared, 500)); var res = await reader.ReadAsync(CancellationToken.None); Assert.Collection( ToEnumerable(res.Headers), i => Assert.Equal("Bar", new string(i.Span)), i => Assert.Equal("Fizz", new string(i.Span)), i => Assert.Equal("Foo", new string(i.Span)) ); Assert.True(res.IsHeader); } } ); } }