public void Z85RegularShouldHaveSameResultsAsSpanVersionTest(int seed, uint byteLength) { // arrange var data = new Span <byte>(MyData.CreatePseudoRandomByteArray(byteLength, seed)); var outputEncode = new Span <char>(new char[byteLength * 2]); var outputDecode = new Span <byte>(new byte[byteLength]); // act var resultEncodeRegular = Z85Extended.Encode(data.ToArray()); var resultEncodeSpan = Z85.Encode(data, outputEncode, out var encodeBytesConsumed, out var encodeCharsWritten); var resultDecodeRegular = Z85Extended.Decode(resultEncodeRegular); var resultDecodeSpan = Z85.Decode(outputEncode.Slice(0, encodeCharsWritten), outputDecode, out var decodeCharsConsumed, out var decodeBytesWritten); // assert // encode resultEncodeSpan.Should().Be(OperationStatus.Done); encodeBytesConsumed.Should().Be(data.Length); encodeCharsWritten.Should().Be(resultEncodeRegular.Length); outputEncode.Slice(0, encodeCharsWritten).ToString().Should().Be(resultEncodeRegular); // decode resultDecodeSpan.Should().Be(OperationStatus.Done); decodeCharsConsumed.Should().Be(resultEncodeRegular.Length); decodeBytesWritten.Should().Be(resultDecodeRegular.Length); outputDecode.Slice(0, decodeBytesWritten).ToArray().Should().BeEquivalentTo(resultDecodeRegular).And.BeEquivalentTo(data.ToArray()); }
public void StringToDecodeCannotHaveSizeOneTest() { // 5n+1 chars is not allowed. Assert.Throws <ArgumentException>(() => Z85Extended.Decode("123456")); }