diff options
author | Hauke Heibel <hauke.heibel@gmail.com> | 2012-03-07 16:18:35 +0100 |
---|---|---|
committer | Hauke Heibel <hauke.heibel@gmail.com> | 2012-03-07 16:18:35 +0100 |
commit | c08521ea6b1a5b239c22771f7735d7f4904b4854 (patch) | |
tree | 2dfa07935de5ca348e4f7601df807d6bd0eaa2cf /test/nullary.cpp | |
parent | ef022da28e51632458f92baabb539bf13a221694 (diff) |
Improved the unit tests for setLinSpaced.
Provide a default constructed step size as opposed to an int when the size is 1.
Diffstat (limited to 'test/nullary.cpp')
-rw-r--r-- | test/nullary.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/test/nullary.cpp b/test/nullary.cpp index 501b579b0..6c9ee5f34 100644 --- a/test/nullary.cpp +++ b/test/nullary.cpp @@ -52,11 +52,14 @@ void testVectorType(const VectorType& base) { typedef typename internal::traits<VectorType>::Index Index; typedef typename internal::traits<VectorType>::Scalar Scalar; - Scalar low = internal::random<Scalar>(-500,500); + + const Index size = base.size(); + Scalar high = internal::random<Scalar>(-500,500); + Scalar low = (size == 1 ? high : internal::random<Scalar>(-500,500)); if (low>high) std::swap(low,high); - const Index size = base.size(); - const Scalar step = (high-low)/(size-1); + + const Scalar step = ((size == 1) ? 1 : (high-low)/(size-1)); // check whether the result yields what we expect it to do VectorType m(base); @@ -130,5 +133,6 @@ void test_nullary() CALL_SUBTEST_6( testVectorType(Vector3d()) ); CALL_SUBTEST_7( testVectorType(VectorXf(internal::random<int>(1,300))) ); CALL_SUBTEST_8( testVectorType(Vector3f()) ); + CALL_SUBTEST_8( testVectorType(Matrix<float,1,1>()) ); } } |