Skip to content

Add comprehensive test cases for cuddAddFind.c with 87% line coverage#86

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

Add comprehensive test cases for cuddAddFind.c with 87% line coverage#86
doganulus merged 3 commits into4.0.0from
copilot/add-test-cases-cuddaddfind

Conversation

Copy link
Copy Markdown

Copilot AI commented Nov 30, 2025

Adds test coverage for src/cuddAddFind.c which had 0% coverage. Achieved 87% line coverage (60/69 lines) and 100% function coverage (4/4 functions).

Changes

  • 42 new test cases covering:
    • Cudd_addFindMax: constant ADDs, multi-variable ADDs, cache hits, plus infinity early return, negative values, deep recursive structures
    • Cudd_addFindMin: constant ADDs, multi-variable ADDs, cache hits, minus infinity early return, negative values, deep recursive structures
    • Cudd_addIthBit: bit extraction for various values (0-255), T==E simplification path, cache hits, fractional truncation, high bit positions

Uncovered Lines

9 lines (13%) remain uncovered—all defensive error handling for memory exhaustion:

  • Lines 211-215: NULL return from addDoIthBit
  • Lines 278-279, 285-287: NULL returns from recursive calls and cuddUniqueInter

These paths require memory allocation failures mid-operation, which cannot be reliably triggered without mocking frameworks.

Example Test

TEST_CASE("Cudd_addFindMax - Complex ADD with multiple variables", "[cuddAddFind]") {
    DdManager *manager = Cudd_Init(0, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0);
    
    DdNode *var0 = Cudd_addIthVar(manager, 0);
    DdNode *var1 = Cudd_addIthVar(manager, 1);
    Cudd_Ref(var0); Cudd_Ref(var1);
    
    // Build: if x0 then (if x1 then 100 else 5) else (if x1 then 7 else 1)
    DdNode *then_branch = Cudd_addIte(manager, var1, const100, const5);
    DdNode *else_branch = Cudd_addIte(manager, var1, const7, const1);
    DdNode *add = Cudd_addIte(manager, var0, then_branch, else_branch);
    
    DdNode *result = Cudd_addFindMax(manager, add);
    REQUIRE(Cudd_V(result) == 100.0);
    // cleanup...
}

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • esm.ubuntu.com
    • Triggering command: /usr/lib/apt/methods/https /usr/lib/apt/methods/https (dns block)

If you need me to access, download, or install something from one of these locations, you can either:

Original prompt

Complete test cases for src/cuddAddFind.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 self-assigned this Nov 30, 2025
Copilot AI and others added 2 commits November 30, 2025 11:48
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] Add test cases for src/cuddAddFind.c to achieve 90% coverage Add comprehensive test cases for cuddAddFind.c with 87% line coverage Nov 30, 2025
Copilot AI requested a review from doganulus November 30, 2025 12:00
@doganulus doganulus marked this pull request as ready for review November 30, 2025 18:12
@doganulus doganulus merged commit afc90aa into 4.0.0 Nov 30, 2025
49 of 74 checks passed
@doganulus doganulus deleted the copilot/add-test-cases-cuddaddfind 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