Skip to content

Commit 23d81ba

Browse files
committed
fix test failures
1 parent cae27ec commit 23d81ba

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/Base32.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ public ulong DecodeUInt64(string text)
185185
public bool TryDecodeUInt64(string text, out ulong number)
186186
{
187187
Span<byte> output = stackalloc byte[sizeof(ulong)];
188-
if (!TryDecode(text, output, out int bytesWritten))
188+
if (!TryDecode(text, output, out _))
189189
{
190190
number = 0;
191191
return false;
@@ -196,7 +196,11 @@ public bool TryDecodeUInt64(string text, out ulong number)
196196
output.Reverse();
197197
}
198198

199-
number = BitConverter.ToUInt64(output[..bytesWritten]);
199+
// BitConverter.ToUInt64() specifically requires
200+
// the span to be 8 bytes long, so we can't just
201+
// use bytesWritten in the decoding here, we
202+
// need to pass the whole thing.
203+
number = BitConverter.ToUInt64(output);
200204
return true;
201205
}
202206

test/Base32/Rfc4648Test.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ public void Encode_BigEndian_ulong_ReturnsExpectedValues(ulong number, string ex
114114

115115
static ulong reverseBytes(ulong number)
116116
{
117-
var span = BitConverter.GetBytes(number).AsSpan();
117+
Span<byte> span = BitConverter.GetBytes(number);
118118
span.Reverse();
119119
return BitConverter.ToUInt64(span);
120120
}

0 commit comments

Comments
 (0)