From ee4715ff488d5cf685820ad06374cbe7d509ac1a Mon Sep 17 00:00:00 2001 From: David Tellenbach Date: Thu, 9 Jul 2020 17:24:00 +0000 Subject: Fix test basic stuff - Guard fundamental types that are not available pre C++11 - Separate subsequent angle brackets >> by spaces - Allow casting of Eigen::half and Eigen::bfloat16 to complex types --- test/basicstuff.cpp | 98 ++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 66 insertions(+), 32 deletions(-) (limited to 'test/basicstuff.cpp') diff --git a/test/basicstuff.cpp b/test/basicstuff.cpp index 80fc8a07f..f9044a27a 100644 --- a/test/basicstuff.cpp +++ b/test/basicstuff.cpp @@ -195,41 +195,73 @@ template void basicStuffComplex(const MatrixType& m) VERIFY(!static_cast(cm).imag().isZero()); } +template::value || internal::is_same::value)> struct casting_test; + + template -void casting_test() -{ - Matrix m; - for (int i=0; i::value(); +struct casting_test { + static void run() { + Matrix m; + for (int i=0; i::value(); + } + } + Matrix n = m.template cast(); + for (int i=0; i(m(i, j))); + } } } - Matrix n = m.template cast(); - for (int i=0; i(m(i, j))); +}; + +template +struct casting_test { + static void run() { + casting_test::run(); + } +}; + +template +struct casting_test, true> { + static void run() { + typedef std::complex TgtScalar; + Matrix m; + for (int i=0; i::value(); + } + } + Matrix n = m.template cast(); + for (int i=0; i(static_cast(m(i, j)))); + } } } -} +}; template struct casting_test_runner { static void run() { - casting_test(); - casting_test(); - casting_test(); - casting_test(); - casting_test(); - casting_test(); - casting_test(); - casting_test(); - casting_test(); - casting_test(); - casting_test(); - casting_test(); - casting_test(); - casting_test>(); - casting_test>(); + casting_test::run(); + casting_test::run(); + casting_test::run(); + casting_test::run(); + casting_test::run(); + casting_test::run(); + casting_test::run(); +#if EIGEN_HAS_CXX11 + casting_test::run(); + casting_test::run(); +#endif + casting_test::run(); + casting_test::run(); + casting_test::run(); + casting_test::run(); + casting_test >::run(); + casting_test >::run(); } }; @@ -238,10 +270,10 @@ struct casting_test_runner are defined. - casting_test(); - casting_test(); - casting_test>(); - casting_test>(); + casting_test::run(); + casting_test::run(); + casting_test >::run(); + casting_test >::run(); } }; @@ -253,14 +285,16 @@ void casting_all() { casting_test_runner::run(); casting_test_runner::run(); casting_test_runner::run(); +#if EIGEN_HAS_CXX11 casting_test_runner::run(); casting_test_runner::run(); +#endif casting_test_runner::run(); casting_test_runner::run(); casting_test_runner::run(); casting_test_runner::run(); - casting_test_runner>::run(); - casting_test_runner>::run(); + casting_test_runner >::run(); + casting_test_runner >::run(); } template -- cgit v1.2.3