A repository for glog CHECK and gtest ASSERT and EXPECT macros for Eigen types.
The Glog CHECK()
macros are used to check errors and exit your program if they are found. These Eigen equivalents can be used to check conditions on matrices. See the glog documentation for a full description. The general form of use is:
CHECK_EIGEN_MATRIX_EQUAL(MatrixA, MatrixB) << "Informative error message!";
All tests happen component-wise. They fail if the matrices are different sizes. If the matrices are the same size, the test is applied to each corresponding pair of components.
To get these macros, use:
#include<eigen-checks/glog.h>
Checks if two matrices are binary equal.
Checks if two matrices are equal to floating-point precision
Checks if two matrices are equal to a user-specified precision.
Checks if a matrix is equal to zero to a user-specified precision.
The gtest macros are built to facilitate unit testing with matrix types. This library provides two pieces of functionality: an macro that defines the main function, or entrypoint, for a guest invocation, and several macros for testing if matrices are similar.
The Gtest EXPECT()
and ASSERT()
macros are used to verify assumptions in your tests and print useful information in case these don't match the expected outcome. These Eigen equivalents can be used to check conditions on matrices. See the gtest documentation for a full description. The general form of use is:
EXPECT_TRUE(EIGEN_MATRIX_EQUAL(MatrixA, MatrixB));
EXPECT_FALSE(EIGEN_MATRIX_EQUAL(MatrixA, MatrixB));
ASSERT_TRUE(EIGEN_MATRIX_EQUAL(MatrixA, MatrixB));
ASSERT_FALSE(EIGEN_MATRIX_EQUAL(MatrixA, MatrixB));
All tests happen component-wise. They fail if the matrices are different sizes. If the matrices are the same size, the test is applied to each corresponding pair of components.
To get these macros, use:
#include<eigen-checks/gtest.h>
Succeeds if two matrices are binary equal.
Succeeds if two matrices are equal to floating-point precision
Succeeds if two matrices are equal to a user-specified precision.
Succeeds if a matrix is equal to zero to a user-specified precision.
Instead of writing the following code in your unit-test runner file:
#include <gtest/gtest.h>
int main(int argc, char** argv) {
testing::InitGoogleTest(&argc, argv);
google::ParseCommandLineFlags(&argc, &argv, true);
::testing::FLAGS_gtest_death_test_style = "threadsafe";
//...
return RUN_ALL_TESTS();
}
You can just use:
#include <eigen-checks/entrypoint.h>
UNITTEST_ENTRYPOINT