mirror of
https://gitlab.com/libeigen/eigen.git
synced 2024-12-15 07:10:37 +08:00
check two ctors
This commit is contained in:
parent
354f14293b
commit
572d62697d
@ -8,7 +8,7 @@ struct Foo
|
|||||||
static Index object_limit;
|
static Index object_limit;
|
||||||
int dummy;
|
int dummy;
|
||||||
|
|
||||||
Foo()
|
Foo() : dummy(0)
|
||||||
{
|
{
|
||||||
#ifdef EIGEN_EXCEPTIONS
|
#ifdef EIGEN_EXCEPTIONS
|
||||||
// TODO: Is this the correct way to handle this?
|
// TODO: Is this the correct way to handle this?
|
||||||
@ -37,22 +37,33 @@ EIGEN_DECLARE_TEST(ctorleak)
|
|||||||
{
|
{
|
||||||
typedef Matrix<Foo, Dynamic, Dynamic> MatrixX;
|
typedef Matrix<Foo, Dynamic, Dynamic> MatrixX;
|
||||||
typedef Matrix<Foo, Dynamic, 1> VectorX;
|
typedef Matrix<Foo, Dynamic, 1> VectorX;
|
||||||
|
|
||||||
Foo::object_count = 0;
|
Foo::object_count = 0;
|
||||||
for(int i = 0; i < g_repeat; i++) {
|
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);
|
Index rows = internal::random<Index>(2,EIGEN_TEST_MAX_SIZE), cols = internal::random<Index>(2,EIGEN_TEST_MAX_SIZE);
|
||||||
Foo::object_limit = internal::random<Index>(0, rows*cols - 2);
|
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;
|
std::cout << "object_limit =" << Foo::object_limit << std::endl;
|
||||||
#ifdef EIGEN_EXCEPTIONS
|
#ifdef EIGEN_EXCEPTIONS
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
#endif
|
#endif
|
||||||
|
if(internal::random<bool>()) {
|
||||||
std::cout << "\nMatrixX m(" << rows << ", " << cols << ");\n";
|
std::cout << "\nMatrixX m(" << rows << ", " << cols << ");\n";
|
||||||
MatrixX m(rows, cols);
|
MatrixX m(rows, cols);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
std::cout << "\nMatrixX m(r);\n";
|
||||||
|
MatrixX m(r);
|
||||||
|
}
|
||||||
#ifdef EIGEN_EXCEPTIONS
|
#ifdef EIGEN_EXCEPTIONS
|
||||||
VERIFY(false); // not reached if exceptions are enabled
|
VERIFY(false); // not reached if exceptions are enabled
|
||||||
}
|
}
|
||||||
catch (const Foo::Fail&) { /* ignore */ }
|
catch (const Foo::Fail&) { /* ignore */ }
|
||||||
#endif
|
#endif
|
||||||
|
}
|
||||||
VERIFY_IS_EQUAL(Index(0), Foo::object_count);
|
VERIFY_IS_EQUAL(Index(0), Foo::object_count);
|
||||||
|
|
||||||
{
|
{
|
||||||
@ -66,4 +77,5 @@ EIGEN_DECLARE_TEST(ctorleak)
|
|||||||
}
|
}
|
||||||
VERIFY_IS_EQUAL(Index(0), Foo::object_count);
|
VERIFY_IS_EQUAL(Index(0), Foo::object_count);
|
||||||
}
|
}
|
||||||
|
std::cout << "\n";
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user