Skip to content

Commit b736700

Browse files
committed
Added tests
1 parent 00a596b commit b736700

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

src/Bencode.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ public static function decode($bencoded)
144144
}
145145
elseif (isset($current))
146146
{
147-
throw new RuntimeException('Unexpected value around offset ' . $pos);
147+
throw new RuntimeException('Unexpected content ending at offset ' . $pos);
148148
}
149149
else
150150
{

tests/Test.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,10 @@ public function getDecodeTests()
119119
'x' => new ArrayObject(['y' => 1])
120120
])
121121
],
122+
[
123+
'3:abc',
124+
'abc'
125+
],
122126
];
123127
}
124128

@@ -187,6 +191,14 @@ public function getDecodeInvalidTests()
187191
'i123',
188192
new RuntimeException('Invalid integer end found at offset 4')
189193
],
194+
[
195+
'3 abc',
196+
new RuntimeException('Invalid character found at offset 1')
197+
],
198+
[
199+
'3:abc3:abc',
200+
new RuntimeException('Unexpected content ending at offset 10')
201+
],
190202
];
191203
}
192204
}

0 commit comments

Comments
 (0)