use mercurys::hydrology::glaciers::{
    has_glaciers, has_polar_ice, ice_stability_depth, known_ice_deposits, psr_equilibrium_temp,
    radar_bright_crater_count, total_polar_ice_mass, total_psr_area_km2,
};
use mercurys::hydrology::lakes::{has_lakes, has_subsurface_liquid};
use mercurys::hydrology::oceans::{has_oceans, has_surface_liquid, triple_point_achievable};
use mercurys::hydrology::rivers::{has_paleochannels, has_rivers};

// ── Oceans ──

#[test]
fn no_oceans() {
    assert!(!has_oceans());
}

#[test]
fn no_surface_liquid() {
    assert!(!has_surface_liquid());
}

#[test]
fn triple_point_not_achievable() {
    assert!(!triple_point_achievable());
}

// ── Rivers ──

#[test]
fn no_rivers() {
    assert!(!has_rivers());
}

#[test]
fn no_paleochannels() {
    assert!(!has_paleochannels());
}

// ── Lakes ──

#[test]
fn no_lakes() {
    assert!(!has_lakes());
}

#[test]
fn no_subsurface_liquid() {
    assert!(!has_subsurface_liquid());
}

// ── Glaciers / Polar Ice ──

#[test]
fn no_surface_glaciers() {
    assert!(!has_glaciers());
}

#[test]
fn has_polar_ice_confirmed() {
    assert!(has_polar_ice());
}

#[test]
fn known_deposits_non_empty() {
    let deposits = known_ice_deposits();
    assert!(!deposits.is_empty());
    assert!(deposits.iter().any(|d| d.crater_name == "Prokofiev"));
}

#[test]
fn deposit_at_high_latitude() {
    for d in &known_ice_deposits() {
        assert!(
            d.latitude_deg.abs() > 70.0,
            "{} should be near pole",
            d.crater_name
        );
    }
}

#[test]
fn deposit_volume_positive() {
    for d in &known_ice_deposits() {
        assert!(d.volume_m3() > 0.0, "{}", d.crater_name);
    }
}

#[test]
fn deposit_mass_positive() {
    for d in &known_ice_deposits() {
        assert!(d.mass_kg() > 0.0, "{}", d.crater_name);
    }
}

#[test]
fn deposit_sublimation_rate_finite() {
    for d in &known_ice_deposits() {
        assert!(d.sublimation_rate().is_finite(), "{}", d.crater_name);
    }
}

#[test]
fn deposit_lifetime_positive() {
    for d in &known_ice_deposits() {
        assert!(d.lifetime_years() > 0.0, "{}", d.crater_name);
    }
}

#[test]
fn cold_deposits_stable() {
    for d in &known_ice_deposits() {
        assert!(
            d.is_stable(),
            "{} at {}K should be stable",
            d.crater_name,
            d.temperature_k
        );
    }
}

#[test]
fn total_polar_ice_mass_positive() {
    assert!(total_polar_ice_mass() > 0.0);
}

#[test]
fn total_psr_area_positive() {
    assert!(total_psr_area_km2() > 0.0);
}

#[test]
fn radar_bright_craters_positive() {
    assert!(radar_bright_crater_count() > 0);
}

#[test]
fn psr_temp_increases_at_lower_lat() {
    let t_pole = psr_equilibrium_temp(89.0);
    let t_lower = psr_equilibrium_temp(80.0);
    assert!(t_lower >= t_pole);
}

#[test]
fn psr_temp_very_cold_at_pole() {
    let t = psr_equilibrium_temp(89.5);
    assert!(t < 120.0);
}

#[test]
fn ice_stability_depth_zero_in_cold() {
    assert_eq!(ice_stability_depth(50.0), 0.0);
}

#[test]
fn ice_needs_burial_warmer() {
    assert!(ice_stability_depth(200.0) > 0.0);
}

#[test]
fn ice_stability_depth_increases_with_temp() {
    let d1 = ice_stability_depth(200.0);
    let d2 = ice_stability_depth(400.0);
    assert!(d2 >= d1);
}
