use pretty_assertions::assert_eq; use super::*; #[test] fn recent_invocations_refresh_recency_and_evict_old_skills() { let history = RecentSkillInvocations::default(); for index in 0..=MAX_SHADOW_RESULTS { history.record(format!("skill-{index}")); } history.record("skill-1".to_string()); let recent = history.snapshot(); assert_eq!(MAX_SHADOW_RESULTS, recent.len()); assert_eq!(Some("skill-1"), recent.first().map(String::as_str)); assert_eq!(Some("skill-2"), recent.last().map(String::as_str)); assert!(!recent.iter().any(|skill| skill == "skill-0")); } #[test] fn rank_buckets_distinguish_results_above_twenty() { assert_eq!("11_20", rank_bucket(Some(20))); assert_eq!("21_50", rank_bucket(Some(21))); assert_eq!("21_50", rank_bucket(Some(50))); assert_eq!("miss", rank_bucket(Some(51))); }