fluxion_test_utils/
test_data.rs1use crate::{animal::Animal, person::Person, plant::Plant};
6use core::fmt::{self, Display};
7
8#[derive(Debug, Clone)]
9pub enum DataVariant {
10 Animal,
11 Person,
12 Plant,
13}
14
15#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord)]
16pub enum TestData {
17 Person(Person),
18 Animal(Animal),
19 Plant(Plant),
20}
21
22#[must_use]
23pub fn person_alice() -> TestData {
24 TestData::Person(Person::new("Alice".to_string(), 25))
25}
26
27#[must_use]
28pub fn person_bob() -> TestData {
29 TestData::Person(Person::new("Bob".to_string(), 30))
30}
31
32#[must_use]
33pub fn person_charlie() -> TestData {
34 TestData::Person(Person::new("Charlie".to_string(), 35))
35}
36
37#[must_use]
38pub fn person_diane() -> TestData {
39 TestData::Person(Person::new("Diane".to_string(), 40))
40}
41
42#[must_use]
43pub fn animal_dog() -> TestData {
44 TestData::Animal(Animal::new("Dog".to_string(), 4))
45}
46
47#[must_use]
48pub fn animal_spider() -> TestData {
49 TestData::Animal(Animal::new("Spider".to_string(), 8))
50}
51
52#[must_use]
53pub fn animal_bird() -> TestData {
54 TestData::Animal(Animal::new("Bird".to_string(), 2))
55}
56
57#[must_use]
58pub fn plant_rose() -> TestData {
59 TestData::Plant(Plant::new("Rose".to_string(), 15))
60}
61
62#[must_use]
63pub fn plant_sunflower() -> TestData {
64 TestData::Plant(Plant::new("Sunflower".to_string(), 180))
65}
66
67#[must_use]
68pub fn person_dave() -> TestData {
69 TestData::Person(Person::new("Dave".to_string(), 28))
70}
71
72#[must_use]
73pub fn animal_ant() -> TestData {
74 TestData::Animal(Animal::new("Ant".to_string(), 6))
75}
76
77#[must_use]
78pub fn animal_cat() -> TestData {
79 TestData::Animal(Animal::new("Cat".to_string(), 4))
80}
81
82#[must_use]
83pub const fn animal(name: String, legs: u32) -> TestData {
84 TestData::Animal(Animal::new(name, legs))
85}
86
87#[must_use]
88pub const fn person(name: String, age: u32) -> TestData {
89 TestData::Person(Person::new(name, age))
90}
91
92#[must_use]
93pub const fn plant(name: String, height: u32) -> TestData {
94 TestData::Plant(Plant::new(name, height))
95}
96
97#[must_use]
98pub fn plant_fern() -> TestData {
99 TestData::Plant(Plant::new("Fern".to_string(), 150))
100}
101
102#[must_use]
103pub fn plant_oak() -> TestData {
104 TestData::Plant(Plant::new("Oak".to_string(), 1000))
105}
106
107impl Display for TestData {
108 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
109 match self {
110 Self::Person(p) => write!(f, "{p}"),
111 Self::Animal(a) => write!(f, "{a}"),
112 Self::Plant(p) => write!(f, "{p}"),
113 }
114 }
115}