diff --git a/riven/src/consts/queue_type.rs b/riven/src/consts/queue_type.rs index be44660..65b687b 100644 --- a/riven/src/consts/queue_type.rs +++ b/riven/src/consts/queue_type.rs @@ -46,6 +46,40 @@ mod test { #[test] fn check_from_string() { - assert_eq!(Some(QueueType::RANKED_SOLO_5x5), "RANKED_SOLO_5x5".parse().ok()); + assert_eq!(QueueType::RANKED_SOLO_5x5, "RANKED_SOLO_5x5".into()); + assert_eq!(QueueType::UNKNOWN("RANKED_MYSTERY_UNKNOWN".to_owned()), "RANKED_MYSTERY_UNKNOWN".into()); + assert_eq!("RANKED_MYSTERY_UNKNOWN", QueueType::UNKNOWN("RANKED_MYSTERY_UNKNOWN".to_owned()).as_ref()); + } + + #[test] + fn check_serialize() { + assert_eq!(Some("\"RANKED_TFT_DOUBLE_UP\""), + serde_json::to_string(&QueueType::RANKED_TFT_DOUBLE_UP) + .ok().as_deref()); + assert_eq!(Some("\"RANKED_MYSTERY_UNKNOWN\""), + serde_json::to_string(&QueueType::UNKNOWN("RANKED_MYSTERY_UNKNOWN".to_owned())) + .ok().as_deref()); + } + + #[test] + fn check_deserialize() { + use std::collections::BTreeMap; + + let dict: BTreeMap = serde_json::from_str( + r#"{ + "100": "RANKED_SOLO_5x5", + "200": "RANKED_TFT_TURBO", + "210": "RANKED_TFT_DOUBLE_UP", + "211": "RANKED_TFT_PAIRS", + "900": "RANKED_MYSTERY_UNKNOWN" + }"# + ).unwrap(); + + assert_eq!(Some(&QueueType::RANKED_SOLO_5x5), dict.get(&100)); + assert_eq!(Some(&QueueType::RANKED_TFT_TURBO), dict.get(&200)); + assert_eq!(Some(&QueueType::RANKED_TFT_DOUBLE_UP), dict.get(&210)); + assert_eq!(Some(&QueueType::RANKED_TFT_PAIRS), dict.get(&211)); + assert_eq!(Some(&QueueType::UNKNOWN("RANKED_MYSTERY_UNKNOWN".to_owned())), dict.get(&900)); + } }