datarust_profile/
types.rs1use std::fmt;
4
5#[derive(Debug, Clone, Copy, PartialEq, Eq)]
11#[cfg_attr(feature = "serde", derive(serde::Serialize))]
12pub enum ColumnType {
13 Numeric,
15 Categorical,
17}
18
19impl fmt::Display for ColumnType {
20 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
21 match self {
22 ColumnType::Numeric => f.write_str("numeric"),
23 ColumnType::Categorical => f.write_str("categorical"),
24 }
25 }
26}
27
28#[derive(Debug, Clone, Copy, PartialEq, Eq)]
30#[cfg_attr(feature = "serde", derive(serde::Serialize))]
31pub enum Severity {
32 Info,
34 Warning,
36 Critical,
38}
39
40impl fmt::Display for Severity {
41 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
42 match self {
43 Severity::Info => f.write_str("info"),
44 Severity::Warning => f.write_str("warning"),
45 Severity::Critical => f.write_str("critical"),
46 }
47 }
48}
49
50#[cfg(test)]
51mod tests {
52 use super::*;
53
54 #[test]
55 fn display_numeric() {
56 assert_eq!(ColumnType::Numeric.to_string(), "numeric");
57 }
58
59 #[test]
60 fn display_categorical() {
61 assert_eq!(ColumnType::Categorical.to_string(), "categorical");
62 }
63
64 #[test]
65 fn severity_info() {
66 assert_eq!(Severity::Info.to_string(), "info");
67 }
68
69 #[test]
70 fn severity_warning() {
71 assert_eq!(Severity::Warning.to_string(), "warning");
72 }
73
74 #[test]
75 fn severity_critical() {
76 assert_eq!(Severity::Critical.to_string(), "critical");
77 }
78
79 #[test]
80 fn column_type_equality() {
81 assert_eq!(ColumnType::Numeric, ColumnType::Numeric);
82 assert_eq!(ColumnType::Categorical, ColumnType::Categorical);
83 assert_ne!(ColumnType::Numeric, ColumnType::Categorical);
84 }
85
86 #[test]
87 fn severity_equality() {
88 assert_eq!(Severity::Info, Severity::Info);
89 assert_ne!(Severity::Info, Severity::Critical);
90 }
91
92 #[test]
93 fn column_type_clone() {
94 let ct = ColumnType::Numeric;
95 let ct2 = ct;
96 assert_eq!(ct, ct2);
97 }
98
99 #[test]
100 fn severity_clone() {
101 let s = Severity::Warning;
102 let s2 = s;
103 assert_eq!(s, s2);
104 }
105
106 #[test]
107 fn column_type_debug() {
108 assert!(format!("{:?}", ColumnType::Numeric).contains("Numeric"));
109 }
110
111 #[test]
112 fn severity_debug() {
113 assert!(format!("{:?}", Severity::Critical).contains("Critical"));
114 }
115}