matcher_test.go 525 B

123456789101112131415161718192021
  1. package domain_test
  2. import (
  3. "testing"
  4. "github.com/sagernet/sing-box/common/domain"
  5. "github.com/stretchr/testify/require"
  6. )
  7. func TestMatch(t *testing.T) {
  8. t.Parallel()
  9. r := require.New(t)
  10. matcher := domain.NewMatcher([]string{"domain.com"}, []string{"suffix.com", ".suffix.org"})
  11. r.True(matcher.Match("domain.com"))
  12. r.False(matcher.Match("my.domain.com"))
  13. r.True(matcher.Match("suffix.com"))
  14. r.True(matcher.Match("my.suffix.com"))
  15. r.False(matcher.Match("suffix.org"))
  16. r.True(matcher.Match("my.suffix.org"))
  17. }