@Test public void serializingEmptyStringShouldBeCorrect() throws IOException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(100); BencodeString bencodeString = new BencodeString(""); bencodeString.serialize(byteArrayOutputStream); String s = byteArrayOutputStream.toString(); Assert.assertEquals("0:", s); }
@Test public void serializingStringShouldCorrespondSpecification() throws IOException { ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(100); BencodeString bencodeString = new BencodeString("Hello"); bencodeString.serialize(byteArrayOutputStream); String s = byteArrayOutputStream.toString(); Assert.assertEquals("5:Hello", s); }