aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/dynalloc.cpp
diff options
context:
space:
mode:
authorGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2014-08-13 22:25:29 -0700
committerGravatar Benoit Steiner <benoit.steiner.goog@gmail.com>2014-08-13 22:25:29 -0700
commit16047c8d4a916baa200036c4d5501707b3552720 (patch)
treee8dc65e4de304a16247f71ca5f40c5194b1aad5e /test/dynalloc.cpp
parent916ef48846b40f690f41583d288eb1c3c40db0a3 (diff)
parente51da9c3a8b448bc06110f1a7376211dcd32cc0e (diff)
Pulled in the latest changes from the Eigen trunk
Diffstat (limited to 'test/dynalloc.cpp')
-rw-r--r--test/dynalloc.cpp33
1 files changed, 32 insertions, 1 deletions
diff --git a/test/dynalloc.cpp b/test/dynalloc.cpp
index c98cc80f0..1190eb9cd 100644
--- a/test/dynalloc.cpp
+++ b/test/dynalloc.cpp
@@ -55,7 +55,7 @@ void check_aligned_new()
void check_aligned_stack_alloc()
{
- for(int i = 1; i < 1000; i++)
+ for(int i = 1; i < 400; i++)
{
ei_declare_aligned_stack_constructed_variable(float,p,i,0);
VERIFY(size_t(p)%ALIGNMENT==0);
@@ -93,6 +93,32 @@ template<typename T> void check_dynaligned()
}
}
+template<typename T> void check_custom_new_delete()
+{
+ {
+ T* t = new T;
+ delete t;
+ }
+
+ {
+ std::size_t N = internal::random<std::size_t>(1,10);
+ T* t = new T[N];
+ delete[] t;
+ }
+
+#ifdef EIGEN_ALIGN
+ {
+ T* t = static_cast<T *>((T::operator new)(sizeof(T)));
+ (T::operator delete)(t, sizeof(T));
+ }
+
+ {
+ T* t = static_cast<T *>((T::operator new)(sizeof(T)));
+ (T::operator delete)(t);
+ }
+#endif
+}
+
void test_dynalloc()
{
// low level dynamic memory allocation
@@ -109,6 +135,11 @@ void test_dynalloc()
CALL_SUBTEST(check_dynaligned<Vector4d>() );
CALL_SUBTEST(check_dynaligned<Vector4i>() );
CALL_SUBTEST(check_dynaligned<Vector8f>() );
+
+ CALL_SUBTEST( check_custom_new_delete<Vector4f>() );
+ CALL_SUBTEST( check_custom_new_delete<Vector2f>() );
+ CALL_SUBTEST( check_custom_new_delete<Matrix4f>() );
+ CALL_SUBTEST( check_custom_new_delete<MatrixXi>() );
}
// check static allocation, who knows ?