Skip to content

Fix : gh #259 : Add missing CUnit assert macro coverage so check_macros passes - #260

Open
Ulrond wants to merge 1 commit into
developfrom
feature/259-add-missing-cunit-macro-coverage
Open

Fix : gh #259 : Add missing CUnit assert macro coverage so check_macros passes#260
Ulrond wants to merge 1 commit into
developfrom
feature/259-add-missing-cunit-macro-coverage

Conversation

@Ulrond

@Ulrond Ulrond commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #259

make check_macros was failing on develop at 30 / 33 because three macros declared in include/ut_cunit.h were never referenced by tests/src/c_source/ut_test_assert.c:

Macro Defined at Gap
UT_ASSERT_NOT_EQUAL include/ut_cunit.h:340 no NOT_EQUAL test existed — test_ut_assert_EQUAL had no negative counterpart
UT_ASSERT_NOT_EQUAL_FATAL include/ut_cunit.h:359 as above
UT_ASSERT_LOG_FATAL include/ut_cunit.h:594 test_ut_assert_log covered UT_ASSERT_LOG but stopped short of the _FATAL variant

Only the C / CUnit variant was affected; CPP / GTest was already 33 / 33.

Changes

All confined to tests/src/c_source/ut_test_assert.c, following the conventions already used throughout that file — step 1 passes, step 2 asserts non-fatally, step 3 asserts fatally, with plain and _for_arg_function variants registered in register_assert_functions:

  • test_ut_assert_NOT_EQUAL and test_ut_assert_NOT_EQUAL_for_arg_function, mirroring the existing EQUAL pair.
  • A UT_ASSERT_LOG_FATAL step appended to test_ut_assert_log and test_ut_assert_log_for_arg_function. It is placed after the existing UT_LOG_INFO("+++ This line SHOULD be seen") so that line remains reachable and its expectation still holds.

No production code changed; no existing test lines were modified.

Verification

check_macros now passes for both variants:

$ cd tests && make check_macros TARGET=linux
Macros found in src/c_source/ut_test_assert.c :: 33 / 33

$ make check_macros TARGET=linux VARIANT=CPP
Macros found in src/cpp_source/ut_test_gtest_asserts.cpp :: 33 / 33

make build TARGET=linux compiles clean, no new warnings.

The assert suites are deliberately excluded from the normal run — register_assert_functions() is commented out in tests/src/ut_test_main.c:38 because these tests intentionally fail, keeping the standard run at 100% pass. To prove the new cases genuinely work I temporarily re-enabled registration locally (per the FIXME note on that line), rebuilt and ran; ut_test_main.c is unchanged in this PR. Observed:

STEP    : 1: UT_ASSERT_NOT_EQUAL ( true, false ) : PASS            <- no assert, as intended
STEP    : 2: UT_ASSERT_NOT_EQUAL ( true, true ) : should assert
ASSERT  : UT_ASSERT_NOT_EQUAL:"true=1, true=1"
STEP    : 3: UT_ASSERT_NOT_EQUAL ( true, true ) : should assert & FATAL
ASSERT  : UT_ASSERT_NOT_EQUAL_FATAL:"true=1, true=1"
ASSERT  : UT_ASSERT_LOG_FATAL:"true==false=0, Step 3: ASSERT_LOG_FATAL : should log and fail :"

Both _for_arg_function variants produced the equivalent sequence. The fatal steps correctly abort their test — ### This line should never be seen appears 0 times in the run.

Note: UT_LOG_INFO output does not appear in automated mode at all (0 INFO lines across the whole run, including pre-existing tests), which is existing behaviour unrelated to this change.

…ATAL

'make check_macros' failed on develop at 30/33: three macros declared in
include/ut_cunit.h were never exercised by the C test source, so the
target could not be used as a coverage gate.

Add the missing cases, following the conventions already in the file
(step 1 passes, step 2 asserts non-fatally, step 3 asserts fatally, with
plain and _for_arg_function variants registered in their suites):

  - test_ut_assert_NOT_EQUAL / _for_arg_function, mirroring the existing
    EQUAL pair, which had no negative counterpart
  - a UT_ASSERT_LOG_FATAL step appended to test_ut_assert_log and
    test_ut_assert_log_for_arg_function, placed after the existing
    UT_LOG_INFO so that line's expectation still holds

check_macros now reports 33/33 for both the C and CPP variants.

Fixes #259
Copilot AI review requested due to automatic review settings August 5, 2026 15:01
@Ulrond
Ulrond requested a review from a team as a code owner August 5, 2026 15:01
@Ulrond Ulrond added bug Something isn't working community-contribution Contribution from community labels Aug 5, 2026
@Ulrond
Ulrond requested a review from kanjoe24 August 5, 2026 15:01

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds missing CUnit assert-macro usage in the ut-core self-test suite so make check_macros reaches full coverage (33/33) for the C/CUnit variant, addressing #259. This keeps the macro-coverage gate meaningful without changing production code.

Changes:

  • Adds test_ut_assert_NOT_EQUAL and test_ut_assert_NOT_EQUAL_for_arg_function to exercise UT_ASSERT_NOT_EQUAL and UT_ASSERT_NOT_EQUAL_FATAL.
  • Extends the existing log-assert tests to also reference UT_ASSERT_LOG_FATAL.
  • Registers the new NOT_EQUAL tests in register_assert_functions().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working community-contribution Contribution from community

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Bug: make check_macros fails on develop — 3 CUnit assert macros have no test coverage

2 participants