Skip to content

Commit

Permalink
doc(formatter.rs): Write document test for a module
Browse files Browse the repository at this point in the history
  • Loading branch information
Syaw0 committed Nov 6, 2024
1 parent df4a75c commit 67b873d
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/styles/formatter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@ use super::{ paint_type::PaintType, Styles, Stylify };

// =======================================================================

/// A struct representing a Formatter with code value.
#[derive(Debug, Clone)]
pub struct Formatter {
code: u8,
}

impl Stylify for Formatter {
/// Returns a string representation of the formatter style.
///
/// The `PaintType` is not any involved in this method!
fn make_styles(&self, _paint_type: Option<&PaintType>) -> String {
format!("{}", self.code)
}
}

/// A macro for generating formatter constants.
macro_rules! formatter_code {
($name:ident, $code:expr) => {
pub const $name: Styles = Styles::StyleFormatter(Formatter { code: $code });
Expand Down Expand Up @@ -82,6 +87,7 @@ mod tests {
}
}

/// A macro for generating formatter tests.
macro_rules! formatter_test {
($test_name:ident, $formatter_name:ident, $code:expr) => {
#[test]
Expand Down

0 comments on commit 67b873d

Please sign in to comment.