add tests to deserializing sequences into a tuple

This commit is contained in:
Erick Tryzelaar
2014-08-14 19:08:41 -07:00
parent 5892d4fd67
commit f967a77a80
2 changed files with 9 additions and 2 deletions
+2 -2
View File
@@ -199,13 +199,13 @@ pub trait Deserializer<E>: Iterator<Result<Token, E>> {
fn expect_null(&mut self, token: Token) -> Result<(), E> { fn expect_null(&mut self, token: Token) -> Result<(), E> {
match token { match token {
Null => Ok(()), Null => Ok(()),
TupleStart(_) => { TupleStart(_) | SeqStart(_) => {
match try!(self.expect_token()) { match try!(self.expect_token()) {
End => Ok(()), End => Ok(()),
token => Err(self.syntax_error(token, [EndKind])), token => Err(self.syntax_error(token, [EndKind])),
} }
} }
token => Err(self.syntax_error(token, [NullKind, TupleStartKind])), token => Err(self.syntax_error(token, [NullKind, TupleStartKind, SeqStartKind])),
} }
} }
+7
View File
@@ -2897,6 +2897,13 @@ mod tests {
test_parse_ok([ test_parse_ok([
("[[3], [1, 2]]", vec!(vec!(3i), vec!(1, 2))), ("[[3], [1, 2]]", vec!(vec!(3i), vec!(1, 2))),
]); ]);
let v: () = from_iter("[]".chars()).unwrap();
assert_eq!(v, ());
test_parse_ok([
("[1, 2, 3]", (1u, 2u, 3u)),
]);
} }
#[test] #[test]