From c17e030d0513612ce18c8f0a1bd76bdedc180bae Mon Sep 17 00:00:00 2001 From: projectmoon Date: Fri, 22 Mar 2024 12:27:59 +0100 Subject: [PATCH] Emoji-related tests --- src/gemfeed.rs | 54 +++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 53 insertions(+), 1 deletion(-) diff --git a/src/gemfeed.rs b/src/gemfeed.rs index fc34cfe..0e3e86a 100644 --- a/src/gemfeed.rs +++ b/src/gemfeed.rs @@ -456,7 +456,7 @@ mod gemfeed_tests { } #[test] - fn parse_gemfeed_valid_if_has_title_with_emoji() -> Result<()> { + fn parse_gemfeed_valid_if_has_title_with_emoji_at_start() -> Result<()> { let gemfeed: String = r#" # 🖊️ My Gemfeed @@ -481,6 +481,58 @@ mod gemfeed_tests { Ok(()) } + #[test] + fn parse_gemfeed_valid_if_has_title_with_emoji_in_middle() -> Result<()> { + let gemfeed: String = r#" + # My 🖊️ Gemfeed + + This is a gemfeed with a title. + => atom.xml Atom Feed + + ## Posts + + => post2.gmi 2023-03-05 Post 2 + => post1.gmi 2023-02-01 Post 1 + "# + .lines() + .map(|line| line.trim_start()) + .map(|line| format!("{}\n", line)) + .collect(); + + let base_url = Url::parse("gemini://example.com/posts")?; + let ast = GemtextAst::from_string(gemfeed); + let result = Gemfeed::load_from_ast(&base_url, &ast); + + assert!(matches!(result, Ok(_))); + Ok(()) + } + + #[test] + fn parse_gemfeed_valid_if_has_title_with_emoji_at_end() -> Result<()> { + let gemfeed: String = r#" + # My Gemfeed 🖊️ + + This is a gemfeed with a title. + => atom.xml Atom Feed + + ## Posts + + => post2.gmi 2023-03-05 Post 2 + => post1.gmi 2023-02-01 Post 1 + "# + .lines() + .map(|line| line.trim_start()) + .map(|line| format!("{}\n", line)) + .collect(); + + let base_url = Url::parse("gemini://example.com/posts")?; + let ast = GemtextAst::from_string(gemfeed); + let result = Gemfeed::load_from_ast(&base_url, &ast); + + assert!(matches!(result, Ok(_))); + Ok(()) + } + #[test] fn parse_gemfeed_ignores_non_post_links() -> Result<()> { let gemfeed: String = r#"