diff options
author | Gael Guennebaud <g.gael@free.fr> | 2009-01-11 21:59:04 +0000 |
---|---|---|
committer | Gael Guennebaud <g.gael@free.fr> | 2009-01-11 21:59:04 +0000 |
commit | 9e8f437a6f3f2184a8b62cd193c5611a9a9b8127 (patch) | |
tree | 2f354c5af4de1808f8cdb5fda98d8b359cff4ee3 /test | |
parent | 824b75f182ee6ab37c34ec8a7d838a6c7e413334 (diff) |
extend stdvector test with more push_back...
Diffstat (limited to 'test')
-rw-r--r-- | test/CMakeLists.txt | 4 | ||||
-rw-r--r-- | test/stdvector.cpp | 16 |
2 files changed, 15 insertions, 5 deletions
diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 68f7f08d7..268440ff4 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -187,6 +187,6 @@ ei_add_test(parametrizedline) ei_add_test(alignedbox) ei_add_test(regression) ei_add_test(stdvector) -ei_add_test(sparse_basic " " "${SPARSE_LIBS}") -ei_add_test(sparse_vector " " "${SPARSE_LIBS}") +ei_add_test(sparse_basic) +ei_add_test(sparse_vector) ei_add_test(sparse_solvers " " "${SPARSE_LIBS}") diff --git a/test/stdvector.cpp b/test/stdvector.cpp index d14b85f95..ea57c0736 100644 --- a/test/stdvector.cpp +++ b/test/stdvector.cpp @@ -40,15 +40,25 @@ void check_stdvector(const MatrixType& m) { VERIFY_IS_APPROX(w[i], v[i]); } - + v.resize(21); v[20].set(x); VERIFY_IS_APPROX(v[20], x); v.resize(22,y); - VERIFY_IS_APPROX(v[21], y); + VERIFY_IS_APPROX(v[21], y); v.push_back(x); VERIFY_IS_APPROX(v[22], x); VERIFY((size_t)&(v[22]) == (size_t)&(v[21]) + sizeof(MatrixType)); + + // do a lot of push_back such that the vector gets internally resized + // (with memory reallocation) + MatrixType* ref = &w[0]; + for(int i=0; i<30 | ((ref==&w[0]) && i<300); ++i) + v.push_back(w[i%w.size()]); + for(int i=23; i<v.size(); ++i) + { + VERIFY(v[i]==w[(i-23)%w.size()]); + } } void test_stdvector() @@ -62,7 +72,7 @@ void test_stdvector() CALL_SUBTEST(check_stdvector(Matrix2f())); CALL_SUBTEST(check_stdvector(Vector4f())); CALL_SUBTEST(check_stdvector(Matrix4f())); - CALL_SUBTEST(check_stdvector(Matrix4d())); + CALL_SUBTEST(check_stdvector(Matrix4d())); // some dynamic sizes CALL_SUBTEST(check_stdvector(MatrixXd(1,1))); |