| 1 | package irc_testscip-go gomod gopkg.in/irc.v4 . `gopkg.in/irc.v4_test`/ |
| 2 | |
| 3 | import ( |
| 4 | "testingscip-go gomod github.com/golang/go/src go1.13 testing/" |
| 5 | |
| 6 | "github.com/stretchr/testify/assertscip-go gomod github.com/stretchr/testify v1.8.0 `github.com/stretchr/testify/assert`/" |
| 7 | |
| 8 | "gopkg.in/irc.v4scip-go gomod gopkg.in/irc.v4 . `gopkg.in/irc.v4`/" |
| 9 | ) |
| 10 | |
| 11 | func TestMaskToRegexscip-go gomod gopkg.in/irc.v4 . `gopkg.in/irc.v4_test`/TestMaskToRegex().(t *testingscip-go gomod github.com/golang/go/src go1.13 testing/.Tscip-go gomod github.com/golang/go/src go1.13 testing/T#) { |
| 12 | t.Parallelscip-go gomod github.com/golang/go/src go1.13 testing/T#Parallel().() |
| 13 | |
| 14 | var testCases = []struct { //nolint:gofumpt |
| 15 | Input string |
| 16 | Expect string |
| 17 | }{ |
| 18 | { // Empty should be fine |
| 19 | Input: "", |
| 20 | Expect: "^$", |
| 21 | }, |
| 22 | { // EVERYONE! |
| 23 | Input: "*!*@*", |
| 24 | Expect: "^.*!.*@.*$", |
| 25 | }, |
| 26 | { |
| 27 | Input: "", |
| 28 | Expect: "^$", |
| 29 | }, |
| 30 | { |
| 31 | Input: "", |
| 32 | Expect: "^$", |
| 33 | }, |
| 34 | { // Escape the slash |
| 35 | Input: "a\\\\b", |
| 36 | Expect: "^a\\\\b$", |
| 37 | }, |
| 38 | { // Escape a * |
| 39 | Input: "a\\*b", |
| 40 | Expect: "^a\\*b$", |
| 41 | }, |
| 42 | { // Escape a ? |
| 43 | Input: "a\\?b", |
| 44 | Expect: "^a\\?b$", |
| 45 | }, |
| 46 | { // Single slash in the middle of a string should be a slash |
| 47 | Input: "a\\b", |
| 48 | Expect: "^a\\\\b$", |
| 49 | }, |
| 50 | { // Single slash should just match a single slash |
| 51 | Input: "\\", |
| 52 | Expect: "^\\\\$", |
| 53 | }, |
| 54 | { |
| 55 | Input: "\\a?", |
| 56 | Expect: "^\\\\a.$", |
| 57 | }, |
| 58 | } |
| 59 | |
| 60 | for _, testCase := range testCases { |
| 61 | ret, err := ircscip-go gomod gopkg.in/irc.v4 . `gopkg.in/irc.v4`/.MaskToRegexscip-go gomod gopkg.in/irc.v4 . `gopkg.in/irc.v4`/MaskToRegex().(testCase.Input) |
| 62 | assertscip-go gomod github.com/stretchr/testify v1.8.0 `github.com/stretchr/testify/assert`/.NoErrorscip-go gomod github.com/stretchr/testify v1.8.0 `github.com/stretchr/testify/assert`/NoError().(t, err) |
| 63 | assertscip-go gomod github.com/stretchr/testify v1.8.0 `github.com/stretchr/testify/assert`/.Equalscip-go gomod github.com/stretchr/testify v1.8.0 `github.com/stretchr/testify/assert`/Equal().(t, testCase.Expect, ret.Stringscip-go gomod github.com/golang/go/src go1.13 regexp/Regexp#String().()) |
| 64 | } |
| 65 | } |