From 650e29d4b5a805b83e30c530c740ade21d7d8542 Mon Sep 17 00:00:00 2001 From: Matthias Beyer Date: Sun, 29 May 2016 11:18:29 +0200 Subject: [PATCH] Add test: Two nonsimilar links --- libimagentrymarkdown/src/link.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/libimagentrymarkdown/src/link.rs b/libimagentrymarkdown/src/link.rs index 4c955fa5..19914308 100644 --- a/libimagentrymarkdown/src/link.rs +++ b/libimagentrymarkdown/src/link.rs @@ -95,5 +95,28 @@ Some more [example text](http://example.com). assert_eq!(exp, links.pop().unwrap()); } + #[test] + fn test_two_links() { + let testtext = r#" +Some [example text](http://example.com). +Some more [foo](http://example.com/foo). + "#; + + let exp1 = Link { + title: String::from("example text"), + link: String::from("http://example.com"), + }; + + let exp2 = Link { + title: String::from("foo"), + link: String::from("http://example.com/foo"), + }; + + let mut links = extract_links(&testtext[..]); + assert_eq!(2, links.len()); + assert_eq!(exp2, links.pop().unwrap()); + assert_eq!(exp1, links.pop().unwrap()); + } + }