aboutsummaryrefslogtreecommitdiff
path: root/test/main.h
diff options
context:
space:
mode:
Diffstat (limited to 'test/main.h')
-rw-r--r--test/main.h73
1 files changed, 55 insertions, 18 deletions
diff --git a/test/main.h b/test/main.h
index 2da327c17..14f0d2f78 100644
--- a/test/main.h
+++ b/test/main.h
@@ -14,6 +14,7 @@
#include <iostream>
#include <fstream>
#include <string>
+#include <sstream>
#include <vector>
#include <typeinfo>
#include <limits>
@@ -30,6 +31,10 @@
// B0 is defined in POSIX header termios.h
#define B0 FORBIDDEN_IDENTIFIER
+
+// shuts down ICC's remark #593: variable "XXX" was set but never used
+#define TEST_SET_BUT_UNUSED_VARIABLE(X) X = X + 0;
+
// the following file is automatically generated by cmake
#include "split_test_helper.h"
@@ -37,6 +42,11 @@
#undef NDEBUG
#endif
+// On windows CE, NDEBUG is automatically defined <assert.h> if NDEBUG is not defined.
+#ifndef DEBUG
+#define DEBUG
+#endif
+
// bounds integer values for AltiVec
#ifdef __ALTIVEC__
#define EIGEN_MAKING_DOCS
@@ -48,11 +58,6 @@
#define DEFAULT_REPEAT 10
-#ifdef __ICC
-// disable warning #279: controlling expression is constant
-#pragma warning disable 279
-#endif
-
namespace Eigen
{
static std::vector<std::string> g_test_stack;
@@ -169,12 +174,17 @@ namespace Eigen
#define EIGEN_INTERNAL_DEBUGGING
#include <Eigen/QR> // required for createRandomPIMatrixOfRank
-static void verify_impl(bool condition, const char *testname, const char *file, int line, const char *condition_as_string)
+inline void verify_impl(bool condition, const char *testname, const char *file, int line, const char *condition_as_string)
{
if (!condition)
{
- std::cerr << "Test " << testname << " failed in " << file << " (" << line << ")" \
- << std::endl << " " << condition_as_string << std::endl << std::endl; \
+ std::cerr << "Test " << testname << " failed in " << file << " (" << line << ")"
+ << std::endl << " " << condition_as_string << std::endl;
+ std::cerr << "Stack:\n";
+ const int test_stack_size = static_cast<int>(Eigen::g_test_stack.size());
+ for(int i=test_stack_size-1; i>=0; --i)
+ std::cerr << " - " << Eigen::g_test_stack[i] << "\n";
+ std::cerr << "\n";
abort();
}
}
@@ -260,6 +270,7 @@ inline bool test_isApprox(const Type1& a, const Type2& b)
// The idea behind this function is to compare the two scalars a and b where
// the scalar ref is a hint about the expected order of magnitude of a and b.
+// WARNING: the scalar a and b must be positive
// Therefore, if for some reason a and b are very small compared to ref,
// we won't issue a false negative.
// This test could be: abs(a-b) <= eps * ref
@@ -290,6 +301,10 @@ inline bool test_isUnitary(const MatrixBase<Derived>& m)
return m.isUnitary(test_precision<typename internal::traits<Derived>::Scalar>());
}
+// Forward declaration to avoid ICC warning
+template<typename T, typename U>
+bool test_is_equal(const T& actual, const U& expected);
+
template<typename T, typename U>
bool test_is_equal(const T& actual, const U& expected)
{
@@ -307,6 +322,9 @@ bool test_is_equal(const T& actual, const U& expected)
* A partial isometry is a matrix all of whose singular values are either 0 or 1.
* This is very useful to test rank-revealing algorithms.
*/
+// Forward declaration to avoid ICC warning
+template<typename MatrixType>
+void createRandomPIMatrixOfRank(typename MatrixType::Index desired_rank, typename MatrixType::Index rows, typename MatrixType::Index cols, MatrixType& m);
template<typename MatrixType>
void createRandomPIMatrixOfRank(typename MatrixType::Index desired_rank, typename MatrixType::Index rows, typename MatrixType::Index cols, MatrixType& m)
{
@@ -345,6 +363,9 @@ void createRandomPIMatrixOfRank(typename MatrixType::Index desired_rank, typenam
m = qra.householderQ() * d * qrb.householderQ();
}
+// Forward declaration to avoid ICC warning
+template<typename PermutationVectorType>
+void randomPermutationVector(PermutationVectorType& v, typename PermutationVectorType::Index size);
template<typename PermutationVectorType>
void randomPermutationVector(PermutationVectorType& v, typename PermutationVectorType::Index size)
{
@@ -371,20 +392,22 @@ template<> struct GetDifferentType<double> { typedef float type; };
template<typename T> struct GetDifferentType<std::complex<T> >
{ typedef std::complex<typename GetDifferentType<T>::type> type; };
-template<typename T> std::string type_name() { return "other"; }
-template<> std::string type_name<float>() { return "float"; }
-template<> std::string type_name<double>() { return "double"; }
-template<> std::string type_name<int>() { return "int"; }
-template<> std::string type_name<std::complex<float> >() { return "complex<float>"; }
+// Forward declaration to avoid ICC warning
+template<typename T> std::string type_name();
+template<typename T> std::string type_name() { return "other"; }
+template<> std::string type_name<float>() { return "float"; }
+template<> std::string type_name<double>() { return "double"; }
+template<> std::string type_name<int>() { return "int"; }
+template<> std::string type_name<std::complex<float> >() { return "complex<float>"; }
template<> std::string type_name<std::complex<double> >() { return "complex<double>"; }
-template<> std::string type_name<std::complex<int> >() { return "complex<int>"; }
+template<> std::string type_name<std::complex<int> >() { return "complex<int>"; }
// forward declaration of the main test function
void EIGEN_CAT(test_,EIGEN_TEST_FUNC)();
using namespace Eigen;
-void set_repeat_from_string(const char *str)
+inline void set_repeat_from_string(const char *str)
{
errno = 0;
g_repeat = int(strtoul(str, 0, 10));
@@ -396,10 +419,10 @@ void set_repeat_from_string(const char *str)
g_has_set_repeat = true;
}
-void set_seed_from_string(const char *str)
+inline void set_seed_from_string(const char *str)
{
errno = 0;
- g_seed = strtoul(str, 0, 10);
+ g_seed = int(strtoul(str, 0, 10));
if(errno || g_seed == 0)
{
std::cout << "Invalid seed value " << str << std::endl;
@@ -462,11 +485,25 @@ int main(int argc, char *argv[])
if(!g_has_set_repeat) g_repeat = DEFAULT_REPEAT;
std::cout << "Initializing random number generator with seed " << g_seed << std::endl;
+ std::stringstream ss;
+ ss << "Seed: " << g_seed;
+ g_test_stack.push_back(ss.str());
srand(g_seed);
std::cout << "Repeating each test " << g_repeat << " times" << std::endl;
- Eigen::g_test_stack.push_back(EI_PP_MAKE_STRING(EIGEN_TEST_FUNC));
+ Eigen::g_test_stack.push_back(std::string(EI_PP_MAKE_STRING(EIGEN_TEST_FUNC)));
EIGEN_CAT(test_,EIGEN_TEST_FUNC)();
return 0;
}
+
+// These warning are disabled here such that they are still ON when parsing Eigen's header files.
+#if defined __INTEL_COMPILER
+ // remark #383: value copied to temporary, reference to temporary used
+ // -> this warning is raised even for legal usage as: g_test_stack.push_back("foo"); where g_test_stack is a std::vector<std::string>
+ // remark #1418: external function definition with no prior declaration
+ // -> this warning is raised for all our test functions. Declaring them static would fix the issue.
+ // warning #279: controlling expression is constant
+ // remark #1572: floating-point equality and inequality comparisons are unreliable
+ #pragma warning disable 279 383 1418 1572
+#endif