fix(s3): robustness & test-gap closure (H3/H4/H5/V5/V6) #45
Reference in New Issue
Block a user
No description provided.
Delete Branch "fix/s3-robustness-gaps"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Implements Session S3 of the test-coverage & input-validation audit. Covers five findings across two audit documents:
H3 —
enforce_gauss_bonnetreports correction magnituderaw property-mapandMapstemplate) now returndouble(the total absolute deficit|Σ(2π−Θ_v) − 2π·χ|)check_gauss_bonnetcallH4 —
reduce_to_fundamental_domainreal-axis boundaryReduceToFD_ThrowsForRealAxisBoundarycoversIm(τ) == 0.0exactlyIm(τ) < 0; the guard is<= 0.0so the boundary was untestedH5 — Degenerate-triangle path in Newton solver characterized
Euclidean_SliverTriangle_CharacterizedBehavior: near-degenerate sliver (aspect ratio ~10000), asserts no crash/NaN and noLinearSolverFailedEuclidean_ExactDegenerateTriangle_NoCrash: collinear vertices (zero area), documents that the solver exits with a meaningful failure statusV5 — XML parser rejects reformatted XML
load_result_xmlnow explicitly rejects non-conforming XML instead of silently mis-reading it into zerosgeometry=on same line as<ConformalResult, (2)>on same line as<DOFVector, (3) root element presentV6 — DOF-vector vs mesh size check
check_dof_vector_size(x, expected_dofs, context)added toserialization.hppstd::runtime_errorwith a clear message naming both loaded and expected sizesTest plan
license-headers.sh,cgal-conventions.py,codespell.sh,shellcheck.sh --strict🤖 Generated with Claude Code
Co-Authored-By: Claude Sonnet 4.6 noreply@anthropic.com
H3: enforce_gauss_bonnet now returns |deficit| (total absolute correction applied) so callers can detect pathological input without a separate check_gauss_bonnet call. Both overloads (raw property-map and Maps template) now return double instead of void. API comment updated. V5: load_result_xml now implements strict-subset XML rejection instead of silently mis-reading reformatted-but-valid XML into zeros. The function documents itself as accepting only the one-element-per-line format written by save_result_xml. Three strict-subset checks added: 1. <ConformalResult geometry=...> attribute must be on its opening line. 2. <Solver> required attributes must be on the same line. 3. <DOFVector> tag '>' must be on the same line as the tag name. Non-conforming files throw std::runtime_error immediately. V6: new helper check_dof_vector_size(x, expected_dofs, context) added to serialization.hpp. Throws std::runtime_error with a clear message when the loaded DOF-vector size does not match the mesh's expected DOF count. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>H3 (GaussBonnet suite, test_phase6.cpp): - EnforceReturnsCorrectionMagnitude_LargeCorrection: feeds tetrahedron with all theta_v=0, asserts returned correction is exactly 4pi. - EnforceReturnsCorrectionMagnitude_NearZeroWhenAlreadyCorrect: angles already satisfy GB, asserts correction near zero. - EnforceRawMapOverload_ReturnsCorrection: verifies the raw-map overload also returns the correction magnitude. H4 (PeriodMatrix suite, test_phase7.cpp): - ReduceToFD_ThrowsForRealAxisBoundary: the boundary Im(tau)==0.0 (real axis) must throw domain_error, covering the <= guard's exact boundary. H5 (NewtonSolver suite, test_newton_solver.cpp): - Euclidean_SliverTriangle_CharacterizedBehavior: near-degenerate sliver triangle (aspect ratio ~10000) — solver must not crash or NaN, and must not report LinearSolverFailed (system is still consistent). - Euclidean_ExactDegenerateTriangle_NoCrash: collinear vertices (zero area) — euclidean_cot_weights returns {0,0,0,false}; asserts no crash and that the reported status is a meaningful failure mode. V5 (Serialization suite, test_layout.cpp): - LoadResultXml_RejectsReformattedRootElement: <ConformalResult> with geometry= on a separate line throws runtime_error. - LoadResultXml_RejectsDOFVectorWithTagOpenOnSeparateLine: <DOFVector> with '>' on a separate line throws runtime_error. - LoadResultXml_CanonicalFormatStillWorks: regression guard confirming save_result_xml canonical output still round-trips correctly. V6 (Serialization suite, test_layout.cpp): - CheckDofVectorSize_ThrowsOnMismatch: size 3 vs expected 5 throws. - CheckDofVectorSize_PassesOnMatch: exact match does not throw. - CheckDofVectorSize_ErrorMessageNamesExpectedAndActual: exception message contains both the actual and expected sizes. Total CGAL tests: 313 (up from 298; 15 new tests, 0 failures). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>