chinasites_test.go 750 B

12345678910111213141516171819202122232425
  1. package json
  2. import (
  3. "testing"
  4. v2net "github.com/v2ray/v2ray-core/common/net"
  5. v2testing "github.com/v2ray/v2ray-core/testing"
  6. "github.com/v2ray/v2ray-core/testing/assert"
  7. )
  8. func makeDomainDestination(domain string) v2net.Destination {
  9. return v2net.NewTCPDestination(v2net.DomainAddress(domain, 80))
  10. }
  11. func TestChinaSites(t *testing.T) {
  12. v2testing.Current(t)
  13. rule := &ChinaSitesRule{}
  14. assert.Bool(rule.Apply(makeDomainDestination("v.qq.com"))).IsTrue()
  15. assert.Bool(rule.Apply(makeDomainDestination("www.163.com"))).IsTrue()
  16. assert.Bool(rule.Apply(makeDomainDestination("ngacn.cc"))).IsTrue()
  17. assert.Bool(rule.Apply(makeDomainDestination("12306.cn"))).IsTrue()
  18. assert.Bool(rule.Apply(makeDomainDestination("v2ray.com"))).IsFalse()
  19. }