From: Denis Davydov Date: Tue, 15 Mar 2016 15:43:14 +0000 (+0100) Subject: use AssertThrow instead of Assert in petsc_complex tests X-Git-Tag: v8.5.0-rc1~1217^2~2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=deb12c7120b2bfa9bf997c73d023b5ad47921dac;p=dealii.git use AssertThrow instead of Assert in petsc_complex tests --- diff --git a/tests/petsc_complex/00.cc b/tests/petsc_complex/00.cc index 17781e5d09..106afb2c89 100644 --- a/tests/petsc_complex/00.cc +++ b/tests/petsc_complex/00.cc @@ -42,11 +42,11 @@ void multiply_petsc_complex_by_a_number () const PetscScalar gamma = alpha * beta; // Check real access - Assert (PetscRealPart (gamma)==0., ExcInternalError()); - Assert (PetscImaginaryPart (gamma) ==5., ExcInternalError()); + AssertThrow (PetscRealPart (gamma)==0., ExcInternalError()); + AssertThrow (PetscImaginaryPart (gamma) ==5., ExcInternalError()); // This is legal too! - Assert (gamma==std::complex (0.,5), ExcInternalError()); + AssertThrow (gamma==std::complex (0.,5), ExcInternalError()); deallog << "OK" << std::endl; } @@ -63,18 +63,18 @@ void divide_petsc_complex_by_a_number () const PetscScalar beta = alpha/2.; // Check real access - Assert (PetscRealPart (alpha)==1., ExcInternalError()); - Assert (PetscRealPart (beta) ==0.5, ExcInternalError()); + AssertThrow (PetscRealPart (alpha)==1., ExcInternalError()); + AssertThrow (PetscRealPart (beta) ==0.5, ExcInternalError()); // operate on alpha (now alpha==beta) alpha /= 2.; // Check complex access - Assert (PetscImaginaryPart (alpha)==1., ExcInternalError()); - Assert (PetscImaginaryPart (beta) ==1., ExcInternalError()); + AssertThrow (PetscImaginaryPart (alpha)==1., ExcInternalError()); + AssertThrow (PetscImaginaryPart (beta) ==1., ExcInternalError()); // This is legal too! - Assert (alpha==beta, ExcInternalError()); + AssertThrow (alpha==beta, ExcInternalError()); deallog << "OK" << std::endl; } @@ -87,7 +87,7 @@ void make_std_complex_from_petsc_complex () const std::complex beta = alpha; // These should be the same of course - Assert (alpha==beta, ExcInternalError()); + AssertThrow (alpha==beta, ExcInternalError()); deallog << "OK" << std::endl; } @@ -100,7 +100,7 @@ void make_petsc_complex_from_std_complex () const PetscScalar alpha = beta; // These should be the same of course - Assert (alpha==beta, ExcInternalError()); + AssertThrow (alpha==beta, ExcInternalError()); deallog << "OK" << std::endl; } @@ -114,7 +114,7 @@ void make_petsc_complex () const PetscScalar alpha = 1.0 + 2.0*PETSC_i; // Test if PetscScalar is an std::complex. - Assert (alpha==std::complex (1.,2.), ExcInternalError()); + AssertThrow (alpha==std::complex (1.,2.), ExcInternalError()); deallog << "OK" << std::endl; } @@ -127,18 +127,18 @@ void init_petsc_complex () // Initialise (no argument) to zero. const PetscScalar alpha; - Assert (alpha==std::complex (0.,0.), ExcInternalError()); + AssertThrow (alpha==std::complex (0.,0.), ExcInternalError()); // Initialise (real argument) to zero. const PetscScalar beta = 0.; - Assert (beta==alpha, ExcInternalError()); + AssertThrow (beta==alpha, ExcInternalError()); // Initialise (real+complex argument) to zero. const PetscScalar gamma = 0. + 0.*PETSC_i; - Assert (gamma==beta, ExcInternalError()); + AssertThrow (gamma==beta, ExcInternalError()); // If alpha==beta==gamma, then: - Assert (alpha==gamma, ExcInternalError()); + AssertThrow (alpha==gamma, ExcInternalError()); deallog << "OK" << std::endl; } diff --git a/tests/petsc_complex/01.cc b/tests/petsc_complex/01.cc index 61a78e9054..6a7bbf3443 100644 --- a/tests/petsc_complex/01.cc +++ b/tests/petsc_complex/01.cc @@ -37,13 +37,13 @@ void test (PETScWrappers::SparseMatrix &m) for (unsigned int j=0; j (0.,i*j*.5+.5), ExcInternalError()); - Assert (m.el(i,j) == std::complex (0.,i*j*.5+.5), ExcInternalError()); + AssertThrow (m(i,j) == std::complex (0.,i*j*.5+.5), ExcInternalError()); + AssertThrow (m.el(i,j) == std::complex (0.,i*j*.5+.5), ExcInternalError()); } else { - Assert (m(i,j) == std::complex (0.,0.), ExcInternalError()); - Assert (m.el(i,j) == std::complex (0.,0.), ExcInternalError()); + AssertThrow (m(i,j) == std::complex (0.,0.), ExcInternalError()); + AssertThrow (m.el(i,j) == std::complex (0.,0.), ExcInternalError()); } deallog << "OK" << std::endl; diff --git a/tests/petsc_complex/02.cc b/tests/petsc_complex/02.cc index ff4e8c87ab..255155da5e 100644 --- a/tests/petsc_complex/02.cc +++ b/tests/petsc_complex/02.cc @@ -39,13 +39,13 @@ void test (PETScWrappers::SparseMatrix &m) for (unsigned int j=0; j (0.,i*j*.5+.5), ExcInternalError()); - Assert (m.el(i,j) == std::complex (0.,i*j*.5+.5), ExcInternalError()); + AssertThrow (m(i,j) == std::complex (0.,i*j*.5+.5), ExcInternalError()); + AssertThrow (m.el(i,j) == std::complex (0.,i*j*.5+.5), ExcInternalError()); } else { - Assert (m(i,j) == std::complex (0.,0.), ExcInternalError()); - Assert (m.el(i,j) == std::complex (0.,0.), ExcInternalError()); + AssertThrow (m(i,j) == std::complex (0.,0.), ExcInternalError()); + AssertThrow (m.el(i,j) == std::complex (0.,0.), ExcInternalError()); } deallog << "OK" << std::endl; diff --git a/tests/petsc_complex/04.cc b/tests/petsc_complex/04.cc index 6312b33fbc..b15489e5a5 100644 --- a/tests/petsc_complex/04.cc +++ b/tests/petsc_complex/04.cc @@ -24,8 +24,8 @@ void test (PETScWrappers::SparseMatrix &m) { - Assert (m.m() == 5, ExcInternalError()); - Assert (m.n() == 5, ExcInternalError()); + AssertThrow (m.m() == 5, ExcInternalError()); + AssertThrow (m.n() == 5, ExcInternalError()); deallog << "OK" << std::endl; } diff --git a/tests/petsc_complex/05.cc b/tests/petsc_complex/05.cc index f6e6422c10..83ab077738 100644 --- a/tests/petsc_complex/05.cc +++ b/tests/petsc_complex/05.cc @@ -38,8 +38,8 @@ void test (PETScWrappers::SparseMatrix &m) m.compress (VectorOperation::insert); deallog << m.n_nonzero_elements() << std::endl; - Assert (m.n_nonzero_elements() == counter, - ExcInternalError()); + AssertThrow (m.n_nonzero_elements() == counter, + ExcInternalError()); deallog << "OK" << std::endl; } diff --git a/tests/petsc_complex/06.cc b/tests/petsc_complex/06.cc index 3790474535..6a58a3227b 100644 --- a/tests/petsc_complex/06.cc +++ b/tests/petsc_complex/06.cc @@ -34,7 +34,7 @@ void test (PETScWrappers::SparseMatrix &m) // compare against the exact value of the l1-norm (max col-sum) deallog << m.l1_norm() << std::endl; - Assert (m.l1_norm() == 7, ExcInternalError()); + AssertThrow (m.l1_norm() == 7, ExcInternalError()); deallog << "OK" << std::endl; } diff --git a/tests/petsc_complex/07.cc b/tests/petsc_complex/07.cc index 75b106ebd4..cc2265bea5 100644 --- a/tests/petsc_complex/07.cc +++ b/tests/petsc_complex/07.cc @@ -35,7 +35,7 @@ void test (PETScWrappers::SparseMatrix &m) // compare against the exact value of the linfty-norm (max row-sum). deallog << m.linfty_norm() << std::endl; - Assert (m.linfty_norm() == 8.5, ExcInternalError()); + AssertThrow (m.linfty_norm() == 8.5, ExcInternalError()); deallog << "OK" << std::endl; } diff --git a/tests/petsc_complex/08.cc b/tests/petsc_complex/08.cc index 3ab73e9b46..bcfdb4f884 100644 --- a/tests/petsc_complex/08.cc +++ b/tests/petsc_complex/08.cc @@ -40,7 +40,7 @@ void test (PETScWrappers::SparseMatrix &m) // compare against the exact value of the l2-norm (max row-sum) deallog << m.frobenius_norm() << std::endl; - Assert (m.frobenius_norm() == norm, ExcInternalError()); + AssertThrow (m.frobenius_norm() == norm, ExcInternalError()); deallog << "OK" << std::endl; } diff --git a/tests/petsc_complex/09.cc b/tests/petsc_complex/09.cc index b4fb084a66..6756f1d4ef 100644 --- a/tests/petsc_complex/09.cc +++ b/tests/petsc_complex/09.cc @@ -41,13 +41,13 @@ void test (PETScWrappers::SparseMatrix &m) for (unsigned int j=0; j ((i*j*.5+.5)*1.25,i*j*.5*1.25), ExcInternalError()); - Assert (m.el(i,j) == std::complex ((i*j*.5+.5)*1.25,i*j*.5*1.25), ExcInternalError()); + AssertThrow (m(i,j) == std::complex ((i*j*.5+.5)*1.25,i*j*.5*1.25), ExcInternalError()); + AssertThrow (m.el(i,j) == std::complex ((i*j*.5+.5)*1.25,i*j*.5*1.25), ExcInternalError()); } else { - Assert (m(i,j) == std::complex (0.,0.), ExcInternalError()); - Assert (m.el(i,j) == std::complex (0.,0.), ExcInternalError()); + AssertThrow (m(i,j) == std::complex (0.,0.), ExcInternalError()); + AssertThrow (m.el(i,j) == std::complex (0.,0.), ExcInternalError()); } deallog << "OK" << std::endl; diff --git a/tests/petsc_complex/10.cc b/tests/petsc_complex/10.cc index 2e22c87c11..9ab7150cc2 100644 --- a/tests/petsc_complex/10.cc +++ b/tests/petsc_complex/10.cc @@ -40,13 +40,13 @@ void test (PETScWrappers::SparseMatrix &m) for (unsigned int j=0; j (0.,(i*j*.5+.5)/4*3), ExcInternalError()); - Assert (m.el(i,j) == std::complex (0.,(i*j*.5+.5)/4*3), ExcInternalError()); + AssertThrow (m(i,j) == std::complex (0.,(i*j*.5+.5)/4*3), ExcInternalError()); + AssertThrow (m.el(i,j) == std::complex (0.,(i*j*.5+.5)/4*3), ExcInternalError()); } else { - Assert (m(i,j) == std::complex (0.,0.), ExcInternalError()); - Assert (m.el(i,j) == std::complex (0.,0.), ExcInternalError()); + AssertThrow (m(i,j) == std::complex (0.,0.), ExcInternalError()); + AssertThrow (m.el(i,j) == std::complex (0.,0.), ExcInternalError()); } deallog << "OK" << std::endl; diff --git a/tests/petsc_complex/11.cc b/tests/petsc_complex/11.cc index 07181f7bbe..10dd0c8896 100644 --- a/tests/petsc_complex/11.cc +++ b/tests/petsc_complex/11.cc @@ -31,7 +31,7 @@ void test (PETScWrappers::Vector &v) v.compress (VectorOperation::insert); - Assert (v.size() == 100, ExcInternalError()); + AssertThrow (v.size() == 100, ExcInternalError()); deallog << "OK" << std::endl; } diff --git a/tests/petsc_complex/12.cc b/tests/petsc_complex/12.cc index d2ab3d5f4d..98e3ac348a 100644 --- a/tests/petsc_complex/12.cc +++ b/tests/petsc_complex/12.cc @@ -44,10 +44,10 @@ void test (PETScWrappers::Vector &v) for (unsigned int k=0; k (1.,1.)) ) || - ( (pattern[i]==false) && (v(i).real()==0.) && (v(i).imag()==0.) ), - ExcInternalError()); + AssertThrow ( ( (pattern[i]==true) && (v(i).real()==i) && (v(i).imag()==i) ) || + //&& (v(i)==std::complex (1.,1.)) ) || + ( (pattern[i]==false) && (v(i).real()==0.) && (v(i).imag()==0.) ), + ExcInternalError()); deallog << "OK" << std::endl; } diff --git a/tests/petsc_complex/17.cc b/tests/petsc_complex/17.cc index 637a8515fa..d01b30e6f6 100644 --- a/tests/petsc_complex/17.cc +++ b/tests/petsc_complex/17.cc @@ -36,7 +36,7 @@ void test (PETScWrappers::Vector &v) v.compress (VectorOperation::insert); // then check the norm - Assert (v.l1_norm() == norm, ExcInternalError()); + AssertThrow (v.l1_norm() == norm, ExcInternalError()); deallog << "OK" << std::endl; } diff --git a/tests/petsc_complex/18.cc b/tests/petsc_complex/18.cc index 37ef593f2d..a8388f34a1 100644 --- a/tests/petsc_complex/18.cc +++ b/tests/petsc_complex/18.cc @@ -41,7 +41,7 @@ void test (PETScWrappers::Vector &v) // then check the l2-norm PetscReal l2_norm = v.l2_norm(); - Assert (l2_norm==std::sqrt(norm), ExcInternalError()); + AssertThrow (l2_norm==std::sqrt(norm), ExcInternalError()); deallog << "OK" << std::endl; } diff --git a/tests/petsc_complex/19.cc b/tests/petsc_complex/19.cc index 169f908281..dfa1a9487d 100644 --- a/tests/petsc_complex/19.cc +++ b/tests/petsc_complex/19.cc @@ -39,7 +39,7 @@ void test (PETScWrappers::Vector &v) v.compress (VectorOperation::insert); // then check the norm - Assert (v.linfty_norm() == norm, ExcInternalError()); + AssertThrow (v.linfty_norm() == norm, ExcInternalError()); deallog << "OK" << std::endl; } diff --git a/tests/petsc_complex/20.cc b/tests/petsc_complex/20.cc index c0bc9db93b..697194861c 100644 --- a/tests/petsc_complex/20.cc +++ b/tests/petsc_complex/20.cc @@ -48,7 +48,7 @@ void test (PETScWrappers::Vector &v, w.compress (VectorOperation::insert); // make sure the scalar product is zero - Assert (v*w == product, ExcInternalError()); + AssertThrow (v*w == product, ExcInternalError()); deallog << "OK" << std::endl; } diff --git a/tests/petsc_complex/element_access_00.cc b/tests/petsc_complex/element_access_00.cc index 09fef7f132..738a1d37fe 100644 --- a/tests/petsc_complex/element_access_00.cc +++ b/tests/petsc_complex/element_access_00.cc @@ -42,16 +42,16 @@ void test_vector (PETScWrappers::Vector &v) // check that is what we get by casting PetscScalar to std::real() // and std::imag() for (unsigned int k=0; k > (v(k)).real ()==k) && - (static_cast > (v(k)).imag ()==v.size()-k), - ExcInternalError()); + AssertThrow ((static_cast > (v(k)).real ()==k) && + (static_cast > (v(k)).imag ()==v.size()-k), + ExcInternalError()); // check that is what we get by // dealii::internal::VectorReference::real() and // dealii::internal::VectorReference::imag() for (unsigned int k=0; k (k+l); PetscReal el_i = static_cast (-1.*(k+l)); - Assert ((m(k,l).real ()==el_r) && (m(k,l).imag ()==el_i), - ExcInternalError()); + AssertThrow ((m(k,l).real ()==el_r) && (m(k,l).imag ()==el_i), + ExcInternalError()); } deallog << "OK" << std::endl; diff --git a/tests/petsc_complex/element_access_02.cc b/tests/petsc_complex/element_access_02.cc index 02b4d04eda..49dc8b0398 100644 --- a/tests/petsc_complex/element_access_02.cc +++ b/tests/petsc_complex/element_access_02.cc @@ -38,8 +38,8 @@ void test (PETScWrappers::SparseMatrix &m) // check the matrix is correctly filled for (unsigned int k=0; k (k+1.,k+1.); } - Assert (!(v==w), ExcInternalError()); + AssertThrow (!(v==w), ExcInternalError()); deallog << "OK" << std::endl; } diff --git a/tests/petsc_complex/vector_equality_2.cc b/tests/petsc_complex/vector_equality_2.cc index 814f8043bb..7d7f78feae 100644 --- a/tests/petsc_complex/vector_equality_2.cc +++ b/tests/petsc_complex/vector_equality_2.cc @@ -38,7 +38,7 @@ void test (PETScWrappers::Vector &v, // then copy elements and make sure the vectors are actually equal v = w; - Assert (v==w, ExcInternalError()); + AssertThrow (v==w, ExcInternalError()); deallog << "OK" << std::endl; } diff --git a/tests/petsc_complex/vector_wrap_01.cc b/tests/petsc_complex/vector_wrap_01.cc index d9c1f4c5e1..eed237c52d 100644 --- a/tests/petsc_complex/vector_wrap_01.cc +++ b/tests/petsc_complex/vector_wrap_01.cc @@ -36,12 +36,12 @@ void test (PETScWrappers::Vector &v, w(k) = v(k); // check that they're equal - Assert (v==w, ExcInternalError()); + AssertThrow (v==w, ExcInternalError()); v=w; // check that they're still equal - Assert (v==w, ExcInternalError()); + AssertThrow (v==w, ExcInternalError()); deallog << "OK" << std::endl; }