pax_global_header00006660000000000000000000000064144671343270014525gustar00rootroot0000000000000052 comment=2f93770ccbe7d1f3e102221d88ade4c0ecca52be go-wildcard-2.0.2/000077500000000000000000000000001446713432700137225ustar00rootroot00000000000000go-wildcard-2.0.2/.gitignore000066400000000000000000000155051446713432700157200ustar00rootroot00000000000000# ---> Go # Binaries for programs and plugins *.exe *.exe~ *.dll *.so *.dylib # Test binary, built with `go test -c` *.test # Output of the go coverage tool, specifically when used with LiteIDE *.out # Dependency directories (remove the comment below to include it) # vendor/ # ---> VisualStudio ## Ignore Visual Studio temporary files, build results, and ## files generated by popular Visual Studio add-ons. ## ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore # User-specific files *.rsuser *.suo *.user *.userosscache *.sln.docstates # User-specific files (MonoDevelop/Xamarin Studio) *.userprefs # Mono auto generated files mono_crash.* # Build results [Dd]ebug/ [Dd]ebugPublic/ [Rr]elease/ [Rr]eleases/ x64/ x86/ [Ww][Ii][Nn]32/ [Aa][Rr][Mm]/ [Aa][Rr][Mm]64/ bld/ [Bb]in/ [Oo]bj/ [Ll]og/ [Ll]ogs/ # Visual Studio 2015/2017 cache/options directory .vs/ # Uncomment if you have tasks that create the project's static files in wwwroot #wwwroot/ # Visual Studio 2017 auto generated files Generated\ Files/ # MSTest test Results [Tt]est[Rr]esult*/ [Bb]uild[Ll]og.* # NUnit *.VisualState.xml TestResult.xml nunit-*.xml # Build Results of an ATL Project [Dd]ebugPS/ [Rr]eleasePS/ dlldata.c # Benchmark Results BenchmarkDotNet.Artifacts/ # .NET Core project.lock.json project.fragment.lock.json artifacts/ # ASP.NET Scaffolding ScaffoldingReadMe.txt # StyleCop StyleCopReport.xml # Files built by Visual Studio *_i.c *_p.c *_h.h *.ilk *.meta *.obj *.iobj *.pch *.pdb *.ipdb *.pgc *.pgd *.rsp *.sbr *.tlb *.tli *.tlh *.tmp *.tmp_proj *_wpftmp.csproj *.log *.vspscc *.vssscc .builds *.pidb *.svclog *.scc # Chutzpah Test files _Chutzpah* # Visual C++ cache files ipch/ *.aps *.ncb *.opendb *.opensdf *.sdf *.cachefile *.VC.db *.VC.VC.opendb # Visual Studio profiler *.psess *.vsp *.vspx *.sap # Visual Studio Trace Files *.e2e # TFS 2012 Local Workspace $tf/ # Guidance Automation Toolkit *.gpState # ReSharper is a .NET coding add-in _ReSharper*/ *.[Rr]e[Ss]harper *.DotSettings.user # TeamCity is a build add-in _TeamCity* # DotCover is a Code Coverage Tool *.dotCover # AxoCover is a Code Coverage Tool .axoCover/* !.axoCover/settings.json # Coverlet is a free, cross platform Code Coverage Tool coverage*.json coverage*.xml coverage*.info # Visual Studio code coverage results *.coverage *.coveragexml # NCrunch _NCrunch_* .*crunch*.local.xml nCrunchTemp_* # MightyMoose *.mm.* AutoTest.Net/ # Web workbench (sass) .sass-cache/ # Installshield output folder [Ee]xpress/ # DocProject is a documentation generator add-in DocProject/buildhelp/ DocProject/Help/*.HxT DocProject/Help/*.HxC DocProject/Help/*.hhc DocProject/Help/*.hhk DocProject/Help/*.hhp DocProject/Help/Html2 DocProject/Help/html # Click-Once directory publish/ # Publish Web Output *.[Pp]ublish.xml *.azurePubxml # Note: Comment the next line if you want to checkin your web deploy settings, # but database connection strings (with potential passwords) will be unencrypted *.pubxml *.publishproj # Microsoft Azure Web App publish settings. Comment the next line if you want to # checkin your Azure Web App publish settings, but sensitive information contained # in these scripts will be unencrypted PublishScripts/ # NuGet Packages *.nupkg # NuGet Symbol Packages *.snupkg # The packages folder can be ignored because of Package Restore **/[Pp]ackages/* # except build/, which is used as an MSBuild target. !**/[Pp]ackages/build/ # Uncomment if necessary however generally it will be regenerated when needed #!**/[Pp]ackages/repositories.config # NuGet v3's project.json files produces more ignorable files *.nuget.props *.nuget.targets # Microsoft Azure Build Output csx/ *.build.csdef # Microsoft Azure Emulator ecf/ rcf/ # Windows Store app package directories and files AppPackages/ BundleArtifacts/ Package.StoreAssociation.xml _pkginfo.txt *.appx *.appxbundle *.appxupload # Visual Studio cache files # files ending in .cache can be ignored *.[Cc]ache # but keep track of directories ending in .cache !?*.[Cc]ache/ # Others ClientBin/ ~$* *~ *.dbmdl *.dbproj.schemaview *.jfm *.pfx *.publishsettings orleans.codegen.cs # Including strong name files can present a security risk # (https://github.com/github/gitignore/pull/2483#issue-259490424) #*.snk # Since there are multiple workflows, uncomment next line to ignore bower_components # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) #bower_components/ # RIA/Silverlight projects Generated_Code/ # Backup & report files from converting an old project file # to a newer Visual Studio version. Backup files are not needed, # because we have git ;-) _UpgradeReport_Files/ Backup*/ UpgradeLog*.XML UpgradeLog*.htm ServiceFabricBackup/ *.rptproj.bak # SQL Server files *.mdf *.ldf *.ndf # Business Intelligence projects *.rdl.data *.bim.layout *.bim_*.settings *.rptproj.rsuser *- [Bb]ackup.rdl *- [Bb]ackup ([0-9]).rdl *- [Bb]ackup ([0-9][0-9]).rdl # Microsoft Fakes FakesAssemblies/ # GhostDoc plugin setting file *.GhostDoc.xml # Node.js Tools for Visual Studio .ntvs_analysis.dat node_modules/ # Visual Studio 6 build log *.plg # Visual Studio 6 workspace options file *.opt # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) *.vbw # Visual Studio LightSwitch build output **/*.HTMLClient/GeneratedArtifacts **/*.DesktopClient/GeneratedArtifacts **/*.DesktopClient/ModelManifest.xml **/*.Server/GeneratedArtifacts **/*.Server/ModelManifest.xml _Pvt_Extensions # Paket dependency manager .paket/paket.exe paket-files/ # FAKE - F# Make .fake/ # CodeRush personal settings .cr/personal # Python Tools for Visual Studio (PTVS) __pycache__/ *.pyc # Cake - Uncomment if you are using it # tools/** # !tools/packages.config # Tabs Studio *.tss # Telerik's JustMock configuration file *.jmconfig # BizTalk build output *.btp.cs *.btm.cs *.odx.cs *.xsd.cs # OpenCover UI analysis results OpenCover/ # Azure Stream Analytics local run output ASALocalRun/ # MSBuild Binary and Structured Log *.binlog # NVidia Nsight GPU debugger configuration file *.nvuser # MFractors (Xamarin productivity tool) working folder .mfractor/ # Local History for Visual Studio .localhistory/ # BeatPulse healthcheck temp database healthchecksdb # Backup folder for Package Reference Convert tool in Visual Studio 2017 MigrationBackup/ # Ionide (cross platform F# VS Code tools) working folder .ionide/ # Fody - auto-generated XML schema FodyWeavers.xsd # ---> VisualStudioCode .vscode/* !.vscode/settings.json !.vscode/tasks.json !.vscode/launch.json !.vscode/extensions.json *.code-workspace # Local History for Visual Studio Code .history/ # ---> Vim # Swap [._]*.s[a-v][a-z] !*.svg # comment out if you don't need vector files [._]*.sw[a-p] [._]s[a-rt-v][a-z] [._]ss[a-gi-z] [._]sw[a-p] # Session Session.vim Sessionx.vim # Temporary .netrwhist *~ # Auto-generated tag files tags # Persistent undo [._]*.un~ go-wildcard-2.0.2/LICENSE.md000066400000000000000000000045001446713432700153250ustar00rootroot00000000000000License ======= go-wildcard is free software under OpenBSD's ISC-style license. > Copyright (c) 2023 Iglou.eu > Copyright (c) 2023 Adrien Kara > > Redistribution and use in source and binary forms, with or without > modification, are permitted provided that the following conditions are met: > > 1. Redistributions of source code must retain the above copyright notice, > this list of conditions and the following disclaimer. > 2. Redistributions in binary form must reproduce the above copyright notice, > this list of conditions and the following disclaimer in the documentation > and/or other materials provided with the distribution. > 3. Neither the name of the copyright holder nor the names of its contributors > may be used to endorse or promote products derived from this software without > specific prior written permission. > > THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS β€œAS IS” > AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, > THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR > PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR > CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, > EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, > PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; > OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, > WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR > OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF > ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. One exception is [`old_wildcard_test.go`](https://github.com/IGLOU-EU/go-wildcard/old_wildcard_test.go) > MinIO Cloud Storage, (C) 2015, 2016 MinIO, Inc. > > Licensed under the Apache License, Version 2.0 (the "License"); > you may not use this file except in compliance with the License. > You may obtain a copy of the License at > > http://www.apache.org/licenses/LICENSE-2.0 > > Unless required by applicable law or agreed to in writing, software > distributed under the License is distributed on an "AS IS" BASIS, > WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. > See the License for the specific language governing permissions and > limitations under the License.go-wildcard-2.0.2/README.md000066400000000000000000000130751446713432700152070ustar00rootroot00000000000000# Go-wildcard [![Go Report Card](https://goreportcard.com/badge/github.com/IGLOU-EU/go-wildcard)](https://goreportcard.com/report/github.com/IGLOU-EU/go-wildcard) [![Go Reference](https://img.shields.io/badge/api-reference-blue)](https://pkg.go.dev/github.com/IGLOU-EU/go-wildcard) [![BSD 3 Clause ](https://img.shields.io/badge/license-BSD_3_Clause-blue)](https://opensource.org/license/bsd-3-clause/) ## πŸ’‘ Why The purpose of this library is to provide a simple and fast wildcard pattern matching. Regex are much more complex, and slower (even prepared regex)... and the filepath.Match is not enough flexible. So, this library is a very simple, very fast and a more flexible alternative to regex and filepath.Match. There are no dependencies and is alocation free. πŸ₯³ ## 🧰 Features There are the supported patterns operators: - `*` match zero or more characters - `?` match zero or one character - `.` match exactly one character ## 🧐 How to >⚠️ WARNING: Unlike the GNU "libc", this library have no equivalent to "FNM_FILE_NAME". >To do this you can use "path/filepath" https://pkg.go.dev/path/filepath#Match There is super simple to use this library, you just have to import it and use the Match function. ```go package main import ( "fmt" "github.com/IGLOU-EU/go-wildcard/v2" ) func main() { str := "daaadabadmanda" pattern := "?a*da*d.?*" result = wildcard.Match(pattern, str) fmt.Println(str, pattern, result) } ``` ## πŸ›Έ Benchmark The benchmark is done with the following command: ```bash go test -benchmem -run=^$ -bench . ``` The tested fonctions are: - regexp.MatchString(t.pattern, t.name) - filepath.Match(t.pattern, t.name) - oldMatchSimple(t.pattern, t.name) `From the commit a899be92514ed08aa5271bc3b93320b719ce2114` - oldMatch(t.pattern, t.name) `From the commit a899be92514ed08aa5271bc3b93320b719ce2114` - Match(t.pattern, t.name) `The actual implementation` ```bash goos: linux goarch: amd64 pkg: github.com/IGLOU-EU/go-wildcard cpu: AMD Ryzen 7 PRO 6850U with Radeon Graphics BenchmarkRegex/0-16 1000000 1322 ns/op 765 B/op 9 allocs/op BenchmarkRegex/1-16 134851 10461 ns/op 6592 B/op 26 allocs/op BenchmarkRegex/2-16 5871756 280.8 ns/op 160 B/op 2 allocs/op BenchmarkRegex/3-16 108092 12096 ns/op 6647 B/op 26 allocs/op BenchmarkRegex/4-16 92070 13924 ns/op 7436 B/op 38 allocs/op BenchmarkRegex/5-16 4702372 277.6 ns/op 160 B/op 2 allocs/op BenchmarkFilepath/0-16 548771120 1.836 ns/op 0 B/op 0 allocs/op BenchmarkFilepath/1-16 9451810 117.8 ns/op 0 B/op 0 allocs/op BenchmarkFilepath/2-16 151409767 7.853 ns/op 0 B/op 0 allocs/op BenchmarkFilepath/3-16 8656650 143.8 ns/op 0 B/op 0 allocs/op BenchmarkFilepath/4-16 67589983 18.33 ns/op 0 B/op 0 allocs/op BenchmarkFilepath/5-16 4805623 240.3 ns/op 0 B/op 0 allocs/op BenchmarkOldMatchSimple/0-16 1000000000 0.4971 ns/op 0 B/op 0 allocs/op BenchmarkOldMatchSimple/1-16 4738023 292.5 ns/op 176 B/op 1 allocs/op BenchmarkOldMatchSimple/2-16 1000000000 0.9130 ns/op 0 B/op 0 allocs/op BenchmarkOldMatchSimple/3-16 1688683 763.8 ns/op 352 B/op 2 allocs/op BenchmarkOldMatchSimple/4-16 2242758 514.0 ns/op 336 B/op 2 allocs/op BenchmarkOldMatchSimple/5-16 10435084 110.7 ns/op 0 B/op 0 allocs/op BenchmarkOldMatch/0-16 1000000000 0.4568 ns/op 0 B/op 0 allocs/op BenchmarkOldMatch/1-16 5300286 286.8 ns/op 176 B/op 1 allocs/op BenchmarkOldMatch/2-16 1000000000 0.7127 ns/op 0 B/op 0 allocs/op BenchmarkOldMatch/3-16 1608777 772.9 ns/op 352 B/op 2 allocs/op BenchmarkOldMatch/4-16 2283015 548.9 ns/op 336 B/op 2 allocs/op BenchmarkOldMatch/5-16 10425933 113.0 ns/op 0 B/op 0 allocs/op BenchmarkMatch/0-16 654065395 1.774 ns/op 0 B/op 0 allocs/op BenchmarkMatch/1-16 352847413 2.973 ns/op 0 B/op 0 allocs/op BenchmarkMatch/2-16 652602918 1.822 ns/op 0 B/op 0 allocs/op BenchmarkMatch/3-16 412494770 2.940 ns/op 0 B/op 0 allocs/op BenchmarkMatch/4-16 197380323 5.447 ns/op 0 B/op 0 allocs/op BenchmarkMatch/5-16 39741439 27.96 ns/op 0 B/op 0 allocs/op PASS ok github.com/IGLOU-EU/go-wildcard 48.707s ``` ## πŸ•° History Originally, this library was a fork from the Minio project. The purpose was to give access to this "lib" under Apache license, without importing the entire Minio project. And to keep it usable under the Apache License Version 2.0 after MinIO project is migrated to GNU Affero General Public License 3.0 or later from [`update license change for MinIO`](https://github.com/minio/minio/commit/069432566fcfac1f1053677cc925ddafd750730a) The actual Minio wildcard matching code can be found in [`wildcard.go`](https://github.com/minio/pkg/tree/main/wildcard)go-wildcard-2.0.2/go.mod000066400000000000000000000000631446713432700150270ustar00rootroot00000000000000module github.com/IGLOU-EU/go-wildcard/v2 go 1.16 go-wildcard-2.0.2/old_wildcard_test.go000066400000000000000000000043141446713432700177410ustar00rootroot00000000000000/* * The old wildcard implementation is kept for reference and benchmarking comparison. * There made by MinIO and this original fork is here: */ /* * MinIO Cloud Storage, (C) 2015, 2016 MinIO, Inc. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ package wildcard_test // MatchSimple - finds whether the text matches/satisfies the pattern string. // supports only '*' wildcard in the pattern. // considers a file system path as a flat name space. func Old_MatchSimple(pattern, name string) bool { if pattern == "" { return name == pattern } if pattern == "*" { return true } // Does only wildcard '*' match. return Old_deepMatchRune([]rune(name), []rune(pattern), true) } // Match - finds whether the text matches/satisfies the pattern string. // supports '*' and '?' wildcards in the pattern string. // unlike path.Match(), considers a path as a flat name space while matching the pattern. // The difference is illustrated in the example here https://play.golang.org/p/Ega9qgD4Qz . func Old_Match(pattern, name string) (matched bool) { if pattern == "" { return name == pattern } if pattern == "*" { return true } // Does extended wildcard '*' and '?' match. return Old_deepMatchRune([]rune(name), []rune(pattern), false) } func Old_deepMatchRune(str, pattern []rune, simple bool) bool { for len(pattern) > 0 { switch pattern[0] { default: if len(str) == 0 || str[0] != pattern[0] { return false } case '?': if len(str) == 0 && !simple { return false } case '*': return Old_deepMatchRune(str, pattern[1:], simple) || (len(str) > 0 && Old_deepMatchRune(str[1:], pattern, simple)) } str = str[1:] pattern = pattern[1:] } return len(str) == 0 && len(pattern) == 0 } go-wildcard-2.0.2/wildcard.go000066400000000000000000000044501446713432700160450ustar00rootroot00000000000000/* * Copyright (c) 2023 Iglou.eu * Copyright (c) 2023 Adrien Kara * * Licensed under the BSD 3-Clause License, * see LICENSE.md for more details. */ package wildcard // Match returns true if the pattern matches the s string. // The pattern can contain the wildcard characters '?' '.' and '*'. func Match(pattern, s string) bool { if pattern == "" { return s == pattern } if pattern == "*" || s == pattern { return true } return match(pattern, s) } func match(pattern, s string) bool { var lastErotemeByte byte var patternIndex, sIndex, lastStar, lastEroteme int patternLen := len(pattern) sLen := len(s) star := -1 eroteme := -1 Loop: if sIndex >= sLen { goto checkPattern } if patternIndex >= patternLen { if star != -1 { patternIndex = star + 1 lastStar++ sIndex = lastStar goto Loop } return false } switch pattern[patternIndex] { case '.': // It matches any single character. So, we don't need to check anything. case '?': // '?' matches one character. Store its position and match exactly one character in the string. eroteme = patternIndex lastEroteme = sIndex lastErotemeByte = s[sIndex] case '*': // '*' matches zero or more characters. Store its position and increment the pattern index. star = patternIndex lastStar = sIndex patternIndex++ goto Loop default: // If the characters don't match, check if there was a previous '?' or '*' to backtrack. if pattern[patternIndex] != s[sIndex] { if eroteme != -1 { patternIndex = eroteme + 1 sIndex = lastEroteme eroteme = -1 goto Loop } if star != -1 { patternIndex = star + 1 lastStar++ sIndex = lastStar goto Loop } return false } // If the characters match, check if it was not the same to validate the eroteme. if eroteme != -1 && lastErotemeByte != s[sIndex] { eroteme = -1 } } patternIndex++ sIndex++ goto Loop // Check if the remaining pattern characters are '*' or '?', which can match the end of the string. checkPattern: if patternIndex < patternLen { if pattern[patternIndex] == '*' { patternIndex++ goto checkPattern } else if pattern[patternIndex] == '?' { if sIndex >= sLen { sIndex-- } patternIndex++ goto checkPattern } } return patternIndex == patternLen } go-wildcard-2.0.2/wildcard_bench_test.go000066400000000000000000000030471446713432700202440ustar00rootroot00000000000000package wildcard_test import ( "fmt" "path/filepath" "regexp" "testing" "github.com/IGLOU-EU/go-wildcard/v2" ) var TestSet = []struct { pattern string name string }{ {"", "These aren't the wildcard you're looking for"}, {"These aren't the wildcard you're looking for", ""}, {"*", "These aren't the wildcard you're looking for"}, {"These aren't the wildcard you're looking for", "These aren't the wildcard you're looking for"}, {"Th.e * the wildcard you?re looking fo?", "These aren't the wildcard you're looking for"}, {"*πŸ€·πŸΎβ€β™‚οΈ*", "TπŸ₯΅πŸ€·πŸΎβ€β™‚️πŸ₯“"}, } func BenchmarkRegex(b *testing.B) { for i, t := range TestSet { b.Run(fmt.Sprint(i), func(b *testing.B) { for i := 0; i < b.N; i++ { regexp.MatchString(t.pattern, t.name) } }) } } func BenchmarkFilepath(b *testing.B) { for i, t := range TestSet { b.Run(fmt.Sprint(i), func(b *testing.B) { for i := 0; i < b.N; i++ { filepath.Match(t.pattern, t.name) } }) } } func BenchmarkOldMatchSimple(b *testing.B) { for i, t := range TestSet { b.Run(fmt.Sprint(i), func(b *testing.B) { for i := 0; i < b.N; i++ { Old_MatchSimple(t.pattern, t.name) } }) } } func BenchmarkOldMatch(b *testing.B) { for i, t := range TestSet { b.Run(fmt.Sprint(i), func(b *testing.B) { for i := 0; i < b.N; i++ { Old_Match(t.pattern, t.name) } }) } } func BenchmarkMatch(b *testing.B) { for i, t := range TestSet { b.Run(fmt.Sprint(i), func(b *testing.B) { for i := 0; i < b.N; i++ { wildcard.Match(t.pattern, t.name) } }) } } go-wildcard-2.0.2/wildcard_test.go000066400000000000000000000103711446713432700171030ustar00rootroot00000000000000/* * Copyright (c) 2023 Iglou.eu * Copyright (c) 2023 Adrien Kara * * Licensed under the BSD 3-Clause License, * see LICENSE.md for more details. */ package wildcard_test import ( "testing" "github.com/IGLOU-EU/go-wildcard/v2" ) // TestMatch - Tests validate the logic of wild card matching. // `Match` supports '*' and '?' wildcards. // Sample usage: In resource matching for bucket policy validation. func TestMatch(t *testing.T) { cases := []struct { s string pattern string result bool }{ {"", "", true}, {"", "*", true}, {"", "**", true}, {"", "?", true}, {"", "??", true}, {"", "?*", true}, {"", "*?", true}, {"", ".", false}, {"", ".?", false}, {"", "?.", false}, {"", ".*", false}, {"", "*.", false}, {"", "*.?", false}, {"", "?.*", false}, {"a", "", false}, {"a", "a", true}, {"a", "*", true}, {"a", "**", true}, {"a", "?", true}, {"a", "??", true}, {"a", ".", true}, {"a", ".?", true}, {"a", "?.", false}, {"a", ".*", true}, {"a", "*.", true}, {"a", "*.?", true}, {"a", "?.*", false}, {"match the exact string", "match the exact string", true}, {"do not match a different string", "this is a different string", false}, {"Match The Exact String WITH DIFFERENT CASE", "Match The Exact String WITH DIFFERENT CASE", true}, {"do not match a different string WITH DIFFERENT CASE", "this is a different string WITH DIFFERENT CASE", false}, {"Do Not Match The Exact String With Different Case", "do not match the exact string with different case", false}, {"match an emoji πŸ˜ƒ", "match an emoji πŸ˜ƒ", true}, {"do not match because of different emoji πŸ˜ƒ", "do not match because of different emoji πŸ˜„", false}, {"πŸŒ…β˜•οΈπŸ“°πŸ‘¨β€πŸ’ΌπŸ‘©β€πŸ’ΌπŸ’πŸ–₯οΈπŸ’ΌπŸ’»πŸ“ŠπŸ“ˆπŸ“‰πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦πŸπŸ•°οΈπŸ’ͺπŸ‹οΈβ€β™‚οΈπŸ‹οΈβ€β™€οΈπŸ‹οΈβ€β™‚οΈπŸ’ΌπŸš΄β€β™‚οΈπŸš΄β€β™€οΈπŸš΄β€β™‚οΈπŸ›€πŸ’€πŸŒƒ", "πŸŒ…β˜•οΈπŸ“°πŸ‘¨β€πŸ’ΌπŸ‘©β€πŸ’ΌπŸ’πŸ–₯οΈπŸ’ΌπŸ’»πŸ“ŠπŸ“ˆπŸ“‰πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦πŸπŸ•°οΈπŸ’ͺπŸ‹οΈβ€β™‚οΈπŸ‹οΈβ€β™€οΈπŸ‹οΈβ€β™‚οΈπŸ’ΌπŸš΄β€β™‚οΈπŸš΄β€β™€οΈπŸš΄β€β™‚οΈπŸ›€πŸ’€πŸŒƒ", true}, {"πŸŒ…β˜•οΈπŸ“°πŸ‘¨β€πŸ’ΌπŸ‘©β€πŸ’ΌπŸ’πŸ–₯οΈπŸ’ΌπŸ’»πŸ“ŠπŸ“ˆπŸ“‰πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦πŸπŸ•°οΈπŸ’ͺπŸ‹οΈβ€β™‚οΈπŸ‹οΈβ€β™€οΈπŸ‹οΈβ€β™‚οΈπŸ’ΌπŸš΄β€β™‚οΈπŸš΄β€β™€οΈπŸš΄β€β™‚οΈπŸ›€πŸ’€πŸŒƒ", "πŸ¦ŒπŸ‡πŸ¦‘πŸΏοΈπŸŒ²πŸŒ³πŸ°πŸŒ³πŸŒ²πŸŒžπŸŒ§οΈβ„οΈπŸŒ¬οΈβ›ˆοΈπŸ”₯πŸŽ„πŸŽ…πŸŽπŸŽ‰πŸŽŠπŸ₯³πŸ‘¨β€πŸ‘©β€πŸ‘§β€πŸ‘¦πŸ’πŸ‘ͺπŸ’–πŸ‘©β€πŸ’ΌπŸ›€", false}, {"match a string with a *", "match a string *", true}, {"match a string with a * at the beginning", "* at the beginning", true}, {"match a string with two *", "match * with *", true}, {"do not match a string with extra and a *", "do not match a string * with more", false}, {"match a string with a ?", "match ? string with a ?", true}, {"match a string with a ? at the beginning", "?atch a string with a ? at the beginning", true}, {"match a string with two ?", "match a string with two ??", true}, {"match a optional char with a ?", "match a optional? char with a ?", true}, {"match a optional char with a ?", "match a optional? char with a ?", true}, {"do not match a string with extra and a ?", "do not match ? string with extra and a ? like this", false}, {"match a string with a .", "match . string with a .", true}, {"match a string with a . at the beginning", ".atch a string with a . at the beginning", true}, {"match a string with two .", "match a ..ring with two .", true}, {"do not match a string with extra .", "do not match a string with extra ..", false}, {"A big brown fox jumps over the lazy dog, with all there wildcards friends", ". big?brown fox jumps over * wildcard. friend??", true}, {"A big brown fox fails to jump over the lazy dog, with all there wildcards friends", ". big?brown fox jumps over * wildcard. friend??", false}, } for i, c := range cases { result := wildcard.Match(c.pattern, c.s) if c.result != result { t.Errorf("Test %d: Expected `%v`, found `%v`; With Pattern: `%s` and String: `%s`", i+1, c.result, result, c.pattern, c.s) } } } func FuzzMatch(f *testing.F) { f.Fuzz(func(t *testing.T, s string) { if !wildcard.Match(s, s) { t.Fatalf("%s does not match %s", s, s) } }) }