From 933e244d9264bea139428c476fcf6feebc967c53 Mon Sep 17 00:00:00 2001 From: v2ray Date: Thu, 18 Aug 2016 07:56:31 +0200 Subject: [PATCH] value receiver for StringList.Len() --- common/collect/string_list.go | 4 ++-- common/collect/string_list_json_test.go | 10 ++++++++++ 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/common/collect/string_list.go b/common/collect/string_list.go index 498f50eca..528c213e9 100644 --- a/common/collect/string_list.go +++ b/common/collect/string_list.go @@ -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) } diff --git a/common/collect/string_list_json_test.go b/common/collect/string_list_json_test.go index beb3d0690..ca2fdc119 100644 --- a/common/collect/string_list_json_test.go +++ b/common/collect/string_list_json_test.go @@ -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) +}