-
Notifications
You must be signed in to change notification settings - Fork 46
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add some tests that pass with the fix and fail without the fix
- Loading branch information
1 parent
4892284
commit c581d9b
Showing
4 changed files
with
82 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
test/NetTopologySuite.IO.GeoJSON4STJ.Test/SingleByteReadingMemoryStream.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
using System; | ||
using System.IO; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
|
||
namespace NetTopologySuite.IO.GeoJSON4STJ.Test; | ||
|
||
/// <summary> | ||
/// A <see cref="MemoryStream"/> implementation that will never read more than one byte at a time. | ||
/// </summary> | ||
internal sealed class SingleByteReadingMemoryStream : MemoryStream | ||
{ | ||
public override int Read(byte[] buffer, int offset, int count) | ||
{ | ||
return base.Read(buffer, offset, Math.Min(1, count)); | ||
} | ||
|
||
public override int Read(Span<byte> buffer) | ||
{ | ||
return base.Read(buffer[.. Math.Min(1, buffer.Length)]); | ||
} | ||
|
||
public override Task<int> ReadAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) | ||
{ | ||
return base.ReadAsync(buffer, offset, Math.Min(1, count), cancellationToken); | ||
} | ||
|
||
public override ValueTask<int> ReadAsync(Memory<byte> buffer, CancellationToken cancellationToken = default) | ||
{ | ||
return base.ReadAsync(buffer[.. Math.Min(1, buffer.Length)], cancellationToken); | ||
} | ||
} |