gofmt and update encoding tags
This commit is contained in:
parent
89e4899841
commit
c4a2cbbbbe
5 changed files with 46 additions and 45 deletions
|
@ -206,19 +206,19 @@ type SVPair struct {
|
|||
|
||||
func TestDecode(t *testing.T) {
|
||||
tests := []SVPair{
|
||||
SVPair{"i0e", int64(0)},
|
||||
SVPair{"i0e", 0},
|
||||
SVPair{"i100e", 100},
|
||||
SVPair{"i-100e", -100},
|
||||
SVPair{"1:a", "a"},
|
||||
SVPair{"2:a\"", "a\""},
|
||||
SVPair{"11:0123456789a", "0123456789a"},
|
||||
SVPair{"le", []int64{}},
|
||||
SVPair{"li1ei2ee", []int{1, 2}},
|
||||
SVPair{"l3:abc3:defe", []string{"abc", "def"}},
|
||||
SVPair{"li42e3:abce", []any{42, "abc"}},
|
||||
SVPair{"de", map[string]any{}},
|
||||
SVPair{"d3:cati1e3:dogi2ee", map[string]any{"cat": 1, "dog": 2}},
|
||||
{"i0e", int64(0)},
|
||||
{"i0e", 0},
|
||||
{"i100e", 100},
|
||||
{"i-100e", -100},
|
||||
{"1:a", "a"},
|
||||
{"2:a\"", "a\""},
|
||||
{"11:0123456789a", "0123456789a"},
|
||||
{"le", []int64{}},
|
||||
{"li1ei2ee", []int{1, 2}},
|
||||
{"l3:abc3:defe", []string{"abc", "def"}},
|
||||
{"li42e3:abce", []any{42, "abc"}},
|
||||
{"de", map[string]any{}},
|
||||
{"d3:cati1e3:dogi2ee", map[string]any{"cat": 1, "dog": 2}},
|
||||
}
|
||||
for _, sv := range tests {
|
||||
if err := check(sv.s, sv.v); err != nil {
|
||||
|
@ -244,19 +244,19 @@ func TestUnmarshal(t *testing.T) {
|
|||
nestedDictionary := structNested{"aa", "q", "ping", innerDict}
|
||||
|
||||
tests := []SVPair{
|
||||
SVPair{"i100e", 100},
|
||||
SVPair{"i-100e", -100},
|
||||
SVPair{"1:a", "a"},
|
||||
SVPair{"2:a\"", "a\""},
|
||||
SVPair{"11:0123456789a", "0123456789a"},
|
||||
SVPair{"le", []int64{}},
|
||||
SVPair{"li1ei2ee", []int{1, 2}},
|
||||
SVPair{"l3:abc3:defe", []string{"abc", "def"}},
|
||||
SVPair{"li42e3:abce", []any{42, "abc"}},
|
||||
SVPair{"de", map[string]any{}},
|
||||
SVPair{"d3:cati1e3:dogi2ee", map[string]any{"cat": 1, "dog": 2}},
|
||||
SVPair{"d1:ai10e1:b3:foo11:sea monster3:bare", structA{10, "foo", "bar"}},
|
||||
SVPair{"d1:ad2:id20:abcdefghij0123456789e1:q4:ping1:t2:aa1:y1:qe", nestedDictionary},
|
||||
{"i100e", 100},
|
||||
{"i-100e", -100},
|
||||
{"1:a", "a"},
|
||||
{"2:a\"", "a\""},
|
||||
{"11:0123456789a", "0123456789a"},
|
||||
{"le", []int64{}},
|
||||
{"li1ei2ee", []int{1, 2}},
|
||||
{"l3:abc3:defe", []string{"abc", "def"}},
|
||||
{"li42e3:abce", []any{42, "abc"}},
|
||||
{"de", map[string]any{}},
|
||||
{"d3:cati1e3:dogi2ee", map[string]any{"cat": 1, "dog": 2}},
|
||||
{"d1:ai10e1:b3:foo11:sea monster3:bare", structA{10, "foo", "bar"}},
|
||||
{"d1:ad2:id20:abcdefghij0123456789e1:q4:ping1:t2:aa1:y1:qe", nestedDictionary},
|
||||
}
|
||||
for _, sv := range tests {
|
||||
if err := checkUnmarshal(sv.s, sv.v); err != nil {
|
||||
|
|
|
@ -66,7 +66,7 @@ func (j *decoder) Elem(i int) builder {
|
|||
v = make([]interface{}, 0, 8)
|
||||
j.value = v
|
||||
}
|
||||
/* XXX There is a bug in here somewhere, but append() works fine.
|
||||
/* XXX There is a bug in here somewhere, but append() works fine.
|
||||
lens := len(v)
|
||||
if cap(v) <= lens {
|
||||
news := make([]interface{}, 0, lens*2)
|
||||
|
@ -74,7 +74,7 @@ func (j *decoder) Elem(i int) builder {
|
|||
v = news
|
||||
}
|
||||
v = v[0 : lens+1]
|
||||
*/
|
||||
*/
|
||||
v = append(v, nil)
|
||||
j.value = v
|
||||
return newDecoder(v, i)
|
||||
|
|
|
@ -534,7 +534,7 @@ func isValueNil(val reflect.Value) bool {
|
|||
// an infinite recursion.
|
||||
//
|
||||
func Marshal(w io.Writer, val interface{}) error {
|
||||
// TODO match other encoders, like encoding/json ...
|
||||
// func Marshal(v interface{}) ([]byte, error)
|
||||
// TODO match other encoders, like encoding/json ...
|
||||
// func Marshal(v interface{}) ([]byte, error)
|
||||
return writeValue(w, reflect.ValueOf(val))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue