示例#1
0
 @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);
 }
示例#2
0
 @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);
 }
示例#3
0
 @Test
 public void parsingEmptyStringShouldBeCorrect() throws IOException, BadBencodingException {
   byte[] buffer;
   buffer = "0:".getBytes();
   ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(buffer);
   BencodeParser parser = new BencodeParser(byteArrayInputStream);
   BencodeString str = (BencodeString) parser.parse();
   Assert.assertEquals("", str.getString());
 }