Skip to content

Improve C++ coverage for helper utilities and terminal/barrier constraints#169

Draft
Copilot wants to merge 4 commits intomasterfrom
copilot/analyze-test-coverage
Draft

Improve C++ coverage for helper utilities and terminal/barrier constraints#169
Copilot wants to merge 4 commits intomasterfrom
copilot/analyze-test-coverage

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 4, 2026

This PR expands coverage in parts of the C++ core that were lightly tested or effectively untested: finite-difference utilities, attitude conversion helpers, and terminal/barrier constraint utilities. It also fixes the terminal-constraint method signatures so those code paths are actually exercised through the existing Constraint interface.

  • Finite-difference helper coverage

    • Replaced the minimal finite-difference test with analytic checks for gradient, Jacobian, and Hessian computation.
    • Covers all supported modes: central, forward, and backward differences.
    • Adds explicit coverage for invalid mode handling.
  • Attitude conversion helper coverage

    • Added focused tests for Euler/rotation round-trips, gimbal-lock handling, MRP shadow-set equivalence, quaternion-to-MRP edge behavior, and skew-matrix cross-product properties.
    • Exercises previously untested branches in /home/runner/work/cddp-cpp/cddp-cpp/src/cddp_core/helper.cpp.
  • Terminal and barrier utility coverage

    • Added tests for terminal equality and inequality constraints, including bounds, Jacobians, Hessian shape/zero structure, violation computation, and dimension mismatch errors.
    • Added tests for relaxed log-barrier value/gradient/Hessian behavior on a linear constraint.
    • Added tests for discrete barrier state initialization, violation extraction, state updates, penalty cost terms, and parameter validation.
  • Constraint interface compatibility

    • Updated /home/runner/work/cddp-cpp/cddp-cpp/include/cddp-cpp/cddp_core/terminal_constraint.hpp overrides to match the base Constraint interface signatures, including the optional index parameter.
    • This makes the terminal constraint types compile and behave correctly when used polymorphically.

Example of the new coverage shape:

for (const int mode :
     std::array<int, 3>{kCentralDifference, kForwardDifference,
                        kBackwardDifference}) {
  const Eigen::MatrixXd jac =
      cddp::finite_difference_jacobian(vector_function, x, 1e-6, mode);
  EXPECT_TRUE(jac.isApprox(jac_expected, 1e-4)) << "mode=" << mode;
}

Copilot AI and others added 4 commits April 4, 2026 21:06
Agent-Logs-Url: https://github.com/astomodynamics/cddp-cpp/sessions/74fc7104-f2ef-41e6-b9dc-7425d8765f3b

Co-authored-by: astomodynamics <49183997+astomodynamics@users.noreply.github.com>
Agent-Logs-Url: https://github.com/astomodynamics/cddp-cpp/sessions/74fc7104-f2ef-41e6-b9dc-7425d8765f3b

Co-authored-by: astomodynamics <49183997+astomodynamics@users.noreply.github.com>
Agent-Logs-Url: https://github.com/astomodynamics/cddp-cpp/sessions/74fc7104-f2ef-41e6-b9dc-7425d8765f3b

Co-authored-by: astomodynamics <49183997+astomodynamics@users.noreply.github.com>
Agent-Logs-Url: https://github.com/astomodynamics/cddp-cpp/sessions/74fc7104-f2ef-41e6-b9dc-7425d8765f3b

Co-authored-by: astomodynamics <49183997+astomodynamics@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants