use eulumdat::{Eulumdat, PhotometricCalculations};
const FIXTURE: &str = include_str!("fixtures/biolux_dn150.ldt");
const SENSOR_WIDE: &str = include_str!("fixtures/variant2_sensor_wide.ldt");
#[test]
fn biolux_dn150_matches_published_flux_code() {
let ldt = Eulumdat::parse(FIXTURE).expect("biolux_dn150 fixture must parse");
let codes = PhotometricCalculations::cie_flux_codes(&ldt);
let formatted = codes.to_string();
assert_eq!(
formatted, "95 100 100 100 100",
"CIE flux code drift — got `{formatted}`, expected `95 100 100 100 100` per CIE 52-1982 \
applied to the published GLDF reference (BIOLUX HCL DL DN150). \
See docs/check_cie_flux_code.md."
);
}
#[test]
fn biolux_dn150_invariants_hold() {
let ldt = Eulumdat::parse(FIXTURE).expect("biolux_dn150 fixture must parse");
let codes = PhotometricCalculations::cie_flux_codes(&ldt);
assert!(
codes.n1 >= 0.0 && codes.n1 <= 100.0,
"n1 out of range: {}",
codes.n1
);
assert!(
codes.n2 >= 0.0 && codes.n2 <= 100.0,
"n2 out of range: {}",
codes.n2
);
assert!(
codes.n3 >= 0.0 && codes.n3 <= 100.0,
"n3 out of range: {}",
codes.n3
);
assert!(codes.n1 <= codes.n2 + 1e-9, "expected n1 ≤ n2");
assert!(codes.n2 <= codes.n3 + 1e-9, "expected n2 ≤ n3");
assert!(
codes.n4 >= 0.0 && codes.n4 <= 100.0,
"n4 (DLOR) out of range: {}",
codes.n4
);
assert!(
(codes.n5 - ldt.light_output_ratio).abs() < 1e-9,
"n5 should equal ldt.light_output_ratio ({}) — got {}",
ldt.light_output_ratio,
codes.n5
);
}
#[test]
fn variant2_sensor_wide_boundary_rounding() {
let ldt = Eulumdat::parse(SENSOR_WIDE).expect("variant2 fixture must parse");
let codes = PhotometricCalculations::cie_flux_codes(&ldt);
let formatted = codes.to_string();
assert_eq!(
formatted, "69 95 99 100 100",
"41.4° boundary interpolation regression — N1 should be 69 (true value 68.525), \
not 68 (the value produced when the trapezoid averages I[40°] with I[42.5°] \
instead of with the linearly-interpolated I(41.4°)). got `{formatted}`"
);
}