add extra debugging info to float_pow_test_impl, clean up array_cwise tests
diff --git a/test/array_cwise.cpp b/test/array_cwise.cpp index d032e0b..01f5a99 100644 --- a/test/array_cwise.cpp +++ b/test/array_cwise.cpp
@@ -65,7 +65,7 @@ template <typename Scalar> void special_value_pairs(Array<Scalar, Dynamic, Dynamic>& x, Array<Scalar, Dynamic, Dynamic>& y) { std::vector<Scalar> vals = special_values<Scalar>(); - int num_cases = vals.size() * vals.size(); + std::size_t num_cases = vals.size() * vals.size(); // ensure both vectorized and non-vectorized paths taken const Index num_repeats = 2 * (Index)internal::packet_traits<Scalar>::size + 1; x.resize(num_repeats, num_cases); @@ -294,6 +294,7 @@ bool success = both_nan || (exact_or_approx && same_sign); all_pass &= success; if (!success) { + std::cout << "Base type: " << type_name(base) << ", Exponent type: " << type_name(exponent) << std::endl; std::cout << "pow(" << bases(j) << "," << exponent << ") = " << a << " != " << e << std::endl; } } @@ -1250,61 +1251,6 @@ typed_logicals_test_impl<ArrayType>::run(m); } -// print non-mangled typenames -template <typename T> -std::string printTypeInfo(const T&) { - return typeid(T).name(); -} -template <> -std::string printTypeInfo(const int8_t&) { - return "int8_t"; -} -template <> -std::string printTypeInfo(const int16_t&) { - return "int16_t"; -} -template <> -std::string printTypeInfo(const int32_t&) { - return "int32_t"; -} -template <> -std::string printTypeInfo(const int64_t&) { - return "int64_t"; -} -template <> -std::string printTypeInfo(const uint8_t&) { - return "uint8_t"; -} -template <> -std::string printTypeInfo(const uint16_t&) { - return "uint16_t"; -} -template <> -std::string printTypeInfo(const uint32_t&) { - return "uint32_t"; -} -template <> -std::string printTypeInfo(const uint64_t&) { - return "uint64_t"; -} -template <> -std::string printTypeInfo(const float&) { - return "float"; -} -template <> -std::string printTypeInfo(const double&) { - return "double"; -} -// template<> std::string printTypeInfo(const long double&) { return "long double"; } -template <> -std::string printTypeInfo(const half&) { - return "half"; -} -template <> -std::string printTypeInfo(const bfloat16&) { - return "bfloat16"; -} - template <typename SrcType, typename DstType, int RowsAtCompileTime, int ColsAtCompileTime> struct cast_test_impl { using SrcArray = Array<SrcType, RowsAtCompileTime, ColsAtCompileTime>; @@ -1340,8 +1286,8 @@ DstType dstVal = dst(i, j); bool isApprox = verifyIsApprox(dstVal, refVal); if (!isApprox) - std::cout << printTypeInfo(srcVal) << ": [" << +srcVal << "] to " << printTypeInfo(dstVal) << ": [" - << +dstVal << "] != [" << +refVal << "]\n"; + std::cout << type_name(srcVal) << ": [" << +srcVal << "] to " << type_name(dstVal) << ": [" << +dstVal + << "] != [" << +refVal << "]\n"; VERIFY(isApprox); } }
diff --git a/test/main.h b/test/main.h index ca1748d..c7cc531 100644 --- a/test/main.h +++ b/test/main.h
@@ -742,41 +742,81 @@ }; template <typename T> -std::string type_name() { - return "other"; +std::string type_name(T) { + return typeid(T).name(); } template <> -std::string type_name<float>() { +std::string type_name<float>(float) { return "float"; } template <> -std::string type_name<double>() { +std::string type_name<double>(double) { return "double"; } template <> -std::string type_name<long double>() { +std::string type_name<long double>(long double) { return "long double"; } template <> -std::string type_name<int>() { - return "int"; +std::string type_name<Eigen::half>(Eigen::half) { + return "half"; } template <> -std::string type_name<std::complex<float> >() { +std::string type_name<Eigen::bfloat16>(Eigen::bfloat16) { + return "bfloat16"; +} +template <> +std::string type_name<int8_t>(int8_t) { + return "int8_t"; +} +template <> +std::string type_name<int16_t>(int16_t) { + return "int16_t"; +} +template <> +std::string type_name<int32_t>(int32_t) { + return "int32_t"; +} +template <> +std::string type_name<int64_t>(int64_t) { + return "int64_t"; +} +template <> +std::string type_name<uint8_t>(uint8_t) { + return "uint8_t"; +} +template <> +std::string type_name<uint16_t>(uint16_t) { + return "uint16_t"; +} +template <> +std::string type_name<uint32_t>(uint32_t) { + return "uint32_t"; +} +template <> +std::string type_name<uint64_t>(uint64_t) { + return "uint64_t"; +} +template <> +std::string type_name<std::complex<float> >(std::complex<float>) { return "complex<float>"; } template <> -std::string type_name<std::complex<double> >() { +std::string type_name<std::complex<double> >(std::complex<double>) { return "complex<double>"; } template <> -std::string type_name<std::complex<long double> >() { +std::string type_name<std::complex<long double> >(std::complex<long double>) { return "complex<long double>"; } template <> -std::string type_name<std::complex<int> >() { +std::string type_name<std::complex<int> >(std::complex<int>) { return "complex<int>"; } +template <typename T> +std::string type_name() { + return type_name(T()); +} using namespace Eigen;