use std::fmt::{self, Debug};
#[derive(Clone, Copy, PartialEq, Eq)]
pub enum CompressionGoal {
UseFastCompression,
UseBestCompression,
IsIncompressible,
}
impl Debug for CompressionGoal {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match self {
Self::UseFastCompression => write!(f, "Use Fast Compression"),
Self::UseBestCompression => write!(f, "Use Best Compression"),
Self::IsIncompressible => write!(f, "Is Incompressible"),
}
}
}
impl Default for CompressionGoal {
fn default() -> Self {
Self::UseBestCompression
}
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn test_debug() {
use CompressionGoal::*;
assert_eq!(format!("{UseFastCompression:?}"), "Use Fast Compression");
assert_eq!(format!("{UseBestCompression:?}"), "Use Best Compression");
assert_eq!(format!("{IsIncompressible:?}"), "Is Incompressible");
}
#[test]
fn test_clone_copy_and_eq() {
let a = CompressionGoal::UseBestCompression;
let b = a;
assert_eq!(a, b);
}
#[test]
fn test_default() {
assert_eq!(CompressionGoal::default(), CompressionGoal::UseBestCompression);
}
}