Skip to content

Commit

Permalink
Tests for Integer decoding
Browse files Browse the repository at this point in the history
  • Loading branch information
greymistcube committed Aug 5, 2023
1 parent 8b7fa1b commit 64fc858
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions Bencodex.Tests/Types/IntegerTest.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Globalization;
using System.Numerics;
using System.Text;
using Bencodex.Types;
using Xunit;
using static Bencodex.Misc.ImmutableByteArrayExtensions;
Expand Down Expand Up @@ -114,6 +115,21 @@ public void CountDecimalDigits()
}
}

[Fact]
public void InvalidFormats()
{
Codec codec = new Codec();
byte[] case1 = Encoding.ASCII.GetBytes("ie");
byte[] case2 = Encoding.ASCII.GetBytes("i+142e");
byte[] case3 = Encoding.ASCII.GetBytes("i00e");
byte[] case4 = Encoding.ASCII.GetBytes("i-0e");

Assert.Throws<DecodingException>(() => codec.Decode(case1));
Assert.Throws<DecodingException>(() => codec.Decode(case2));
Assert.Throws<DecodingException>(() => codec.Decode(case3));
Assert.Throws<DecodingException>(() => codec.Decode(case4));
}

private void IntegerGeneric(Func<int, Integer?> convert)
{
Codec codec = new Codec();
Expand Down

0 comments on commit 64fc858

Please sign in to comment.