Compare commits
3 Commits
c8a2f03ca1
...
c118a4d7ef
Author | SHA1 | Date | |
---|---|---|---|
c118a4d7ef | |||
877698d402 | |||
5989a82bee |
@ -129,7 +129,7 @@ func decodeAny(decoder *Decoder, destination reflect.Value, tag Tag) (n int, err
|
|||||||
return n, errWrongDestinationType("slice")
|
return n, errWrongDestinationType("slice")
|
||||||
}
|
}
|
||||||
if destination.Cap() < int(length) {
|
if destination.Cap() < int(length) {
|
||||||
destination.Grow(destination.Cap() - int(length))
|
destination.Grow(int(length) - destination.Cap())
|
||||||
}
|
}
|
||||||
destination.SetLen(int(length))
|
destination.SetLen(int(length))
|
||||||
for index := range length {
|
for index := range length {
|
||||||
@ -154,7 +154,7 @@ func decodeAny(decoder *Decoder, destination reflect.Value, tag Tag) (n int, err
|
|||||||
if err != nil { return n, err }
|
if err != nil { return n, err }
|
||||||
nn, err = decodeAny(decoder, value.Elem(), itemTag)
|
nn, err = decodeAny(decoder, value.Elem(), itemTag)
|
||||||
n += nn; if err != nil { return n, err }
|
n += nn; if err != nil { return n, err }
|
||||||
table.SetMapIndex(reflect.ValueOf(key), value)
|
table.SetMapIndex(reflect.ValueOf(key), value.Elem())
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
return n, fmt.Errorf("unknown TN %d", tag.TN())
|
return n, fmt.Errorf("unknown TN %d", tag.TN())
|
||||||
@ -352,7 +352,6 @@ func peekSlice(decoder *Decoder, tag Tag) (Tag, int, error) {
|
|||||||
currentTag = elem
|
currentTag = elem
|
||||||
offset = n
|
offset = n
|
||||||
dimension += 1
|
dimension += 1
|
||||||
fmt.Println(n)
|
|
||||||
if elem.Is(OTA) {
|
if elem.Is(OTA) {
|
||||||
if !populated {
|
if !populated {
|
||||||
// default to a large byte array, will be
|
// default to a large byte array, will be
|
||||||
|
@ -56,11 +56,11 @@ func TestEncodeAnyTable(test *testing.T) {
|
|||||||
if err != nil { test.Fatal(err) }
|
if err != nil { test.Fatal(err) }
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestEncodeDecodeAnyMap(test *testing.T) {
|
func TestEncodeDecodeAnyTable(test *testing.T) {
|
||||||
err := testEncodeDecodeAny(test, map[uint16] any {
|
err := testEncodeDecodeAny(test, map[uint16] any {
|
||||||
0xF3B9: 1,
|
0xF3B9: 1,
|
||||||
0x0102: 2,
|
0x0102: 2,
|
||||||
0x0000: "hi!",
|
0x0000: []byte("hi!"),
|
||||||
0xFFFF: []uint16 { 0xBEE5, 0x7777 },
|
0xFFFF: []uint16 { 0xBEE5, 0x7777 },
|
||||||
0x1234: [][]uint16 { []uint16 { 0x5 }, []uint16 { 0x17, 0xAAAA} },
|
0x1234: [][]uint16 { []uint16 { 0x5 }, []uint16 { 0x17, 0xAAAA} },
|
||||||
}, nil)
|
}, nil)
|
||||||
|
Loading…
Reference in New Issue
Block a user