Skip to content

test(rust): improve unit test quality and consistency#15

Merged
coreyhn merged 3 commits into
mainfrom
tests/polish-rust-unit-tests
Jul 7, 2025
Merged

test(rust): improve unit test quality and consistency#15
coreyhn merged 3 commits into
mainfrom
tests/polish-rust-unit-tests

Conversation

@coreyhn
Copy link
Copy Markdown
Collaborator

@coreyhn coreyhn commented Jul 6, 2025

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:

  • Add test helper functions to reduce code duplication
  • Replace string-based error checking with type-based assertions
  • Fix brittle assertions that could break on minor message changes
  • 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 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_str for borrowed C strings (CStr) and c_string for owned C strings (CString). This builds upon and improves the standardization work from PR #13.

coreyhn and others added 3 commits July 6, 2025 13:12
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.
@coreyhn coreyhn requested a review from calvinbrewer July 7, 2025 23:08
@coreyhn coreyhn merged commit 592231f into main Jul 7, 2025
@coreyhn coreyhn deleted the tests/polish-rust-unit-tests branch July 7, 2025 23:21
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