From 1ffcd71d0a43e74df3dc431e97b9bef21d9c0c0f Mon Sep 17 00:00:00 2001 From: Simon Laux Date: Tue, 31 Oct 2023 23:18:55 +0100 Subject: [PATCH] more tests (this time about ending chars) --- tests/text_to_ast/text_only.rs | 50 ++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/tests/text_to_ast/text_only.rs b/tests/text_to_ast/text_only.rs index e319ad1..b2ee0ea 100644 --- a/tests/text_to_ast/text_only.rs +++ b/tests/text_to_ast/text_only.rs @@ -354,6 +354,56 @@ fn link_special_chars_in_location_part() { } } +#[test] +fn link_stop_at_ending_char() { + let endings = vec![ + "\"", + "'", + "''", + "\n\n", + ]; + + for end_case in &endings { + let test_case = format!("https://delta.chat/delta{end_case}"); + println!("testing {}", test_case); + let mut parsed_ending = parse_only_text(end_case); + let mut result = vec![Link { + destination: link_destination_for_testing("https://delta.chat/delta") + }]; + result.append(&mut parsed_ending); + assert_eq!( + parse_only_text(&test_case), + result + ); + } +} + +#[test] +fn link_stop_at_ending_char_with_space() { + let endings = vec![ + "\" ", + "' ", + "'' ", + "\n\n ", + " ", + ": " + ]; + + for end_case in &endings { + let test_case = format!("https://delta.chat/delta{end_case}"); + println!("testing {}", test_case); + let mut parsed_ending = parse_only_text(end_case); + let mut result = vec![Link { + destination: link_destination_for_testing("https://delta.chat/delta") + }]; + result.append(&mut parsed_ending); + assert_eq!( + parse_only_text(&test_case), + result + ); + } +} + #[test] fn test_link_example() {