Skip to content

Commit

Permalink
add more test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
dwrensha committed Nov 29, 2023
1 parent a95d3e3 commit d27e043
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 0 deletions.
6 changes: 6 additions & 0 deletions capnp/src/text_list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,12 @@ impl<'a> Reader<'a> {
let l = self.len();
ListIter::new(self, l)
}

pub fn reborrow<'b>(&'b self) -> Reader<'b> {
Reader {
reader: self.reader,
}
}
}

impl<'a> FromPointerReader<'a> for Reader<'a> {
Expand Down
19 changes: 19 additions & 0 deletions capnpc/test/test_util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,15 @@ pub fn init_test_message(mut builder: test_all_types::Builder<'_>) {

// ...

{
let mut text_list = builder.reborrow().init_text_list(3);
text_list.set(0, "plugh".into());
text_list.set(1, "xyzzy".into());
text_list.set(2, "thud".into());
}

// ...

{
let mut struct_list = builder.reborrow().init_struct_list(3);
struct_list
Expand Down Expand Up @@ -393,6 +402,16 @@ check_test_message_impl(($mod:ident::$typ:ident) => (

// ...

{
let mut text_list = reader.reborrow().get_text_list().unwrap();
assert_eq!(3, text_list.len());
assert_eq!("plugh", text_list.reborrow().get(0).unwrap());
assert_eq!("xyzzy", text_list.reborrow().get(1).unwrap());
assert_eq!("thud", text_list.reborrow().get(2).unwrap());
}

// ...

{
let mut struct_list = reader.reborrow().get_struct_list().unwrap();
assert_eq!(3, struct_list.len());
Expand Down

0 comments on commit d27e043

Please sign in to comment.