mirror of
https://github.com/MingweiSamuel/Riven.git
synced 2024-12-26 10:56:34 +00:00
Add special parsing for GameType
s missing _GAME
suffix, add tests
https://github.com/RiotGames/developer-relations/issues/878
This commit is contained in:
parent
2c284d860c
commit
172bc84620
2 changed files with 30 additions and 0 deletions
24
riven/src/consts/game_type/test.rs
Normal file
24
riven/src/consts/game_type/test.rs
Normal file
|
@ -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 a new issue