diff options
| author | Fuwn <[email protected]> | 2025-09-11 05:57:01 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2025-09-11 05:57:01 +0000 |
| commit | 28581ff44e9b6d98879807ecc78c8cd709af371a (patch) | |
| tree | 2ba228efc41ef90623106bb9c1ed75dc3b8f251c /tests | |
| parent | fix(ast): Gracefully handle malformed link lines (diff) | |
| download | germ-28581ff44e9b6d98879807ecc78c8cd709af371a.tar.xz germ-28581ff44e9b6d98879807ecc78c8cd709af371a.zip | |
fix(ast): Improve UTF-8 handling
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/ast.rs | 41 |
1 files changed, 40 insertions, 1 deletions
diff --git a/tests/ast.rs b/tests/ast.rs index 7a71f5c..5249931 100644 --- a/tests/ast.rs +++ b/tests/ast.rs @@ -95,7 +95,46 @@ mod test { assert_eq!(to, ""); assert_eq!(text, &None); } else { - panic!("Expected Link node"); + panic!("Expected link node"); + } + } + + #[test] + fn build_heading_with_unicode_and_edge_cases() { + // Unicode characters + let ast = Ast::from_string("# Hello, 世界!"); + + assert_eq!(ast.inner().len(), 1); + + if let Node::Heading { level, text } = ast.inner().first().unwrap() { + assert_eq!(level, &1); + assert_eq!(text, "Hello, 世界!"); + } else { + panic!("Expected heading node"); + } + + // Only hashes + let ast = Ast::from_string("###"); + + assert_eq!(ast.inner().len(), 1); + + if let Node::Heading { level, text } = ast.inner().first().unwrap() { + assert_eq!(level, &3); + assert_eq!(text, ""); + } else { + panic!("Expected heading node"); + } + + // Many hashes + let ast = Ast::from_string("########## Very Deep Heading"); + + assert_eq!(ast.inner().len(), 1); + + if let Node::Heading { level, text } = ast.inner().first().unwrap() { + assert_eq!(level, &10); + assert_eq!(text, "Very Deep Heading"); + } else { + panic!("Expected heading node"); } } } |