Skip to content

Commit

Permalink
update comments for icc fields spec example
Browse files Browse the repository at this point in the history
  • Loading branch information
alovak committed Aug 19, 2024
1 parent 446a89b commit ccfc21b
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions examples/icc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,30 @@ func TestICCField55(t *testing.T) {
Description: "Integrated Circuit Card (ICC) Data",
Pref: prefix.Binary.L,
Tag: &field.TagSpec{
Length: 1,
Enc: encoding.ASCIIHexToBytes,
Sort: sort.StringsByHex,
// We have 1 byte length tag, that in the spec is seen as a Hex string
// but will be encoded as a binary byte (ASCIIHexToBytes)
// We sort the TLV tags by their hex values, but it's not important
// Finally, if we have unknown tag, in order to skip it, we need to know
// how long its value is. For this, we need to read the length tag.
// To read the length tag, we need to know its length.
// Setting PrefUnknownTLV to prefix.Binary.LL will read the length prefix
// as a 2-byte binary value.
Length: 1,
Enc: encoding.ASCIIHexToBytes,
Sort: sort.StringsByHex,
SkipUnknownTLVTags: true,
// if we have unknown TLV tags,
PrefUnknownTLV: prefix.Binary.LL,
},
Subfields: map[string]field.Field{
"01": field.NewComposite(&field.Spec{
Length: 252,
Description: "VSDC Data",
Pref: prefix.Binary.LL,
Tag: &field.TagSpec{
Enc: encoding.BerTLVTag,
Sort: sort.StringsByHex,
Enc: encoding.BerTLVTag,
Sort: sort.StringsByHex,
SkipUnknownTLVTags: true,
},
Subfields: map[string]field.Field{
"9A": field.NewString(&field.Spec{
Expand Down

0 comments on commit ccfc21b

Please sign in to comment.