1
0
mirror of https://github.com/json-iterator/go.git synced 2025-06-15 22:50:24 +02:00

fix random go test failure

This commit is contained in:
Tao Wen
2017-06-02 17:34:40 +08:00
parent 59e71bacc8
commit e36f926072
7 changed files with 16 additions and 9 deletions

View File

@ -102,8 +102,11 @@ func Test_object_any_lazy_iterator(t *testing.T) {
should.Equal(map[string]string{"a":"b", "c":"d"}, vals)
vals = map[string]string{}
for next, hasNext := any.IterateObject(); hasNext; k, v, hasNext = next() {
vals[k] = v.ToString()
for next, hasNext := any.IterateObject(); hasNext; {
k, v, hasNext = next()
if v.ValueType() == String {
vals[k] = v.ToString()
}
}
should.Equal(map[string]string{"a":"b", "c":"d"}, vals)
}
@ -150,7 +153,7 @@ func Test_object_lazy_any_get_all(t *testing.T) {
should := require.New(t)
any, err := UnmarshalAnyFromString(`{"a":[0],"b":[1]}`)
should.Nil(err)
should.Equal(`{"a":0,"b":1}`, any.Get('*', 0).ToString())
should.Contains(any.Get('*', 0).ToString(), `"a":0`)
}
func Test_object_lazy_any_get_invalid(t *testing.T) {
@ -201,7 +204,7 @@ func Test_object_wrapper_any_get_all(t *testing.T) {
Field2 []int
}
any := Wrap(TestObject{[]int{1, 2}, []int{3, 4}})
should.Equal(`{"Field2":3,"Field1":1}`, any.Get('*', 0).ToString())
should.Contains(any.Get('*', 0).ToString(), `"Field2":3`)
}
func Test_write_object(t *testing.T) {