diff options
author | Christoph Hertzberg <chtz@informatik.uni-bremen.de> | 2020-04-13 16:41:20 +0200 |
---|---|---|
committer | Christoph Hertzberg <chtz@informatik.uni-bremen.de> | 2020-04-13 16:41:20 +0200 |
commit | d46d726e9d06416c7d1d5a81bdeae04c629f93d8 (patch) | |
tree | 8ec04276f6ef722dfd7b5f3baceba54af85e3fad /test/commainitializer.cpp | |
parent | c854e189e6d4868fedc7d4ef81cc3485f5b24841 (diff) |
CommaInitializer wrongfully asserted for 0-sized blocks
commainitialier unit-test never actually called `test_block_recursion`, which also was not correctly implemented and would have caused too deep template recursion.
Diffstat (limited to 'test/commainitializer.cpp')
-rw-r--r-- | test/commainitializer.cpp | 26 |
1 files changed, 17 insertions, 9 deletions
diff --git a/test/commainitializer.cpp b/test/commainitializer.cpp index 3cb94da62..f535117d5 100644 --- a/test/commainitializer.cpp +++ b/test/commainitializer.cpp @@ -34,8 +34,14 @@ void test_blocks() if(N1 > 0) { - VERIFY_RAISES_ASSERT((m_fixed << mat11, mat12, mat11, mat21, mat22)); - VERIFY_RAISES_ASSERT((m_fixed << mat11, mat12, mat21, mat21, mat22)); + if(M1 > 0) + { + VERIFY_RAISES_ASSERT((m_fixed << mat11, mat12, mat11, mat21, mat22)); + } + if(M2 > 0) + { + VERIFY_RAISES_ASSERT((m_fixed << mat11, mat12, mat21, mat21, mat22)); + } } else { @@ -49,20 +55,22 @@ void test_blocks() } -template<int N> +template<int depth, int N=0> struct test_block_recursion { static void run() { - test_blocks<(N>>6)&3, (N>>4)&3, (N>>2)&3, N & 3>(); - test_block_recursion<N-1>::run(); + test_block_recursion<depth-1, N>::run(); + test_block_recursion<depth-1, N + (1 << (depth-1))>::run(); } }; -template<> -struct test_block_recursion<-1> +template<int N> +struct test_block_recursion<0,N> { - static void run() { } + static void run() { + test_blocks<(N>>6)&3, (N>>4)&3, (N>>2)&3, N & 3>(); + } }; EIGEN_DECLARE_TEST(commainitializer) @@ -102,5 +110,5 @@ EIGEN_DECLARE_TEST(commainitializer) // recursively test all block-sizes from 0 to 3: - test_block_recursion<(1<<8) - 1>(); + test_block_recursion<8>::run(); } |