From b020566ae369bef1116b7ea91d62884116be73d5 Mon Sep 17 00:00:00 2001 From: Titus Wormer Date: Wed, 15 Jun 2022 13:56:34 +0200 Subject: Add tests for urls --- tests/misc_url.rs | 152 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 152 insertions(+) create mode 100644 tests/misc_url.rs (limited to 'tests') diff --git a/tests/misc_url.rs b/tests/misc_url.rs new file mode 100644 index 0000000..a6f8ead --- /dev/null +++ b/tests/misc_url.rs @@ -0,0 +1,152 @@ +extern crate micromark; +use micromark::micromark; + +#[test] +fn url() { + assert_eq!( + micromark(""), + "

https://%

", + "should support incorrect percentage encoded values (0)" + ); + + // To do: link. + // assert_eq!( + // micromark("[](<%>)"), + // "

", + // "should support incorrect percentage encoded values (1)" + // ); + + // To do: link. + // assert_eq!( + // micromark("[](<%%20>)"), + // "

", + // "should support incorrect percentage encoded values (2)" + // ); + + // To do: link. + // assert_eq!( + // micromark("[](<%a%20>)"), + // "

", + // "should support incorrect percentage encoded values (3)" + // ); + + // Surrogate handling not needed in Rust. + // assert_eq!( + // micromark("[]()"), + // "

", + // "should support a lone high surrogate (lowest)" + // ); + + // Surrogate handling not needed in Rust. + // assert_eq!( + // micromark("[]()"), + // "

", + // "should support a lone high surrogate (highest)" + // ); + + // Surrogate handling not needed in Rust. + // assert_eq!( + // micromark("[](<\u{D800}bar>)"), + // "

", + // "should support a lone high surrogate at the start (lowest)" + // ); + + // Surrogate handling not needed in Rust. + // assert_eq!( + // micromark("[](<\u{DBFF}bar>)"), + // "

", + // "should support a lone high surrogate at the start (highest)" + // ); + + // Surrogate handling not needed in Rust. + // assert_eq!( + // micromark("[]()"), + // "

", + // "should support a lone high surrogate at the end (lowest)" + // ); + + // Surrogate handling not needed in Rust. + // assert_eq!( + // micromark("[]()"), + // "

", + // "should support a lone high surrogate at the end (highest)" + // ); + + // Surrogate handling not needed in Rust. + // assert_eq!( + // micromark("[]()"), + // "

", + // "should support a lone low surrogate (lowest)" + // ); + + // Surrogate handling not needed in Rust. + // assert_eq!( + // micromark("[]()"), + // "

", + // "should support a lone low surrogate (highest)" + // ); + + // Surrogate handling not needed in Rust. + // assert_eq!( + // micromark("[](<\u{DC00}bar>)"), + // "

", + // "should support a lone low surrogate at the start (lowest)" + // ); + + // Surrogate handling not needed in Rust. + // assert_eq!( + // micromark("[](<\u{DFFF}bar>)"), + // "

", + // "should support a lone low surrogate at the start (highest)" + // ); + + // Surrogate handling not needed in Rust. + // assert_eq!( + // micromark("[]()"), + // "

", + // "should support a lone low surrogate at the end (lowest)" + // ); + + // Surrogate handling not needed in Rust. + // assert_eq!( + // micromark("[]()"), + // "

", + // "should support a lone low surrogate at the end (highest)" + // ); + + // To do: link. + // assert_eq!( + // micromark("[](<🤔>)"), + // "

", + // "should support an emoji" + // ); + + // To do: link. + // let mut ascii: Vec = vec![]; + // let mut code = 0; + + // while code < 128 { + // // LF and CR can’t be in resources. + // if code == 10 || code == 13 { + // code += 1; + // continue; + // } + + // // `<`, `>`, `\` need to be escaped. + // if code == 60 || code == 62 || code == 92 { + // ascii.push('\\'); + // } + + // ascii.push(char::from_u32(code).unwrap()); + + // code += 1; + // } + + // let ascii_in = ascii.into_iter().collect::(); + // let ascii_out = "%EF%BF%BD%01%02%03%04%05%06%07%08%09%0B%0C%0E%0F%10%11%12%13%14%15%16%17%18%19%1A%1B%1C%1D%1E%1F%20!%22#$%25&\"()*+,-./0123456789:;%3C=%3E?@ABCDEFGHIJKLMNOPQRSTUVWXYZ%5B%5C%5D%5E_%60abcdefghijklmnopqrstuvwxyz%7B%7C%7D~%7F"; + // assert_eq!( + // micromark(&format!("[](<{}>)", ascii_in)), + // format!("

", ascii_out), + // "should support ascii characters" + // ); +} -- cgit