mirror of
https://github.com/YGGverse/ggemtext.git
synced 2026-03-31 09:05:32 +00:00
implement test
This commit is contained in:
parent
9392b39327
commit
f550041b55
1 changed files with 30 additions and 0 deletions
|
|
@ -43,3 +43,33 @@ impl Header {
|
|||
self.value.to_source(&self.level)
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test() {
|
||||
fn test(source: &str, value: &str) {
|
||||
fn filter(s: &str) -> String {
|
||||
s.chars().filter(|&c| c != ' ').collect()
|
||||
}
|
||||
let header = Header::parse(source).unwrap();
|
||||
assert_eq!(header.value, value);
|
||||
assert_eq!(filter(&header.to_source()), filter(source));
|
||||
}
|
||||
// h1
|
||||
test("# H1", "H1");
|
||||
test("# H1 ", "H1");
|
||||
test("#H1", "H1");
|
||||
test("#H1 ", "H1");
|
||||
// h2
|
||||
test("## H2", "H2");
|
||||
test("## H2 ", "H2");
|
||||
test("##H2", "H2");
|
||||
test("##H2 ", "H2");
|
||||
// h3
|
||||
test("### H3", "H3");
|
||||
test("### H3 ", "H3");
|
||||
test("###H3", "H3");
|
||||
test("###H3 ", "H3");
|
||||
// other
|
||||
assert!(Header::parse("H").is_none());
|
||||
assert!(Header::parse("#### H").is_none())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue