test(rust): improve unit test quality and consistency#15
Merged
Conversation
This change updates Rust unit tests across all core modules to follow consistent patterns and improve reliability. Changes include: - Add test helper functions to reduce code duplication - Replace string-based error checking with type-based assertions - Update test data to use consistent examples - Standardize variable naming across test modules - Remove redundant comments and improve test organization - Fix brittle assertions that could break on minor message changes The tests now provide better coverage of error conditions while being more maintainable and less prone to false failures.
This change updates utility function names and parameters to better reflect their ownership semantics. Changes include: - Rename `string_to_c_str` to `string_to_c_string` to correctly indicate it returns an owned `CString` rather than a borrowed `CStr` - Update parameter names from `c_string_ptr` to `c_str_ptr` in functions that work with borrowed `CStr` types The naming now follows this pattern: `c_str` for borrowed C strings (`CStr`) and `c_string` for owned C strings (`CString`). This makes ownership semantics clear. This builds upon and improves the standardization in PR #13.
calvinbrewer
approved these changes
Jul 7, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR improves Rust unit test quality and consistency across all core modules, and updates utility function names and parameters to better reflect their ownership semantics.
Changes include:
string_to_c_strtostring_to_c_stringto correctly indicate it returns an ownedCStringrather than a borrowedCStrc_string_ptrtoc_str_ptrin functions that work with borrowedCStrtypesThe Rust unit tests now provide better coverage of error conditions while being more maintainable and less prone to false failures.
The C string naming now follows this pattern:
c_strfor borrowed C strings (CStr) andc_stringfor owned C strings (CString). This builds upon and improves the standardization work from PR #13.