Test compilation fixes (8 integration test files): 1. Ambiguous float types — added f32/f64 annotations 2. chrono API — replaced with_hour() with date_naive().and_hms_opt() 3. Missing dev-dependencies — added sqlx + base64 4. Generic parse — wrapped f32 comparison in parens 5. Incorrect assertion — 3^5=243 > 100, changed nodes to 1000 CI fixes: 6. Missing benchmark fixtures — created 3 files in fixtures/benchmarks/ 7. clippy absurd_extreme_comparisons — usize >= 0 always true 8. authentik_jwt test — Option<SystemTime> type mismatch 9. http_server tests — removed broken RBAC test module (types deleted) Result: cargo build --all clean, cargo test --all --lib passes
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