Add unit tests for bug #981: valid and invalid usage of ternary operator

This commit is contained in:
Gael Guennebaud
2015-09-09 11:38:25 +02:00
parent 84e0c27b61
commit 680d318352
4 changed files with 43 additions and 0 deletions

View File

@@ -41,6 +41,9 @@ ei_add_failtest("ref_5")
ei_add_failtest("swap_1")
ei_add_failtest("swap_2")
ei_add_failtest("ternary_1")
ei_add_failtest("ternary_2")
ei_add_failtest("sparse_ref_1")
ei_add_failtest("sparse_ref_2")
ei_add_failtest("sparse_ref_3")

13
failtest/ternary_1.cpp Normal file
View File

@@ -0,0 +1,13 @@
#include "../Eigen/Core"
using namespace Eigen;
int main(int argc,char **)
{
VectorXf a(10), b(10);
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
b = argc>1 ? 2*a : -a;
#else
b = argc>1 ? 2*a : VectorXf(-a);
#endif
}

13
failtest/ternary_2.cpp Normal file
View File

@@ -0,0 +1,13 @@
#include "../Eigen/Core"
using namespace Eigen;
int main(int argc,char **)
{
VectorXf a(10), b(10);
#ifdef EIGEN_SHOULD_FAIL_TO_BUILD
b = argc>1 ? 2*a : a+a;
#else
b = argc>1 ? VectorXf(2*a) : VectorXf(a+a);
#endif
}