Skip to content

Commit

Permalink
fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
zyk-mjzs committed Apr 4, 2024
1 parent 8e7f06b commit 8a8b976
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
7 changes: 4 additions & 3 deletions src/lexer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,9 @@ impl Lexer {

#[cfg(test)]
pub(crate) mod tests {
use crate::header::Color;
use crate::lexer::Lexer;
use crate::tokens::ControlWord::{Ansi, Bold, FontNumber, FontSize, FontTable, Italic, Par, Pard, Rtf, Underline, Unknown};
use crate::tokens::ControlWord::{Ansi, Bold, FontNumber, ColorNumber, FontSize, FontTable, Italic, Par, Pard, Rtf, Underline, Unknown};
use crate::tokens::Property::*;
use crate::tokens::Token::*;

Expand Down Expand Up @@ -202,7 +203,7 @@ if (a == b) \{\
vec![
ControlSymbol((FontNumber, Value(0))),
ControlSymbol((FontSize, Value(24))),
ControlSymbol((Unknown("\\cf"), Value(0))),
ControlSymbol((ColorNumber, Value(0))),
PlainText("test de code "),
CRLF,
PlainText("if (a == b) "),
Expand Down Expand Up @@ -266,7 +267,7 @@ if (a == b) \{\
OpeningBracket,
ControlSymbol((Unknown("\\partightenfactor"), Value(0))),
ControlSymbol((FontSize, Value(24))),
ControlSymbol((Unknown("\\cf"), Value(0))),
ControlSymbol((ColorNumber, Value(0))),
PlainText("Font size 12,"),
ControlSymbol((FontNumber, Value(0))),
ControlSymbol((Bold, None)),
Expand Down
8 changes: 7 additions & 1 deletion src/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,9 @@ pub mod tests {
}
)
]),
color_table: ColorTable::from([
(1, Color { red: 255, green: 255, blue: 255 }),
]),
..RtfHeader::default()
}
);
Expand Down Expand Up @@ -614,7 +617,10 @@ pub mod tests {
let rtf = r"{\rtf1{\fonttbl {\f0 Times;}}\f0\b\fs36\u\cf2\plain Plain text}";
let tokens = Lexer::scan(rtf).unwrap();
let document = Parser::new(tokens).parse().unwrap();
assert_eq!(document.body[0].painter, Painter::default());
let mut painter = Painter::default();
painter.bold = true;
painter.font_size = 36;
assert_eq!(document.body[0].painter, painter);
}

#[test]
Expand Down

0 comments on commit 8a8b976

Please sign in to comment.