62 template <
typename V1,
typename V2>
65 SCOPED_TRACE(
"EXPECT_EQ_VECTORS failed");
66 EXPECT_EQ (v1.size (), v2.size ());
67 std::size_t length = std::min<std::size_t> (v1.size (), v2.size ());
68 for (std::size_t i = 0; i < length; ++i)
69 EXPECT_EQ (v1[i], v2[i]);
72 template <
typename V1,
typename V2,
typename Scalar>
75 SCOPED_TRACE(
"EXPECT_NEAR_VECTORS failed");
76 EXPECT_EQ (v1.size (), v2.size ());
77 std::size_t length = std::min<std::size_t> (v1.size (), v2.size());
78 for (std::size_t i = 0; i < length; ++i)
79 EXPECT_NEAR (v1[i], v2[i], epsilon);
85 template <
typename Po
int1T,
typename Po
int2T>
86 ::testing::AssertionResult
XYZEQ (
const char* expr1,
91 if ((p1).getVector3fMap ().cwiseEqual ((p2).getVector3fMap ()).all ())
92 return ::testing::AssertionSuccess ();
93 return ::testing::AssertionFailure ()
94 <<
"Value of: " << expr2 <<
".getVector3fMap ()" << std::endl
95 <<
" Actual: " << p2.getVector3fMap ().transpose () << std::endl
96 <<
"Expected: " << expr1 <<
".getVector3fMap ()" << std::endl
97 <<
"Which is: " << p1.getVector3fMap ().transpose ();
100 template <
typename Po
int1T,
typename Po
int2T>
101 ::testing::AssertionResult
XYZNear (
const char* expr1,
103 const char* abs_error_expr,
108 const Eigen::Vector3f diff = ((p1).getVector3fMap () -
109 (p2).getVector3fMap ()).cwiseAbs ();
110 if ((diff.array () < abs_error).all ())
111 return ::testing::AssertionSuccess ();
112 return ::testing::AssertionFailure ()
113 <<
"Some of the element-wise differences exceed " << abs_error_expr
114 <<
" (which evaluates to " << abs_error <<
")" << std::endl
115 <<
"Difference: " << diff.transpose () << std::endl
116 <<
" Value of: " << expr2 <<
".getVector3fMap ()" << std::endl
117 <<
" Actual: " << p2.getVector3fMap ().transpose () << std::endl
118 <<
" Expected: " << expr1 <<
".getVector3fMap ()" << std::endl
119 <<
" Which is: " << p1.getVector3fMap ().transpose ();
122 template <
typename Po
int1T,
typename Po
int2T>
123 ::testing::AssertionResult
NormalEQ (
const char* expr1,
128 if ((p1).getNormalVector3fMap ().cwiseEqual ((p2).getNormalVector3fMap ()).all ())
129 return ::testing::AssertionSuccess ();
130 return ::testing::AssertionFailure ()
131 <<
"Value of: " << expr2 <<
".getNormalVector3fMap ()" << std::endl
132 <<
" Actual: " << p2.getNormalVector3fMap ().transpose () << std::endl
133 <<
"Expected: " << expr1 <<
".getNormalVector3fMap ()" << std::endl
134 <<
"Which is: " << p1.getNormalVector3fMap ().transpose ();
137 template <
typename Po
int1T,
typename Po
int2T>
140 const char* abs_error_expr,
145 const Eigen::Vector3f diff = ((p1).getNormalVector3fMap () -
146 (p2).getNormalVector3fMap ()).cwiseAbs ();
147 if ((diff.array () < abs_error).all ())
148 return ::testing::AssertionSuccess ();
149 return ::testing::AssertionFailure ()
150 <<
"Some of the element-wise differences exceed " << abs_error_expr
151 <<
" (which evaluates to " << abs_error <<
")" << std::endl
152 <<
"Difference: " << diff.transpose () << std::endl
153 <<
" Value of: " << expr2 <<
".getNormalVector3fMap ()" << std::endl
154 <<
" Actual: " << p2.getNormalVector3fMap ().transpose () << std::endl
155 <<
" Expected: " << expr1 <<
".getNormalVector3fMap ()" << std::endl
156 <<
" Which is: " << p1.getNormalVector3fMap ().transpose ();
159 template <
typename Po
int1T,
typename Po
int2T>
160 ::testing::AssertionResult
RGBEQ (
const char* expr1,
165 if ((p1).getRGBVector3i ().cwiseEqual ((p2).getRGBVector3i ()).all ())
166 return ::testing::AssertionSuccess ();
167 return ::testing::AssertionFailure ()
168 <<
"Value of: " << expr2 <<
".getRGBVector3i ()" << std::endl
169 <<
" Actual: " << p2.getRGBVector3i ().transpose () << std::endl
170 <<
"Expected: " << expr1 <<
".getRGBVector3i ()" << std::endl
171 <<
"Which is: " << p1.getRGBVector3i ().transpose ();
174 template <
typename Po
int1T,
typename Po
int2T>
175 ::testing::AssertionResult
RGBAEQ (
const char* expr1,
180 if ((p1).getRGBAVector4i ().cwiseEqual ((p2).getRGBAVector4i ()).all ())
181 return ::testing::AssertionSuccess ();
182 return ::testing::AssertionFailure ()
183 <<
"Value of: " << expr2 <<
".getRGBAVector4i ()" << std::endl
184 <<
" Actual: " << p2.getRGBAVector4i ().transpose () << std::endl
185 <<
"Expected: " << expr1 <<
".getRGBAVector4i ()" << std::endl
186 <<
"Which is: " << p1.getRGBAVector4i ().transpose ();
189 template <
typename Po
intCloud1T,
typename Po
intCloud2T>
192 const PointCloud1T& p1,
193 const PointCloud2T& p2)
195 if (!(p1.header == p2.header))
196 return ::testing::AssertionFailure () <<
"Headers are different";
197 if (p1.width != p2.width)
198 return ::testing::AssertionFailure ()
199 <<
"Value of: " << expr2 <<
".width" << std::endl
200 <<
" Actual: " << p2.width << std::endl
201 <<
"Expected: " << expr1 <<
".width" << std::endl
202 <<
"Which is: " << p1.width << std::endl;
203 if (p1.height != p2.height)
204 return ::testing::AssertionFailure ()
205 <<
"Value of: " << expr2 <<
".height" << std::endl
206 <<
" Actual: " << p2.height << std::endl
207 <<
"Expected: " << expr1 <<
".height" << std::endl
208 <<
"Which is: " << p1.height << std::endl;
209 if (p1.is_dense != p2.is_dense)
210 return ::testing::AssertionFailure ()
211 <<
"Value of: " << expr2 <<
".is_dense" << std::endl
212 <<
" Actual: " << p2.is_dense << std::endl
213 <<
"Expected: " << expr1 <<
".is_dense" << std::endl
214 <<
"Which is: " << p1.is_dense << std::endl;
215 if (p1.sensor_origin_ != p2.sensor_origin_)
216 return ::testing::AssertionFailure () <<
"Sensor origins are different";
217 if (p1.sensor_orientation_.coeffs () != p2.sensor_orientation_.coeffs ())
218 return ::testing::AssertionFailure () <<
"Sensor orientations are different";
219 return ::testing::AssertionSuccess ();
224 ::testing::AssertionResult
VectorContainsAll(
const char* expr1,
const char* expr2,
const std::vector<V>& elements,
const std::vector<V>& v) {
225 for(
const V& item : elements) {
226 if(std::find(v.cbegin(), v.cend(), item)==v.cend()) {
228 std::ostringstream vec_rep;
229 std::copy(v.cbegin(), v.cend()-1, std::ostream_iterator<V>(vec_rep,
", "));
232 std::ostringstream elements_rep;
233 std::copy(elements.cbegin(), elements.cend()-1, std::ostream_iterator<V>(elements_rep,
", "));
234 elements_rep << elements.back();
236 return ::testing::AssertionFailure ()
237 <<
"Actual : " << expr2 << std::endl
238 <<
"contains : " << vec_rep.str() << std::endl
239 <<
"Target set : " << expr1 << std::endl
240 <<
"contains : " << elements_rep.str() << std::endl;
243 return ::testing::AssertionSuccess ();
247 ::testing::AssertionResult
VectorDoesNotContain(
const char* expr1,
const char* expr2,
const std::vector<V>& elements,
const std::vector<V>& v) {
248 for(
const V& item : elements) {
249 if(std::find(v.cbegin(), v.cend(), item)!=v.cend()) {
250 std::ostringstream vec_rep;
251 std::copy(v.cbegin(), v.cend()-1, std::ostream_iterator<V>(vec_rep,
", "));
254 std::ostringstream elements_rep;
255 std::copy(elements.cbegin(), elements.cend()-1, std::ostream_iterator<V>(elements_rep,
", "));
256 elements_rep << elements.back();
258 return ::testing::AssertionFailure ()
259 <<
"Actual : " << expr2 << std::endl
260 <<
"contains : " << vec_rep.str() << std::endl
261 <<
"Forbidden set: " << expr1 << std::endl
262 <<
"contains : " << elements_rep.str() << std::endl;
265 return ::testing::AssertionSuccess ();
276 #define EXPECT_XYZ_EQ(expected, actual) \
277 EXPECT_PRED_FORMAT2(::pcl::test::internal::XYZEQ, \
278 (expected), (actual))
282 #define ASSERT_XYZ_EQ(expected, actual) \
283 ASSERT_PRED_FORMAT2(::pcl::test::internal::XYZEQ, \
284 (expected), (actual))
288 #define EXPECT_XYZ_NEAR(expected, actual, abs_error) \
289 EXPECT_PRED_FORMAT3(::pcl::test::internal::XYZNear, \
290 (expected), (actual), abs_error)
294 #define ASSERT_XYZ_NEAR(expected, actual, abs_error) \
295 ASSERT_PRED_FORMAT3(::pcl::test::internal::XYZNear, \
296 (expected), (actual), abs_error)
300 #define EXPECT_NORMAL_EQ(expected, actual) \
301 EXPECT_PRED_FORMAT2(::pcl::test::internal::NormalEQ, \
302 (expected), (actual))
306 #define ASSERT_NORMAL_EQ(expected, actual) \
307 ASSERT_PRED_FORMAT2(::pcl::test::internal::NormalEQ, \
308 (expected), (actual))
313 #define EXPECT_NORMAL_NEAR(expected, actual, abs_error) \
314 EXPECT_PRED_FORMAT3(::pcl::test::internal::NormalNear, \
315 (expected), (actual), abs_error)
320 #define ASSERT_NORMAL_NEAR(expected, actual, abs_error) \
321 ASSERT_PRED_FORMAT3(::pcl::test::internal::NormalNear, \
322 (expected), (actual), abs_error)
326 #define EXPECT_RGB_EQ(expected, actual) \
327 EXPECT_PRED_FORMAT2(::pcl::test::internal::RGBEQ, \
328 (expected), (actual))
332 #define ASSERT_RGB_EQ(expected, actual) \
333 ASSERT_PRED_FORMAT2(::pcl::test::internal::RGBEQ, \
334 (expected), (actual))
338 #define EXPECT_RGBA_EQ(expected, actual) \
339 EXPECT_PRED_FORMAT2(::pcl::test::internal::RGBAEQ, \
340 (expected), (actual))
344 #define ASSERT_RGBA_EQ(expected, actual) \
345 ASSERT_PRED_FORMAT2(::pcl::test::internal::RGBAEQ, \
346 (expected), (actual))
351 #define ASSERT_METADATA_EQ(expected, actual) \
352 ASSERT_PRED_FORMAT2(::pcl::test::internal::MetaDataEQ, \
358 #define EXPECT_METADATA_EQ(expected, actual) \
359 EXPECT_PRED_FORMAT2(::pcl::test::internal::MetaDataEQ, \
365 #define EXPECT_VECTOR_CONTAINS_ALL(expected, actual) \
366 EXPECT_PRED_FORMAT2(::pcl::test::internal::VectorContainsAll, \
372 #define EXPECT_VECTOR_DOES_NOT_CONTAIN(expected, actual) \
373 EXPECT_PRED_FORMAT2(::pcl::test::internal::VectorDoesNotContain, \
380 #define ASSERT_VECTOR_CONTAINS_ALL(expected, actual) \
381 ASSERT_PRED_FORMAT2(::pcl::test::internal::VectorContainsAll, \
387 #define ASSERT_VECTOR_DOES_NOT_CONTAIN(expected, actual) \
388 ASSERT_PRED_FORMAT2(::pcl::test::internal::VectorDoesNotContain, \
::testing::AssertionResult RGBAEQ(const char *expr1, const char *expr2, const Point1T &p1, const Point2T &p2)
::testing::AssertionResult MetaDataEQ(const char *expr1, const char *expr2, const PointCloud1T &p1, const PointCloud2T &p2)
::testing::AssertionResult VectorContainsAll(const char *expr1, const char *expr2, const std::vector< V > &elements, const std::vector< V > &v)
::testing::AssertionResult RGBEQ(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)
::testing::AssertionResult XYZEQ(const char *expr1, const char *expr2, const Point1T &p1, const Point2T &p2)
::testing::AssertionResult VectorDoesNotContain(const char *expr1, const char *expr2, const std::vector< V > &elements, const std::vector< V > &v)
::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 NormalEQ(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)
void EXPECT_EQ_VECTORS(const V1 &v1, const V2 &v2)