From 84f99fc47174bb71c8a7ff25cdae88444a0ed559 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Sat, 19 Oct 2019 23:30:46 +0100 Subject: [PATCH] New tests --- implementations/rust/src/lib.rs | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/implementations/rust/src/lib.rs b/implementations/rust/src/lib.rs index ee5f9f6..1b63b94 100644 --- a/implementations/rust/src/lib.rs +++ b/implementations/rust/src/lib.rs @@ -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)]