use rustsim_crowd::error::CrowdError;
use rustsim_crowd::{
anticipation_velocity, collision_free_speed, generalized_centrifugal_force, optimal_steps,
social_force,
};
#[test]
fn sfm_validate_enforces_cfl_bound() {
let params = social_force::Params {
max_accel: 100.0,
max_speed: 1.34,
..social_force::Params::default()
};
let dt = 0.05;
match params.validate(dt) {
Err(CrowdError::CflViolation {
model,
product,
max_speed,
..
}) => {
assert_eq!(model, "SocialForce");
assert!((product - dt * 100.0).abs() < 1e-12);
assert_eq!(max_speed, 1.34);
}
other => panic!("expected CflViolation, got {other:?}"),
}
social_force::Params::default()
.validate(0.05)
.expect("default SFM params at dt=0.05 must validate");
}
#[test]
fn gcf_validate_enforces_cfl_bound() {
let params = generalized_centrifugal_force::Params {
max_accel: 100.0,
max_speed: 1.34,
..generalized_centrifugal_force::Params::default()
};
let dt = 0.05;
match params.validate(dt) {
Err(CrowdError::CflViolation { model, .. }) => {
assert_eq!(model, "GeneralizedCentrifugalForce");
}
other => panic!("expected CflViolation, got {other:?}"),
}
generalized_centrifugal_force::Params::default()
.validate(0.05)
.expect("default GCF params at dt=0.05 must validate");
}
#[test]
fn cfs_validate_skips_cfl_even_for_pathological_dt() {
collision_free_speed::Params::default()
.validate(1.0)
.expect("CFS first-order kinematic: no CFL gate must trip");
}
#[test]
fn avm_validate_skips_cfl_even_for_pathological_dt() {
anticipation_velocity::Params::default()
.validate(1.0)
.expect("AVM first-order kinematic: no CFL gate must trip");
}
#[test]
fn osm_validate_skips_cfl_even_for_pathological_dt() {
optimal_steps::Params::default()
.validate(1.0)
.expect("OSM discrete-step kinematic: no CFL gate must trip");
}