fix(wildcard): partial match ignoring consumed pattern (#1765)

* tests(wildcard): ?

* really?

* Franklin

* remember when regex was easy

* ==

* why not.

* I need an adult.

* Update match_test.go

* tests + readability

* back to basics
This commit is contained in:
Kyle Sanderson 2024-10-20 04:03:52 -07:00 committed by GitHub
parent 2386a9db31
commit 5df6e78d3b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 52 additions and 22 deletions

View file

@ -107,6 +107,26 @@ func TestMatch(t *testing.T) {
text: "them",
matched: false,
},
{
pattern: "t?q*",
text: "tam e",
matched: false,
},
{
pattern: "Hard?Quiz*",
text: "HardX 24 10 12 Ella Reese XXX 1080p MP4-WRB",
matched: false,
},
{
pattern: "Hard?Quiz*",
text: "HardX",
matched: false,
},
{
pattern: "T?Q*",
text: "T?Q",
matched: true,
},
}
// Iterating over the test cases, call the function under test and assert the output.
for i, testCase := range testCases {
@ -157,6 +177,7 @@ func TestMatchSliceSimple(t *testing.T) {
}{
{[]string{"*", "test"}, "test", true},
{[]string{"te?t", "tost", "random"}, "tost", true},
{[]string{"te?t", "t?s?", "random"}, "tost", false},
{[]string{"*st", "n?st", "l*st"}, "list", true},
{[]string{"?", "?*", "?**"}, "t", false},
{[]string{"a", "b", "c"}, "d", false},
@ -182,6 +203,7 @@ func TestMatchSlice(t *testing.T) {
}{
{[]string{"*", "test", "t?st"}, "test", true},
{[]string{"te?t", "t?st", "random"}, "tost", true},
{[]string{"te?t", "t?s?", "random"}, "tost", true},
{[]string{"te?t", "t??e?", "random"}, "toser", true},
{[]string{"*st", "n?st", "l*st"}, "list", true},
{[]string{"?", "??", "???"}, "t", true},