Skip to content

Add parameterized tests (CTEST_PARAMETERIZED_TEST_FUNCTION)#291

Merged
mattdurak merged 2 commits intomasterfrom
parameterized_tests
Mar 9, 2026
Merged

Add parameterized tests (CTEST_PARAMETERIZED_TEST_FUNCTION)#291
mattdurak merged 2 commits intomasterfrom
parameterized_tests

Conversation

@mattdurak
Copy link
Contributor

Migrated from Azure/c-testrunnerswitcher#268.

Summary

Adds \CTEST_PARAMETERIZED_TEST_FUNCTION\ macro that generates multiple \CTEST_FUNCTION\ wrappers from a single test body with different argument sets. Each \CASE\ produces an individually named and filterable test.

Usage

\\c
CTEST_PARAMETERIZED_TEST_FUNCTION(test_addition,
ARGS(int, a, int, b, int, expected),
CASE((1, 2, 3), when_adding_1_and_2),
CASE((0, 0, 0), when_adding_zeros))
{
CTEST_ASSERT_ARE_EQUAL(int, expected, a + b);
}
\\

Changes

  • **\inc/ctest.h**: Added \CTEST_PARAMETERIZED_TEST_FUNCTION\ and helper macros. Includes an indirection macro (\CTEST_PARAMETERIZED_TEST_CALL_CTEST_FUNCTION) to force \MU_C3\ expansion before \CTEST_FUNCTION's ##\ operator.
  • **\ ests/ctest_parameterized_ut/**: New test directory with 4 parameterized test functions (16 total test cases) covering addition, multiplication, boolean checks, and execution verification.
  • **\doc/ctest_user_manual.md**: Added parameterized tests section; also documented the recently added test name filter feature.
  • **.github/copilot-instructions.md**: Added parameterized tests, test name filtering, and updated running tests examples.

Add CTEST_PARAMETERIZED_TEST_FUNCTION macro that generates multiple
CTEST_FUNCTION wrappers from a single test body with different argument
sets. Each CASE produces an individually named and filterable test.

- Add parameterized test macros to inc/ctest.h
- Add tests/ctest_parameterized_ut/ with 4 parameterized test functions
  (16 total test cases)
- Update doc/ctest_user_manual.md with parameterized tests section and
  test filter documentation
- Update .github/copilot-instructions.md with parameterized tests,
  test filter, and updated running tests examples

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Address PR review comment: parameterized tests are a tool used by
other tests, not a test category.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mattdurak
Copy link
Contributor Author

/azp run

@azure-pipelines
Copy link

Azure Pipelines successfully started running 1 pipeline(s).

Copy link
Contributor

@jebrando jebrando left a comment

Choose a reason for hiding this comment

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

:shipit:

@mattdurak mattdurak merged commit 52028ff into master Mar 9, 2026
13 checks passed
@mattdurak mattdurak deleted the parameterized_tests branch March 9, 2026 20:50
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