Add test: Two nonsimilar links
This commit is contained in:
parent
1bb961ecb3
commit
650e29d4b5
1 changed files with 23 additions and 0 deletions
|
@ -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());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue