From 143e6ab9d0a86407763e3608ef60f8c9c69a33fd Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 2 Jun 2010 10:12:13 +0200 Subject: improve aliasing detection for inverse and add unit test --- test/inverse.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'test/inverse.cpp') diff --git a/test/inverse.cpp b/test/inverse.cpp index 1e567ad14..4d9297eb4 100644 --- a/test/inverse.cpp +++ b/test/inverse.cpp @@ -82,6 +82,19 @@ template void inverse(const MatrixType& m) m3.computeInverseWithCheck(m4, invertible); VERIFY( rows==1 ? invertible : !invertible ); #endif + + // check in-place inversion + if(MatrixType::RowsAtCompileTime>=2 && MatrixType::RowsAtCompileTime<=4) + { + // in-place is forbidden + VERIFY_RAISES_ASSERT(m1 = m1.inverse()); + } + else + { + m2 = m1.inverse(); + m1 = m1.inverse(); + VERIFY_IS_APPROX(m1,m2); + } } void test_inverse() -- cgit v1.2.3