From 43c747fe006aa396204a377d404a7fcfb03a7347 Mon Sep 17 00:00:00 2001 From: "KOKO\\Mimi" Date: Wed, 14 Oct 2026 17:05:52 +0900 Subject: [PATCH] test(hex8): pin original overflow diagnostic priorities --- tests/unit/elements/hex8_element_test.cpp | 30 +++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/unit/elements/hex8_element_test.cpp b/tests/unit/elements/hex8_element_test.cpp index 6ce64ae..7c055af 100644 --- a/tests/unit/elements/hex8_element_test.cpp +++ b/tests/unit/elements/hex8_element_test.cpp @@ -811,6 +811,36 @@ TEST(Hex8Element, FiniteInputsThatOverflowDerivedArithmeticFailClosed) { std::string::npos); } +TEST(Hex8Element, BackendOperandRejectionRetainsOriginalStiffnessDiagnostic) { + Coordinates coordinates{}; + for (std::size_t a = 0; a < 8; ++a) + for (std::size_t i = 0; i < 3; ++i) + coordinates[a][i] = 0.01 * kSigns[a][i]; + // Original native probe: finite moduli/volume, but mu*gradient overflows. + // The failed diagnostic candidate must not become a scalar success fallback. + const auto element = Make(coordinates, 1e308, -0.5); + ASSERT_FALSE(element.HasValue()); + EXPECT_EQ(element.GetStatus().Diagnostics()[0].code, "invalid-hex8"); + EXPECT_EQ(element.GetStatus().Diagnostics()[0].message, + "Hex8 reference stiffness is nonfinite."); +} + +TEST(Hex8Element, TensorFailureRetainsPriorityOverEnergyAndTangentOverflow) { + Coordinates coordinates{}; + for (std::size_t a = 0; a < 8; ++a) + for (std::size_t i = 0; i < 3; ++i) + coordinates[a][i] = 0.01 * kSigns[a][i]; + const auto element = Make(coordinates, 1e200, -0.5); + ASSERT_TRUE(element.HasValue()); + const auto displacement = Affine(coordinates, + Tensor{{{1e100, 0, 0}, {0, 1e100, 0}, {0, 0, 1e100}}}); + const auto response = element.Value().EvaluateNonlinear(displacement); + ASSERT_FALSE(response.HasValue()); + EXPECT_EQ(response.GetStatus().Diagnostics()[0].code, "invalid-hex8"); + EXPECT_EQ(response.GetStatus().Diagnostics()[0].message, + "Hex8 trial tensor is nonfinite."); +} + // Independent Gauss-Legendre abscissae from polynomial root iteration. This // test does not call the kernel's shapes, Jacobian, inverse or quadrature. std::vector> LegendreRule(unsigned count) {