1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-01-02 23:47:07 -05:00

value receiver for StringList.Len()

This commit is contained in:
v2ray 2016-08-18 07:56:31 +02:00
parent 89a876a6d4
commit 933e244d92
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
2 changed files with 12 additions and 2 deletions

View File

@ -7,6 +7,6 @@ func NewStringList(raw []string) *StringList {
return &list
}
func (this *StringList) Len() int {
return len(*this)
func (this StringList) Len() int {
return len(this)
}

View File

@ -18,3 +18,13 @@ func TestStringListUnmarshalError(t *testing.T) {
err := json.Unmarshal([]byte(rawJson), list)
assert.Error(err).IsNotNil()
}
func TestStringListLen(t *testing.T) {
assert := assert.On(t)
rawJson := `"a, b, c, d"`
list := new(StringList)
err := json.Unmarshal([]byte(rawJson), list)
assert.Error(err).IsNil()
assert.Int(list.Len()).Equals(4)
}