@@ -3999,7 +3999,7 @@ struct TestInput {
3999
3999
* but still nice to organize into an array with descriptions. */
4000
4000
static const struct TestInput spTagInput2 [] = {
4001
4001
/* 0 */
4002
- "55799([4([1, 3])]), CBOR magic number in from of decimal fraction" ,
4002
+ "55799([4([1, 3])]), CBOR magic number in front of decimal fraction" ,
4003
4003
{
4004
4004
(uint8_t []){0xd9 , 0xd9 , 0xf7 , // CBOR magic number
4005
4005
0x81 , // Array of one
@@ -4346,16 +4346,11 @@ int32_t TagNumberDecodeTest(void)
4346
4346
return -10 ;
4347
4347
}
4348
4348
4349
- /* Testing with v2 */
4350
- QCBORDecode_Init (& DCtx ,
4351
- UsefulBuf_FROM_BYTE_ARRAY_LITERAL (spTagInput ),
4352
- QCBOR_DECODE_MODE_NORMAL );
4353
4349
4354
- /*
4355
- This test matches the magic number tag and the fraction tag
4356
- 55799([...])
4357
- */
4350
+ /* V2 tag mode testing */
4358
4351
uint64_t uTagNumber ;
4352
+
4353
+ QCBORDecode_Init (& DCtx , spTagInput2 [0 ].EncodedCBOR , QCBOR_DECODE_MODE_NORMAL );
4359
4354
uError = QCBORDecode_GetNextTagNumber (& DCtx , & uTagNumber );
4360
4355
if (uError != QCBOR_SUCCESS ) {
4361
4356
return -200 ;
@@ -4375,45 +4370,35 @@ int32_t TagNumberDecodeTest(void)
4375
4370
return -500 ;
4376
4371
}
4377
4372
4373
+ /* More than 4 tag numbers */
4374
+ QCBORDecode_Init (& DCtx , spTagInput2 [1 ].EncodedCBOR , QCBOR_DECODE_MODE_NORMAL );
4375
+ uError = QCBORDecode_GetNextTagNumber (& DCtx , & uTagNumber );
4376
+ if (uError != QCBOR_ERR_TOO_MANY_TAGS ) {
4377
+ return -2 ;
4378
+ }
4378
4379
4379
-
4380
- /*
4381
- 4([1,3])
4382
- */
4380
+ /* An array with for big tag numbers on it */
4381
+ QCBORDecode_Init (& DCtx , spTagInput2 [2 ].EncodedCBOR , QCBOR_DECODE_MODE_NORMAL );
4383
4382
uError = QCBORDecode_GetNextTagNumber (& DCtx , & uTagNumber );
4384
- if (uError != QCBOR_SUCCESS ) {
4385
- return -200 ;
4383
+ if (uError != QCBOR_SUCCESS || uTagNumber != 10489608748473423768ULL ) {
4384
+ return -81 ;
4386
4385
}
4387
- if (uTagNumber != CBOR_TAG_DECIMAL_FRACTION ) {
4388
- return -300 ;
4386
+ uError = QCBORDecode_GetNextTagNumber (& DCtx , & uTagNumber );
4387
+ if (uError != QCBOR_SUCCESS || uTagNumber != 2442302356ULL ) {
4388
+ return -81 ;
4389
4389
}
4390
-
4391
-
4392
- uError = QCBORDecode_GetNext (& DCtx , & Item );
4393
- if (uError != QCBOR_SUCCESS ||
4394
- Item .uDataType != QCBOR_TYPE_ARRAY ||
4395
- QCBORDecode_GetNthTag (& DCtx , & Item , 0 ) != CBOR_TAG_DECIMAL_FRACTION ||
4396
- QCBORDecode_GetNthTag (& DCtx , & Item , 1 ) != CBOR_TAG_INVALID64 ||
4397
- QCBORDecode_GetNthTag (& DCtx , & Item , 2 ) != CBOR_TAG_INVALID64 ||
4398
- QCBORDecode_GetNthTag (& DCtx , & Item , 3 ) != CBOR_TAG_INVALID64 ||
4399
- QCBORDecode_GetNthTag (& DCtx , & Item , 4 ) != CBOR_TAG_INVALID64 ||
4400
- Item .val .uCount != 2 ) {
4401
- return -4 ;
4390
+ uError = QCBORDecode_GetNextTagNumber (& DCtx , & uTagNumber );
4391
+ if (uError != QCBOR_SUCCESS || uTagNumber != 21590ULL ) {
4392
+ return -81 ;
4402
4393
}
4403
- // consume the items in the array
4404
- uError = QCBORDecode_GetNext (& DCtx , & Item );
4405
- uError = QCBORDecode_GetNext (& DCtx , & Item );
4406
-
4407
-
4408
- /*
4409
- More than 4 tags on an item 225(226(227(228(229([])))))
4410
- */
4411
4394
uError = QCBORDecode_GetNextTagNumber (& DCtx , & uTagNumber );
4412
- if (uError != QCBOR_ERR_TOO_MANY_TAGS ) {
4413
- return -2 ;
4395
+ if (uError != QCBOR_SUCCESS || uTagNumber != 240ULL ) {
4396
+ return -81 ;
4397
+ }
4398
+ uError = QCBORDecode_GetNext (& DCtx , & Item );
4399
+ if (uError != QCBOR_SUCCESS || Item .uDataType != QCBOR_TYPE_ARRAY ) {
4400
+ return -81 ;
4414
4401
}
4415
-
4416
-
4417
4402
4418
4403
4419
4404
/* Decode the four tag numbers and see success */
@@ -4463,9 +4448,7 @@ int32_t TagNumberDecodeTest(void)
4463
4448
return -9 ;
4464
4449
}
4465
4450
4466
-
4467
4451
/* The input is a bad decimal frac with extra tag number */
4468
- /* TODO: maybe look into how this behaved internally more */
4469
4452
QCBORDecode_Init (& DCtx , spTagInput2 [5 ].EncodedCBOR , QCBOR_DECODE_MODE_NORMAL );
4470
4453
QCBORDecode_InstallTagDecoders (& DCtx , QCBORDecode_TagDecoderTablev1 , NULL );
4471
4454
uError = QCBORDecode_GetNextTagNumber (& DCtx , & uTagNumber );
0 commit comments