sing-box/common/domain/matcher_test.go

21 lines
511 B
Go
Raw Normal View History

2022-07-07 13:47:21 +00:00
package domain_test
2022-07-02 14:55:10 +00:00
import (
"testing"
2022-07-07 13:47:21 +00:00
"github.com/sagernet/sing-box/common/domain"
2022-07-02 14:55:10 +00:00
"github.com/stretchr/testify/require"
)
func TestMatch(t *testing.T) {
r := require.New(t)
2022-07-07 13:47:21 +00:00
matcher := domain.NewMatcher([]string{"domain.com"}, []string{"suffix.com", ".suffix.org"})
2022-07-02 14:55:10 +00:00
r.True(matcher.Match("domain.com"))
r.False(matcher.Match("my.domain.com"))
r.True(matcher.Match("suffix.com"))
r.True(matcher.Match("my.suffix.com"))
r.False(matcher.Match("suffix.org"))
r.True(matcher.Match("my.suffix.org"))
}