added more tests
All checks were successful
.NET Test / test (push) Successful in 1m6s
.NET Publish / publish (push) Successful in 38s

This commit is contained in:
2024-08-15 22:00:49 +04:00
parent 43135a5ffb
commit 2b68ba982d
9 changed files with 206 additions and 7 deletions

View File

@@ -24,6 +24,8 @@ public static class Base32
[Pure]
public static int Encode(ReadOnlySpan<byte> input, Span<char> output)
{
if (input.IsEmpty) return 0;
int i = 0;
ReadOnlySpan<char> alphabet = Alphabet;
for (int offset = 0; offset < input.Length;)

View File

@@ -95,6 +95,8 @@ public static class Base64Url
[Pure] public static int Encode(ReadOnlySpan<byte> input, Span<char> output)
{
if (input.IsEmpty) return 0;
var charlen = 8 * ((input.Length + 5) / 6);
Span<char> chars = stackalloc char[charlen];
Convert.TryToBase64Chars(input, chars, out int charsWritten);

View File

@@ -8,7 +8,7 @@ public static class SystemIOStreamExtensions
=> stream.Populate(buffer.AsSpan());
public static void Populate(this Stream stream, Span<byte> buffer)
{
do
while (buffer.Length > 0)
{
var readed = stream.Read(buffer);
@@ -19,7 +19,6 @@ public static class SystemIOStreamExtensions
buffer = buffer[readed..];
}
while (buffer.Length > 0);
}
public static async ValueTask PopulateAsync(this Stream stream, byte[] buffer, CancellationToken cancellationToken = default)
@@ -28,7 +27,7 @@ public static class SystemIOStreamExtensions
=> await stream.PopulateAsync(buffer.AsMemory(offset, length), cancellationToken);
public static async ValueTask PopulateAsync(this Stream stream, Memory<byte> buffer, CancellationToken cancellationToken = default)
{
do
while (buffer.Length > 0)
{
cancellationToken.ThrowIfCancellationRequested();
@@ -41,6 +40,5 @@ public static class SystemIOStreamExtensions
buffer = buffer[readed..];
}
while (buffer.Length > 0);
}
}