chinasites_json_test.go 750 B

123456789101112131415161718192021222324252627
  1. // +build json
  2. package rules_test
  3. import (
  4. "testing"
  5. . "github.com/v2ray/v2ray-core/app/router/rules"
  6. v2testing "github.com/v2ray/v2ray-core/testing"
  7. "github.com/v2ray/v2ray-core/testing/assert"
  8. )
  9. func TestChinaSitesJson(t *testing.T) {
  10. v2testing.Current(t)
  11. rule := ParseRule([]byte(`{
  12. "type": "chinasites",
  13. "outboundTag": "y"
  14. }`))
  15. assert.StringLiteral(rule.Tag).Equals("y")
  16. assert.Bool(rule.Apply(makeDomainDestination("v.qq.com"))).IsTrue()
  17. assert.Bool(rule.Apply(makeDomainDestination("www.163.com"))).IsTrue()
  18. assert.Bool(rule.Apply(makeDomainDestination("ngacn.cc"))).IsTrue()
  19. assert.Bool(rule.Apply(makeDomainDestination("12306.cn"))).IsTrue()
  20. assert.Bool(rule.Apply(makeDomainDestination("v2ray.com"))).IsFalse()
  21. }