fix: resolve 8 integration test compilation errors (#46)
CI / CI (push) Successful in 11m36s
CI / CI (push) Successful in 11m36s
## Problem 8 integration test files failed to compile due to: 1. Ambiguous float types (Rust 2024+ stricter inference) 2. chrono 0.4 API change (`with_hour` removed) 3. Missing `sqlx` + `base64` in `[dev-dependencies]` 4. `<` parsed as generics instead of comparison 5. Incorrect assertion (3^5=243 > 100) ## Fix - Added `f32`/`f64` type annotations to vec declarations and bindings - Replaced `with_hour(0)` with `date_naive().and_hms_opt(0,0,0).unwrap().and_utc()` - Added `sqlx` + `base64` to `[dev-dependencies]` - Wrapped comparison in parens - Fixed assertion: nodes=100 → nodes=1000 ## Validation - `cargo build --release` clean - `cargo test` — 20 test suites, 0 failures - 10 files changed, 46 insertions, 42 deletionsReviewed-on: #46 Co-authored-by: rock <[email protected]>
This commit was merged in pull request #46.
This commit is contained in:
@@ -45,16 +45,16 @@ mod tests {
|
||||
let possible_edges = nodes * (nodes - 1) / 2;
|
||||
|
||||
let density = actual_edges as f32 / possible_edges as f32;
|
||||
assert!((density - 0.2).abs() < 0.001);
|
||||
assert!((density - 0.2_f32).abs() < 0.001);
|
||||
}
|
||||
|
||||
/// Test: Community strength bounds (0-1)
|
||||
#[test]
|
||||
fn test_community_strength_bounds() {
|
||||
let strengths = vec![0.0, 0.5, 1.0];
|
||||
let strengths: Vec<f32> = vec![0.0, 0.5, 1.0];
|
||||
|
||||
for strength in strengths {
|
||||
let normalized = strength.max(0.0).min(1.0);
|
||||
let normalized = strength.max(0.0_f32).min(1.0_f32);
|
||||
assert!(normalized >= 0.0 && normalized <= 1.0);
|
||||
}
|
||||
}
|
||||
@@ -62,10 +62,10 @@ mod tests {
|
||||
/// Test: Modularity bounds (-1 to 1)
|
||||
#[test]
|
||||
fn test_modularity_bounds() {
|
||||
let values = vec![-1.5, -0.5, 0.0, 0.5, 1.5];
|
||||
let values: Vec<f32> = vec![-1.5, -0.5, 0.0, 0.5, 1.5];
|
||||
|
||||
for value in values {
|
||||
let clamped = value.max(-1.0).min(1.0);
|
||||
let clamped = value.max(-1.0_f32).min(1.0_f32);
|
||||
assert!(clamped >= -1.0 && clamped <= 1.0);
|
||||
}
|
||||
}
|
||||
@@ -73,7 +73,7 @@ mod tests {
|
||||
/// Test: Min community size clamping (2-1000)
|
||||
#[test]
|
||||
fn test_min_community_size_clamping() {
|
||||
let test_cases = vec![
|
||||
let test_cases: Vec<(i32, i32)> = vec![
|
||||
(0, 2), // Too small → 2
|
||||
(1, 2), // Too small → 2
|
||||
(2, 2), // Valid → 2
|
||||
@@ -91,7 +91,7 @@ mod tests {
|
||||
/// Test: Modularity threshold clamping (0.0001-0.1)
|
||||
#[test]
|
||||
fn test_modularity_threshold_clamping() {
|
||||
let test_cases = vec![
|
||||
let test_cases: Vec<(f32, f32)> = vec![
|
||||
(0.00001, 0.0001), // Too small → 0.0001
|
||||
(0.0001, 0.0001), // Valid → 0.0001
|
||||
(0.01, 0.01), // Valid → 0.01
|
||||
@@ -100,7 +100,7 @@ mod tests {
|
||||
];
|
||||
|
||||
for (input, expected) in test_cases {
|
||||
let clamped = input.max(0.0001).min(0.1);
|
||||
let clamped = input.max(0.0001_f32).min(0.1_f32);
|
||||
assert!((clamped - expected).abs() < 0.00001);
|
||||
}
|
||||
}
|
||||
@@ -117,7 +117,7 @@ mod tests {
|
||||
let total_size: usize = communities.iter().map(|(_, m)| m.len()).sum();
|
||||
let avg = total_size as f32 / communities.len() as f32;
|
||||
|
||||
assert!((avg - 3.333).abs() < 0.01); // (3 + 2 + 5) / 3 ≈ 3.33
|
||||
assert!((avg - 3.333_f32).abs() < 0.01); // (3 + 2 + 5) / 3 ≈ 3.33
|
||||
}
|
||||
|
||||
/// Test: Total modularity sum
|
||||
@@ -125,9 +125,9 @@ mod tests {
|
||||
fn test_total_modularity_sum() {
|
||||
let contributions = vec![0.3, 0.25, 0.2, 0.15];
|
||||
let total: f32 = contributions.iter().sum();
|
||||
let clamped = total.max(-1.0).min(1.0);
|
||||
let clamped = total.max(-1.0_f32).min(1.0_f32);
|
||||
|
||||
assert!((clamped - 0.9).abs() < 0.001);
|
||||
assert!((clamped - 0.9_f32).abs() < 0.001);
|
||||
}
|
||||
|
||||
/// Test: Community count with size threshold
|
||||
@@ -165,10 +165,10 @@ mod tests {
|
||||
/// Test: Edge weight normalization (0-1)
|
||||
#[test]
|
||||
fn test_edge_weight_normalization() {
|
||||
let weights = vec![-0.5, 0.0, 0.5, 1.0, 1.5];
|
||||
let weights: Vec<f32> = vec![-0.5, 0.0, 0.5, 1.0, 1.5];
|
||||
|
||||
for weight in weights {
|
||||
let normalized = weight.max(0.0).min(1.0);
|
||||
let normalized = weight.max(0.0_f32).min(1.0_f32);
|
||||
assert!(normalized >= 0.0 && normalized <= 1.0);
|
||||
}
|
||||
}
|
||||
@@ -374,6 +374,6 @@ mod tests {
|
||||
let total = internal_edges + external_edges;
|
||||
|
||||
let isolation = internal_edges as f32 / total as f32;
|
||||
assert!((isolation - 0.833).abs() < 0.01); // 10 / 12
|
||||
assert!((isolation - 0.833_f32).abs() < 0.01); // 10 / 12
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user