diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 55571f3..b332999 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -72,7 +72,6 @@ jobs: matrix: target: - parse - - parse_balance - html runs-on: ubuntu-latest steps: diff --git a/tests/afl/Cargo.toml b/tests/afl/Cargo.toml index 66b25e1..70e156b 100644 --- a/tests/afl/Cargo.toml +++ b/tests/afl/Cargo.toml @@ -17,10 +17,6 @@ path = "src/main.rs" name = "parse" path = "src/parse.rs" -[[bin]] -name = "parse_balance" -path = "src/parse_balance.rs" - [[bin]] name = "html" path = "src/html.rs" diff --git a/tests/afl/src/lib.rs b/tests/afl/src/lib.rs index 0591238..c6a8bb8 100644 --- a/tests/afl/src/lib.rs +++ b/tests/afl/src/lib.rs @@ -5,27 +5,26 @@ use html5ever::tendril::TendrilSink; use html5ever::tokenizer; use html5ever::tree_builder; +/// Perform sanity checks on events. pub fn parse(data: &[u8]) { - if let Ok(s) = std::str::from_utf8(data) { - jotdown::Parser::new(s).last(); - } -} - -/// Ensure containers are always balanced, i.e. opened and closed in correct order. -pub fn parse_balance(data: &[u8]) { if let Ok(s) = std::str::from_utf8(data) { let mut open = Vec::new(); for event in jotdown::Parser::new(s) { match event { jotdown::Event::Start(c, ..) => open.push(c.clone()), - jotdown::Event::End(c) => assert_eq!(open.pop().unwrap(), c), + jotdown::Event::End(c) => { + // closes correct event + assert_eq!(open.pop().unwrap(), c); + } _ => {} } } + // no missing close assert_eq!(open, &[]); } } +/// Validate rendered html output. pub fn html(data: &[u8]) { if data.iter().any(|i| *i == 0) { return; diff --git a/tests/afl/src/main.rs b/tests/afl/src/main.rs index ad09a2d..b0a66c8 100644 --- a/tests/afl/src/main.rs +++ b/tests/afl/src/main.rs @@ -8,7 +8,6 @@ fn main() { let f = match target.as_str() { "parse" => jotdown_afl::parse, - "parse_balance" => jotdown_afl::parse_balance, "html" => jotdown_afl::html, _ => panic!("unknown target '{}'", target), }; diff --git a/tests/afl/src/parse_balance.rs b/tests/afl/src/parse_balance.rs deleted file mode 100644 index 9118fb2..0000000 --- a/tests/afl/src/parse_balance.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - afl::fuzz!(|data: &[u8]| { jotdown_afl::parse_balance(data) }); -}