From 2d7186bb0308b61337d8bbdc6dd2547a8719b6dd Mon Sep 17 00:00:00 2001 From: Wijtze Pieter Kikstra Date: Fri, 27 Sep 2024 15:22:30 +0200 Subject: [PATCH] Added test with matching number of tables and coordinates. --- ...atic_multi_line_pressure_table_process.cpp | 42 +++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/applications/GeoMechanicsApplication/tests/cpp_tests/test_apply_phreatic_multi_line_pressure_table_process.cpp b/applications/GeoMechanicsApplication/tests/cpp_tests/test_apply_phreatic_multi_line_pressure_table_process.cpp index 514648885a0d..0bf75282f452 100644 --- a/applications/GeoMechanicsApplication/tests/cpp_tests/test_apply_phreatic_multi_line_pressure_table_process.cpp +++ b/applications/GeoMechanicsApplication/tests/cpp_tests/test_apply_phreatic_multi_line_pressure_table_process.cpp @@ -16,6 +16,23 @@ using namespace Kratos; +namespace +{ + +bool CanCreateInstanceOfApplyPhreaticMultiLinePressureTableProcessWithoutFailure(ModelPart& rModelPart, + const Parameters& rProcessParameters) +{ + try { + ApplyPhreaticMultiLinePressureTableProcess{rModelPart, rProcessParameters}; + } catch (const Exception&) { + return false; + } + + return true; +} + +} // namespace + namespace Kratos::Testing { @@ -36,9 +53,28 @@ KRATOS_TEST_CASE_IN_SUITE(ApplyPhreaticMultiLinePressureTableProcessThrowsWhenTa "table": [1, 2, 3, 4] } )"}; - KRATOS_EXPECT_EXCEPTION_IS_THROWN( - (ApplyPhreaticMultiLinePressureTableProcess{r_model_part, test_parameters}), - "Got 2 coordinates and 4 table references. The number of coordinates and table references should be equal.") + KRATOS_EXPECT_EXCEPTION_IS_THROWN((ApplyPhreaticMultiLinePressureTableProcess{r_model_part, test_parameters}), "Got 2 coordinates and 4 table references. The number of coordinates and table references should be equal.") +} + +KRATOS_TEST_CASE_IN_SUITE(ApplyPhreaticMultiLinePressureTableProcessDoesNotThrowWhenTableLengthMatchesCoordinates, + KratosGeoMechanicsFastSuiteWithoutKernel) +{ + auto model = Model{}; + auto& r_model_part = model.CreateModelPart("foo"); + auto test_parameters = Parameters{R"( + { + "model_part_name": "foo", + "variable_name": "WATER_PRESSURE", + "x_coordinates": [0.0, 1.0, 2.0], + "y_coordinates": [0.0, 1.0, 2.0], + "z_coordinates": [0.0, 0.0, 0.0], + "gravity_direction": 1, + "out_of_plane_direction": 2, + "table": [0, 0, 3] + } )"}; + + KRATOS_EXPECT_TRUE(CanCreateInstanceOfApplyPhreaticMultiLinePressureTableProcessWithoutFailure( + r_model_part, test_parameters)) } } // namespace Kratos::Testing \ No newline at end of file