Skip to content

Add comprehensive tests for cstringstream.c achieving 95.5% line coverage#94

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

Add comprehensive tests for cstringstream.c achieving 95.5% line coverage#94
doganulus merged 3 commits into4.0.0from
copilot/add-test-cases-for-cstringstream

Conversation

Copy link
Copy Markdown

Copilot AI commented Nov 30, 2025

Adds test coverage for src/cstringstream.c to meet the 90% coverage target.

Coverage Results

  • Line coverage: 95.5% (85/89 lines)
  • Function coverage: 100% (16/16 functions)
  • Uncovered lines are malloc failure paths (lines 68-69, 93-94)

Tests Added

  • Creation/deletion: newStringStream, deleteStringStream with NULL handling
  • Stream operations: clearStringStream, copyStringStream, resizeStringStream
  • Accessors: sizeStringStream, getStringStream, putStringStream
  • Append functions: char, string, int, unsigned, long, unsigned long, double
  • String extraction: stringFromStringStream
  • Edge cases: NULL parameters, invalid indices, resize triggers, empty streams
TEST_CASE("cstringstream - appendStringStringStream", "[cstringstream]") {
    SECTION("Append string") {
        cstringstream ss = newStringStream();
        REQUIRE(appendStringStringStream(ss, "Hello") == 0);
        REQUIRE(appendStringStringStream(ss, " World") == 0);
        
        char *str = stringFromStringStream(ss);
        REQUIRE(strcmp(str, "Hello World") == 0);
        
        free(str);
        deleteStringStream(ss);
    }
    
    SECTION("NULL stream returns -1") {
        REQUIRE(appendStringStringStream(nullptr, "test") == -1);
    }
}

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/cstringstream.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 19:50
…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/cstringstream.c to achieve 90% coverage Add comprehensive tests for cstringstream.c achieving 95.5% line coverage Nov 30, 2025
Copilot AI requested a review from doganulus November 30, 2025 19:55
@doganulus doganulus marked this pull request as ready for review December 1, 2025 05:16
@doganulus doganulus merged commit f08ad13 into 4.0.0 Dec 1, 2025
46 of 75 checks passed
@doganulus doganulus deleted the copilot/add-test-cases-for-cstringstream 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