use crate::{
schema::{self, OcpiEnum as _},
weekday::Weekday,
FromSchema as _,
};
#[test]
fn a_name_resolves_to_the_day_it_came_from() {
for day in Weekday::ALL {
assert_eq!(Weekday::from_canonical(day.canonical()), Some(day));
}
}
#[test]
fn the_names_are_the_ones_the_v221_schema_permits() {
for day in Weekday::ALL {
let variant = schema::v221::DayOfWeek::from_canonical(day.canonical())
.expect("the v221 schema names the same days");
let lowered = Weekday::from_schema(&variant).expect("the lowering is infallible");
assert_eq!(lowered.ignore_warnings(), day);
}
}
#[test]
fn the_names_are_the_ones_the_v211_schema_permits() {
for day in Weekday::ALL {
let variant = schema::v211::DayOfWeek::from_canonical(day.canonical())
.expect("the v211 schema names the same days");
let lowered = Weekday::from_schema(&variant).expect("the lowering is infallible");
assert_eq!(lowered.ignore_warnings(), day);
}
}
#[test]
fn the_days_are_declared_in_spec_order() {
assert!(Weekday::ALL.is_sorted());
}
#[test]
fn a_name_the_spec_does_not_define_is_not_a_day() {
assert_eq!(Weekday::from_canonical("CHRISTMAS"), None);
}
#[test]
fn a_name_in_the_wrong_case_is_not_a_day() {
assert_eq!(Weekday::from_canonical("Monday"), None);
}