Skip to content

Commit 04b8559

Browse files
committed
Improve code style of new voxel grid tests
1 parent 09325e3 commit 04b8559

File tree

1 file changed

+11
-28
lines changed

1 file changed

+11
-28
lines changed

test/filters/test_experimental_voxel_grid.cpp

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ EXPECT_POINT_EQ(const PointXYZRGBA& pt1, const PointXYZRGBA& pt2)
5151

5252
template <typename PointT>
5353
void
54-
EXPECT_POINTS_EQ(PointCloud<PointT> pc1, PointCloud<PointT> pc2)
54+
EXPECT_POINTS_EQ(PointCloud<PointT>& pc1, PointCloud<PointT>& pc2)
5555
{
5656
ASSERT_EQ(pc1.size(), pc2.size());
5757

@@ -187,31 +187,14 @@ TEST(LeafLayout, ExperimentalVoxelGridEquivalency)
187187
}
188188
}
189189

190-
// Update to std::tuple which can get by type in C++17
191-
template <typename PointT>
192-
typename PointCloud<PointT>::Ptr
193-
getCloud();
194-
template <>
195-
PointCloud<PointXYZ>::Ptr
196-
getCloud<PointXYZ>()
197-
{
198-
return cloud;
199-
}
200-
template <>
201-
PointCloud<PointXYZRGB>::Ptr
202-
getCloud<PointXYZRGB>()
203-
{
204-
return cloud_rgb;
205-
}
206-
template <>
207-
PointCloud<PointXYZRGBA>::Ptr
208-
getCloud<PointXYZRGBA>()
209-
{
210-
return cloud_rgba;
211-
}
212-
213190
template <typename T>
214-
class PointTypesTest : public ::testing::Test {};
191+
class PointTypesTest : public ::testing::Test {
192+
protected:
193+
const std::tuple<PointCloud<PointXYZ>::Ptr,
194+
PointCloud<PointXYZRGB>::Ptr,
195+
PointCloud<PointXYZRGBA>::Ptr>
196+
clouds{cloud, cloud_rgb, cloud_rgba};
197+
};
215198
using PointTypes = ::testing::Types<PointXYZ, PointXYZRGB, PointXYZRGBA>;
216199
TYPED_TEST_SUITE(PointTypesTest, PointTypes);
217200

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

223206
PointCloud<PointT> new_out, old_out;
224-
PointCloudPtr cloudT = getCloud<PointT>();
207+
const PointCloudPtr input_cloud = std::get<PointCloudPtr>(TestFixture::clouds);
225208

226209
pcl::experimental::VoxelGrid<PointT> new_grid;
227210
pcl::VoxelGrid<PointT> old_grid;
228211
new_grid.setLeafSize(0.05f, 0.05f, 0.05f);
229212
old_grid.setLeafSize(0.05f, 0.05f, 0.05f);
230-
new_grid.setInputCloud(cloudT);
231-
old_grid.setInputCloud(cloudT);
213+
new_grid.setInputCloud(input_cloud);
214+
old_grid.setInputCloud(input_cloud);
232215

233216
new_grid.setDownsampleAllData(false);
234217
old_grid.setDownsampleAllData(false);

0 commit comments

Comments
 (0)