use secfinding::*;
use secfinding::severity::*;
use super::*;
#[test]
fn ordering_and_display() {
assert!(Severity::Critical > Severity::High);
assert!(Severity::High > Severity::Medium);
assert!(Severity::Medium > Severity::Low);
assert!(Severity::Low > Severity::Info);
assert_eq!(Severity::Critical.to_string(), "critical");
assert_eq!(Severity::Info.to_string(), "info");
}
#[test]
fn from_str_loose_variants() {
assert_eq!(
Severity::from_str_loose("CRITICAL"),
Some(Severity::Critical)
);
assert_eq!(Severity::from_str_loose("crit"), Some(Severity::Critical));
assert_eq!(Severity::from_str_loose("med"), Some(Severity::Medium));
assert_eq!(
Severity::from_str_loose("informational"),
Some(Severity::Info)
);
assert_eq!(Severity::from_str_loose("bogus"), None);
}
#[test]
fn serde_roundtrip() {
let json = serde_json::to_string(&Severity::High).unwrap();
assert_eq!(json, "\"high\"");
let back: Severity = serde_json::from_str(&json).unwrap();
assert_eq!(back, Severity::High);
}