Skip to content

Commit

Permalink
Fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
stephentoub committed Sep 14, 2023
1 parent 83dfa61 commit 40298bd
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ public RegexFindOptimizations(RegexNode root, RegexOptions options)
// If there are multiple leading strings, we can search for any of them.
if (compiled)
{
if (RegexPrefixAnalyzer.FindPrefixes(root) is { Length: > 1 and < 8 } prefixes)
if (RegexPrefixAnalyzer.FindPrefixes(root) is { Length: > 1 } prefixes)
{
LeadingPrefixes = prefixes;
FindMode = FindNextStartingPositionMode.LeadingStrings_LeftToRight;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,16 @@ public void FindFirstCharClass_StressDeep()
[InlineData("abc|def", new[] { "abc", "def" })]
[InlineData("abc|def|(ghi|jklm)", new[] { "abc", "def", "ghi", "jklm" })]
[InlineData("abc[def]ghi", new[] { "abcdghi", "abceghi", "abcfghi" })]
[InlineData("abc[def]ghi|[jkl]", new[] { "abcdghi", "abceghi", "abcfghi", "j", "k", "l" })]
[InlineData("abcdefg|h", new[] { "abcdefg", "h" })]
[InlineData("abc[def]ghi|[jkl]m", new[] { "abcdghi", "abceghi", "abcfghi", "jm", "km", "lm" })]
[InlineData("agggtaaa|tttaccct", new[] { "agggtaaa", "tttaccct" })]
[InlineData("[cgt]gggtaaa|tttaccc[acg]", new[] { "cgggtaaa", "ggggtaaa", "tgggtaaa", "tttaccca", "tttacccc", "tttacccg" })]
[InlineData("a[act]ggtaaa|tttacc[agt]t", new[] { "aaggtaaa", "acggtaaa", "atggtaaa", "tttaccat", "tttaccgt", "tttacctt" })]
[InlineData("ag[act]gtaaa|tttac[agt]ct", new[] { "agagtaaa", "agcgtaaa", "agtgtaaa", "tttacact", "tttacgct", "tttactct" })]
[InlineData("agg[act]taaa|ttta[agt]cct", new[] { "aggataaa", "aggctaaa", "aggttaaa", "tttaacct", "tttagcct", "tttatcct" })]
[InlineData("\b(abc|def)\b", new[] { "abc", "def" })]
[InlineData("^(abc|def)$", new[] { "abc", "def" })]
[InlineData("abcdefg|h", null)]
[InlineData("abc[def]ghi|[jkl]", null)]
public void FindPrefixes(string pattern, string[] expectedSet)
{
RegexTree tree = RegexParser.Parse(pattern, RegexOptions.None, CultureInfo.InvariantCulture);
Expand Down

0 comments on commit 40298bd

Please sign in to comment.