diff options
author | Mathieu Gautier <mathieu.gautier@cea.fr> | 2011-04-12 14:49:50 +0200 |
---|---|---|
committer | Mathieu Gautier <mathieu.gautier@cea.fr> | 2011-04-12 14:49:50 +0200 |
commit | 392eb9fee887d34fb3f90ea3e2a1d101c7e08418 (patch) | |
tree | fa22ecd052592b4654b39e6c25a40510ced4868f /test | |
parent | f85db18c1ceff3af7ced18da8c2ce6a11016eb41 (diff) |
Quaternion : add Flags on Quaternion's traits with the LvalueBit set if needed
Quaternion : change PacketAccess to IsAligned to mimic other traits
test : add a test and 4 failtest on Map<const Quaternion> based on Eigen::Map ones
Diffstat (limited to 'test')
-rw-r--r-- | test/geo_quaternion.cpp | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/test/geo_quaternion.cpp b/test/geo_quaternion.cpp index e5b64e939..c1c0f279c 100644 --- a/test/geo_quaternion.cpp +++ b/test/geo_quaternion.cpp @@ -124,7 +124,8 @@ template<typename Scalar, int Options> void quaternion(void) template<typename Scalar> void mapQuaternion(void){ typedef Map<Quaternion<Scalar>, Aligned> MQuaternionA; - typedef Map<Quaternion<Scalar> > MQuaternionUA; + typedef Map<Quaternion<Scalar> > MQuaternionUA;
+ typedef Map<const Quaternion<Scalar> > MCQuaternionUA; typedef Quaternion<Scalar> Quaternionx; EIGEN_ALIGN16 Scalar array1[4]; @@ -139,9 +140,11 @@ template<typename Scalar> void mapQuaternion(void){ Quaternionx q1 = MQuaternionA(array1); Quaternionx q2 = MQuaternionA(array2); Quaternionx q3 = MQuaternionUA(array3unaligned); + Quaternionx q4 = MCQuaternionUA(array3unaligned); VERIFY_IS_APPROX(q1.coeffs(), q2.coeffs()); VERIFY_IS_APPROX(q1.coeffs(), q3.coeffs()); + VERIFY_IS_APPROX(q4.coeffs(), q3.coeffs()); #ifdef EIGEN_VECTORIZE VERIFY_RAISES_ASSERT((MQuaternionA(array3unaligned))); #endif @@ -171,11 +174,28 @@ template<typename Scalar> void quaternionAlignment(void){ #endif } +template<typename PlainObjectType> void check_const_correctness(const PlainObjectType&) +{ + // there's a lot that we can't test here while still having this test compile! + // the only possible approach would be to run a script trying to compile stuff and checking that it fails. + // CMake can help with that. + + // verify that map-to-const don't have LvalueBit + typedef typename internal::add_const<PlainObjectType>::type ConstPlainObjectType; + VERIFY( !(internal::traits<Map<ConstPlainObjectType> >::Flags & LvalueBit) ); + VERIFY( !(internal::traits<Map<ConstPlainObjectType, Aligned> >::Flags & LvalueBit) ); + VERIFY( !(Map<ConstPlainObjectType>::Flags & LvalueBit) ); + VERIFY( !(Map<ConstPlainObjectType, Aligned>::Flags & LvalueBit) ); +} + + void test_geo_quaternion() { for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_1(( quaternion<float,AutoAlign>() )); + CALL_SUBTEST_1( check_const_correctness(Quaternionf()) ); CALL_SUBTEST_2(( quaternion<double,AutoAlign>() )); + CALL_SUBTEST_2( check_const_correctness(Quaterniond()) ); CALL_SUBTEST_3(( quaternion<float,DontAlign>() )); CALL_SUBTEST_4(( quaternion<double,DontAlign>() )); CALL_SUBTEST_5(( quaternionAlignment<float>() )); |