Skip to content

Add comprehensive unit tests for colvartypes and colvarvalue#928

Draft
Copilot wants to merge 1 commit into
masterfrom
copilot/analyze-test-coverage
Draft

Add comprehensive unit tests for colvartypes and colvarvalue#928
Copilot wants to merge 1 commit into
masterfrom
copilot/analyze-test-coverage

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 17, 2026

Summary

Adds 3 new unit test files to improve test coverage of core mathematical and data types in the Colvars library.

Changes

New test files

tests/unittests/colvartypes_vectors.cpp
Tests for cvm::rvector (construction, arithmetic, dot/cross product, norm, unit vector) and cvm::vector1d (construction, arithmetic, inner product, norm, sum, slice, serialization round-trip).

tests/unittests/colvartypes_quaternion.cpp
Tests for cvm::quaternion (construction, arithmetic, Hamilton product, conjugate, norm, set_positive, rotation of 3-vectors, rotation matrix, dist2, dist2_grad, cosine, as_vector/get_vector conversions).

tests/unittests/colvarvalue_all_types.cpp
Tests for colvarvalue across all supported types — scalar, 3-vector, quaternion, generic vector:

  • Construction from type flag, base type, and copy constructor
  • Binary arithmetic (+, -, *, /)
  • In-place operators (+=, -=, *=, /=)
  • Inner product
  • norm2(), norm(), sum()
  • dist2(), dist2_grad()
  • interpolate()
  • apply_constraints()
  • set_ones(), reset()
  • is_derivative()
  • Type metadata: type_desc(), type_keyword(), num_dimensions(), size()

tests/unittests/CMakeLists.txt — Adds a new foreach loop to build and register the 3 new tests (without requiring the colvars_stubs proxy library, since these tests only exercise core mathematical operations).

Testing

All 8 unit tests pass (5 original + 3 new):

  • colvarvalue_unit3vector
  • file_io
  • memory_stream
  • read_xyz_traj
  • parse_error
  • colvartypes_vectors ✅ (new)
  • colvartypes_quaternion ✅ (new)
  • colvarvalue_all_types ✅ (new)

…(all types)

Agent-Logs-Url: https://github.com/Colvars/colvars/sessions/dc8f0335-4a36-4e6e-8082-04a74cf37249

Co-authored-by: giacomofiorin <4512089+giacomofiorin@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