Skip to content

Commit

Permalink
test(pattern): Add tests for empty alternates (#4282)
Browse files Browse the repository at this point in the history
  • Loading branch information
Dav1dde authored Nov 22, 2024
1 parent 4614953 commit 7f43f6f
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions relay-pattern/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1414,6 +1414,9 @@ mod tests {

#[test]
fn test_alternates() {
assert_pattern!("{}foo{}", "foo");
assert_pattern!("foo{}bar", "foobar");
assert_pattern!("foo{}{}bar", "foobar");
assert_pattern!("{foo}", "foo");
assert_pattern!("{foo}", NOT "fOo");
assert_pattern!("{foo}", NOT "bar");
Expand Down Expand Up @@ -1475,6 +1478,14 @@ mod tests {
assert_pattern!("{foo,abc}{def,bar}", NOT "defabc");
}

#[test]
fn test_alternate_strategy() {
// Empty alternates can be simplified.
assert_strategy!("{}foo{}", Literal);
assert_strategy!("foo{}bar", Literal);
assert_strategy!("foo{}{}{}bar", Literal);
}

#[test]
fn test_alternates_case_insensitive() {
assert_pattern!("{foo}", "foo", i);
Expand Down

0 comments on commit 7f43f6f

Please sign in to comment.