#![no_std]
mod generated;
pub use generated::{Colo, LocationHint};
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_location_hint_roundtrip() {
for hint in LocationHint::ALL {
let code = hint.as_str();
let parsed = LocationHint::parse(code);
assert_eq!(parsed, Some(*hint));
}
}
#[test]
fn test_colo_roundtrip() {
for colo in Colo::ALL {
let code = colo.code();
let parsed = Colo::from_code(code);
assert_eq!(parsed, Some(*colo));
}
}
#[test]
fn test_known_colos() {
let lax = Colo::from_code("LAX").unwrap();
assert_eq!(lax.name(), "Los Angeles, CA, United States");
assert_eq!(lax.location_hint(), Some(LocationHint::WNam));
let ams = Colo::from_code("AMS").unwrap();
assert_eq!(ams.name(), "Amsterdam, Netherlands");
let sin = Colo::from_code("SIN").unwrap();
assert!(sin.name().contains("Singapore"));
assert_eq!(sin.location_hint(), Some(LocationHint::Apac));
}
#[test]
fn test_location_hint_names() {
assert_eq!(LocationHint::WNam.name(), "Western North America");
assert_eq!(LocationHint::ENam.name(), "Eastern North America");
assert_eq!(LocationHint::WEur.name(), "Western Europe");
assert_eq!(LocationHint::EEur.name(), "Eastern Europe");
assert_eq!(LocationHint::Apac.name(), "Asia-Pacific");
assert_eq!(LocationHint::Oc.name(), "Oceania");
assert_eq!(LocationHint::Sam.name(), "South America");
assert_eq!(LocationHint::Afr.name(), "Africa");
assert_eq!(LocationHint::Me.name(), "Middle East");
}
#[test]
fn test_display() {
assert_eq!(LocationHint::WNam.as_str(), "wnam");
assert_eq!(Colo::LAX.code(), "LAX");
}
}