test: add 56 unit tests for semantic, slab_alloc, and ast_profile modules#681
Conversation
…ules Add focused unit tests for three previously untested modules: - tests/test_semantic.c (32 tests): cbm_sem_tokenize (camel/snake/dot/abbrev), cbm_sem_cosine (identical/orthogonal/zero/negative/null), cbm_sem_normalize, cbm_sem_vec_add_scaled, cbm_sem_random_index (determinism), cbm_sem_proximity, cbm_sem_diffuse, corpus lifecycle, IDF, config - tests/test_slab_alloc.c (14 tests): slab malloc/free (≤64B and >64B), calloc zeroing/overflow, realloc (shrink/promote/same-size), free-list cycling, pointer uniqueness, thread reset - tests/test_ast_profile.c (10 tests): to_str/from_str round-trip (25 fields), null/empty/invalid inputs, to_vector range/saturation All 56 tests pass with ASan+UBSan. Registered in Makefile.cbm and test_main.c. Signed-off-by: Raul Acosta <raulacosta@users.noreply.github.com> Signed-off-by: Raul Acosta <raul.acosta.mmm@gmail.com>
…on on Windows/clang Signed-off-by: Raul Acosta <raul.acosta.mmm@gmail.com>
9c50b26 to
08437cf
Compare
|
Huge thanks for opening this PR and for the work you put into it. The maintainer shop is currently full, so this may sit for a bit before it gets a proper review. We will come back to this as soon as possible with real feedback; I wanted to make sure it did not sit unacknowledged in the meantime. |
|
Thanks for adding coverage. Before review can continue, please add a DCO |
|
Thank you — these are genuine, non-vacuous guards (exact-value assertions on the semantic proximity/cosine math, slab calloc-overflow + realloc-promotion, and the 25-field ast_profile roundtrip), not coverage padding, and they're black-box on the public slab API. That last part is timely: there's an in-flight slab-allocator redesign (cross-thread frees / #852), and this suite is exactly the independent regression net it needs. Merged as a4e1f21. Appreciated! |
Summary
Adds 56 unit tests across 3 new test files for previously untested modules:
tests/test_semantic.c(32 tests):cbm_sem_tokenize(camel/snake/dot/abbrev),cbm_sem_cosine(identical/orthogonal/zero/negative/null),cbm_sem_normalize,cbm_sem_vec_add_scaled,cbm_sem_random_index(determinism),cbm_sem_proximity,cbm_sem_diffuse, corpus lifecycle, IDF, configtests/test_slab_alloc.c(14 tests): Slab malloc/free (≤64B and >64B), calloc zeroing/overflow, realloc (shrink/promote/same-size), free-list cycling, pointer uniqueness, thread resettests/test_ast_profile.c(10 tests):to_str/from_strround-trip (25 fields), null/empty/invalid inputs,to_vectorrange/saturationVerification
All 56 pass with ASan+UBSan.
Files modified
Makefile.cbm: Register new test sources inALL_TEST_SRCStests/test_main.c: Registersuite_semantic,suite_ast_profile,suite_slab_alloc