From 392eb9fee887d34fb3f90ea3e2a1d101c7e08418 Mon Sep 17 00:00:00 2001 From: Mathieu Gautier Date: Tue, 12 Apr 2011 14:49:50 +0200 Subject: 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 based on Eigen::Map ones --- test/geo_quaternion.cpp | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) (limited to 'test/geo_quaternion.cpp') 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 void quaternion(void) template void mapQuaternion(void){ typedef Map, Aligned> MQuaternionA; - typedef Map > MQuaternionUA; + typedef Map > MQuaternionUA; + typedef Map > MCQuaternionUA; typedef Quaternion Quaternionx; EIGEN_ALIGN16 Scalar array1[4]; @@ -139,9 +140,11 @@ template 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 void quaternionAlignment(void){ #endif } +template 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::type ConstPlainObjectType; + VERIFY( !(internal::traits >::Flags & LvalueBit) ); + VERIFY( !(internal::traits >::Flags & LvalueBit) ); + VERIFY( !(Map::Flags & LvalueBit) ); + VERIFY( !(Map::Flags & LvalueBit) ); +} + + void test_geo_quaternion() { for(int i = 0; i < g_repeat; i++) { CALL_SUBTEST_1(( quaternion() )); + CALL_SUBTEST_1( check_const_correctness(Quaternionf()) ); CALL_SUBTEST_2(( quaternion() )); + CALL_SUBTEST_2( check_const_correctness(Quaterniond()) ); CALL_SUBTEST_3(( quaternion() )); CALL_SUBTEST_4(( quaternion() )); CALL_SUBTEST_5(( quaternionAlignment() )); -- cgit v1.2.3