Skip to content

Add comprehensive test coverage for cuddAddInv.c (88.9% line coverage)#87

Merged
doganulus merged 3 commits into4.0.0from
copilot/add-test-cases-for-cuddaddinv
Nov 30, 2025
Merged

Add comprehensive test coverage for cuddAddInv.c (88.9% line coverage)#87
doganulus merged 3 commits into4.0.0from
copilot/add-test-cases-for-cuddaddinv

Conversation

Copy link
Copy Markdown

Copilot AI commented Nov 30, 2025

Adds test cases for Cudd_addScalarInverse and cuddAddScalarInverseRecur in src/cuddAddInv.c, achieving 88.9% line coverage and 100% function coverage.

Tests Added

  • Constant ADD operations: Inverse of various constants (2.0 → 0.5, 0.25 → 4.0, negatives)
  • Invalid inputs: Non-constant epsilon returns NULL, values below epsilon threshold
  • Multi-level ADDs: Single/multiple variable structures, 3-level deep ADDs
  • Cache behavior: Verifies repeated calls return cached result
  • Branch coverage: t == e optimization path, partial recursion failures
  • Mathematical correctness: Validates inverse × original = 1

Example Test

TEST_CASE("Cudd_addScalarInverse - Constant ADD", "[cuddAddInv]") {
    DdManager *manager = Cudd_Init(0, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0);
    
    DdNode *two = Cudd_addConst(manager, 2.0);
    Cudd_Ref(two);
    DdNode *epsilon = Cudd_addConst(manager, 1e-10);
    Cudd_Ref(epsilon);
    
    DdNode *result = Cudd_addScalarInverse(manager, two, epsilon);
    REQUIRE(result != nullptr);
    REQUIRE_THAT(Cudd_V(result), Catch::Matchers::WithinAbs(0.5, 1e-10));
    // ...
}

Uncovered Lines (4/36)

  • Line 118: Timeout handler callback (requires CUDD_TIMEOUT_EXPIRED state)
  • Lines 173-175: Memory exhaustion handling (requires cuddUniqueInter failure)

These are defensive error paths requiring runtime conditions not reliably reproducible in unit tests.

Original prompt

Complete test cases for src/cuddAddInv.c and target 90% coverage for the source file.


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 2 commits November 30, 2025 13:42
Co-authored-by: doganulus <1174212+doganulus@users.noreply.github.com>
Co-authored-by: doganulus <1174212+doganulus@users.noreply.github.com>
Copilot AI changed the title [WIP] Complete test cases for src/cuddAddInv.c Add comprehensive test coverage for cuddAddInv.c (88.9% line coverage) Nov 30, 2025
Copilot AI requested a review from doganulus November 30, 2025 13:59
@doganulus doganulus marked this pull request as ready for review November 30, 2025 18:12
@doganulus doganulus merged commit 6bd3268 into 4.0.0 Nov 30, 2025
53 of 74 checks passed
@doganulus doganulus deleted the copilot/add-test-cases-for-cuddaddinv branch November 30, 2025 19:39
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