1 use crate::display::color_mode::ColorMode::{EightBit, FourBit, TrueColor}; 2 3 #[derive(Debug, PartialEq)] 4 pub(super) enum ColorMode { 5 TwoTone, 6 ThreeBit, 7 FourBit, 8 EightBit, 9 TrueColor, 10 } 11 12 impl ColorMode { has_minimum_four_bit_color(&self) -> bool13 pub(super) fn has_minimum_four_bit_color(&self) -> bool { 14 *self == FourBit || *self == EightBit || *self == TrueColor 15 } 16 has_true_color(&self) -> bool17 pub(super) fn has_true_color(&self) -> bool { 18 *self == TrueColor 19 } 20 } 21 22 #[cfg(test)] 23 mod tests { 24 use crate::display::color_mode::ColorMode; 25 26 #[test] color_mode_has_minimum_four_bit_color_two_tone()27 fn color_mode_has_minimum_four_bit_color_two_tone() { 28 assert!(!ColorMode::TwoTone.has_minimum_four_bit_color()); 29 } 30 31 #[test] color_mode_has_minimum_four_bit_color_three_bit()32 fn color_mode_has_minimum_four_bit_color_three_bit() { 33 assert!(!ColorMode::ThreeBit.has_minimum_four_bit_color()); 34 } 35 36 #[test] color_mode_has_minimum_four_bit_color_four_bit()37 fn color_mode_has_minimum_four_bit_color_four_bit() { 38 assert!(ColorMode::FourBit.has_minimum_four_bit_color()); 39 } 40 41 #[test] color_mode_has_minimum_four_bit_color_eight_bit()42 fn color_mode_has_minimum_four_bit_color_eight_bit() { 43 assert!(ColorMode::EightBit.has_minimum_four_bit_color()); 44 } 45 46 #[test] color_mode_has_minimum_four_bit_color_true_color()47 fn color_mode_has_minimum_four_bit_color_true_color() { 48 assert!(ColorMode::TrueColor.has_minimum_four_bit_color()); 49 } 50 #[test] color_mode_has_true_color_two_tone()51 fn color_mode_has_true_color_two_tone() { 52 assert!(!ColorMode::TwoTone.has_true_color()); 53 } 54 55 #[test] color_mode_has_true_color_three_bit()56 fn color_mode_has_true_color_three_bit() { 57 assert!(!ColorMode::ThreeBit.has_true_color()); 58 } 59 60 #[test] color_mode_has_true_color_four_bit()61 fn color_mode_has_true_color_four_bit() { 62 assert!(!ColorMode::FourBit.has_true_color()); 63 } 64 65 #[test] color_mode_has_true_color_eight_bit()66 fn color_mode_has_true_color_eight_bit() { 67 assert!(!ColorMode::EightBit.has_true_color()); 68 } 69 70 #[test] color_mode_has_true_color_true_color()71 fn color_mode_has_true_color_true_color() { 72 assert!(ColorMode::TrueColor.has_true_color()); 73 } 74 75 #[test] color_mode_equals_other_color_mode()76 fn color_mode_equals_other_color_mode() { 77 assert!(ColorMode::TrueColor == ColorMode::TrueColor); 78 } 79 } 80