New tests

This commit is contained in:
Tony Garnock-Jones 2019-10-19 23:30:46 +01:00
parent 4b957d8785
commit 84f99fc471
1 changed files with 17 additions and 0 deletions

View File

@ -206,6 +206,23 @@ mod decoder_tests {
assert_eq!(v.annotations().len(), 0);
assert_eq!(v.value(), &Value::from(1));
}
#[test] fn two_values_at_once() {
let mut buf = &b"\x81tPing\x81tPong"[..];
assert_eq!(buf.len(), 12);
let mut d = Decoder::<_, PlainValue>::new(&mut buf, None);
assert_eq!(d.next().unwrap().value(), &Value::simple_record("Ping", vec![]));
assert_eq!(d.next().unwrap().value(), &Value::simple_record("Pong", vec![]));
assert_eq!(buf.len(), 0);
}
#[test] fn buf_advanced() {
let mut buf = &b"\x81tPing\x81tPong"[..];
assert_eq!(buf.len(), 12);
let mut d = Decoder::<_, PlainValue>::new(&mut buf, None);
assert_eq!(d.next().unwrap().value(), &Value::simple_record("Ping", vec![]));
assert_eq!(buf.len(), 6);
}
}
#[cfg(test)]