Merge floating-point disabling into spiffy decode
diff --git a/test/qcbor_decode_tests.c b/test/qcbor_decode_tests.c
index deb4c6c..c3dcc1e 100644
--- a/test/qcbor_decode_tests.c
+++ b/test/qcbor_decode_tests.c
@@ -372,7 +372,7 @@
return -1;
- if(( nCBORError = QCBORDecode_GetNext(pDCtx, &Item)))
+ if(( nCBORError = QCBORDecode_GetNext(pDCtx, &Item)))
return (int32_t)nCBORError;
if(Item.uDataType != QCBOR_TYPE_INT64 ||
Item.val.int64 != 4294967295)
@@ -1276,19 +1276,19 @@
UsefulBuf_Compare(Item.val.string, UsefulBuf_FromSZ("lies, damn lies and statistics"))) {
return -17;
}
-
-
+
+
/*
Test with map that nearly QCBOR_MAX_ITEMS_IN_ARRAY items in a
map that when interpreted as an array will be too many. Test
data just has the start of the map, not all the items in the map.
*/
static const uint8_t pTooLargeMap[] = {0xb9, 0xff, 0xfd};
-
+
QCBORDecode_Init(&DCtx,
UsefulBuf_FROM_BYTE_ARRAY_LITERAL(pTooLargeMap),
QCBOR_DECODE_MODE_MAP_AS_ARRAY);
-
+
if((QCBOR_ERR_ARRAY_TOO_LONG != QCBORDecode_GetNext(&DCtx, &Item))) {
return -50;
}
@@ -2105,14 +2105,14 @@
0x1a, 0x53, 0x72, 0x4E, 0x00, // Epoch date 1400000000; Tue, 13 May 2014 16:53:20 GMT
// CBOR_TAG_B64
- 0xc1, 0xcf, 0xd8, 0x22, // 0xee, // Epoch date with extra tags TODO: fix this test
+ 0xc1, 0xcf, 0xd8, 0x22, // 0xee, // Epoch date with extra tags
0x1a, 0x53, 0x72, 0x4E, 0x01,
0xc1, // tag for epoch date
0x1b, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, 0xf0, // Too large integer
0xc1, // tag for epoch date
- 0xfa, 0x3f, 0x8c, 0xcc, 0xcd, // double with value 1.1
+ 0xfa, 0x3f, 0x8c, 0xcc, 0xcd, // single with value 1.1
0xc1, // tag for epoch date
0xfa, 0x7f, 0x7f, 0xff, 0xff, // 3.4028234663852886e+38 too large
@@ -2127,7 +2127,7 @@
// have to check float expected only to within an epsilon
-int CHECK_EXPECTED_DOUBLE(double val, double expected) {
+static int CHECK_EXPECTED_DOUBLE(double val, double expected) {
double diff = val - expected;
@@ -2160,7 +2160,7 @@
return -2;
}
- // Epoch date
+ // Epoch date 1400000000; Tue, 13 May 2014 16:53:20 GMT
if((nCBORError = QCBORDecode_GetNext(&DCtx, &Item)))
return -3;
if(Item.uDataType != QCBOR_TYPE_DATE_EPOCH ||
@@ -2186,6 +2186,7 @@
}
// Epoch date in float format with fractional seconds
+#ifndef QCBOR_DISABLE_FLOAT_HW_USE
if((nCBORError = QCBORDecode_GetNext(&DCtx, &Item)))
return -8;
if(Item.uDataType != QCBOR_TYPE_DATE_EPOCH ||
@@ -2205,12 +2206,28 @@
}
// Largest double epoch date supported
- if(QCBORDecode_GetNext(&DCtx, &Item) != QCBOR_SUCCESS ||
- Item.uDataType != QCBOR_TYPE_DATE_EPOCH ||
- Item.val.epochDate.nSeconds != 9223372036854773760 ||
- Item.val.epochDate.nSeconds == 0) {
- return -12;
+ if(QCBORDecode_GetNext(&DCtx, &Item) != QCBOR_SUCCESS ||
+ Item.uDataType != QCBOR_TYPE_DATE_EPOCH ||
+ Item.val.epochDate.nSeconds != 9223372036854773760 ||
+ Item.val.epochDate.nSeconds == 0) {
+ return -12;
+ }
+#else
+ if(QCBORDecode_GetNext(&DCtx, &Item) != QCBOR_ERR_FLOAT_DATE_UNSUPPORTED) {
+ return -80;
}
+ if(QCBORDecode_GetNext(&DCtx, &Item) != QCBOR_ERR_FLOAT_DATE_UNSUPPORTED) {
+ return -80;
+ }
+ if(QCBORDecode_GetNext(&DCtx, &Item) != QCBOR_ERR_FLOAT_DATE_UNSUPPORTED) {
+ return -80;
+ }
+ if(QCBORDecode_GetNext(&DCtx, &Item) != QCBOR_ERR_FLOAT_DATE_UNSUPPORTED) {
+ return -80;
+ }
+#endif
+
+
// TODO: could use a few more tests with float, double, and half precsion
// and negative (but coverage is still pretty good)
@@ -4096,8 +4113,10 @@
[],
[]
]
- }
+ }
*/
+
+
static const uint8_t spMapOfEmpty[] = {
0xa6, 0x00, 0x80, 0x09, 0x82, 0x80, 0x80, 0x08, 0xa3, 0x01,
0x80, 0x02, 0xa0, 0x03, 0x80, 0x04, 0xa0, 0x05, 0x9f, 0xff,
@@ -4826,15 +4845,15 @@
if(uCBORError != QCBOR_SUCCESS) {
return 5;
}
-
-
+
+
// --- Sequence with unclosed indefinite length array ---
static const uint8_t xx[] = {0x01, 0x9f, 0x02};
-
+
QCBORDecode_Init(&DCtx,
UsefulBuf_FROM_BYTE_ARRAY_LITERAL(xx),
QCBOR_DECODE_MODE_NORMAL);
-
+
// Get the first item
uCBORError = QCBORDecode_GetNext(&DCtx, &Item);
if(uCBORError != QCBOR_SUCCESS) {
@@ -4843,7 +4862,7 @@
if(Item.uDataType != QCBOR_TYPE_INT64) {
return 8;
}
-
+
// Get a second item
uCBORError = QCBORDecode_GetNext(&DCtx, &Item);
if(uCBORError != QCBOR_SUCCESS) {
@@ -4860,14 +4879,14 @@
return 11;
}
-
+
// --- Sequence with a closed indefinite length array ---
static const uint8_t yy[] = {0x01, 0x9f, 0xff};
-
+
QCBORDecode_Init(&DCtx,
UsefulBuf_FROM_BYTE_ARRAY_LITERAL(yy),
QCBOR_DECODE_MODE_NORMAL);
-
+
// Get the first item
uCBORError = QCBORDecode_GetNext(&DCtx, &Item);
if(uCBORError != QCBOR_SUCCESS) {
@@ -4876,7 +4895,7 @@
if(Item.uDataType != QCBOR_TYPE_INT64) {
return 13;
}
-
+
// Get a second item
uCBORError = QCBORDecode_GetNext(&DCtx, &Item);
if(uCBORError != QCBOR_SUCCESS) {
@@ -4893,7 +4912,7 @@
return 16;
}
-
+
return 0;
}