test: add comprehensive test coverage for Rust modules#49
Merged
Conversation
fb4c91a to
4bb1bfd
Compare
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds comprehensive test coverage for Rust modules in the ruby_native_statistics gem. It introduces Rust testing infrastructure to the CI workflow and adds extensive unit and integration tests.
- Added Rust testing support to GitHub Actions workflow
- Added comprehensive unit tests for mathematical functions with edge cases
- Cleaned up build configuration by removing unused build.rs file
Reviewed Changes
Copilot reviewed 5 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| ext/ruby_native_statistics/src/mathematics.rs | Added 20+ unit tests covering mean/median calculations, edge cases, and integration tests |
| ext/ruby_native_statistics/src/dispersion.rs | Added comprehensive tests for variance, standard deviation, and percentile calculations |
| ext/ruby_native_statistics/build.rs | Removed unused build.rs file entirely |
| ext/ruby_native_statistics/Cargo.toml | Updated dependencies and added test-specific dependencies |
| .github/workflows/branch-protection.yaml | Added Rust toolchain setup and cargo test command |
Comments suppressed due to low confidence (3)
ext/ruby_native_statistics/Cargo.toml:13
- The version "0.1" for rb-sys-env in dev-dependencies conflicts with version "0.2" in build-dependencies. This version downgrade in dev-dependencies may indicate a non-existent or incompatible version.
rb-sys-env = { version = "0.1" }
ext/ruby_native_statistics/src/mathematics.rs:100
- Missing test coverage for calculate_mean with empty array. The test only covers calculate_median with empty arrays, but calculate_mean would panic with division by zero on empty input.
fn test_calculate_median_empty_array() {
ext/ruby_native_statistics/src/mathematics.rs:167
- The NaN test is incomplete - it only verifies that the function doesn't panic but doesn't test the actual behavior. Consider asserting the specific expected result or behavior when NaN values are present.
let result = calculate_median(&[1.0, f64::NAN, 3.0]);
4bb1bfd to
1df1bca
Compare
- Add extensive unit tests for mathematics module (mean, median functions) - Add comprehensive test coverage for dispersion module (variance, stdev, percentile) - Include edge case tests for empty arrays, NaN, infinity, and large datasets - Add rb-sys-test-helpers dependency for Rust testing infrastructure - Integrate Rust testing into GitHub Actions CI workflow - Remove unused build.rs file and update Cargo.toml dependencies
1df1bca to
e5ec873
Compare
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.
Uh oh!
There was an error while loading. Please reload this page.