Skip to main content

battler_data/mons/
color.rs

1use serde_string_enum::{
2    DeserializeLabeledStringEnum,
3    SerializeLabeledStringEnum,
4};
5
6/// A defined enumeration of species colors.
7#[derive(Debug, Clone, PartialEq, SerializeLabeledStringEnum, DeserializeLabeledStringEnum)]
8pub enum Color {
9    #[string = "Red"]
10    Red,
11    #[string = "Blue"]
12    Blue,
13    #[string = "Yellow"]
14    Yellow,
15    #[string = "Green"]
16    Green,
17    #[string = "Black"]
18    Black,
19    #[string = "Brown"]
20    Brown,
21    #[string = "Purple"]
22    Purple,
23    #[string = "Gray"]
24    Gray,
25    #[string = "White"]
26    White,
27    #[string = "Pink"]
28    Pink,
29}
30
31#[cfg(test)]
32mod color_test {
33    use crate::{
34        mons::Color,
35        test_util::{
36            test_string_deserialization,
37            test_string_serialization,
38        },
39    };
40
41    #[test]
42    fn serializes_to_string() {
43        test_string_serialization(Color::Red, "Red");
44        test_string_serialization(Color::Blue, "Blue");
45        test_string_serialization(Color::Yellow, "Yellow");
46    }
47
48    #[test]
49    fn deserializes_lowercase() {
50        test_string_deserialization("green", Color::Green);
51        test_string_deserialization("black", Color::Black);
52        test_string_deserialization("brown", Color::Brown);
53    }
54}