testing derive in separate crate

This commit is contained in:
stelzo 2024-05-20 00:36:30 +02:00
parent 080ced8816
commit f19a8e8df7
No known key found for this signature in database
GPG Key ID: FC4EF89052319374
3 changed files with 29 additions and 1 deletions

View File

@ -1,5 +1,5 @@
[workspace]
members = ["rpcl2", "rpcl2-derive"]
members = [ "derive-test","rpcl2", "rpcl2-derive"]
resolver = "2"

8
derive-test/Cargo.toml Normal file
View File

@ -0,0 +1,8 @@
[package]
name = "derive-test"
version = "0.1.0"
edition = "2021"
[dependencies]
ros_pointcloud2 = { path = "../rpcl2", features = ["std", "derive"] }
rpcl2-derive = { path = "../rpcl2-derive" }

View File

@ -0,0 +1,20 @@
use ros_pointcloud2::PointConvertible;
use rpcl2_derive::*;
#[derive(Debug, PartialEq, Clone, Default, PointConvertible)]
#[repr(C, align(4))]
struct MyPointXYZI {
x: f32,
#[rpcl2(rename("test"))]
y: u16,
z: f32,
#[rpcl2(rename("i"))]
intensity: i32,
label: u8,
}
#[test]
fn layout() {
let layout_str = format!("{:?}", MyPointXYZI::layout());
assert_eq!("LayoutDescription([Field { name: \"x\", ty: \"f32\", size: 4 }, Field { name: \"test\", ty: \"u16\", size: 2 }, Padding { size: 2 }, Field { name: \"z\", ty: \"f32\", size: 4 }, Field { name: \"i\", ty: \"i32\", size: 4 }, Field { name: \"label\", ty: \"u8\", size: 1 }, Padding { size: 3 }])", layout_str);
}