diff --git a/test/engine/engine_derivative_test.cc b/test/engine/engine_derivative_test.cc index 51dc26b7..1db7731a 100644 --- a/test/engine/engine_derivative_test.cc +++ b/test/engine/engine_derivative_test.cc @@ -14,8 +14,6 @@ // Tests for engine/engine_derivative.c. -#include -#include #include #include #include @@ -74,19 +72,6 @@ static mjtNum CompareMatrices(mjtNum* Actual, mjtNum* Expected, return max_error; } -// utility function for matrix printing (debug) -// NOLINTNEXTLINE(clang-diagnostic-unused-function) -static void PrintMatrix(mjtNum* mat, int nrow, int ncol) { - std::cerr.precision(5); - std::cerr << "\n"; - for (int r=0; r < nrow; r++) { - for (int c=0; c < ncol; c++) { - std::cerr << std::fixed << std::setw(9) << mat[c + r*ncol] << " "; - } - std::cerr << "\n"; - } -} - static const char* const kEnergyConservingPendulumPath = "engine/testdata/derivative/energy_conserving_pendulum.xml"; static const char* const kTumblingThinObjectPath = diff --git a/test/fixture.h b/test/fixture.h index 8da8ef5c..4d65623d 100644 --- a/test/fixture.h +++ b/test/fixture.h @@ -17,6 +17,8 @@ #include #include +#include +#include #include #include #include @@ -110,6 +112,18 @@ inline std::vector AsVector(const mjtNum* array, int n) { return std::vector(array, array + n); } +// Prints a matrix to stderr, useful for debugging. +inline void PrintMatrix(const mjtNum* mat, int nrow, int ncol, int p = 5) { + std::cerr.precision(p); + std::cerr << "\n"; + for (int r = 0; r < nrow; r++) { + for (int c = 0; c < ncol; c++) { + std::cerr << std::fixed << std::setw(4 + p) << mat[c + r*ncol] << " "; + } + std::cerr << "\n"; + } +} + // Installs a mock filesystem via a resource provider. To obtain thread safety, // each filesystem is scoped for individual unit tests with destructive // operations not permitted.