Skip to content

Commit bdc0c37

Browse files
committed
Add tests for #17
1 parent 3fec3d1 commit bdc0c37

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

resources/tests/google-docs.rtf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{\rtf1\ansi\ansicpg1252\uc0\stshfdbch0\stshfloch0\stshfhich0\stshfbi0\deff0\adeff0{\*\generator Aspose.Words for Java 23.4.0;}{\cf1 Lorem}{\cf1 }{\cf1 ipsum}{\cf1 }{\cf1 odor}{\cf1 }{\cf1 amet}}

src/lexer.rs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,4 +311,25 @@ if (a == b) \{\
311311
[OpeningBracket, PlainText("je suis une b"), ControlSymbol((Unicode, Value(234))), PlainText("te"), ClosingBracket,]
312312
);
313313
}
314+
315+
#[test]
316+
fn should_handle_whitspace_group() {
317+
let rtf = r"{\cf1 }"; // two whitespaces : one should be ignored, the other should be treated as plain text
318+
let tokens = Lexer::scan(rtf).unwrap();
319+
assert_eq!(
320+
tokens,
321+
[OpeningBracket, ControlSymbol((ColorNumber, Value(1))), PlainText(" "), ClosingBracket]
322+
);
323+
}
324+
325+
#[test]
326+
fn should_handle_google_docs_files() {
327+
use crate::include_test_file;
328+
let rtf = include_test_file!("google-docs.rtf");
329+
let tokens = Lexer::scan(rtf).unwrap();
330+
assert_eq!(
331+
tokens,
332+
[]
333+
);
334+
}
314335
}

0 commit comments

Comments
 (0)