String bencodedOneIntElementList = "lli-3eeli-2eeli-1eeli0eeli1eeli2eeli3eee";
long[] intValuesExpected = {-3, -2, -1, 0, 1, 2, 3};
BencodeInputFactory f = new DefaultBencodeInputFactory();
try (InputStream s = new ByteArrayInputStream(bencodedOneIntElementList.getBytes("US-ASCII"))) {
BencodeStreamReader r = f.createBencodeStreamReader(s);
int decodedIntIndex = 0;
while(r.hasNext()) {
r.next();
if (EventType.LIST == r.getEventType()) {
List<BencodeData> list = r.getList();
for (BencodeData bencodeData : list) {
if (BencodeType.LIST != bencodeData.getType()) {
List<BencodeData> innerList = r.getList();
BencodeData num = innerList.get(0);
assertEquals(intValuesExpected[decodedIntIndex++], num.getInt());
}
}
}