Skip to content

Add comprehensive CBOR_Packet unit tests covering nested structures and realistic models#28

Closed
Copilot wants to merge 6 commits into
masterfrom
copilot/create-cbor-fields-similar-asn1
Closed

Add comprehensive CBOR_Packet unit tests covering nested structures and realistic models#28
Copilot wants to merge 6 commits into
masterfrom
copilot/create-cbor-fields-similar-asn1

Conversation

Copilot AI commented Mar 17, 2026

Copy link
Copy Markdown

Expands CBOR test coverage from 378 to 413 passing tests, adding 35 new tests targeting CBOR_Packet with complex field compositions that were previously untested or only minimally covered.

New test categories

  • CBORF_PACKET nesting — 3-level deep nesting (ARRAY→ARRAY→ARRAY), CBORF_PACKET inside CBORF_MAP, and the Document/Metadata nested MAP-in-MAP pattern
  • CBORF_ARRAY_OF with CBOR_Packet elements — encode/decode/roundtrip/empty, including CBORF_ARRAY_OF embedded in a CBORF_MAP via CBORF_PACKET
  • CBORF_optional edge cases — type-mismatch sets field to None, correct type decoded normally, behavior inside CBORF_MAP when key is present vs. absent
  • CBORF_SEMANTIC_TAG extendedTEXT_STRING inner (cbor2 decodes to datetime), INTEGER unix timestamp, tag byte major-type assertion, byte-exact comparison with cbor2.CBORTag, inside both CBORF_MAP and CBORF_ARRAY
  • Realistic models — EAT-like attestation token, SensorReport with nested CBORF_PACKET inner reading, HttpStatusList (CBORF_ARRAY_OF of CBOR_Packets), HTTP response header map, COSE-like header with negative algorithm value

Notable pitfalls documented via tests

CBORF_INTEGER.val = -7 on a field defaulted to 0 fails at build time because the stored object is CBOR_UNSIGNED_INTEGER; feeding the negative value via cbor2.dumps(...) and dissecting it first is required:

# Wrong: pkt.alg.val = -7  →  CBOR_Codec_Encoding_Error at bytes(pkt)
pkt = CoseHeader(cbor2.dumps({'alg': -7, 'kid': 'key-42'}))  # correct
dec = cbor2.loads(bytes(pkt))
assert dec['alg'] == -7

📱 Kick off Copilot coding agent tasks wherever you are with GitHub Mobile, available on iOS and Android.

Copilot AI self-assigned this Mar 17, 2026
Co-authored-by: polybassa <1676055+polybassa@users.noreply.github.com>
Copilot AI changed the title [WIP] Add CBOR fields similar to ASN1 fields Add CBOR fields and packet class mirroring ASN.1 fields infrastructure Mar 17, 2026
Copilot AI requested a review from polybassa March 17, 2026 22:40
Co-authored-by: polybassa <1676055+polybassa@users.noreply.github.com>
@polybassa

Copy link
Copy Markdown
Owner

@copilot add more unit test and interoperability tests with the cbor2 library

Co-authored-by: polybassa <1676055+polybassa@users.noreply.github.com>
Copilot AI changed the title Add CBOR fields and packet class mirroring ASN.1 fields infrastructure Add cbor2 interoperability tests for CBORF fields Mar 18, 2026
Co-authored-by: polybassa <1676055+polybassa@users.noreply.github.com>
…, SEMANTIC_TAG, realistic models

Co-authored-by: polybassa <1676055+polybassa@users.noreply.github.com>
Copilot AI changed the title Add cbor2 interoperability tests for CBORF fields Add comprehensive CBOR_Packet unit tests covering nested structures and realistic models Mar 18, 2026
@polybassa polybassa closed this Apr 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants