diff options
author | Gael Guennebaud <g.gael@free.fr> | 2017-01-25 18:13:53 +0100 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2017-01-25 18:13:53 +0100 |
commit | 850ca961d28df99a0ba44bd8bf034ac08e39686e (patch) | |
tree | b13edddb2b703365096c9c5ce3a50492dc81e8ec /test/nullary.cpp | |
parent | 296d24be4dd3c700089d1d9182a843c60d68019c (diff) |
bug #1383: fix regression in LinSpaced for integers and high<low
Diffstat (limited to 'test/nullary.cpp')
-rw-r--r-- | test/nullary.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/test/nullary.cpp b/test/nullary.cpp index bb0cea937..acd55506e 100644 --- a/test/nullary.cpp +++ b/test/nullary.cpp @@ -175,6 +175,21 @@ void testVectorType(const VectorType& base) VERIFY_IS_APPROX(VectorType::LinSpaced(size,low,low),VectorType::Constant(size,low)); m.setLinSpaced(size,low,low); VERIFY_IS_APPROX(m,VectorType::Constant(size,low)); + + if(NumTraits<Scalar>::IsInteger) + { + VERIFY_IS_APPROX( VectorType::LinSpaced(size,low,Scalar(low+size-1)), VectorType::LinSpaced(size,Scalar(low+size-1),low).reverse() ); + + if(VectorType::SizeAtCompileTime==Dynamic) + { + // Check negative multiplicator path: + for(Index k=1; k<5; ++k) + VERIFY_IS_APPROX( VectorType::LinSpaced(size,low,Scalar(low+(size-1)*k)), VectorType::LinSpaced(size,Scalar(low+(size-1)*k),low).reverse() ); + // Check negative divisor path: + for(Index k=1; k<5; ++k) + VERIFY_IS_APPROX( VectorType::LinSpaced(size*k,low,Scalar(low+size-1)), VectorType::LinSpaced(size*k,Scalar(low+size-1),low).reverse() ); + } + } } } @@ -222,7 +237,8 @@ void test_nullary() CALL_SUBTEST_8( testVectorType(Matrix<float,8,1>()) ); CALL_SUBTEST_8( testVectorType(Matrix<float,1,1>()) ); - CALL_SUBTEST_9( testVectorType(VectorXi(internal::random<int>(1,300))) ); + CALL_SUBTEST_9( testVectorType(VectorXi(internal::random<int>(1,10))) ); + CALL_SUBTEST_9( testVectorType(VectorXi(internal::random<int>(9,300))) ); CALL_SUBTEST_9( testVectorType(Matrix<int,1,1>()) ); } |