Skip to content

Add C API tests for error handling, indexing, and search parameters#306

Open
rfsaliev wants to merge 7 commits into
dev/c-apifrom
rfsaliev/c-api-tests
Open

Add C API tests for error handling, indexing, and search parameters#306
rfsaliev wants to merge 7 commits into
dev/c-apifrom
rfsaliev/c-api-tests

Conversation

@rfsaliev

Copy link
Copy Markdown
Member

This pull request introduces a comprehensive C API test suite for the SVS project, leveraging the Catch2 testing framework. It adds new test files covering all major C API functionalities, integrates automated test building and execution into the CMake build system, and improves error handling and testability for dynamic index operations.

C API Test Infrastructure and Test Coverage:

  • Added a new directory of C API tests using Catch2, with individual test files for error handling, algorithm configuration, storage, search parameters, index building, and dynamic index operations. Each test file is organized by functionality and follows consistent patterns for assertions and resource cleanup. [1] [2] [3]
  • Introduced a CMakeLists.txt for the test suite that automatically fetches Catch2 if not found, builds the test executable, and integrates with CTest for automated test discovery and execution.
  • Added a detailed README.md explaining test structure, coverage, build/run instructions, and contribution guidelines for new tests.

Build System Improvements:

  • Enabled building of C API tests by default with a new SVS_BUILD_C_API_TESTS CMake option, and added logic to include the tests subdirectory conditionally.

Dynamic Index Error Handling:

  • Refactored svs_index_dynamic_delete_points to improve error handling: split the operation into two exception-wrapped phases, ensuring correct error reporting when deleting points from a dynamic index.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new Catch2-based test suite for the SVS C API, wires it into the CMake/CTest build, and refactors dynamic-index deletion to improve error reporting.

Changes:

  • Added multiple Catch2 test files covering C API error handling, algorithms, storage, search params, index building/search, and dynamic index operations.
  • Added bindings/c/tests/CMakeLists.txt and bindings/c/tests/README.md to build and run the new C API tests via CTest.
  • Refactored svs_index_dynamic_delete_points to split validation and deletion into separate exception-wrapped phases.

Reviewed changes

Copilot reviewed 11 out of 11 changed files in this pull request and generated 15 comments.

Show a summary per file
File Description
bindings/c/tests/c_api_storage.cpp Adds storage-handle tests (Simple/LeanVec/LVQ/SQ).
bindings/c/tests/c_api_search_params.cpp Adds search-parameter creation tests and invalid-size coverage.
bindings/c/tests/c_api_index_builder.cpp Adds index-builder creation/config tests (metric/storage/threadpool).
bindings/c/tests/c_api_index.cpp Adds build/search tests plus distance/reconstruct and threadpool management checks.
bindings/c/tests/c_api_error.cpp Adds basic error-handle lifecycle and invalid-call behavior tests.
bindings/c/tests/c_api_dynamic_index.cpp Adds dynamic index build/add/delete/consolidate/compact/search tests.
bindings/c/tests/README.md Documents test structure and build/run instructions.
bindings/c/tests/CMakeLists.txt Builds the C API test executable and integrates with CTest/Catch discovery.
bindings/c/src/svs_c.cpp Refactors svs_index_dynamic_delete_points exception handling.
bindings/c/CMakeLists.txt Introduces SVS_BUILD_C_API_TESTS option and conditionally adds the tests subdir.

Comment thread bindings/c/tests/c_api_index.cpp
Comment thread bindings/c/tests/c_api_storage.cpp Outdated
Comment thread bindings/c/tests/CMakeLists.txt
Comment thread bindings/c/src/svs_c.cpp Outdated
Comment thread bindings/c/tests/c_api_index_builder.cpp Outdated
Comment thread bindings/c/tests/README.md
Comment thread bindings/c/tests/c_api_dynamic_index.cpp Outdated
Comment thread bindings/c/tests/c_api_storage.cpp
Comment thread bindings/c/tests/c_api_storage.cpp Outdated
Comment thread bindings/c/CMakeLists.txt Outdated
Base automatically changed from rfsaliev/c-api-index-num-threads to dev/c-api April 16, 2026 15:42
rfsaliev added 2 commits June 8, 2026 07:48
…rch parameters, and storage

- Introduced tests for error handling in the C API, ensuring proper creation, cleanup, and state management of error handles.
- Implemented tests for index building and searching, covering various scenarios including different metrics, storage types, and threadpool configurations.
- Added tests for search parameters creation and validation, including handling of invalid sizes.
- Developed tests for storage creation, validating various data types and ensuring proper error handling for invalid arguments.
- Ensured all tests utilize the Catch2 framework for consistency and clarity.
@rfsaliev rfsaliev force-pushed the rfsaliev/c-api-tests branch from 46038d6 to b9020f1 Compare June 8, 2026 14:50
rfsaliev added 2 commits June 10, 2026 03:53
…orting

- Refactor CMake configuration to support coverage options for C API tests.
- Update test build options to allow dynamic index testing with configurable block sizes.
- Introduce a utility for managing temporary directories in tests.
- Improve dynamic index tests to include save/load functionality and multi-threading support.
- Update README and test commands for consistency with new test target names.
@rfsaliev rfsaliev marked this pull request as ready for review June 10, 2026 13:17
@rfsaliev rfsaliev requested a review from Copilot June 10, 2026 13:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 12 out of 12 changed files in this pull request and generated 7 comments.

Comment thread bindings/c/src/svs_c.cpp Outdated
Comment thread bindings/c/tests/CMakeLists.txt
Comment thread bindings/c/tests/CMakeLists.txt
Comment thread bindings/c/tests/c_api_test_utils.h
Comment thread bindings/c/tests/c_api_test_utils.h
Comment thread bindings/c/tests/c_api_test_utils.h
Comment thread bindings/c/CMakeLists.txt
rfsaliev added 3 commits June 10, 2026 07:10
- Bump project version to 0.4.0 in CMakeLists.txt
- Set default C++ standard to 20 if not defined
- Change target_link_libraries to target_link_options for coverage
- Improve delete_points method in DynamicIndex to handle non-existing IDs
- Add tests for deleting existing and non-existing IDs in c_api_dynamic_index.cpp
- Include C API header in test utilities for better integration
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