Skip to content

Commit 6cb2e22

Browse files
committed
Add tests for #21
1 parent 6e490de commit 6cb2e22

2 files changed

Lines changed: 15 additions & 7 deletions

File tree

Cargo.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ debug = true
2525
default = ["jsbindings"]
2626
jsbindings = ["dep:wasm-bindgen", "dep:tsify"]
2727

28+
[lints.clippy]
29+
needless_return = "allow"
30+
31+
2832
[dependencies]
2933
serde = { version = "1.0", features = ["derive"] }
3034

src/lexer.rs

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -313,23 +313,27 @@ if (a == b) \{\
313313
}
314314

315315
#[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
316+
fn should_lex_unicode() {
317+
let rtf = r#"{\u21834 \u21834 }"#;
318318
let tokens = Lexer::scan(rtf).unwrap();
319319
assert_eq!(
320320
tokens,
321-
[OpeningBracket, ControlSymbol((ColorNumber, Value(1))), PlainText(" "), ClosingBracket]
321+
vec![OpeningBracket, ControlSymbol((Unicode, Value(21834))), PlainText(" "), ControlSymbol((Unicode, Value(21834))), ClosingBracket]
322322
);
323323
}
324324

325+
#[test]
326+
fn should_handle_whitespace_group() {
327+
let rtf = r"{\cf1 }"; // two whitespaces : one should be ignored, the other should be treated as plain text
328+
let tokens = Lexer::scan(rtf).unwrap();
329+
assert_eq!(tokens, [OpeningBracket, ControlSymbol((ColorNumber, Value(1))), PlainText(" "), ClosingBracket]);
330+
}
331+
325332
#[test]
326333
fn should_handle_google_docs_files() {
327334
use crate::include_test_file;
328335
let rtf = include_test_file!("google-docs.rtf");
329336
let tokens = Lexer::scan(rtf).unwrap();
330-
assert_eq!(
331-
tokens,
332-
[]
333-
);
337+
assert_eq!(tokens, []);
334338
}
335339
}

0 commit comments

Comments
 (0)