Skip to content

Commit 3a449d7

Browse files
authored
Merge pull request #466 from OSVR/fix-debug-build-gtest
Workaround an issue with GTest and Debug builds
2 parents 3b5e029 + bfb04fa commit 3a449d7

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

tests/cplusplus/Util/QuatExpMap.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@
2626
#include <osvr/Util/EigenQuatExponentialMap.h>
2727

2828
// Library/third-party includes
29-
#include "gtest/gtest.h"
3029
#include "../EigenTestHelpers.h"
3130
#include "quat.h"
31+
#include "gtest/gtest.h"
3232

3333
// Standard includes
3434
#include <array>
@@ -38,6 +38,12 @@ using osvr::util::quat_exp_map;
3838
static const double SMALL = 0.1;
3939
static const double SMALLER = 1.0e-5;
4040

41+
#if !defined(_WIN32) || defined(NDEBUG)
42+
/// @todo These cause link failures in Windows/DLL debug builds. For now,
43+
/// just assume they're tested enough in release mode.
44+
#define OSVR_CAN_USE_PARAMETERIZED_TESTS
45+
#endif
46+
4147
namespace quat_array {
4248

4349
using array_type = std::array<double, 4>;
@@ -163,6 +169,8 @@ class UnitQuatInput : public ::testing::TestWithParam<QuatCreator> {
163169
Eigen::Quaterniond getQuat() const { return GetParam().get(); }
164170
};
165171

172+
#ifdef OSVR_CAN_USE_PARAMETERIZED_TESTS
173+
166174
TEST_P(UnitQuatInput, BasicRunLn) {
167175
ASSERT_NO_THROW(quat_exp_map(getQuat()).ln());
168176
if (getQuat().vec().norm() > 0) {
@@ -212,6 +220,8 @@ INSTANTIATE_TEST_CASE_P(
212220
QuatCreator::AngleAxis(-SMALLER, Vector3d::UnitX()),
213221
QuatCreator::AngleAxis(-SMALLER, Vector3d::UnitY()),
214222
QuatCreator::AngleAxis(-SMALLER, Vector3d::UnitZ())));
223+
224+
#endif // OSVR_CAN_USE_PARAMETERIZED_TESTS
215225
#if 0
216226
QuatCreator::AngleAxis(M_PI, Vector3d::UnitX()),
217227
QuatCreator::AngleAxis(M_PI, Vector3d::UnitY()),
@@ -221,6 +231,7 @@ QuatCreator::AngleAxis(3 * M_PI / 2, Vector3d::UnitY()),
221231
QuatCreator::AngleAxis(3 * M_PI / 2, Vector3d::UnitZ()),
222232
#endif
223233

234+
#ifdef OSVR_CAN_USE_PARAMETERIZED_TESTS
224235
class ExpMapVecInput : public ::testing::TestWithParam<Eigen::Vector3d> {
225236
public:
226237
// You can implement all the usual fixture class members here.
@@ -269,6 +280,8 @@ INSTANTIATE_TEST_CASE_P(
269280
Vector3d(0, 0, -SMALL), Vector3d(-SMALLER, 0, 0),
270281
Vector3d(0, -SMALLER, 0), Vector3d(0, 0, -SMALLER)));
271282

283+
#endif // OSVR_CAN_USE_PARAMETERIZED_TESTS
284+
272285
inline Quaterniond makeQuat(double angle, Vector3d const &axis) {
273286
return Quaterniond(AngleAxisd(angle, axis));
274287
}
@@ -283,6 +296,7 @@ TEST(SimpleEquivalencies, Exp) {
283296
quat_exp_map(Vector3d::Zero().eval()).exp());
284297
}
285298

299+
#ifdef OSVR_CAN_USE_PARAMETERIZED_TESTS
286300
class EquivalentInput : public ::testing::TestWithParam<QuatVecPair> {
287301
public:
288302
// Gets the first part of theparameter and converts it to a real Eigen quat.
@@ -352,3 +366,5 @@ INSTANTIATE_TEST_CASE_P(
352366
makePairFromAngleAxis(-SMALLER, Vector3d::UnitX()),
353367
makePairFromAngleAxis(-SMALLER, Vector3d::UnitY()),
354368
makePairFromAngleAxis(-SMALLER, Vector3d::UnitZ())));
369+
370+
#endif // OSVR_CAN_USE_PARAMETERIZED_TESTS

0 commit comments

Comments
 (0)