From 45744ca2899d824bc2d3d98c1cdbc5f6731f61dc Mon Sep 17 00:00:00 2001 From: David Renshaw Date: Wed, 8 Nov 2023 11:26:39 -0500 Subject: [PATCH] add test for capnp-futures serialize_packed EOF --- capnp-futures/src/serialize_packed.rs | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/capnp-futures/src/serialize_packed.rs b/capnp-futures/src/serialize_packed.rs index 14ade2762..67ff85be4 100644 --- a/capnp-futures/src/serialize_packed.rs +++ b/capnp-futures/src/serialize_packed.rs @@ -524,7 +524,7 @@ where #[cfg(test)] pub mod test { use crate::serialize::test::{BlockingRead, BlockingWrite}; - use crate::serialize_packed::{PackedRead, PackedWrite}; + use crate::serialize_packed::{try_read_message, PackedRead, PackedWrite}; use capnp::message::ReaderSegments; use futures::{AsyncReadExt, AsyncWriteExt}; use quickcheck::{quickcheck, TestResult}; @@ -691,4 +691,15 @@ pub mod test { fn check_packed_round_trip_async() { quickcheck(round_trip as fn(usize, usize, Vec>) -> TestResult); } + + #[test] + fn read_empty() { + let words = vec![]; + // Before https://github.com/capnproto/capnproto-rust/pull/446 + // this would loop forever. + let message = + futures::executor::block_on(Box::pin(try_read_message(&words[..], Default::default()))) + .expect("reading"); + assert!(message.is_none()); + } }