chinasites_test.go 771 B

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