Skip to content

Conversation

Copy link

Copilot AI commented Dec 6, 2025

Symbol table library src/st.c had only 12.9% test coverage. Added comprehensive tests to achieve 90.2% line coverage (248/275 lines).

Test Coverage Added

  • Initialization: st_init_table, st_init_table_with_params, st_init_table_with_arg, st_init_table_with_params_and_arg
  • Hash/Compare functions: st_numhash, st_ptrhash, st_strhash, st_numcmp, st_ptrcmp
  • Lookup: st_lookup, st_lookup_int, st_find, st_is_member
  • Modification: st_insert, st_add_direct, st_find_or_add, st_delete, st_delete_int
  • Copy: st_copy (previously 0% coverage)
  • Iteration: st_foreach with ST_CONTINUE/ST_STOP/ST_DELETE, st_gen, st_gen_int
  • Edge cases: null value pointers, reorder_flag, rehash triggers, collision handling
TEST_CASE("st - st_foreach with ST_DELETE", "[st]") {
    st_table *tbl = st_init_table(st_numcmp, st_numhash);
    for (int i = 0; i < 10; i++) {
        st_insert(tbl, (void *)(intptr_t)i, (void *)(intptr_t)(i * 10));
    }
    
    int count = 0;
    int result = st_foreach(tbl, foreach_delete, &count);
    REQUIRE(result == 1);
    REQUIRE(st_count(tbl) == 0);  // All entries deleted
    st_free_table(tbl);
}

Remaining uncovered lines (~10%) are memory allocation failure paths requiring allocator mocking.

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 -plugin-opt=-pass-through=-lgcc_s --build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed -dynamic-linker /lib64/ld-linux-x86-64.so.2 -pie -z (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/st.c and target 90% coverage for the source file.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add test cases for src/st.c to achieve 90% coverage Add comprehensive test coverage for st.c (90.2%) Dec 6, 2025
Copilot AI requested a review from doganulus December 6, 2025 08:00
@doganulus doganulus marked this pull request as ready for review December 6, 2025 14:11
@doganulus doganulus merged commit 61fdf48 into 4.0.0 Dec 6, 2025
44 of 74 checks passed
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