Skip to content

Commit e9d80cf

Browse files
committed
Add test for parsing with latin1 encoding
1 parent 73bb3b1 commit e9d80cf

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

BencodeNET.Tests/Parsing/BStringParserTests.cs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,5 +135,19 @@ public void LengthBelowInt32MaxValue_ShouldNotThrowUnsupportedException()
135135
Action action = () => Parser.ParseString(bencode);
136136
action.ShouldNotThrow<UnsupportedBencodeException<BString>>();
137137
}
138+
139+
[Fact]
140+
public void CanParseEncodedAsLatin1()
141+
{
142+
var encoding = Encoding.GetEncoding("LATIN1");
143+
var expected = new BString("æøå", encoding);
144+
var parser = new BStringParser(encoding);
145+
146+
// "3:æøå"
147+
var bytes = new byte[] {51, 58, 230, 248, 229};
148+
var bstring = parser.Parse(bytes);
149+
150+
bstring.Should().Be(expected);
151+
}
138152
}
139153
}

0 commit comments

Comments
 (0)