Make the JSON parser accept trailing whitespace

This commit is contained in:
inrustwetrust 2015-02-18 20:39:24 +01:00
parent 4e4172ec85
commit fb77b13174

View File

@ -32,6 +32,7 @@ impl<Iter: Iterator<Item=u8>> Parser<Iter> {
#[inline]
pub fn end(&mut self) -> Result<(), Error> {
self.parse_whitespace();
if self.eof() {
Ok(())
} else {
@ -735,4 +736,14 @@ mod tests {
),
]);
}
#[test]
fn test_parse_trailing_whitespace() {
test_parse_ok(vec![
("[1, 2] ", vec![1, 2]),
("[1, 2]\n", vec![1, 2]),
("[1, 2]\t", vec![1, 2]),
("[1, 2]\t \n", vec![1, 2]),
]);
}
}