mirror of https://github.com/MingweiSamuel/Riven
Add special parsing for `GameType`s missing `_GAME` suffix, add tests
https://github.com/RiotGames/developer-relations/issues/878pull/62/head
parent
2c284d860c
commit
172bc84620
|
@ -0,0 +1,24 @@
|
|||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn check_as_ref() {
|
||||
assert_eq!("MATCHED_GAME", GameType::MATCHED_GAME.as_ref());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_to_string() {
|
||||
assert_eq!("MATCHED_GAME", GameType::MATCHED_GAME.to_string());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_from_string() {
|
||||
assert_eq!(Ok(GameType::MATCHED_GAME), "MATCHED_GAME".parse());
|
||||
assert_eq!(Ok(GameType::MATCHED_GAME), "MATCHED".parse());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn check_serialize() {
|
||||
assert_eq!(Some("\"MATCHED_GAME\""),
|
||||
serde_json::to_string(&GameType::MATCHED_GAME)
|
||||
.ok().as_deref());
|
||||
}
|
|
@ -16,12 +16,18 @@ pub enum GameType {
|
|||
{{
|
||||
for (const e of gameTypes) {
|
||||
const desc = e['x-desc'] ? e['x-desc'].split('\n') : [];
|
||||
const nameNoGame = e['x-name'].replace(/_GAME$/, "");
|
||||
}}
|
||||
{{~ desc :line }}
|
||||
/// {{= line }}
|
||||
{{~}}
|
||||
#[strum(to_string = "{{= e['x-name'] }}", serialize = "{{= nameNoGame }}")]
|
||||
#[serde(alias = "{{= nameNoGame }}")]
|
||||
{{= e['x-name'] }},
|
||||
{{
|
||||
}
|
||||
}}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod test;
|
||||
|
|
Loading…
Reference in New Issue