Skip to content

Commit

Permalink
Add box test
Browse files Browse the repository at this point in the history
  • Loading branch information
zakarumych committed May 16, 2024
1 parent 7a45d26 commit 48f954d
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions src/boxed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,3 +191,27 @@ where
Ok(())
}
}

#[cfg(feature = "derive")]
#[test]
pub fn test_box() {
#[derive(alkahest_proc::Formula)]
struct Foo {
a: u32,
}

#[alkahest_proc::alkahest(SerializeRef<Foo>, Deserialize<'_, Foo>)]
#[derive(Debug, PartialEq, Eq)]
struct FooWithBox {
a: Box<u32>,
}

let foo = FooWithBox { a: Box::new(42) };

let mut buffer = [0u8; 4];
crate::serialize::<Foo, _>(&foo, &mut buffer).unwrap();

let foo2 = crate::deserialize::<Foo, FooWithBox>(&buffer).unwrap();

assert_eq!(foo, foo2);
}

0 comments on commit 48f954d

Please sign in to comment.