/usr/include/pcl-1.7/pcl/pcl_tests.h is in libpcl-dev 1.7.2-14build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 | /*
* Software License Agreement (BSD License)
*
* Point Cloud Library (PCL) - www.pointclouds.org
* Copyright (c) 2010-2012, Willow Garage, Inc.
*
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided
* with the distribution.
* * Neither the name of the copyright holder(s) nor the names of its
* contributors may be used to endorse or promote products derived
* from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*
* $Id$
*/
#ifndef PCL_TEST_MACROS
#define PCL_TEST_MACROS
#include <Eigen/Core>
/** \file pcl_tests.h
* Helper macros for testing equality of various data fields in PCL points */
namespace pcl
{
/** test_macros.h provide helper macros for testing vectors, matrices etc.
* We took some liberty with upcasing names to make them look like googletest
* macros names so that reader is not confused.
*
* This file also provides a family of googletest-style macros for asserting
* equality or nearness of xyz, normal, and rgba fields.
*
* \author Nizar Sallem, Sergey Alexandrov
*/
namespace test
{
template <typename V1, typename V2>
void EXPECT_EQ_VECTORS (const V1& v1, const V2& v2)
{
SCOPED_TRACE("EXPECT_EQ_VECTORS failed");
EXPECT_EQ (v1.size (), v2.size ());
size_t length = v1.size ();
for (size_t i = 0; i < length; ++i)
EXPECT_EQ (v1[i], v2[i]);
}
template <typename V1, typename V2, typename Scalar>
void EXPECT_NEAR_VECTORS (const V1& v1, const V2& v2, const Scalar& epsilon)
{
SCOPED_TRACE("EXPECT_NEAR_VECTORS failed");
EXPECT_EQ (v1.size (), v2.size ());
size_t length = v1.size ();
for (size_t i = 0; i < length; ++i)
EXPECT_NEAR (v1[i], v2[i], epsilon);
}
namespace internal
{
template <typename Point1T, typename Point2T>
::testing::AssertionResult XYZEQ (const char* expr1,
const char* expr2,
const Point1T& p1,
const Point2T& p2)
{
if ((p1).getVector3fMap ().cwiseEqual ((p2).getVector3fMap ()).all ())
return ::testing::AssertionSuccess ();
return ::testing::AssertionFailure ()
<< "Value of: " << expr2 << ".getVector3fMap ()" << std::endl
<< " Actual: " << p2.getVector3fMap ().transpose () << std::endl
<< "Expected: " << expr1 << ".getVector3fMap ()" << std::endl
<< "Which is: " << p1.getVector3fMap ().transpose ();
}
template <typename Point1T, typename Point2T>
::testing::AssertionResult XYZNear (const char* expr1,
const char* expr2,
const char* abs_error_expr,
const Point1T& p1,
const Point2T& p2,
double abs_error)
{
const Eigen::Vector3f diff = ((p1).getVector3fMap () -
(p2).getVector3fMap ()).cwiseAbs ();
if ((diff.array () < abs_error).all ())
return ::testing::AssertionSuccess ();
return ::testing::AssertionFailure ()
<< "Some of the element-wise differences exceed " << abs_error_expr
<< " (which evaluates to " << abs_error << ")" << std::endl
<< "Difference: " << diff.transpose () << std::endl
<< " Value of: " << expr2 << ".getVector3fMap ()" << std::endl
<< " Actual: " << p2.getVector3fMap ().transpose () << std::endl
<< " Expected: " << expr1 << ".getVector3fMap ()" << std::endl
<< " Which is: " << p1.getVector3fMap ().transpose ();
}
template <typename Point1T, typename Point2T>
::testing::AssertionResult NormalEQ (const char* expr1,
const char* expr2,
const Point1T& p1,
const Point2T& p2)
{
if ((p1).getNormalVector3fMap ().cwiseEqual ((p2).getNormalVector3fMap ()).all ())
return ::testing::AssertionSuccess ();
return ::testing::AssertionFailure ()
<< "Value of: " << expr2 << ".getNormalVector3fMap ()" << std::endl
<< " Actual: " << p2.getNormalVector3fMap ().transpose () << std::endl
<< "Expected: " << expr1 << ".getNormalVector3fMap ()" << std::endl
<< "Which is: " << p1.getNormalVector3fMap ().transpose ();
}
template <typename Point1T, typename Point2T>
::testing::AssertionResult NormalNear (const char* expr1,
const char* expr2,
const char* abs_error_expr,
const Point1T& p1,
const Point2T& p2,
double abs_error)
{
const Eigen::Vector3f diff = ((p1).getNormalVector3fMap () -
(p2).getNormalVector3fMap ()).cwiseAbs ();
if ((diff.array () < abs_error).all ())
return ::testing::AssertionSuccess ();
return ::testing::AssertionFailure ()
<< "Some of the element-wise differences exceed " << abs_error_expr
<< " (which evaluates to " << abs_error << ")" << std::endl
<< "Difference: " << diff.transpose () << std::endl
<< " Value of: " << expr2 << ".getNormalVector3fMap ()" << std::endl
<< " Actual: " << p2.getNormalVector3fMap ().transpose () << std::endl
<< " Expected: " << expr1 << ".getNormalVector3fMap ()" << std::endl
<< " Which is: " << p1.getNormalVector3fMap ().transpose ();
}
template <typename Point1T, typename Point2T>
::testing::AssertionResult RGBEQ (const char* expr1,
const char* expr2,
const Point1T& p1,
const Point2T& p2)
{
if ((p1).getRGBVector3i ().cwiseEqual ((p2).getRGBVector3i ()).all ())
return ::testing::AssertionSuccess ();
return ::testing::AssertionFailure ()
<< "Value of: " << expr2 << ".getRGBVector3i ()" << std::endl
<< " Actual: " << p2.getRGBVector3i ().transpose () << std::endl
<< "Expected: " << expr1 << ".getRGBVector3i ()" << std::endl
<< "Which is: " << p1.getRGBVector3i ().transpose ();
}
template <typename Point1T, typename Point2T>
::testing::AssertionResult RGBAEQ (const char* expr1,
const char* expr2,
const Point1T& p1,
const Point2T& p2)
{
if ((p1).getRGBAVector4i ().cwiseEqual ((p2).getRGBAVector4i ()).all ())
return ::testing::AssertionSuccess ();
return ::testing::AssertionFailure ()
<< "Value of: " << expr2 << ".getRGBAVector4i ()" << std::endl
<< " Actual: " << p2.getRGBAVector4i ().transpose () << std::endl
<< "Expected: " << expr1 << ".getRGBAVector4i ()" << std::endl
<< "Which is: " << p1.getRGBAVector4i ().transpose ();
}
}
}
}
/// Expect that each of x, y, and z fields are equal in
/// two points.
#define EXPECT_XYZ_EQ(expected, actual) \
EXPECT_PRED_FORMAT2(::pcl::test::internal::XYZEQ, \
(expected), (actual))
/// Assert that each of x, y, and z fields are equal in
/// two points.
#define ASSERT_XYZ_EQ(expected, actual) \
ASSERT_PRED_FORMAT2(::pcl::test::internal::XYZEQ, \
(expected), (actual))
/// Expect that differences between x, y, and z fields in
/// two points are each within abs_error.
#define EXPECT_XYZ_NEAR(expected, actual, abs_error) \
EXPECT_PRED_FORMAT3(::pcl::test::internal::XYZNear, \
(expected), (actual), abs_error)
/// Assert that differences between x, y, and z fields in
/// two points are each within abs_error.
#define ASSERT_XYZ_NEAR(expected, actual, abs_error) \
EXPECT_PRED_FORMAT3(::pcl::test::internal::XYZNear, \
(expected), (actual), abs_error)
/// Expect that each of normal_x, normal_y, and normal_z
/// fields are equal in two points.
#define EXPECT_NORMAL_EQ(expected, actual) \
EXPECT_PRED_FORMAT2(::pcl::test::internal::NormalEQ, \
(expected), (actual))
/// Assert that each of normal_x, normal_y, and normal_z
/// fields are equal in two points.
#define ASSERT_NORMAL_EQ(expected, actual) \
ASSERT_PRED_FORMAT2(::pcl::test::internal::NormalEQ, \
(expected), (actual))
/// Expect that differences between normal_x, normal_y,
/// and normal_z fields in two points are each within
/// abs_error.
#define EXPECT_NORMAL_NEAR(expected, actual, abs_error) \
EXPECT_PRED_FORMAT3(::pcl::test::internal::NormalNear, \
(expected), (actual), abs_error)
/// Assert that differences between normal_x, normal_y,
/// and normal_z fields in two points are each within
/// abs_error.
#define ASSERT_NORMAL_NEAR(expected, actual, abs_error) \
EXPECT_PRED_FORMAT3(::pcl::test::internal::NormalNear, \
(expected), (actual), abs_error)
/// Expect that each of r, g, and b fields are equal in
/// two points.
#define EXPECT_RGB_EQ(expected, actual) \
EXPECT_PRED_FORMAT2(::pcl::test::internal::RGBEQ, \
(expected), (actual))
/// Assert that each of r, g, and b fields are equal in
/// two points.
#define ASSERT_RGB_EQ(expected, actual) \
ASSERT_PRED_FORMAT2(::pcl::test::internal::RGBEQ, \
(expected), (actual))
/// Expect that each of r, g, b, and a fields are equal
/// in two points.
#define EXPECT_RGBA_EQ(expected, actual) \
EXPECT_PRED_FORMAT2(::pcl::test::internal::RGBAEQ, \
(expected), (actual))
/// Assert that each of r, g, b, and a fields are equal
/// in two points.
#define ASSERT_RGBA_EQ(expected, actual) \
ASSERT_PRED_FORMAT2(::pcl::test::internal::RGBAEQ, \
(expected), (actual))
#endif
|