diff --git a/codetemplates eclipse.xml b/codetemplates eclipse.xml index a83cc56bd43bb272eff012dd89a401c33283610f..85f43146f9e51b952d6bc33e75bcda962262dd0a 100644 --- a/codetemplates eclipse.xml +++ b/codetemplates eclipse.xml @@ -23,7 +23,7 @@ ${declarations} ${namespace_end}</template><template autoinsert="false" context="org.eclipse.cdt.core.cxxSource.contenttype_context" deleted="false" description="Default template for newly created C++ test files" enabled="true" id="org.eclipse.cdt.ui.text.codetemplates.cpptestfile" name="Default C++ test template">${filecomment} -#include "utils_gtest.h" +#include <core/utils/utils_gtest.h> ${includes} diff --git a/test/gtest_IMU.cpp b/test/gtest_IMU.cpp index 4f2f6025e6b73a16770dc49a1159c004b7cefe8c..78244fd32dbe1c510c3fa2b64c87a6c3697b2b8b 100644 --- a/test/gtest_IMU.cpp +++ b/test/gtest_IMU.cpp @@ -13,7 +13,7 @@ #include "core/processor/processor_odom_3D.h" #include "core/ceres_wrapper/ceres_manager.h" -#include "utils_gtest.h" +#include <core/utils/utils_gtest.h> #include "core/utils/logging.h" // make my life easier diff --git a/test/gtest_IMU_tools.cpp b/test/gtest_IMU_tools.cpp index 7faf06fde2baf5f3cf0c810cca1c1f070a0a3c1d..c1b438d68d3471f5439730ab50c015cd0260f8fa 100644 --- a/test/gtest_IMU_tools.cpp +++ b/test/gtest_IMU_tools.cpp @@ -6,7 +6,7 @@ */ #include "IMU/math/IMU_tools.h" -#include "utils_gtest.h" +#include <core/utils/utils_gtest.h> using namespace Eigen; using namespace wolf; diff --git a/test/gtest_example.cpp b/test/gtest_example.cpp index 0cadea4ffe640770290f82ea4b5e17542468d404..140792d538ab5ae568ba7743fbc49bce0bb6d9f2 100644 --- a/test/gtest_example.cpp +++ b/test/gtest_example.cpp @@ -1,4 +1,4 @@ -#include "utils_gtest.h" +#include <core/utils/utils_gtest.h> TEST(TestTest, DummyTestExample) { diff --git a/test/gtest_factor_IMU.cpp b/test/gtest_factor_IMU.cpp index 49ff47590f31c2a49e67117e4dd1f727a14500cb..6224c83f27b594c23234449b781b5cf3f56bae77 100644 --- a/test/gtest_factor_IMU.cpp +++ b/test/gtest_factor_IMU.cpp @@ -13,7 +13,7 @@ #include "core/processor/processor_odom_3D.h" #include "ceres_wrapper/ceres_manager.h" -#include "utils_gtest.h" +#include <core/utils/utils_gtest.h> #include "core/utils/logging.h" #include <iostream> diff --git a/test/gtest_feature_IMU.cpp b/test/gtest_feature_IMU.cpp index 15b39b3fc66d0aa4eb5df1a23c114ed7869145f9..04946583e0df53ced27e92e6406bc9c5defe4020 100644 --- a/test/gtest_feature_IMU.cpp +++ b/test/gtest_feature_IMU.cpp @@ -6,7 +6,7 @@ #include "core/problem/problem.h" #include "core/state_block/state_block.h" #include "core/state_block/state_quaternion.h" -#include "utils_gtest.h" +#include <core/utils/utils_gtest.h> #include "core/utils/logging.h" class FeatureIMU_test : public testing::Test diff --git a/test/gtest_processor_IMU.cpp b/test/gtest_processor_IMU.cpp index 5dbd53a11144e37663cbef6d4dfbfa20542ac205..4029c0f60a76d7b4e231897ce73d3bd02934b209 100644 --- a/test/gtest_processor_IMU.cpp +++ b/test/gtest_processor_IMU.cpp @@ -10,7 +10,7 @@ #include "IMU/sensor/sensor_IMU.h" #include "core/common/wolf.h" -#include "utils_gtest.h" +#include <core/utils/utils_gtest.h> #include "core/utils/logging.h" #include "core/math/rotations.h" diff --git a/test/gtest_processor_IMU_jacobians.cpp b/test/gtest_processor_IMU_jacobians.cpp index 369233724601924e9c402ae3f0ba621e8eda7882..422972ea078fc1cce80297009e7d2e4edbf9e243 100644 --- a/test/gtest_processor_IMU_jacobians.cpp +++ b/test/gtest_processor_IMU_jacobians.cpp @@ -20,7 +20,7 @@ #include <cmath> //google test -#include "utils_gtest.h" +#include <core/utils/utils_gtest.h> //#define DEBUG_RESULTS //#define WRITE_RESULTS diff --git a/test/utils_gtest.h b/test/utils_gtest.h deleted file mode 100644 index 9cb2166e8429cd236f77c502891c14880e57ec30..0000000000000000000000000000000000000000 --- a/test/utils_gtest.h +++ /dev/null @@ -1,146 +0,0 @@ -/** - * \file utils_gtest.h - * \brief Some utils for gtest - * \author Jeremie Deray - * Created on: 26/09/2016 - * Eigen macros extension by: Joan Sola on 26/04/2017 - */ - -#ifndef WOLF_UTILS_GTEST_H -#define WOLF_UTILS_GTEST_H - -#include <gtest/gtest.h> - -// Macros for testing equalities and inequalities. -// -// * {ASSERT|EXPECT}_EQ(expected, actual): Tests that expected == actual -// * {ASSERT|EXPECT}_NE(v1, v2): Tests that v1 != v2 -// * {ASSERT|EXPECT}_LT(v1, v2): Tests that v1 < v2 -// * {ASSERT|EXPECT}_LE(v1, v2): Tests that v1 <= v2 -// * {ASSERT|EXPECT}_GT(v1, v2): Tests that v1 > v2 -// * {ASSERT|EXPECT}_GE(v1, v2): Tests that v1 >= v2 -// -// C String Comparisons. All tests treat NULL and any non-NULL string -// as different. Two NULLs are equal. -// -// * {ASSERT|EXPECT}_STREQ(s1, s2): Tests that s1 == s2 -// * {ASSERT|EXPECT}_STRNE(s1, s2): Tests that s1 != s2 -// * {ASSERT|EXPECT}_STRCASEEQ(s1, s2): Tests that s1 == s2, ignoring case -// * {ASSERT|EXPECT}_STRCASENE(s1, s2): Tests that s1 != s2, ignoring case -// -// Macros for comparing floating-point numbers. -// -// * {ASSERT|EXPECT}_FLOAT_EQ(expected, actual): -// Tests that two float values are almost equal. -// * {ASSERT|EXPECT}_DOUBLE_EQ(expected, actual): -// Tests that two double values are almost equal. -// * {ASSERT|EXPECT}_NEAR(v1, v2, abs_error): -// Tests that v1 and v2 are within the given distance to each other. -// -// These predicate format functions work on floating-point values, and -// can be used in {ASSERT|EXPECT}_PRED_FORMAT2*(), e.g. -// -// EXPECT_PRED_FORMAT2(testing::DoubleLE, Foo(), 5.0); -// -// Macros that execute statement and check that it doesn't generate new fatal -// failures in the current thread. -// -// * {ASSERT|EXPECT}_NO_FATAL_FAILURE(statement); - -// http://stackoverflow.com/a/29155677 - -namespace testing -{ -namespace internal -{ -enum GTestColor -{ - COLOR_DEFAULT, - COLOR_RED, - COLOR_GREEN, - COLOR_YELLOW -}; - -extern void ColoredPrintf(GTestColor color, const char* fmt, ...); - -#define PRINTF(...) \ - do { testing::internal::ColoredPrintf(testing::internal::COLOR_GREEN,\ - "[ ] "); \ - testing::internal::ColoredPrintf(testing::internal::COLOR_YELLOW, __VA_ARGS__); } \ - while(0) - -#define PRINT_TEST_FINISHED \ -{ \ - const ::testing::TestInfo* const test_info = \ - ::testing::UnitTest::GetInstance()->current_test_info(); \ - PRINTF(std::string("Finished test case ").append(test_info->test_case_name()).\ - append(" of test ").append(test_info->name()).append(".\n").c_str()); \ -} - -// C++ stream interface -class TestCout : public std::stringstream -{ -public: - ~TestCout() - { - PRINTF("%s\n", str().c_str()); - } -}; - -/* Usage : - -TEST(Test, Foo) -{ - // the following works but prints default stream - EXPECT_TRUE(false) << "Testing Stream."; - - // or you can play with AINSI color code - EXPECT_TRUE(false) << "\033[1;31m" << "Testing Stream."; - - // or use the above defined macros - - PRINTF("Hello world"); - - // or - - TEST_COUT << "Hello world"; -} - -*/ -#define TEST_COUT testing::internal::TestCout() - -} // namespace internal - -/* Macros related to testing Eigen classes: - */ -#define EXPECT_MATRIX_APPROX(C_expect, C_actual, precision) EXPECT_PRED2([](const Eigen::MatrixXs lhs, const Eigen::MatrixXs rhs) { \ - return (lhs - rhs).isMuchSmallerThan(1, precision); \ - }, \ - C_expect, C_actual); - -#define ASSERT_MATRIX_APPROX(C_expect, C_actual, precision) ASSERT_PRED2([](const Eigen::MatrixXs lhs, const Eigen::MatrixXs rhs) { \ - return (lhs - rhs).isMuchSmallerThan(1, precision); \ - }, \ - C_expect, C_actual); - -#define EXPECT_QUATERNION_APPROX(C_expect, C_actual, precision) EXPECT_MATRIX_APPROX((C_expect).coeffs(), (C_actual).coeffs(), precision) - -#define ASSERT_QUATERNION_APPROX(C_expect, C_actual, precision) ASSERT_MATRIX_APPROX((C_expect).coeffs(), (C_actual).coeffs(), precision) - -#define EXPECT_POSE2D_APPROX(C_expect, C_actual, precision) EXPECT_PRED2([](const Eigen::MatrixXs lhs, const Eigen::MatrixXs rhs) { \ - MatrixXs er = lhs - rhs; \ - er(2) = pi2pi((Scalar)er(2)); \ - return er.isMuchSmallerThan(1, precision); \ - }, \ - C_expect, C_actual); - -#define ASSERT_POSE2D_APPROX(C_expect, C_actual, precision) EXPECT_PRED2([](const Eigen::MatrixXs lhs, const Eigen::MatrixXs rhs) { \ - MatrixXs er = lhs - rhs; \ - er(2) = pi2pi((Scalar)er(2)); \ - return er.isMuchSmallerThan(1, precision); \ - }, \ - C_expect, C_actual); - -} // namespace testing - -#endif /* WOLF_UTILS_GTEST_H */