public async Task NaughtyStringsAsync()
        {
            var failures = new StringBuilder();

            for (var i = 0; i < _NaughtStringsAsync_AllEncodings.Length; i++)
            {
                var encoding = _NaughtStringsAsync_AllEncodings[i];

                for (var j = 0; j < _NaughtStringsAsync_Strings.Length; j++)
                {
                    var str         = _NaughtStringsAsync_Strings[j];
                    var shouldMatch = encoding.GetBytes(str);

                    var pipe   = new Pipe();
                    var writer = pipe.Writer;
                    var reader = pipe.Reader;

                    await using (var adapter = new PipeWriterAdapter(writer, encoding, MemoryPool <char> .Shared))
                    {
                        await adapter.WriteAsync(str.AsMemory(), default);

                        writer.Complete();
                        var writtenBytes = await ReadAsync(reader);

                        var success = shouldMatch.SequenceEqual(writtenBytes);
                        if (success)
                        {
                            continue;
                        }

                        failures.AppendLine($"Starting ({shouldMatch.Length}) ({i}, {j}) with ({encoding.EncodingName}): {str}");
                    }
                }
            }

            var allFails = failures.ToString();

            Assert.Equal("", allFails);
        public async Task TransitionsAsync()
        {
            var data =
                string.Join(
                    ", ",
                    Enumerable.Repeat("hello world", 1_000)
                    );
            var dataBytes = Encoding.UTF8.GetBytes(data);

            // walk each async transition point
            var forceUpTo = 0;

            while (true)
            {
                var pipe = new Pipe();

                await using (var adapter = new PipeWriterAdapter(pipe.Writer, Encoding.UTF8, MemoryPool <char> .Shared))
                {
                    var provider = (ITestableAsyncProvider)adapter;
                    provider.GoAsyncAfter = forceUpTo;

                    var dataMem = data.AsMemory();

                    for (var i = 0; i < data.Length; i += 100)
                    {
                        var segment = dataMem.Slice(i);
                        if (segment.Length > 100)
                        {
                            segment = segment.Slice(0, 100);
                        }

                        await adapter.WriteAsync(segment, default);
                    }

                    pipe.Writer.Complete();

                    var readBytes = new List <byte>();
                    while (true)
                    {
                        var res = await pipe.Reader.ReadAsync();

                        foreach (var seg in res.Buffer)
                        {
                            readBytes.AddRange(seg.ToArray());
                        }

                        if (res.IsCompleted)
                        {
                            break;
                        }
                    }

                    Assert.True(dataBytes.SequenceEqual(readBytes));

                    if (provider.AsyncCounter >= forceUpTo)
                    {
                        forceUpTo++;
                    }
                    else
                    {
                        break;
                    }
                }
            }
        }