using SimpleBase;
namespace SimpleBaseTests;
public class UnitTest1
{
[Fact]
public void Encode_Base32_Long()
{
var someFailures = FailingBase32Rfc4648Encodes().Take(10).ToArray();
Assert.Empty(someFailures);
}
private IEnumerable<(long, Exception)> FailingBase32Rfc4648Encodes()
{
for (var val = 0; val >= 0; ++val)
{
(long, Exception)? problem = null;
try
{
Base32.Rfc4648.Encode(val);
}
catch (Exception ex)
{
problem = (val, ex);
}
if (problem is not null)
{
yield return problem.Value;
problem = null;
}
}
}
}
will produce output like
Xunit.Sdk.EmptyException
Assert.Empty() Failure: Collection was not empty
Collection: [Tuple (0, System.IndexOutOfRangeException: Index was outside the bounds of the array.
at SimpleBase.Base32.Encode(UInt64 number)
at SimpleBase.Base32.Encode(Int64 number)
at SimpleBaseTests.UnitTest1.FailingBase32Rfc4648Encodes()+MoveNext() in C:\Projects\PS.Playgrounds\SimpleBaseTests\UnitTest1.cs:line 22), Tuple (256, System.IndexOutOfRangeException: Index was outside the bounds of the array.
at SimpleBase.Base32.Encode(UInt64 number)
at SimpleBase.Base32.Encode(Int64 number)
at SimpleBaseTests.UnitTest1.FailingBase32Rfc4648Encodes()+MoveNext() in C:\Projects\PS.Playgrounds\SimpleBaseTests\UnitTest1.cs:line 22), Tuple (512, System.IndexOutOfRangeException: Index was outside the bounds of the array.
at SimpleBase.Base32.Encode(UInt64 number)
at SimpleBase.Base32.Encode(Int64 number)
at SimpleBaseTests.UnitTest1.FailingBase32Rfc4648Encodes()+MoveNext() in C:\Projects\PS.Playgrounds\SimpleBaseTests\UnitTest1.cs:line 22), Tuple (768, System.IndexOutOfRangeException: Index was outside the bounds of the array.
at SimpleBase.Base32.Encode(UInt64 number)
at SimpleBase.Base32.Encode(Int64 number)
at SimpleBaseTests.UnitTest1.FailingBase32Rfc4648Encodes()+MoveNext() in C:\Projects\PS.Playgrounds\SimpleBaseTests\UnitTest1.cs:line 22), Tuple (1024, System.IndexOutOfRangeException: Index was outside the bounds of the array.
at SimpleBase.Base32.Encode(UInt64 number)
at SimpleBase.Base32.Encode(Int64 number)
at SimpleBaseTests.UnitTest1.FailingBase32Rfc4648Encodes()+MoveNext() in C:\Projects\PS.Playgrounds\SimpleBaseTests\UnitTest1.cs:line 22), ···]
at SimpleBaseTests.UnitTest1.Encode_Base32_Long() in C:\Projects\PS.Playgrounds\SimpleBaseTests\UnitTest1.cs:line 11
at System.RuntimeMethodHandle.InvokeMethod(Object target, Void** arguments, Signature sig, Boolean isConstructor)
at System.Reflection.MethodBaseInvoker.InvokeWithNoArgs(Object obj, BindingFlags invokeAttr)
Throws
IndexOutOfRangeException
.will produce output like