-
Notifications
You must be signed in to change notification settings - Fork 290
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
60 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
dd-trace-core/src/test/groovy/datadog/trace/core/util/MatchersTest.groovy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
package datadog.trace.core.util | ||
|
||
import datadog.trace.test.util.DDSpecification | ||
|
||
class MatchersTest extends DDSpecification { | ||
|
||
def "match-all scenarios must return a null matcher"() { | ||
expect: | ||
Matchers.compileGlob(glob) == null | ||
|
||
where: | ||
glob << [null, "*"] | ||
} | ||
|
||
def "pattern without * or ? must be an ExactMatcher"() { | ||
expect: | ||
Matchers.compileGlob(glob) instanceof Matchers.ExactMatcher | ||
|
||
where: | ||
glob << ["a", "ogre", "bcoho34e2"] | ||
} | ||
|
||
def "pattern with either * or ? must be a PatternMatcher"() { | ||
expect: | ||
Matchers.compileGlob(glob) instanceof Matchers.PatternMatcher | ||
|
||
where: | ||
glob << ["?", "foo*", "*bar", "F?oB?r", "F?o*", "?*", "*?"] | ||
} | ||
|
||
def "an exact matcher is self matching"() { | ||
expect: | ||
Matchers.compileGlob(pattern).matches(pattern) | ||
|
||
where: | ||
pattern << ["", "a", "abc", "cde"] | ||
} | ||
|
||
def "a pattern matcher test"() { | ||
when: | ||
def matcher = Matchers.compileGlob(pattern) | ||
|
||
then: | ||
matcher.matches(matching) | ||
!matcher.matches(nonMatching) | ||
|
||
where: | ||
pattern | matching | nonMatching | ||
"Fo?" | "Foo" | "Fooo" | ||
"Fo*" | "Fo" | "Fa" | ||
"F*B?r" | "FooBar" | "FooFar" | ||
"" | "" | "non-empty" | ||
} | ||
} |