use crate::refraction::*;
#[test]
fn test_refraction_below_horizon() {
let r = refraction_bennett(-5.0).unwrap();
assert_eq!(r, 0.0);
let r2 = refraction_saemundsson(-5.0, 1013.25, 10.0).unwrap();
assert_eq!(r2, 0.0);
}
#[test]
fn test_refraction_increases_with_lower_altitude() {
let r_high = refraction_bennett(45.0).unwrap();
let r_mid = refraction_bennett(20.0).unwrap();
let r_low = refraction_bennett(5.0).unwrap();
let r_horizon = refraction_bennett(0.0).unwrap();
assert!(r_high < r_mid);
assert!(r_mid < r_low);
assert!(r_low < r_horizon);
}
#[test]
fn test_extreme_conditions() {
let r_everest = refraction_saemundsson(10.0, 350.0, -40.0).unwrap(); let r_death_valley = refraction_saemundsson(10.0, 1030.0, 50.0).unwrap();
assert!(r_everest > 0.0 && r_everest < 0.08,
"Refraction at 10° with low pressure should be < 0.08°, got {}°", r_everest);
assert!(r_death_valley > 0.08 && r_death_valley < 0.15,
"Refraction at 10° with high pressure should be 0.08-0.15°, got {}°", r_death_valley);
assert!(r_everest < r_death_valley,
"Lower pressure should give less refraction: {} vs {}", r_everest, r_death_valley);
}
#[test]
fn test_radio_vs_optical() {
let r_radio_dry = refraction_radio(10.0, 1013.25, 20.0, 0.0).unwrap();
let r_radio_humid = refraction_radio(10.0, 1013.25, 20.0, 100.0).unwrap();
assert!(r_radio_humid > r_radio_dry,
"100% humidity ({}) should give more refraction than 0% ({})", r_radio_humid, r_radio_dry);
let humidity_effect = r_radio_humid - r_radio_dry;
assert!(humidity_effect > 0.0,
"Humidity should increase refraction, difference = {}°", humidity_effect);
}
#[test]
fn test_refraction_edge_case() {
let refr = refraction_radio(0.0, 1013.25, 20.0, 50.0).unwrap();
assert!(refr > 0.0, "Radio refraction at horizon should be positive, got {}°", refr);
let refr_above = refraction_radio(0.1, 1013.25, 20.0, 50.0).unwrap();
assert!(refr_above > 0.3 && refr_above < 15.0,
"Radio refraction near horizon should be significant, got {}°", refr_above);
let optical = refraction_saemundsson(0.1, 1013.25, 20.0).unwrap();
assert!(optical > 0.3 && optical < 1.0,
"Optical refraction near horizon should be ~0.3-1.0°, got {}°", optical);
}
#[test]
fn test_refraction_below_limit() {
let r1 = refraction_bennett(-1.0).unwrap();
assert_eq!(r1, 0.0);
let r2 = refraction_saemundsson(-2.0, 1013.25, 10.0).unwrap();
assert_eq!(r2, 0.0);
let r3 = refraction_radio(-2.0, 1013.25, 10.0, 50.0).unwrap();
assert_eq!(r3, 0.0);
}