disable encode guards mostly working
diff --git a/test/qcbor_encode_tests.c b/test/qcbor_encode_tests.c
index c573a4b..57c4ff8 100644
--- a/test/qcbor_encode_tests.c
+++ b/test/qcbor_encode_tests.c
@@ -924,6 +924,8 @@
static const uint8_t spExpectedEncodedSimpleIndefiniteLength[] = {
0x9f, 0xf5, 0xf4, 0xf6, 0xf7, 0xbf, 0x65, 0x55, 0x4e, 0x44, 0x65, 0x66, 0xf7, 0xff, 0xff};
+// 9F F5 F4 F6 F7 BF 65 55 4E 44 65 66 F7 F8 1F F8 1F 69 73 20 74 68 65 20
+
int32_t SimpleValuesIndefiniteLengthTest1()
{
QCBOREncodeContext ECtx;
@@ -1780,8 +1782,12 @@
int32_t BstrWrapErrorTest()
{
- // ---- Test closing a bstrwrap when it is an array that is open ---------
QCBOREncodeContext EC;
+ UsefulBufC Wrapped;
+ UsefulBufC Encoded2;
+
+#ifndef QCBOR_DISABLE_ENCODE_USAGE_GUARDS
+ // ---- Test closing a bstrwrap when it is an array that is open ---------
QCBOREncode_Init(&EC, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
@@ -1792,12 +1798,10 @@
QCBOREncode_AddUInt64(&EC, 466);
QCBOREncode_OpenArray(&EC);
- UsefulBufC Wrapped;
QCBOREncode_CloseBstrWrap(&EC, &Wrapped);
QCBOREncode_CloseArray(&EC);
- UsefulBufC Encoded2;
if(QCBOREncode_Finish(&EC, &Encoded2) != QCBOR_ERR_CLOSE_MISMATCH) {
return -1;
}
@@ -1808,6 +1812,7 @@
if(QCBOREncode_Finish(&EC, &Encoded2) != QCBOR_ERR_TOO_MANY_CLOSES) {
return -2;
}
+#endif /* QCBOR_DISABLE_ENCODE_USAGE_GUARDS */
// --------------- test nesting too deep ----------------------------------
QCBOREncode_Init(&EC, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
@@ -2358,13 +2363,13 @@
// Second verify error from an array in encoded output too large
// Also test fetching the error code before finish
- QCBOREncode_Init(&EC, Buffer);
+ QCBOREncode_Init(&EC, (UsefulBuf){NULL, UINT32_MAX});
QCBOREncode_OpenArray(&EC);
- QCBOREncode_AddBytes(&EC, (UsefulBufC){NULL, UINT32_MAX-6});
+ QCBOREncode_AddBytes(&EC, (UsefulBufC){NULL, UINT32_MAX-10});
QCBOREncode_OpenArray(&EC); // Where QCBOR internally encounters and records error
if(QCBOREncode_GetErrorState(&EC) != QCBOR_ERR_BUFFER_TOO_LARGE) {
// Error fetch failed.
- return -12;
+ return -122;
}
QCBOREncode_CloseArray(&EC);
QCBOREncode_CloseArray(&EC);
@@ -2435,6 +2440,7 @@
}
+#ifndef QCBOR_DISABLE_ENCODE_USAGE_GUARDS
// ------ QCBOR_ERR_TOO_MANY_CLOSES --------
QCBOREncode_Init(&EC, Large);
for(int i = QCBOR_MAX_ARRAY_NESTING; i > 0; i--) {
@@ -2471,6 +2477,7 @@
// One more level to cause error
return -9;
}
+#endif /* QCBOR_DISABLE_ENCODE_USAGE_GUARDS */
/* QCBOR_ERR_ARRAY_TOO_LONG is not tested here as
it would require a 64KB of RAM to test */
@@ -2482,6 +2489,7 @@
return -11;
}
+#ifndef QCBOR_DISABLE_ENCODE_USAGE_GUARDS
// ------ QCBOR_ERR_UNSUPPORTED --------
QCBOREncode_Init(&EC, Large);
QCBOREncode_OpenArray(&EC);
@@ -2496,6 +2504,8 @@
if(QCBOREncode_FinishGetSize(&EC, &xx) != QCBOR_ERR_ENCODE_UNSUPPORTED) {
return -13;
}
+#endif /* #ifndef QCBOR_DISABLE_ENCODE_USAGE_GUARDS */
+
return 0;
}