Skip to content

Improve test coverage of FORM code#333

Merged
greenc-FNAL merged 1 commit intomainfrom
maintenance/improve-FORM-test-coverage
Feb 18, 2026
Merged

Improve test coverage of FORM code#333
greenc-FNAL merged 1 commit intomainfrom
maintenance/improve-FORM-test-coverage

Conversation

@greenc-FNAL
Copy link
Contributor

@greenc-FNAL greenc-FNAL commented Feb 18, 2026

Factored out of #329.

  • Added new unit tests for 'form'

  • Added test/form_basics_test.cpp to cover previously untested code in
    form libraries.

  • Fixed possible ODR violations in form/util/factories.hpp by adding
    inline.

Co-authored-by: greenc-FNAL 2372949+greenc-FNAL@users.noreply.github.com

Copilot AI review requested due to automatic review settings February 18, 2026 21:07
gemmeren
gemmeren previously approved these changes Feb 18, 2026
Copy link
Contributor

@gemmeren gemmeren left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @greenc-FNAL , this looks good to me.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves FORM library test coverage by adding a new Catch2 unit test covering core FORM storage/config/persistence primitives, and it fixes potential ODR violations by making header-defined factory functions inline.

Changes:

  • Added test/form/form_basics_test.cpp with unit tests covering Token, storage containers/files, factories, storage, persistence, and config helpers.
  • Registered the new test target in test/form/CMakeLists.txt.
  • Marked factory functions in form/util/factories.hpp as inline to prevent ODR issues across translation units.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
test/form/form_basics_test.cpp Adds baseline unit coverage for FORM primitives and basic storage/persistence flows.
test/form/CMakeLists.txt Adds a new Catch2-based test target and include path needed to compile it.
form/util/factories.hpp Adds inline to header-defined factory functions to avoid ODR violations.

Comment on lines +19 to +22
Token t("file.root", "container", 1, 42);
CHECK(t.fileName() == "file.root");
CHECK(t.containerName() == "container");
CHECK(t.technology() == 1);
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this codebase, technology values appear to be encoded using form::technology constants (e.g. ROOT_TTREE = major*256+minor). Using the literal 1 here is not a valid technology constant (it would yield GetMajor(1)==0) and may confuse future readers of the test. Consider using a real constant like form::technology::ROOT_TTREE (or another explicitly-valid tech value) for the Token construction.

Suggested change
Token t("file.root", "container", 1, 42);
CHECK(t.fileName() == "file.root");
CHECK(t.containerName() == "container");
CHECK(t.technology() == 1);
Token t("file.root", "container", form::technology::ROOT_TTREE, 42);
CHECK(t.fileName() == "file.root");
CHECK(t.containerName() == "container");
CHECK(t.technology() == form::technology::ROOT_TTREE);

Copilot uses AI. Check for mistakes.
c.setFile(f);

c.setupWrite(typeid(int));
c.fill(nullptr);
Copy link

Copilot AI Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Storage_Container::fill is exercised with nullptr here. Even though the current stub implementation ignores the pointer, this test can unintentionally codify that passing null is acceptable, and could become a crash if fill() later dereferences the input. Prefer passing a valid object pointer (e.g. an int on the stack) so the test remains correct if fill() gains real behavior.

Suggested change
c.fill(nullptr);
int value = 0;
c.fill(&value);

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Feb 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

@@            Coverage Diff             @@
##             main     #333      +/-   ##
==========================================
+ Coverage   80.39%   81.23%   +0.83%     
==========================================
  Files         127      127              
  Lines        3102     3102              
  Branches      547      547              
==========================================
+ Hits         2494     2520      +26     
+ Misses        381      360      -21     
+ Partials      227      222       -5     
Flag Coverage Δ
unittests 81.23% <ø> (+0.83%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
form/util/factories.hpp 45.00% <ø> (ø)

... and 8 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update f508fb6...33fefb4. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

- Added new unit tests for 'form'

- Added `test/form_basics_test.cpp` to cover previously untested code in
  form libraries.

- Fixed possible ODR violations in `form/util/factories.hpp` by adding
  `inline`.

Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>
@greenc-FNAL greenc-FNAL force-pushed the maintenance/improve-FORM-test-coverage branch from 33fefb4 to f54d1a4 Compare February 18, 2026 21:17
@greenc-FNAL greenc-FNAL merged commit 67d1adc into main Feb 18, 2026
46 of 48 checks passed
greenc-FNAL added a commit that referenced this pull request Feb 18, 2026
greenc-FNAL added a commit that referenced this pull request Feb 18, 2026
greenc-FNAL added a commit that referenced this pull request Feb 19, 2026
* Improve test coverage of FORM code

- Added new unit tests for 'form'

- Added `test/form_basics_test.cpp` to cover previously untested code in
  form libraries.

- Fixed possible ODR violations in `form/util/factories.hpp` by adding
  `inline`.

Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@users.noreply.github.com>

* Address #333 (review)

---------

Co-authored-by: greenc-FNAL <2372949+greenc-FNAL@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.

3 participants