Skip to content

Commit

Permalink
unsafe impl in tests
Browse files Browse the repository at this point in the history
  • Loading branch information
stelzo committed Jun 23, 2024
1 parent 4b9a4dd commit d72a449
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
5 changes: 3 additions & 2 deletions tests/Dockerfile_rclrs_jazzy
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,16 @@ RUN apt-get install -y \
curl \
libclang-dev \
git \
python3 \
python3-pip \
python3-vcstool

# Get Rust
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
Expand Down
30 changes: 22 additions & 8 deletions tests/e2e_test.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
use pretty_assertions::assert_eq;
use ros_pointcloud2::prelude::*;

#[cfg(feature = "derive")]
Expand Down Expand Up @@ -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() {
Expand Down Expand Up @@ -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,
Expand All @@ -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),
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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),
Expand All @@ -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,
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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,
Expand All @@ -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),
Expand Down

0 comments on commit d72a449

Please sign in to comment.