40 #ifndef PCL_TEST_MACROS 41 #define PCL_TEST_MACROS 64 template <
typename V1,
typename V2>
67 SCOPED_TRACE(
"EXPECT_EQ_VECTORS failed");
68 EXPECT_EQ (v1.size (), v2.size ());
69 size_t length = v1.size ();
70 for (
size_t i = 0; i < length; ++i)
71 EXPECT_EQ (v1[i], v2[i]);
74 template <
typename V1,
typename V2,
typename Scalar>
77 SCOPED_TRACE(
"EXPECT_NEAR_VECTORS failed");
78 EXPECT_EQ (v1.size (), v2.size ());
79 size_t length = v1.size ();
80 for (
size_t i = 0; i < length; ++i)
81 EXPECT_NEAR (v1[i], v2[i], epsilon);
87 template <
typename Po
int1T,
typename Po
int2T>
88 ::testing::AssertionResult
XYZEQ (
const char* expr1,
93 if ((p1).getVector3fMap ().cwiseEqual ((p2).getVector3fMap ()).all ())
94 return ::testing::AssertionSuccess ();
95 return ::testing::AssertionFailure ()
96 <<
"Value of: " << expr2 <<
".getVector3fMap ()" << std::endl
97 <<
" Actual: " << p2.getVector3fMap ().transpose () << std::endl
98 <<
"Expected: " << expr1 <<
".getVector3fMap ()" << std::endl
99 <<
"Which is: " << p1.getVector3fMap ().transpose ();
102 template <
typename Po
int1T,
typename Po
int2T>
103 ::testing::AssertionResult
XYZNear (
const char* expr1,
105 const char* abs_error_expr,
110 const Eigen::Vector3f diff = ((p1).getVector3fMap () -
111 (p2).getVector3fMap ()).cwiseAbs ();
112 if ((diff.array () < abs_error).all ())
113 return ::testing::AssertionSuccess ();
114 return ::testing::AssertionFailure ()
115 <<
"Some of the element-wise differences exceed " << abs_error_expr
116 <<
" (which evaluates to " << abs_error <<
")" << std::endl
117 <<
"Difference: " << diff.transpose () << std::endl
118 <<
" Value of: " << expr2 <<
".getVector3fMap ()" << std::endl
119 <<
" Actual: " << p2.getVector3fMap ().transpose () << std::endl
120 <<
" Expected: " << expr1 <<
".getVector3fMap ()" << std::endl
121 <<
" Which is: " << p1.getVector3fMap ().transpose ();
124 template <
typename Po
int1T,
typename Po
int2T>
125 ::testing::AssertionResult
NormalEQ (
const char* expr1,
130 if ((p1).getNormalVector3fMap ().cwiseEqual ((p2).getNormalVector3fMap ()).all ())
131 return ::testing::AssertionSuccess ();
132 return ::testing::AssertionFailure ()
133 <<
"Value of: " << expr2 <<
".getNormalVector3fMap ()" << std::endl
134 <<
" Actual: " << p2.getNormalVector3fMap ().transpose () << std::endl
135 <<
"Expected: " << expr1 <<
".getNormalVector3fMap ()" << std::endl
136 <<
"Which is: " << p1.getNormalVector3fMap ().transpose ();
139 template <
typename Po
int1T,
typename Po
int2T>
142 const char* abs_error_expr,
147 const Eigen::Vector3f diff = ((p1).getNormalVector3fMap () -
148 (p2).getNormalVector3fMap ()).cwiseAbs ();
149 if ((diff.array () < abs_error).all ())
150 return ::testing::AssertionSuccess ();
151 return ::testing::AssertionFailure ()
152 <<
"Some of the element-wise differences exceed " << abs_error_expr
153 <<
" (which evaluates to " << abs_error <<
")" << std::endl
154 <<
"Difference: " << diff.transpose () << std::endl
155 <<
" Value of: " << expr2 <<
".getNormalVector3fMap ()" << std::endl
156 <<
" Actual: " << p2.getNormalVector3fMap ().transpose () << std::endl
157 <<
" Expected: " << expr1 <<
".getNormalVector3fMap ()" << std::endl
158 <<
" Which is: " << p1.getNormalVector3fMap ().transpose ();
161 template <
typename Po
int1T,
typename Po
int2T>
162 ::testing::AssertionResult
RGBEQ (
const char* expr1,
167 if ((p1).getRGBVector3i ().cwiseEqual ((p2).getRGBVector3i ()).all ())
168 return ::testing::AssertionSuccess ();
169 return ::testing::AssertionFailure ()
170 <<
"Value of: " << expr2 <<
".getRGBVector3i ()" << std::endl
171 <<
" Actual: " << p2.getRGBVector3i ().transpose () << std::endl
172 <<
"Expected: " << expr1 <<
".getRGBVector3i ()" << std::endl
173 <<
"Which is: " << p1.getRGBVector3i ().transpose ();
176 template <
typename Po
int1T,
typename Po
int2T>
177 ::testing::AssertionResult
RGBAEQ (
const char* expr1,
182 if ((p1).getRGBAVector4i ().cwiseEqual ((p2).getRGBAVector4i ()).all ())
183 return ::testing::AssertionSuccess ();
184 return ::testing::AssertionFailure ()
185 <<
"Value of: " << expr2 <<
".getRGBAVector4i ()" << std::endl
186 <<
" Actual: " << p2.getRGBAVector4i ().transpose () << std::endl
187 <<
"Expected: " << expr1 <<
".getRGBAVector4i ()" << std::endl
188 <<
"Which is: " << p1.getRGBAVector4i ().transpose ();
191 template <
typename Po
intCloud1T,
typename Po
intCloud2T>
194 const PointCloud1T& p1,
195 const PointCloud2T& p2)
197 if (!(p1.header == p2.header))
198 return ::testing::AssertionFailure () <<
"Headers are different";
199 if (p1.width != p2.width)
200 return ::testing::AssertionFailure ()
201 <<
"Value of: " << expr2 <<
".width" << std::endl
202 <<
" Actual: " << p2.width << std::endl
203 <<
"Expected: " << expr1 <<
".width" << std::endl
204 <<
"Which is: " << p1.width << std::endl;
205 if (p1.height != p2.height)
206 return ::testing::AssertionFailure ()
207 <<
"Value of: " << expr2 <<
".height" << std::endl
208 <<
" Actual: " << p2.height << std::endl
209 <<
"Expected: " << expr1 <<
".height" << std::endl
210 <<
"Which is: " << p1.height << std::endl;
211 if (p1.is_dense != p2.is_dense)
212 return ::testing::AssertionFailure ()
213 <<
"Value of: " << expr2 <<
".is_dense" << std::endl
214 <<
" Actual: " << p2.is_dense << std::endl
215 <<
"Expected: " << expr1 <<
".is_dense" << std::endl
216 <<
"Which is: " << p1.is_dense << std::endl;
217 if (p1.sensor_origin_ != p2.sensor_origin_)
218 return ::testing::AssertionFailure () <<
"Sensor origins are different";
219 if (p1.sensor_orientation_.coeffs () != p2.sensor_orientation_.coeffs ())
220 return ::testing::AssertionFailure () <<
"Sensor orientations are different";
221 return ::testing::AssertionSuccess ();
232 #define EXPECT_XYZ_EQ(expected, actual) \ 233 EXPECT_PRED_FORMAT2(::pcl::test::internal::XYZEQ, \ 234 (expected), (actual)) 238 #define ASSERT_XYZ_EQ(expected, actual) \ 239 ASSERT_PRED_FORMAT2(::pcl::test::internal::XYZEQ, \ 240 (expected), (actual)) 244 #define EXPECT_XYZ_NEAR(expected, actual, abs_error) \ 245 EXPECT_PRED_FORMAT3(::pcl::test::internal::XYZNear, \ 246 (expected), (actual), abs_error) 250 #define ASSERT_XYZ_NEAR(expected, actual, abs_error) \ 251 ASSERT_PRED_FORMAT3(::pcl::test::internal::XYZNear, \ 252 (expected), (actual), abs_error) 256 #define EXPECT_NORMAL_EQ(expected, actual) \ 257 EXPECT_PRED_FORMAT2(::pcl::test::internal::NormalEQ, \ 258 (expected), (actual)) 262 #define ASSERT_NORMAL_EQ(expected, actual) \ 263 ASSERT_PRED_FORMAT2(::pcl::test::internal::NormalEQ, \ 264 (expected), (actual)) 269 #define EXPECT_NORMAL_NEAR(expected, actual, abs_error) \ 270 EXPECT_PRED_FORMAT3(::pcl::test::internal::NormalNear, \ 271 (expected), (actual), abs_error) 276 #define ASSERT_NORMAL_NEAR(expected, actual, abs_error) \ 277 ASSERT_PRED_FORMAT3(::pcl::test::internal::NormalNear, \ 278 (expected), (actual), abs_error) 282 #define EXPECT_RGB_EQ(expected, actual) \ 283 EXPECT_PRED_FORMAT2(::pcl::test::internal::RGBEQ, \ 284 (expected), (actual)) 288 #define ASSERT_RGB_EQ(expected, actual) \ 289 ASSERT_PRED_FORMAT2(::pcl::test::internal::RGBEQ, \ 290 (expected), (actual)) 294 #define EXPECT_RGBA_EQ(expected, actual) \ 295 EXPECT_PRED_FORMAT2(::pcl::test::internal::RGBAEQ, \ 296 (expected), (actual)) 300 #define ASSERT_RGBA_EQ(expected, actual) \ 301 ASSERT_PRED_FORMAT2(::pcl::test::internal::RGBAEQ, \ 302 (expected), (actual)) 307 #define ASSERT_METADATA_EQ(expected, actual) \ 308 ASSERT_PRED_FORMAT2(::pcl::test::internal::MetaDataEQ, \ 314 #define EXPECT_METADATA_EQ(expected, actual) \ 315 EXPECT_PRED_FORMAT2(::pcl::test::internal::MetaDataEQ, \ ::testing::AssertionResult NormalNear(const char *expr1, const char *expr2, const char *abs_error_expr, const Point1T &p1, const Point2T &p2, double abs_error)
::testing::AssertionResult RGBAEQ(const char *expr1, const char *expr2, const Point1T &p1, const Point2T &p2)
void EXPECT_EQ_VECTORS(const V1 &v1, const V2 &v2)
::testing::AssertionResult MetaDataEQ(const char *expr1, const char *expr2, const PointCloud1T &p1, const PointCloud2T &p2)
This file defines compatibility wrappers for low level I/O functions.
::testing::AssertionResult XYZEQ(const char *expr1, const char *expr2, const Point1T &p1, const Point2T &p2)
void EXPECT_NEAR_VECTORS(const V1 &v1, const V2 &v2, const Scalar &epsilon)
::testing::AssertionResult RGBEQ(const char *expr1, const char *expr2, const Point1T &p1, const Point2T &p2)
::testing::AssertionResult NormalEQ(const char *expr1, const char *expr2, const Point1T &p1, const Point2T &p2)
::testing::AssertionResult XYZNear(const char *expr1, const char *expr2, const char *abs_error_expr, const Point1T &p1, const Point2T &p2, double abs_error)