use crate::types::ShiftType;
use chrono::NaiveDate;
pub const DEFAULT_CYCLE_LENGTH: u32 = 42;
pub const DEFAULT_TOTAL_TEAMS: u32 = 6;
pub fn default_reference_date() -> NaiveDate {
NaiveDate::from_ymd_opt(2025, 12, 15).unwrap()
}
pub fn default_shift_cycle() -> Vec<ShiftType> {
use ShiftType::*;
vec![
Morning, Morning, Afternoon, Afternoon, Rest, Night, Night,
Rest, Rest, Morning, Morning, Afternoon, Afternoon, Rest,
Night, Rest, Rest, Rest, Morning, Morning, Afternoon, Rest,
Night, Night, Rest, Rest, Rest, Morning, Afternoon, Afternoon,
Rest, Night, Night, Rest, Rest, Study, Study, Study, Study,
Study, Rest, Rest,
]
}
pub fn default_config() -> crate::types::ShiftCycleConfig {
crate::types::ShiftCycleConfig {
cycle: default_shift_cycle(),
cycle_length: DEFAULT_CYCLE_LENGTH,
reference_date: default_reference_date(),
total_teams: DEFAULT_TOTAL_TEAMS,
}
}
#[cfg(test)]
mod tests {
use super::*;
#[cfg(test)]
use chrono::Datelike;
#[test]
fn cycle_length_is_42() {
assert_eq!(default_shift_cycle().len(), 42);
}
#[test]
fn cycle_starts_with_morning() {
assert_eq!(default_shift_cycle()[0], ShiftType::Morning);
}
#[test]
fn cycle_ends_with_rest() {
assert_eq!(default_shift_cycle()[41], ShiftType::Rest);
}
#[test]
fn reference_date_equals_android() {
let d = default_reference_date();
assert_eq!(d.year(), 2025);
assert_eq!(d.month(), 12);
assert_eq!(d.day(), 15);
}
#[test]
fn team_phase_offset_formula() {
let config = default_config();
assert_eq!(config.team_phase_offset(1), 0);
assert_eq!(config.team_phase_offset(2), 7);
assert_eq!(config.team_phase_offset(6), 35);
}
}