From 9d51bd2985b102b0bed278ff7a1fd4ca42ae24cb Mon Sep 17 00:00:00 2001 From: v2ray Date: Tue, 8 Dec 2015 18:19:40 +0100 Subject: [PATCH] test case for chinaip --- app/router/rules/json/chinaip_test.go | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 app/router/rules/json/chinaip_test.go diff --git a/app/router/rules/json/chinaip_test.go b/app/router/rules/json/chinaip_test.go new file mode 100644 index 00000000..8d611e95 --- /dev/null +++ b/app/router/rules/json/chinaip_test.go @@ -0,0 +1,25 @@ +package json + +import ( + "net" + "testing" + + v2net "github.com/v2ray/v2ray-core/common/net" + v2testing "github.com/v2ray/v2ray-core/testing" + "github.com/v2ray/v2ray-core/testing/assert" +) + +func makeDestination(ip string) v2net.Destination { + return v2net.NewTCPDestination(v2net.IPAddress(net.ParseIP(ip), 80)) +} + +func TestChinaIP(t *testing.T) { + v2testing.Current(t) + + rule := &ChinaIPRule{} + assert.Bool(rule.Apply(makeDestination("121.14.1.189"))).IsTrue() // sina.com.cn + assert.Bool(rule.Apply(makeDestination("101.226.103.106"))).IsTrue() // qq.com + assert.Bool(rule.Apply(makeDestination("115.239.210.36"))).IsTrue() // image.baidu.com + + assert.Bool(rule.Apply(makeDestination("8.8.8.8"))).IsFalse() +}