use mercurys::atmosphere::climate::MercuryThermalState;
use mercurys::biosphere::ecosystems::{
    habitability_index, has_ecosystems, surface_uv_flux_relative_to_earth,
};
use mercurys::biosphere::fauna::{has_extremophile_potential, has_fauna};
use mercurys::biosphere::vegetation::{has_vegetation, par_flux_relative_to_earth};

// ── Ecosystems ──

#[test]
fn no_ecosystems() {
    assert!(!has_ecosystems());
}

#[test]
fn habitability_index_near_zero() {
    let h = habitability_index();
    assert!((0.0..0.1).contains(&h));
}

#[test]
fn uv_flux_higher_than_earth() {
    let f = surface_uv_flux_relative_to_earth();
    assert!(f > 1.0, "Mercury gets more UV than Earth");
}

// ── Fauna ──

#[test]
fn no_fauna() {
    assert!(!has_fauna());
}

#[test]
fn extremophile_potential_bool() {
    assert!(
        !has_extremophile_potential(),
        "Mercury should have no extremophile potential"
    );
}

// ── Vegetation ──

#[test]
fn no_vegetation() {
    assert!(!has_vegetation());
}

#[test]
fn par_flux_higher_than_earth() {
    let p = par_flux_relative_to_earth();
    assert!(p > 1.0, "Mercury is closer to the Sun");
}

// ── Cross-checks with atmosphere ──

#[test]
fn subsolar_temp_too_hot_for_life() {
    let state = MercuryThermalState::at_perihelion();
    assert!(
        state.subsolar_temperature_k() > 400.0,
        "Way above life tolerance"
    );
}

#[test]
fn nightside_too_cold_for_life() {
    assert_eq!(mercurys::NIGHTSIDE_TEMP_K, 100.0);
}

#[test]
fn no_atmosphere_for_life() {
    assert_eq!(mercurys::EXOSPHERE_SURFACE_PRESSURE_PA, 1.0e-10);
}
