Add main.rs
This commit is contained in:
commit
acaeea2165
25
main.rs
Normal file
25
main.rs
Normal file
@ -0,0 +1,25 @@
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
for (ty, str) in [
|
||||
(TileType::Rock, r#""ROCK""#),
|
||||
(TileType::Grass, r#""GRASS""#),
|
||||
(TileType::Force, r#""FORCE""#),
|
||||
(TileType::MedicCenter, r#""MEDIC_CENTER""#),
|
||||
(TileType::Lava, r#""LAVA""#),
|
||||
] {
|
||||
assert_eq!(serde_json::to_string(&ty).unwrap(), str);
|
||||
assert_eq!(serde_json::from_str::<TileType>(str).unwrap(), ty);
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, PartialEq, Eq)]
|
||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||
enum TileType {
|
||||
Rock,
|
||||
Grass,
|
||||
Force,
|
||||
MedicCenter,
|
||||
Lava,
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user