Skip to content

Commit

Permalink
Added test when no null char presented
Browse files Browse the repository at this point in the history
  • Loading branch information
sakno committed Sep 21, 2023
1 parent b833baf commit 2d79111
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/DotNext.Tests/IO/StreamExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -711,6 +711,22 @@ public static void DecodeNullTerminatedString(int bufferSize)
Equal("Привет, \u263A!", writer.WrittenSpan.ToString());
}

[Theory]
[InlineData(8)]
[InlineData(16)]
[InlineData(32)]
public static void DecodeNullTerminatedStringNoTrailinigZeroByte(int bufferSize)
{
using var ms = new MemoryStream();
ms.Write("Привет, \u263A!"u8);
ms.Position = 0L;

Span<byte> buffer = stackalloc byte[bufferSize];
var writer = new ArrayBufferWriter<char>();
ms.ReadUtf8(buffer, writer);
Equal("Привет, \u263A!", writer.WrittenSpan.ToString());
}

[Fact]
public static void DecodeNullTerminatedEmptyString()
{
Expand Down

0 comments on commit 2d79111

Please sign in to comment.