aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/basicstuff.cpp
diff options
context:
space:
mode:
authorGravatar Gael Guennebaud <g.gael@free.fr>2017-02-13 17:14:04 +0100
committerGravatar Gael Guennebaud <g.gael@free.fr>2017-02-13 17:14:04 +0100
commit707343094637b112d49089372a0a8e0a06b0b34c (patch)
tree0e60e893a2a478515d3a93e32e80e13557787c48 /test/basicstuff.cpp
parent3453b00a1ef895a4b2eb5f349ab0bf2d50ca0535 (diff)
Fix overflow and make use of long long in c++11 only.
Diffstat (limited to 'test/basicstuff.cpp')
-rw-r--r--test/basicstuff.cpp25
1 files changed, 14 insertions, 11 deletions
diff --git a/test/basicstuff.cpp b/test/basicstuff.cpp
index 52b89c0d6..c346ce6cb 100644
--- a/test/basicstuff.cpp
+++ b/test/basicstuff.cpp
@@ -50,17 +50,20 @@ template<typename MatrixType> void basicStuff(const MatrixType& m)
VERIFY_IS_APPROX(x, v1[r]);
// test fetching with various index types.
- x = v1(static_cast<char>(r));
- x = v1(static_cast<signed char>(r));
- x = v1(static_cast<unsigned char>(r));
- x = v1(static_cast<signed short>(r));
- x = v1(static_cast<unsigned short>(r));
- x = v1(static_cast<signed int>(r));
- x = v1(static_cast<unsigned int>(r));
- x = v1(static_cast<signed long>(r));
- x = v1(static_cast<unsigned long>(r));
- x = v1(static_cast<long long int>(r));
- x = v1(static_cast<unsigned long long int>(r));
+ Index r1 = internal::random<Index>(0, numext::mini(Index(127),rows-1));
+ x = v1(static_cast<char>(r1));
+ x = v1(static_cast<signed char>(r1));
+ x = v1(static_cast<unsigned char>(r1));
+ x = v1(static_cast<signed short>(r1));
+ x = v1(static_cast<unsigned short>(r1));
+ x = v1(static_cast<signed int>(r1));
+ x = v1(static_cast<unsigned int>(r1));
+ x = v1(static_cast<signed long>(r1));
+ x = v1(static_cast<unsigned long>(r1));
+#if EIGEN_HAS_CXX11
+ x = v1(static_cast<long long int>(r1));
+ x = v1(static_cast<unsigned long long int>(r1));
+#endif
VERIFY_IS_APPROX( v1, v1);
VERIFY_IS_NOT_APPROX( v1, 2*v1);