@@ -1080,18 +1080,24 @@ int32_t BigNumEncodeTests(void)
1080
1080
}
1081
1081
}
1082
1082
1083
+ #ifndef QCBOR_DISABLE_ENCODE_USAGE_GUARDS
1084
+ QCBORError uExpectedErr = QCBOR_ERR_NOT_PREFERRED ;
1085
+ #else
1086
+ QCBORError uExpectedErr = QCBOR_SUCCESS ;
1087
+ #endif /* !QCBOR_DISABLE_ENCODE_USAGE_GUARDS */
1088
+
1083
1089
/* Test failure for attempting non-prefered serialiation */
1084
1090
QCBOREncode_Init (& Enc , UsefulBuf_FROM_BYTE_ARRAY (spBigBuf ));
1085
1091
QCBOREncode_Config (& Enc , QCBOR_ENCODE_CONFIG_ONLY_PREFERRED_BIG_NUMBERS );
1086
1092
QCBOREncode_AddTBigNumberRaw (& Enc , QCBOR_ENCODE_AS_TAG , false, UsefulBuf_FROM_SZ_LITERAL ("\x00" ));
1087
- if (QCBOREncode_GetErrorState (& Enc ) != QCBOR_ERR_NOT_PREFERRED ) {
1093
+ if (QCBOREncode_GetErrorState (& Enc ) != uExpectedErr ) {
1088
1094
return -1 ;
1089
1095
}
1090
1096
1091
1097
QCBOREncode_Init (& Enc , UsefulBuf_FROM_BYTE_ARRAY (spBigBuf ));
1092
1098
QCBOREncode_Config (& Enc , QCBOR_ENCODE_CONFIG_ONLY_PREFERRED_BIG_NUMBERS );
1093
1099
QCBOREncode_AddTBigNumberNoPreferred (& Enc , QCBOR_ENCODE_AS_TAG , false, UsefulBuf_FROM_SZ_LITERAL ("\x00" ));
1094
- if (QCBOREncode_GetErrorState (& Enc ) != QCBOR_ERR_NOT_PREFERRED ) {
1100
+ if (QCBOREncode_GetErrorState (& Enc ) != uExpectedErr ) {
1095
1101
return -2 ;
1096
1102
}
1097
1103
@@ -3547,6 +3553,7 @@ OpenCloseBytesTest(void)
3547
3553
}
3548
3554
3549
3555
3556
+ #ifndef QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS
3550
3557
3551
3558
struct SortTests {
3552
3559
const char * szDescription ;
@@ -3613,7 +3620,7 @@ static const struct SortTests sSortTests[] =
3613
3620
QCBOR_SUCCESS
3614
3621
}
3615
3622
};
3616
-
3623
+ #endif /* ! QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS */
3617
3624
3618
3625
int32_t
3619
3626
SortMapTest (void )
@@ -3624,6 +3631,8 @@ SortMapTest(void)
3624
3631
QCBORError uErr ;
3625
3632
struct UBCompareDiagnostic CompareDiagnostics ;
3626
3633
3634
+ #ifndef QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS
3635
+
3627
3636
for (int nIndex = 0 ; ; nIndex ++ ) {
3628
3637
const struct SortTests * pTest = & sSortTests [nIndex ];
3629
3638
@@ -3657,6 +3666,7 @@ SortMapTest(void)
3657
3666
}
3658
3667
}
3659
3668
}
3669
+ #endif /* ! QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS */
3660
3670
// TODO: Move most of the tests below into sSortTests
3661
3671
3662
3672
@@ -4203,12 +4213,10 @@ int32_t DCBORTest(void)
4203
4213
QCBOREncode_Init (& EC , UsefulBuf_FROM_BYTE_ARRAY (spBigBuf ));
4204
4214
QCBOREncode_Config (& EC , QCBOR_ENCODE_CONFIG_DCBOR );
4205
4215
QCBOREncode_AddUndef (& EC );
4206
- QCBOREncode_CloseMap (& EC );
4207
4216
if (QCBOREncode_GetErrorState (& EC ) != uExpectedErr ) {
4208
4217
return 102 ;
4209
4218
}
4210
4219
4211
-
4212
4220
/* Improvement: when indefinite length string encoding is supported
4213
4221
* test it here too. */
4214
4222
0 commit comments