added more tests
This commit is contained in:
@@ -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;)
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user