rumdl_lib/rules/
strong_style.rs

1use std::fmt;
2
3/// The style for strong emphasis (MD050)
4#[derive(Debug, PartialEq, Eq, Clone, Copy, Default, Hash)]
5pub enum StrongStyle {
6    /// Consistent with the first strong style found
7    #[default]
8    Consistent,
9    /// Asterisk style (**)
10    Asterisk,
11    /// Underscore style (__)
12    Underscore,
13}
14
15impl fmt::Display for StrongStyle {
16    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
17        match self {
18            StrongStyle::Asterisk => write!(f, "asterisk"),
19            StrongStyle::Underscore => write!(f, "underscore"),
20            StrongStyle::Consistent => write!(f, "consistent"),
21        }
22    }
23}
24
25#[cfg(test)]
26mod tests {
27    use super::*;
28
29    #[test]
30    fn test_strong_style_default() {
31        let style: StrongStyle = Default::default();
32        assert_eq!(style, StrongStyle::Consistent);
33    }
34
35    #[test]
36    fn test_strong_style_display() {
37        assert_eq!(StrongStyle::Asterisk.to_string(), "asterisk");
38        assert_eq!(StrongStyle::Underscore.to_string(), "underscore");
39        assert_eq!(StrongStyle::Consistent.to_string(), "consistent");
40    }
41
42    #[test]
43    fn test_strong_style_clone() {
44        let style = StrongStyle::Asterisk;
45        let cloned = style;
46        assert_eq!(style, cloned);
47    }
48
49    #[test]
50    fn test_strong_style_debug() {
51        let style = StrongStyle::Underscore;
52        let debug_str = format!("{style:?}");
53        assert_eq!(debug_str, "Underscore");
54    }
55}