Skip to content

Commit

Permalink
tests: add tests involving the Empty regex
Browse files Browse the repository at this point in the history
  • Loading branch information
v-gb authored and BurntSushi committed May 28, 2020
1 parent d50d31b commit ed581f5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
12 changes: 12 additions & 0 deletions tests/crazy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,18 @@ matiter!(match_empty8, r"()+|z", "abc", (0, 0), (1, 1), (2, 2), (3, 3));
matiter!(match_empty9, r"z|()+", "abc", (0, 0), (1, 1), (2, 2), (3, 3));
matiter!(match_empty10, r"()+|b", "abc", (0, 0), (1, 1), (2, 2), (3, 3));
matiter!(match_empty11, r"b|()+", "abc", (0, 0), (1, 2), (3, 3));
matiter!(match_empty12, r"|b", "abc", (0, 0), (1, 1), (2, 2), (3, 3));
matiter!(match_empty13, r"b|", "abc", (0, 0), (1, 2), (3, 3));
matiter!(match_empty14, r"|z", "abc", (0, 0), (1, 1), (2, 2), (3, 3));
matiter!(match_empty15, r"z|", "abc", (0, 0), (1, 1), (2, 2), (3, 3));
matiter!(match_empty16, r"|", "abc", (0, 0), (1, 1), (2, 2), (3, 3));
matiter!(match_empty17, r"||", "abc", (0, 0), (1, 1), (2, 2), (3, 3));
matiter!(match_empty18, r"||z", "abc", (0, 0), (1, 1), (2, 2), (3, 3));
matiter!(match_empty19, r"(?:)|b", "abc", (0, 0), (1, 1), (2, 2), (3, 3));
matiter!(match_empty20, r"b|(?:)", "abc", (0, 0), (1, 2), (3, 3));
matiter!(match_empty21, r"(?:|)", "abc", (0, 0), (1, 1), (2, 2), (3, 3));
matiter!(match_empty22, r"(?:|)|z", "abc", (0, 0), (1, 1), (2, 2), (3, 3));
matiter!(match_empty23, r"a(?:)|b", "abc", (0, 1), (1, 2));

// Test that the DFA can handle pathological cases.
// (This should result in the DFA's cache being flushed too frequently, which
Expand Down
7 changes: 0 additions & 7 deletions tests/noparse.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,3 @@ noparse!(fail_range_end_no_class, "[a-[:lower:]]");
noparse!(fail_range_end_no_begin, r"[a-\A]");
noparse!(fail_range_end_no_end, r"[a-\z]");
noparse!(fail_range_end_no_boundary, r"[a-\b]");
noparse!(fail_empty_alt1, r"|z");
noparse!(fail_empty_alt2, r"z|");
noparse!(fail_empty_alt3, r"|");
noparse!(fail_empty_alt4, r"||");
noparse!(fail_empty_alt5, r"()|z");
noparse!(fail_empty_alt6, r"z|()");
noparse!(fail_empty_alt7, r"(|)");
11 changes: 11 additions & 0 deletions tests/set.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,17 @@ matset!(set16, &["a"], "a", 0);
matset!(set17, &[".*a"], "a", 0);
matset!(set18, &["a", "β"], "β", 1);

// regexes that match the empty string
matset!(setempty1, &["", "a"], "abc", 0, 1);
matset!(setempty2, &["", "b"], "abc", 0, 1);
matset!(setempty3, &["", "z"], "abc", 0);
matset!(setempty4, &["a", ""], "abc", 0, 1);
matset!(setempty5, &["b", ""], "abc", 0, 1);
matset!(setempty6, &["z", ""], "abc", 1);
matset!(setempty7, &["b", "(?:)"], "abc", 0, 1);
matset!(setempty8, &["(?:)", "b"], "abc", 0, 1);
matset!(setempty9, &["c(?:)", "b"], "abc", 0, 1);

nomatset!(nset1, &["a", "a"], "b");
nomatset!(nset2, &["^foo", "bar$"], "bar foo");
nomatset!(
Expand Down

0 comments on commit ed581f5

Please sign in to comment.