mirror of
https://gitlab.com/libeigen/eigen.git
synced 2026-04-10 11:34:33 +08:00
Clang-format tests, examples, libraries, benchmarks, etc.
This commit is contained in:
committed by
Rasmus Munk Larsen
parent
3252ecc7a4
commit
46e9cdb7fe
@@ -2,25 +2,25 @@
|
||||
|
||||
#include <exception> // std::exception
|
||||
|
||||
struct Foo
|
||||
{
|
||||
struct Foo {
|
||||
static Index object_count;
|
||||
static Index object_limit;
|
||||
int dummy;
|
||||
|
||||
Foo() : dummy(0)
|
||||
{
|
||||
Foo() : dummy(0) {
|
||||
#ifdef EIGEN_EXCEPTIONS
|
||||
// TODO: Is this the correct way to handle this?
|
||||
if (Foo::object_count > Foo::object_limit) { std::cout << "\nThrow!\n"; throw Foo::Fail(); }
|
||||
if (Foo::object_count > Foo::object_limit) {
|
||||
std::cout << "\nThrow!\n";
|
||||
throw Foo::Fail();
|
||||
}
|
||||
#endif
|
||||
std::cout << '+';
|
||||
std::cout << '+';
|
||||
++Foo::object_count;
|
||||
}
|
||||
|
||||
~Foo()
|
||||
{
|
||||
std::cout << '-';
|
||||
~Foo() {
|
||||
std::cout << '-';
|
||||
--Foo::object_count;
|
||||
}
|
||||
|
||||
@@ -33,47 +33,45 @@ Index Foo::object_limit = 0;
|
||||
#undef EIGEN_TEST_MAX_SIZE
|
||||
#define EIGEN_TEST_MAX_SIZE 3
|
||||
|
||||
EIGEN_DECLARE_TEST(ctorleak)
|
||||
{
|
||||
EIGEN_DECLARE_TEST(ctorleak) {
|
||||
typedef Matrix<Foo, Dynamic, Dynamic> MatrixX;
|
||||
typedef Matrix<Foo, Dynamic, 1> VectorX;
|
||||
|
||||
|
||||
Foo::object_count = 0;
|
||||
for(int i = 0; i < g_repeat; i++) {
|
||||
Index rows = internal::random<Index>(2,EIGEN_TEST_MAX_SIZE), cols = internal::random<Index>(2,EIGEN_TEST_MAX_SIZE);
|
||||
Foo::object_limit = rows*cols;
|
||||
for (int i = 0; i < g_repeat; i++) {
|
||||
Index rows = internal::random<Index>(2, EIGEN_TEST_MAX_SIZE),
|
||||
cols = internal::random<Index>(2, EIGEN_TEST_MAX_SIZE);
|
||||
Foo::object_limit = rows * cols;
|
||||
{
|
||||
MatrixX r(rows, cols);
|
||||
Foo::object_limit = r.size()+internal::random<Index>(0, rows*cols - 2);
|
||||
std::cout << "object_limit =" << Foo::object_limit << std::endl;
|
||||
MatrixX r(rows, cols);
|
||||
Foo::object_limit = r.size() + internal::random<Index>(0, rows * cols - 2);
|
||||
std::cout << "object_limit =" << Foo::object_limit << std::endl;
|
||||
#ifdef EIGEN_EXCEPTIONS
|
||||
try
|
||||
{
|
||||
try {
|
||||
#endif
|
||||
if(internal::random<bool>()) {
|
||||
std::cout << "\nMatrixX m(" << rows << ", " << cols << ");\n";
|
||||
MatrixX m(rows, cols);
|
||||
}
|
||||
else {
|
||||
std::cout << "\nMatrixX m(r);\n";
|
||||
MatrixX m(r);
|
||||
}
|
||||
if (internal::random<bool>()) {
|
||||
std::cout << "\nMatrixX m(" << rows << ", " << cols << ");\n";
|
||||
MatrixX m(rows, cols);
|
||||
} else {
|
||||
std::cout << "\nMatrixX m(r);\n";
|
||||
MatrixX m(r);
|
||||
}
|
||||
#ifdef EIGEN_EXCEPTIONS
|
||||
VERIFY(false); // not reached if exceptions are enabled
|
||||
}
|
||||
catch (const Foo::Fail&) { /* ignore */ }
|
||||
VERIFY(false); // not reached if exceptions are enabled
|
||||
} catch (const Foo::Fail&) { /* ignore */
|
||||
}
|
||||
#endif
|
||||
}
|
||||
VERIFY_IS_EQUAL(Index(0), Foo::object_count);
|
||||
|
||||
{
|
||||
Foo::object_limit = (rows+1)*(cols+1);
|
||||
Foo::object_limit = (rows + 1) * (cols + 1);
|
||||
MatrixX A(rows, cols);
|
||||
VERIFY_IS_EQUAL(Foo::object_count, rows*cols);
|
||||
VectorX v=A.row(0);
|
||||
VERIFY_IS_EQUAL(Foo::object_count, (rows+1)*cols);
|
||||
VERIFY_IS_EQUAL(Foo::object_count, rows * cols);
|
||||
VectorX v = A.row(0);
|
||||
VERIFY_IS_EQUAL(Foo::object_count, (rows + 1) * cols);
|
||||
v = A.col(0);
|
||||
VERIFY_IS_EQUAL(Foo::object_count, rows*(cols+1));
|
||||
VERIFY_IS_EQUAL(Foo::object_count, rows * (cols + 1));
|
||||
}
|
||||
VERIFY_IS_EQUAL(Index(0), Foo::object_count);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user