cp
This commit is contained in:
parent
f3e6db018e
commit
551a05ad63
2 changed files with 38 additions and 10 deletions
|
@ -230,13 +230,25 @@ mod test {
|
|||
use super::Container::*;
|
||||
use super::Event::*;
|
||||
|
||||
macro_rules! test_parse {
|
||||
($($st:ident,)? $src:expr $(,$($token:expr),* $(,)?)?) => {
|
||||
#[allow(unused)]
|
||||
let mut p = super::Parser::new();
|
||||
p.parse($src);
|
||||
let actual = p.collect::<Vec<_>>();
|
||||
let expected = &[$($($token),*,)?];
|
||||
assert_eq!(actual, expected, "\n\n{}\n\n", $src);
|
||||
};
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn str() {
|
||||
test_parse!("abc", Atom(Str));
|
||||
test_parse!("abc def", Atom(Str));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn container_brace() {
|
||||
let mut p = super::Parser::new();
|
||||
p.parse("{_hej_}");
|
||||
assert_eq!(
|
||||
p.collect::<Vec<_>>().as_slice(),
|
||||
&[Enter(Emphasis), Atom(Str), Exit(Emphasis)],
|
||||
);
|
||||
test_parse!("{_abc_}", Enter(Emphasis), Atom(Str), Exit(Emphasis));
|
||||
}
|
||||
}
|
||||
|
|
24
src/lib.rs
24
src/lib.rs
|
@ -97,11 +97,27 @@ mod test {
|
|||
use crate::inline::Atom::*;
|
||||
use crate::inline::Event::*;
|
||||
|
||||
macro_rules! test_parse {
|
||||
($($st:ident,)? $src:expr $(,$($token:expr),* $(,)?)?) => {
|
||||
#[allow(unused)]
|
||||
let actual = super::Parser::new($src).iter().collect::<Vec<_>>();
|
||||
let expected = &[$($($token),*,)?];
|
||||
assert_eq!(actual, expected, "\n\n{}\n\n", $src);
|
||||
};
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn basic() {
|
||||
assert_eq!(
|
||||
super::Parser::new("abc").iter().collect::<Vec<_>>(),
|
||||
&[Start(Leaf(Paragraph)), Inline(Atom(Str)), End]
|
||||
fn para() {
|
||||
test_parse!("abc", Start(Leaf(Paragraph)), Inline(Atom(Str)), End);
|
||||
test_parse!("abc def", Start(Leaf(Paragraph)), Inline(Atom(Str)), End);
|
||||
test_parse!(
|
||||
"this is a paragraph\n\nfollowed by another one",
|
||||
Start(Leaf(Paragraph)),
|
||||
Inline(Atom(Str)),
|
||||
End,
|
||||
Start(Leaf(Paragraph)),
|
||||
Inline(Atom(Str)),
|
||||
End,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue