Skip to content

Commit

Permalink
Improve code style of new voxel grid tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tin1254 committed Aug 21, 2021
1 parent a4974e5 commit 1401a73
Showing 1 changed file with 11 additions and 28 deletions.
39 changes: 11 additions & 28 deletions test/filters/test_experimental_voxel_grid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ EXPECT_POINT_EQ(const PointXYZRGBA& pt1, const PointXYZRGBA& pt2)

template <typename PointT>
void
EXPECT_POINTS_EQ(PointCloud<PointT> pc1, PointCloud<PointT> pc2)
EXPECT_POINTS_EQ(PointCloud<PointT>& pc1, PointCloud<PointT>& pc2)
{
ASSERT_EQ(pc1.size(), pc2.size());

Expand Down Expand Up @@ -187,31 +187,14 @@ TEST(LeafLayout, ExperimentalVoxelGridEquivalency)
}
}

// Update to std::tuple which can get by type in C++17
template <typename PointT>
typename PointCloud<PointT>::Ptr
getCloud();
template <>
PointCloud<PointXYZ>::Ptr
getCloud<PointXYZ>()
{
return cloud;
}
template <>
PointCloud<PointXYZRGB>::Ptr
getCloud<PointXYZRGB>()
{
return cloud_rgb;
}
template <>
PointCloud<PointXYZRGBA>::Ptr
getCloud<PointXYZRGBA>()
{
return cloud_rgba;
}

template <typename T>
class PointTypesTest : public ::testing::Test {};
class PointTypesTest : public ::testing::Test {
protected:
const std::tuple<PointCloud<PointXYZ>::Ptr,
PointCloud<PointXYZRGB>::Ptr,
PointCloud<PointXYZRGBA>::Ptr>
clouds{cloud, cloud_rgb, cloud_rgba};
};
using PointTypes = ::testing::Types<PointXYZ, PointXYZRGB, PointXYZRGBA>;
TYPED_TEST_SUITE(PointTypesTest, PointTypes);

Expand All @@ -221,14 +204,14 @@ TYPED_TEST(PointTypesTest, ExperimentalVoxelGridEquivalency)
using PointCloudPtr = typename PointCloud<PointT>::Ptr;

PointCloud<PointT> new_out, old_out;
PointCloudPtr cloudT = getCloud<PointT>();
const PointCloudPtr input_cloud = std::get<PointCloudPtr>(TestFixture::clouds);

pcl::experimental::VoxelGrid<PointT> new_grid;
pcl::VoxelGrid<PointT> old_grid;
new_grid.setLeafSize(0.05f, 0.05f, 0.05f);
old_grid.setLeafSize(0.05f, 0.05f, 0.05f);
new_grid.setInputCloud(cloudT);
old_grid.setInputCloud(cloudT);
new_grid.setInputCloud(input_cloud);
old_grid.setInputCloud(input_cloud);

new_grid.setDownsampleAllData(false);
old_grid.setDownsampleAllData(false);
Expand Down

0 comments on commit 1401a73

Please sign in to comment.