mirror of
https://github.com/golang/go
synced 2024-11-21 12:04:41 -07:00
encoding/asn1: unmarshal enumerated values correctly into ANY
Previously we didn't unmarshal enumerated values into any, now we do. Also add a test-case that covers this.
This commit is contained in:
parent
49dd7726a9
commit
56b246dd45
@ -728,6 +728,10 @@ func parseField(v reflect.Value, bytes []byte, initOffset int, params fieldParam
|
||||
result = innerBytes
|
||||
case TagBMPString:
|
||||
result, err = parseBMPString(innerBytes)
|
||||
case TagEnum:
|
||||
parsedInt, err1 := parseInt32(innerBytes)
|
||||
result = Enumerated(parsedInt)
|
||||
err = err1
|
||||
default:
|
||||
// If we don't know how to handle the type, we just leave Value as nil.
|
||||
}
|
||||
|
@ -506,6 +506,7 @@ var unmarshalTestData = []struct {
|
||||
{[]byte{0x30, 0x05, 0x02, 0x03, 0x12, 0x34, 0x56}, &TestBigInt{big.NewInt(0x123456)}},
|
||||
{[]byte{0x30, 0x0b, 0x31, 0x09, 0x02, 0x01, 0x01, 0x02, 0x01, 0x02, 0x02, 0x01, 0x03}, &TestSet{Ints: []int{1, 2, 3}}},
|
||||
{[]byte{0x12, 0x0b, '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', ' '}, newString("0123456789 ")},
|
||||
{[]byte{0x30, 0x0f, 0x06, 0x0a, 0x2a, 0x86, 0x48, 0x86, 0xf8, 0x4d, 0x01, 0x0d, 0x01, 0x05, 0x0a, 0x01, 0x01}, &AttributeTypeAndValue{Type: ObjectIdentifier{1, 2, 840, 113741, 1, 13, 1, 5}, Value: Enumerated(1)}},
|
||||
}
|
||||
|
||||
func TestUnmarshal(t *testing.T) {
|
||||
|
Loading…
Reference in New Issue
Block a user