bug #1457: add setUnit() methods for consistency.

This commit is contained in:
Gael Guennebaud
2017-08-22 16:48:07 +02:00
parent bc4dae9aeb
commit 9deee79922
4 changed files with 65 additions and 1 deletions

View File

@@ -191,6 +191,24 @@ void testVectorType(const VectorType& base)
}
}
}
// test setUnit()
if(m.size()>0)
{
for(Index k=0; k<10; ++k)
{
Index i = internal::random<Index>(0,m.size()-1);
m.setUnit(i);
VERIFY_IS_APPROX( m, VectorType::Unit(m.size(), i) );
}
if(VectorType::SizeAtCompileTime==Dynamic)
{
Index i = internal::random<Index>(0,2*m.size()-1);
m.setUnit(2*m.size(),i);
VERIFY_IS_APPROX( m, VectorType::Unit(m.size(),i) );
}
}
}
template<typename MatrixType>