1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2026-01-06 17:25:27 -05:00

improve performance of domain matcher

This commit is contained in:
Darien Raymond
2018-08-19 21:04:15 +02:00
parent 2ab6da28ba
commit edcf564dd7
7 changed files with 234 additions and 106 deletions

View File

@@ -0,0 +1,35 @@
package strmatcher_test
import (
"testing"
. "v2ray.com/core/common/strmatcher"
)
func TestDomainMatcherGroup(t *testing.T) {
g := new(DomainMatcherGroup)
g.Add("v2ray.com", 1)
g.Add("google.com", 2)
g.Add("x.a.com", 3)
testCases := []struct {
Domain string
Result uint32
}{
{
Domain: "x.v2ray.com",
Result: 1,
},
{
Domain: "y.com",
Result: 0,
},
}
for _, testCase := range testCases {
r := g.Match(testCase.Domain)
if r != testCase.Result {
t.Error("Failed to match domain: ", testCase.Domain, ", expect ", testCase.Result, ", but got ", r)
}
}
}