From: Martin Kronbichler Date: Wed, 15 Jun 2022 11:34:27 +0000 (+0200) Subject: Make test more robust: Check tolerance rather than == X-Git-Tag: v9.4.0-rc1~14^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7633e8014c37655538e93feb415f5a3bf491c517;p=dealii.git Make test more robust: Check tolerance rather than == --- diff --git a/tests/fe/fe_values_view_25b_nonsymmetric.cc b/tests/fe/fe_values_view_25b_nonsymmetric.cc index 5911e0ac7b..fd424cdb2c 100644 --- a/tests/fe/fe_values_view_25b_nonsymmetric.cc +++ b/tests/fe/fe_values_view_25b_nonsymmetric.cc @@ -165,19 +165,21 @@ test(const Triangulation &tr, const FiniteElement &fe) dealii::Tensor<2, dim>::unrolled_to_component_indices(k); if (ind_k == nonzero_ind) { - AssertThrow(val_q[ind_k] == scalar_values[i_node][q], + AssertThrow(std::abs(val_q[ind_k] - + scalar_values[i_node][q]) < 1e-12, ExcInternalError()); - AssertThrow((grad_q[ind_k[0]][ind_k[1]] == - scalar_gradients[i_node][q]), + AssertThrow((grad_q[ind_k[0]][ind_k[1]] - + scalar_gradients[i_node][q]) + .norm() < 1e-11, ExcInternalError()); } else { - AssertThrow(val_q[ind_k] == 0., + AssertThrow(std::abs(val_q[ind_k]) < 1e-12, ExcMessage(std::to_string(k) + " " + std::to_string(ind_k[0]) + " " + std::to_string(ind_k[1]))); - AssertThrow((grad_q[ind_k[0]][ind_k[1]] == Tensor<1, dim>()), + AssertThrow(grad_q[ind_k[0]][ind_k[1]].norm() < 1e-11, ExcInternalError()); } } @@ -190,7 +192,8 @@ test(const Triangulation &tr, const FiniteElement &fe) for (unsigned int j = 0; j < dim; ++j) div_tmp += grad_q[i][j][j]; - AssertThrow(div_tmp == div_q[i], ExcInternalError()); + AssertThrow(std::abs(div_tmp - div_q[i]) < 1e-11, + ExcInternalError()); } } } @@ -198,9 +201,12 @@ test(const Triangulation &tr, const FiniteElement &fe) // compare function values/gradients/divergences: for (unsigned int q = 0; q < quadrature.size(); ++q) { - AssertThrow(values_manual[q] == values[q], ExcInternalError()); - AssertThrow(gradients_manual[q] == gradients[q], ExcInternalError()); - AssertThrow(divergences_manual[q] == divergences[q], ExcInternalError()); + AssertThrow((values_manual[q] - values[q]).norm() < 1e-12, + ExcInternalError()); + AssertThrow((gradients_manual[q] - gradients[q]).norm() < 1e-11, + ExcInternalError()); + AssertThrow((divergences_manual[q] - divergences[q]).norm() < 1e-11, + ExcInternalError()); } }