From: Bruno Turcksin Date: Tue, 19 Dec 2017 01:58:16 +0000 (-0500) Subject: Improve move constructor tests X-Git-Tag: v9.0.0-rc1~643^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=395ed038389f1fff859b17d6b3ebdaa096e2f109;p=dealii.git Improve move constructor tests Improve the move constructor tests of TrilinosWrappers::SparseMatrix and TrilinosWrappers::SparsityPattern by checking the object whose data has been stolen can be reinitialized --- diff --git a/tests/trilinos/sparse_matrix_08.cc b/tests/trilinos/sparse_matrix_08.cc index ab1ee3b1fe..927d4c18e6 100644 --- a/tests/trilinos/sparse_matrix_08.cc +++ b/tests/trilinos/sparse_matrix_08.cc @@ -14,7 +14,8 @@ // --------------------------------------------------------------------- -// Test move constructor +// Test move constructor of sparse matrix and check that the matrix that has +// been move can be reinitialized #include "../tests.h" #include @@ -41,8 +42,8 @@ int main (int argc,char **argv) A.add (2, 1, 2.0); A.compress(VectorOperation::add); + // Check that the B stole the data of A TrilinosWrappers::SparseMatrix B(std::move(A)); - for (unsigned int i=0; i<3; ++i) for (unsigned int j=0; j<3; ++j) { @@ -56,5 +57,25 @@ int main (int argc,char **argv) } } + // Check that A can be reinitialized + TrilinosWrappers::SparsityPattern sp_2 (partitioning); + sp_2.add (1,2); + sp_2.compress(); + A.reinit(sp_2); + A.add(1, 2, 2.0); + A.compress(VectorOperation::add); + for (unsigned int i=0; i<3; ++i) + for (unsigned int j=0; j<3; ++j) + { + if ((i == 1) && (j == 2)) + { + AssertThrow(A.el(i,j) == 2, ExcInternalError()); + } + else + { + AssertThrow(A.el(i,j) == 0, ExcInternalError()); + } + } + deallog << "OK" << std::endl; } diff --git a/tests/trilinos/sparsity_pattern_04.cc b/tests/trilinos/sparsity_pattern_04.cc index f45898ec1f..212fabf030 100644 --- a/tests/trilinos/sparsity_pattern_04.cc +++ b/tests/trilinos/sparsity_pattern_04.cc @@ -14,6 +14,9 @@ // --------------------------------------------------------------------- +// Test the move constructor of the sparsity pattern and check the sparsity +// pattern whose data have been stolen can be reinitialized + #include "../tests.h" #include #include @@ -33,17 +36,35 @@ int main (int argc, char **argv) A.add(2,1); A.compress(); + // Check the move constructor TrilinosWrappers::SparsityPattern B(std::move(A)); for (unsigned int i=0; i<3; ++i) for (unsigned int j=0; j<3; ++j) { if ((i == 2) && (j == 1)) { - AssertThrow(B.exist(i,j) == true, ExcInternalError()); + AssertThrow(B.exists(i,j) == true, ExcInternalError()); + } + else + { + AssertThrow(B.exists(i,j) == false, ExcInternalError()); + } + } + + // Check that A can be reinitialized + A.reinit(partitioning); + A.add(1,2); + A.compress(); + for (unsigned int i=0; i<3; ++i) + for (unsigned int j=0; j<3; ++j) + { + if ((i == 1) && (j == 2)) + { + AssertThrow(A.exists(i,j) == true, ExcInternalError()); } else { - AssertThrow(B.exist(i,j) == false, ExcInternalError()); + AssertThrow(A.exists(i,j) == false, ExcInternalError()); } }