Skip to content

Add comprehensive test cases for cuddAddWalsh.c#91

Merged
doganulus merged 3 commits into4.0.0from
copilot/add-test-cases-cuddaddwalsh
Dec 1, 2025
Merged

Add comprehensive test cases for cuddAddWalsh.c#91
doganulus merged 3 commits into4.0.0from
copilot/add-test-cases-cuddaddwalsh

Conversation

Copy link
Copy Markdown

Copilot AI commented Nov 30, 2025

Adds test coverage for Cudd_addWalsh and Cudd_addResidue functions. Achieves 64.8% line coverage and 100% function coverage.

Test Cases Added

Cudd_addWalsh:

  • Base case (n=0), n=1 through n=4 exercising loop iterations
  • Walsh matrix property verification (±1 terminals only)
  • Memory management and stress tests

Cudd_addResidue:

  • All option combinations: LSB/MSB, unsigned/two's complement
  • Various moduli including primes
  • Edge cases: n=1, different top variable indices
  • Invalid parameter handling

Coverage Limitations

The remaining 35% (51 lines) consists entirely of error handling paths for:

  • Memory allocation failures (ALLOC returning NULL)
  • Internal function failures (cuddUniqueConst, cuddUniqueInter, Cudd_addIte)
  • Timeout handler callback

These paths require mocking infrastructure to trigger—not achievable through normal unit testing without library modifications.

Example Test

TEST_CASE("Cudd_addWalsh - n=2 case with loop", "[cuddAddWalsh]") {
    DdManager *manager = Cudd_Init(0, 0, CUDD_UNIQUE_SLOTS, CUDD_CACHE_SLOTS, 0);
    
    DdNode *x[2], *y[2];
    for (int i = 0; i < 2; i++) {
        x[i] = Cudd_addIthVar(manager, i);
        y[i] = Cudd_addIthVar(manager, i + 2);
        Cudd_Ref(x[i]);
        Cudd_Ref(y[i]);
    }
    
    DdNode *result = Cudd_addWalsh(manager, x, y, 2);
    REQUIRE(result != nullptr);
    REQUIRE(Cudd_CountLeaves(result) == 2);  // Only +1 and -1
    
    // 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/cuddAddWalsh.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 18:52
…rage

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/cuddAddWalsh.c to achieve 90% coverage Add comprehensive test cases for cuddAddWalsh.c Nov 30, 2025
Copilot AI requested a review from doganulus November 30, 2025 19:00
@doganulus doganulus marked this pull request as ready for review December 1, 2025 05:17
@doganulus doganulus merged commit b096cbb into 4.0.0 Dec 1, 2025
37 checks passed
@doganulus doganulus deleted the copilot/add-test-cases-cuddaddwalsh branch December 5, 2025 14:18
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