Add tests for the content syntax parser

This commit is contained in:
Juno Takano 2025-12-26 04:19:21 -03:00
commit e50bbd468d
12 changed files with 383 additions and 120 deletions

View file

@ -1,4 +1,3 @@
use std::fmt::Display;
use crate::syntax::content::{Parseable, parser::lexeme::Lexeme};
#[derive(Debug)]
@ -37,16 +36,22 @@ impl Parseable for Paragraph {
}
}
impl Display for Paragraph {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
if let Some(open) = self.open {
if open {
write!(f, "Open Paragraph")
} else {
write!(f, "Closed Paragraph")
}
} else {
write!(f, "Unitialized Paragraph (Unknown open state)")
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn lex() {
let p = Paragraph::lex(&Lexeme::new("", ""));
assert!(p.open.is_none());
}
#[test]
#[should_panic(
expected = "Attempt to render a paragraph tag while open state is unknown"
)]
fn render_state_unknown() {
let p = Paragraph::lex(&Lexeme::new("", ""));
drop(p.render());
}
}