Skip to content

Commit

Permalink
add test for capnp-futures serialize_packed EOF
Browse files Browse the repository at this point in the history
  • Loading branch information
dwrensha committed Nov 8, 2023
1 parent 161b848 commit 45744ca
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion capnp-futures/src/serialize_packed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -691,4 +691,15 @@ pub mod test {
fn check_packed_round_trip_async() {
quickcheck(round_trip as fn(usize, usize, Vec<Vec<capnp::Word>>) -> 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());
}
}

0 comments on commit 45744ca

Please sign in to comment.