use super::*;

#[test]
fn kind_maps_known_labels_and_keeps_the_rest_verbatim() {
    assert_eq!(TfrKind::from_label("SCHEDULED"), TfrKind::Scheduled);
    assert_eq!(TfrKind::from_label("firefighting"), TfrKind::Firefighting);
    assert_eq!(TfrKind::from_label("PRESIDENTIAL"), TfrKind::Presidential);
    assert_eq!(
        TfrKind::from_label("HAZARDS"),
        TfrKind::Other("HAZARDS".to_owned())
    );
}

#[test]
fn contains_tests_the_polygon_and_is_none_without_an_area() {
    let square = Area::Polygon {
        vertices: vec![
            GeoPoint {
                lat: 40.0,
                lon: -112.0,
            },
            GeoPoint {
                lat: 40.0,
                lon: -111.0,
            },
            GeoPoint {
                lat: 41.0,
                lon: -111.0,
            },
            GeoPoint {
                lat: 41.0,
                lon: -112.0,
            },
        ],
    };
    let tfr = Tfr::new("FDC 6/7864", TfrKind::Scheduled, "…").with_area(Some(square));
    assert_eq!(
        tfr.contains(GeoPoint {
            lat: 40.5,
            lon: -111.5
        }),
        Some(true)
    );
    assert_eq!(
        tfr.contains(GeoPoint {
            lat: 10.0,
            lon: 10.0
        }),
        Some(false)
    );

    let no_area = Tfr::new("FDC 6/0001", TfrKind::Firefighting, "…");
    assert_eq!(no_area.contains(GeoPoint { lat: 0.0, lon: 0.0 }), None);
}
