unsafe impl in tests

This commit is contained in:
stelzo 2024-06-23 19:20:29 +02:00
parent 4b9a4ddae3
commit d72a4491d4
No known key found for this signature in database
GPG Key ID: FC4EF89052319374
2 changed files with 25 additions and 10 deletions

View File

@ -10,6 +10,7 @@ RUN apt-get install -y \
curl \
libclang-dev \
git \
python3 \
python3-pip \
python3-vcstool
@ -17,8 +18,8 @@ RUN apt-get install -y \
RUN curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | bash -s -- -y
RUN echo 'source $HOME/.cargo/env' >> $HOME/.bashrc
RUN . $HOME/.cargo/env && cargo install --debug cargo-ament-build
RUN pip install git+https://github.com/colcon/colcon-cargo.git
RUN pip install git+https://github.com/colcon/colcon-ros-cargo.git
RUN python3 -m pip install git+https://github.com/colcon/colcon-cargo.git
RUN python3 -m pip install git+https://github.com/colcon/colcon-ros-cargo.git
WORKDIR /ros2_rust_build
RUN git clone https://github.com/ros2-rust/ros2_rust.git src/ros2_rust

View File

@ -1,3 +1,4 @@
use pretty_assertions::assert_eq;
use ros_pointcloud2::prelude::*;
#[cfg(feature = "derive")]
@ -55,6 +56,19 @@ fn write_cloud() {
let msg = PointCloud2Msg::try_from_iter(cloud);
assert!(msg.is_ok());
}
/*
#[test]
fn collect_vec() {
let cloud = vec![
PointXYZ::new(0.0, 1.0, 5.0),
PointXYZ::new(1.0, 1.5, 5.0),
PointXYZ::new(1.3, 1.6, 5.7),
PointXYZ::new(f32::MAX, f32::MIN, f32::MAX),
]
.into_iter();
let msg: Result<PointCloud2Msg, MsgConversionError> = cloud.collect();
}*/
#[test]
fn write_cloud_from_vec() {
@ -130,7 +144,7 @@ fn conv_cloud_par_par_iter() {
#[cfg(feature = "derive")]
fn custom_xyz_f32() {
#[derive(Debug, PartialEq, Clone, Default)]
#[repr(C)]
#[repr(C, align(4))]
struct CustomPoint {
x: f32,
y: f32,
@ -153,7 +167,7 @@ fn custom_xyz_f32() {
}
}
impl PointConvertible<3> for CustomPoint {
unsafe impl PointConvertible<3> for CustomPoint {
fn layout() -> LayoutDescription {
LayoutDescription::new(&[
LayoutField::new("x", "f32", 4),
@ -215,7 +229,7 @@ fn custom_xyzi_f32() {
];
#[derive(Debug, PartialEq, Clone, Default)]
#[repr(C)]
#[repr(C, align(4))]
struct CustomPointXYZI {
x: f32,
y: f32,
@ -246,7 +260,7 @@ fn custom_xyzi_f32() {
}
}
impl PointConvertible<4> for CustomPointXYZI {
unsafe impl PointConvertible<4> for CustomPointXYZI {
fn layout() -> LayoutDescription {
LayoutDescription::new(&[
LayoutField::new("x", "f32", 4),
@ -265,7 +279,7 @@ fn custom_xyzi_f32() {
#[cfg(feature = "derive")]
fn custom_rgba_f32() {
#[derive(Debug, PartialEq, Clone, Default)]
#[repr(C)]
#[repr(C, align(4))]
struct CustomPoint {
x: f32,
y: f32,
@ -305,7 +319,7 @@ fn custom_rgba_f32() {
}
}
impl PointConvertible<7> for CustomPoint {
unsafe impl PointConvertible<7> for CustomPoint {
fn layout() -> LayoutDescription {
LayoutDescription::new(&[
LayoutField::new("x", "f32", 4),
@ -556,7 +570,7 @@ fn write_xyzi_read_xyz_vec() {
#[test]
fn write_less_than_available() {
#[derive(Debug, PartialEq, Clone, Default)]
#[repr(C)]
#[repr(C, align(4))]
struct CustomPoint {
x: f32,
y: f32,
@ -581,7 +595,7 @@ fn write_less_than_available() {
}
}
impl PointConvertible<3> for CustomPoint {
unsafe impl PointConvertible<3> for CustomPoint {
fn layout() -> LayoutDescription {
LayoutDescription::new(&[
LayoutField::new("x", "f32", 4),