1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-12-22 18:17:52 -05:00
v2fly/common/collect/string_list_json_test.go

31 lines
570 B
Go
Raw Normal View History

2016-01-21 18:53:51 -05:00
// +build json
2016-05-24 16:41:51 -04:00
package collect_test
2016-01-21 18:53:51 -05:00
import (
"encoding/json"
"testing"
2016-08-20 14:55:45 -04:00
. "v2ray.com/core/common/collect"
"v2ray.com/core/testing/assert"
2016-01-21 18:53:51 -05:00
)
func TestStringListUnmarshalError(t *testing.T) {
2016-05-24 15:55:46 -04:00
assert := assert.On(t)
2016-01-21 18:53:51 -05:00
rawJson := `1234`
2016-05-24 16:41:51 -04:00
list := new(StringList)
2016-01-21 18:53:51 -05:00
err := json.Unmarshal([]byte(rawJson), list)
assert.Error(err).IsNotNil()
}
2016-08-18 01:56:31 -04:00
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)
}