Skip to content

Commit fdea1c9

Browse files
author
Laurence Lundblade
committed
Fix ifdef test fan out
1 parent 9bf731a commit fdea1c9

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

test/qcbor_encode_tests.c

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1080,18 +1080,24 @@ int32_t BigNumEncodeTests(void)
10801080
}
10811081
}
10821082

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+
10831089
/* Test failure for attempting non-prefered serialiation */
10841090
QCBOREncode_Init(&Enc, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
10851091
QCBOREncode_Config(&Enc, QCBOR_ENCODE_CONFIG_ONLY_PREFERRED_BIG_NUMBERS);
10861092
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) {
10881094
return -1;
10891095
}
10901096

10911097
QCBOREncode_Init(&Enc, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
10921098
QCBOREncode_Config(&Enc, QCBOR_ENCODE_CONFIG_ONLY_PREFERRED_BIG_NUMBERS);
10931099
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) {
10951101
return -2;
10961102
}
10971103

@@ -3547,6 +3553,7 @@ OpenCloseBytesTest(void)
35473553
}
35483554

35493555

3556+
#ifndef QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS
35503557

35513558
struct SortTests {
35523559
const char *szDescription;
@@ -3613,7 +3620,7 @@ static const struct SortTests sSortTests[] =
36133620
QCBOR_SUCCESS
36143621
}
36153622
};
3616-
3623+
#endif /* ! QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS */
36173624

36183625
int32_t
36193626
SortMapTest(void)
@@ -3624,6 +3631,8 @@ SortMapTest(void)
36243631
QCBORError uErr;
36253632
struct UBCompareDiagnostic CompareDiagnostics;
36263633

3634+
#ifndef QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS
3635+
36273636
for(int nIndex = 0; ; nIndex++) {
36283637
const struct SortTests *pTest = &sSortTests[nIndex];
36293638

@@ -3657,6 +3666,7 @@ SortMapTest(void)
36573666
}
36583667
}
36593668
}
3669+
#endif /* ! QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS */
36603670
// TODO: Move most of the tests below into sSortTests
36613671

36623672

@@ -4203,12 +4213,10 @@ int32_t DCBORTest(void)
42034213
QCBOREncode_Init(&EC, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
42044214
QCBOREncode_Config(&EC, QCBOR_ENCODE_CONFIG_DCBOR);
42054215
QCBOREncode_AddUndef(&EC);
4206-
QCBOREncode_CloseMap(&EC);
42074216
if(QCBOREncode_GetErrorState(&EC) != uExpectedErr) {
42084217
return 102;
42094218
}
42104219

4211-
42124220
/* Improvement: when indefinite length string encoding is supported
42134221
* test it here too. */
42144222

0 commit comments

Comments
 (0)