use wasm4pm_compat::conformance::ConformanceResult;
#[test]
fn builder_clamps_out_of_range_into_unit_interval() {
let r = ConformanceResult::new(0.5, 1, 1, 0)
.with_precision(1.7) .with_generalization(-0.3) .with_simplicity(0.4); assert_eq!(r.precision, Some(1.0), "above-1 precision clamped to 1.0");
assert_eq!(
r.generalization,
Some(0.0),
"below-0 generalization clamped to 0.0"
);
assert_eq!(r.simplicity, Some(0.4), "in-range simplicity kept");
}
#[test]
fn builder_coerces_nan_to_low_bound() {
let r = ConformanceResult::new(0.5, 1, 1, 0).with_precision(f64::NAN);
let p = r.precision.expect("precision set");
assert!(!p.is_nan(), "NaN must not be stored");
assert_eq!(p, 0.0, "NaN coerced to the conservative low bound");
let inf = ConformanceResult::new(0.5, 1, 1, 0).with_generalization(f64::INFINITY);
assert_eq!(inf.generalization, Some(1.0), "+inf clamped to upper bound");
}