qualia_vision/tracker/
score_tier_of.rs1#[repr(u8)]
9#[derive(Debug, Clone, Copy, PartialEq, Eq)]
10pub enum ScoreTier {
11 High = 0,
13 Low = 1,
15 Reject = 2,
17}
18
19#[inline]
24pub fn score_tier_of(score_u16: u16, high_score_u16: u16, low_score_u16: u16) -> ScoreTier {
25 if score_u16 >= high_score_u16 {
26 ScoreTier::High
27 } else if high_score_u16 > low_score_u16 && score_u16 >= low_score_u16 {
28 ScoreTier::Low
29 } else {
30 ScoreTier::Reject
31 }
32}
33
34#[cfg(test)]
35mod tests {
36 use super::*;
37
38 #[test]
39 fn tiers_partition_scores() {
40 assert_eq!(score_tier_of(50_000, 32_768, 6_554), ScoreTier::High);
41 assert_eq!(score_tier_of(32_768, 32_768, 6_554), ScoreTier::High);
42 assert_eq!(score_tier_of(10_000, 32_768, 6_554), ScoreTier::Low);
43 assert_eq!(score_tier_of(6_554, 32_768, 6_554), ScoreTier::Low);
44 assert_eq!(score_tier_of(100, 32_768, 6_554), ScoreTier::Reject);
45 }
46
47 #[test]
48 fn collapsed_thresholds_reject_low_band() {
49 assert_eq!(score_tier_of(40_000, 10_000, 10_000), ScoreTier::High);
50 assert_eq!(score_tier_of(9_999, 10_000, 10_000), ScoreTier::Reject);
51 }
52}