-
-
Notifications
You must be signed in to change notification settings - Fork 144
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
627f540
commit 2baa435
Showing
3 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,6 @@ mod layer; | |
mod player_list; | ||
mod potions; | ||
mod scoreboard; | ||
mod serialization; | ||
mod weather; | ||
mod world_border; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
use crate::ItemKind; | ||
|
||
#[test] | ||
fn test_serialize_item_kind() { | ||
let item = ItemKind::WhiteWool; | ||
let serialized = serde_json::to_string(&item).unwrap(); | ||
assert_eq!(serialized, "\"white_wool\""); | ||
|
||
let item = ItemKind::GoldenSword; | ||
let serialized = serde_json::to_string(&item).unwrap(); | ||
assert_eq!(serialized, "\"golden_sword\""); | ||
|
||
let item = ItemKind::NetheriteAxe; | ||
let serialized = serde_json::to_string(&item).unwrap(); | ||
assert_eq!(serialized, "\"netherite_axe\""); | ||
|
||
let item = ItemKind::WaxedWeatheredCutCopperStairs; | ||
let serialized = serde_json::to_string(&item).unwrap(); | ||
assert_eq!(serialized, "\"waxed_weathered_cut_copper_stairs\""); | ||
} | ||
|
||
#[test] | ||
fn test_deserialize_item_kind() { | ||
let id = "\"diamond_shovel\""; | ||
let deserialized: ItemKind = serde_json::from_str(id).unwrap(); | ||
assert_eq!(deserialized, ItemKind::DiamondShovel); | ||
|
||
let id = "\"minecart\""; | ||
let deserialized: ItemKind = serde_json::from_str(id).unwrap(); | ||
assert_eq!(deserialized, ItemKind::Minecart); | ||
|
||
let id = "\"vindicator_spawn_egg\""; | ||
let deserialized: ItemKind = serde_json::from_str(id).unwrap(); | ||
assert_eq!(deserialized, ItemKind::VindicatorSpawnEgg); | ||
} |