diff --git a/app/router/condition_geoip_test.go b/app/router/condition_geoip_test.go index 8a3784d2f3a..b2fed7a5a1f 100644 --- a/app/router/condition_geoip_test.go +++ b/app/router/condition_geoip_test.go @@ -13,6 +13,33 @@ import ( "v2ray.com/ext/sysio" ) +func TestGeoIPMatcherContainer(t *testing.T) { + container := &router.GeoIPMatcherContainer{} + + m1, err := container.Add(&router.GeoIP{ + CountryCode: "CN", + }) + common.Must(err) + + m2, err := container.Add(&router.GeoIP{ + CountryCode: "US", + }) + common.Must(err) + + m3, err := container.Add(&router.GeoIP{ + CountryCode: "CN", + }) + common.Must(err) + + if m1 != m3 { + t.Error("expect same matcher for same geoip, but not") + } + + if m1 == m2 { + t.Error("expect different matcher for different geoip, but actually same") + } +} + func TestGeoIPMatcher(t *testing.T) { cidrList := router.CIDRList{ {Ip: []byte{0, 0, 0, 0}, Prefix: 8},