CDE and dCBOR encode-side support (#193)
A mode that errors out if non-preferred serialization is attempted.
Layered on top of that is CDE mode that always sorts maps.
Layered on top of the dCBOR mode, that disallows a few things and unifies encoding of the float and integer number spaces. There is no change to decoding, though some are planned.
NaN Payloads can no longer be output by default. You must explicitly allow them. This is a non-compatibility with QCBOR 1.x
65-bit negative integers also cannot be output without explicitly allowing them.
* CDE and dCBOR support
* Tests for single precision and exponent boundaries
* test complete and passing; code clean up; bug fix
* Add comments for encoding modes
* tidy up and documentation
* Check point progress on CDE, preferred and dCBOR
* documentation updates
* Minor test fixes; minor code improvements
* full test fan out passes
* Formatting and documentation nits
---------
Co-authored-by: Laurence Lundblade <lgl@securitytheory.com>
diff --git a/test/float_tests.c b/test/float_tests.c
index 1a7ade1..ce078d4 100644
--- a/test/float_tests.c
+++ b/test/float_tests.c
@@ -41,16 +41,16 @@
#include "half_to_double_from_rfc7049.h"
-struct DoubleTestCase {
+struct FloatTestCase {
double dNumber;
- double fNumber;
+ float fNumber;
UsefulBufC Preferred;
UsefulBufC NotPreferred;
UsefulBufC CDE;
UsefulBufC DCBOR;
};
-/* Boundaries for all destination conversions to test at.
+/* Boundaries for destination conversions:
*
* smallest subnormal single 1.401298464324817e-45 2^^-149
* largest subnormal single 1.1754942106924411e-38 2^^-126
@@ -62,29 +62,34 @@
* smallest normal half 6.103515625E-5
* largest half 65504.0
*
- * Boundaries for origin conversions
+ * Boundaries for origin conversions:
* smallest subnormal double 5.0e-324 2^^-1074
* largest subnormal double
* smallest normal double 2.2250738585072014e-308 2^^-1022
* largest normal double 1.7976931348623157e308 2^^-1023
+ *
+ * Boundaries for double conversion to 64-bit integer:
+ * exponent 51, 52 significand bits set 4503599627370495
+ * exponent 52, 52 significand bits set 9007199254740991
+ * exponent 53, 52 bits set in significand 18014398509481982
*/
/* Always four lines per test case so shell scripts can process into
- * other formats. CDE and DCBOR standards are not complete yet,
- * encodings are a guess. C string literals are used because they
+ * other formats. CDE and DCBOR standards are not complete yet,
+ * encodings are what is expected. C string literals are used because they
* are the shortest notation. They are used __with a length__ . Null
- * termination doesn't work because * there are zero bytes.
+ * termination doesn't work because there are zero bytes.
*/
-static const struct DoubleTestCase DoubleTestCases[] = {
+static const struct FloatTestCase FloatTestCases[] = {
/* Zero */
{0.0, 0.0f,
{"\xF9\x00\x00", 3}, {"\xFB\x00\x00\x00\x00\x00\x00\x00\x00", 9},
- {"\xF9\x00\x00", 3}, {"\xF9\x00\x00", 3}},
+ {"\xF9\x00\x00", 3}, {"\x00", 1}},
/* Negative Zero */
{-0.0, -0.0f,
{"\xF9\x80\x00", 3}, {"\xFB\x80\x00\x00\x00\x00\x00\x00\x00", 9},
- {"\xF9\x80\x00", 3}, {"\xF9\x80\x00", 3}},
+ {"\xF9\x80\x00", 3}, {"\x00", 1}},
/* NaN */
{NAN, NAN,
@@ -104,12 +109,12 @@
/* 1.0 */
{1.0, 1.0f,
{"\xF9\x3C\x00", 3}, {"\xFB\x3F\xF0\x00\x00\x00\x00\x00\x00", 9},
- {"\xF9\x3C\x00", 3}, {"\xF9\x3C\x00", 3}},
+ {"\xF9\x3C\x00", 3}, {"\x01", 1}},
- /* -2.0 -- a negative number that is not zero */
+ /* -2.0 -- a negative */
{-2.0, -2.0f,
{"\xF9\xC0\x00", 3}, {"\xFB\xC0\x00\x00\x00\x00\x00\x00\x00", 9},
- {"\xF9\xC0\x00", 3}, {"\xF9\x3C\x00", 3}},
+ {"\xF9\xC0\x00", 3}, {"\x21", 1}},
/* 1/3 */
{0.333251953125, 0.333251953125f,
@@ -129,45 +134,44 @@
/* 6.097555160522461E-5 -- largest half-precision subnormal */
{6.097555160522461E-5, 0.0f,
{"\xF9\x03\xFF", 3}, {"\xFB\x3F\x0F\xF8\x00\x00\x00\x00\x00", 9},
- {"\xF9\x03\xFF", 3}, {"\xF9\04\00", 3}},
-
- /* 6.103515625E-5 -- smallest possible half-precision normal */
- {6.103515625E-5, 0.0f,
- {"\xF9\04\00", 3}, {"\xFB\x3F\x10\x00\x00\x00\x00\x00\x00", 9},
- {"\xF9\04\00", 3}, {"\xF9\04\00", 3}},
-
- /* 6.1035156250000014E-5 -- slightly larger than smallest half-precision normal */
- {6.1035156250000014E-5, 6.1035156250000014E-5f,
- {"\xFB\x3F\x10\x00\x00\x00\x00\x00\x01", 9}, {"\xFB\x3F\x10\x00\x00\x00\x00\x00\x01", 9},
- {"\xFB\x3F\x10\x00\x00\x00\x00\x00\x01", 9}, {"\xFB\x3F\x10\x00\x00\x00\x00\x00\x01", 9}},
+ {"\xF9\x03\xFF", 3}, {"\xF9\x03\xFF", 3}},
/* 6.1035156249999993E-5 -- slightly smaller than smallest half-precision normal */
{6.1035156249999993E-5, 0.0f,
{"\xFB\x3F\x0F\xFF\xFF\xFF\xFF\xFF\xFF", 9}, {"\xFB\x3F\x0F\xFF\xFF\xFF\xFF\xFF\xFF", 9},
{"\xFB\x3F\x0F\xFF\xFF\xFF\xFF\xFF\xFF", 9}, {"\xFB\x3F\x0F\xFF\xFF\xFF\xFF\xFF\xFF", 9}},
- /* 65504.0 -- largest possible half-precision */
+ /* 6.103515625E-5 -- smallest half-precision normal */
+ {6.103515625E-5, 0.0f,
+ {"\xF9\04\00", 3}, {"\xFB\x3F\x10\x00\x00\x00\x00\x00\x00", 9},
+ {"\xF9\04\00", 3}, {"\xF9\04\00", 3}},
+
+ /* 6.1035156250000014E-5 -- slightly larger than smallest half-precision normal */
+ {6.1035156250000014E-5, 0.0f,
+ {"\xFB\x3F\x10\x00\x00\x00\x00\x00\x01", 9}, {"\xFB\x3F\x10\x00\x00\x00\x00\x00\x01", 9},
+ {"\xFB\x3F\x10\x00\x00\x00\x00\x00\x01", 9}, {"\xFB\x3F\x10\x00\x00\x00\x00\x00\x01", 9}},
+
+ /* 65504.0 -- largest half-precision */
{65504.0, 0.0f,
{"\xF9\x7B\xFF", 3}, {"\xFB\x40\xEF\xFC\x00\x00\x00\x00\x00", 9},
- {"\xF9\x7B\xFF", 3}, {"\xF9\x7B\xFF", 3}},
+ {"\xF9\x7B\xFF", 3}, {"\x19\xFF\xE0", 3}},
- /* 65504.1 -- exponent too large and too much precision to convert */
+ /* 65504.1 -- exponent too large and too much precision to convert to half */
{65504.1, 0.0f,
{"\xFB\x40\xEF\xFC\x03\x33\x33\x33\x33", 9}, {"\xFB\x40\xEF\xFC\x03\x33\x33\x33\x33", 9},
{"\xFB\x40\xEF\xFC\x03\x33\x33\x33\x33", 9}, {"\xFB\x40\xEF\xFC\x03\x33\x33\x33\x33", 9}},
- /* 65536.0 -- exponent too large but not too much precision for single */
+ /* 65536.0 -- exponent too large for half but not too much precision for single */
{65536.0, 65536.0f,
{"\xFA\x47\x80\x00\x00", 5}, {"\xFB\x40\xF0\x00\x00\x00\x00\x00\x00", 9},
- {"\xFA\x47\x80\x00\x00", 5}, {"\xFA\x47\x80\x00\x00", 5}},
+ {"\xFA\x47\x80\x00\x00", 5}, {"\x1A\x00\x01\x00\x00", 5}},
/* 1.401298464324817e-45 -- smallest single subnormal */
{1.401298464324817e-45, 1.40129846E-45f,
{"\xFA\x00\x00\x00\x01", 5}, {"\xFB\x36\xA0\x00\x00\x00\x00\x00\x00", 9},
{"\xFA\x00\x00\x00\x01", 5}, {"\xFA\x00\x00\x00\x01", 5}},
- /* 5.8774717541114375E-39 -- slightly smaller than the smallest
- // single normal */
+ /* 5.8774717541114375E-39 -- slightly smaller than the smallest single normal */
{5.8774717541114375E-39, 5.87747175E-39f,
{"\xFA\x00\x40\x00\x00", 5}, {"\xFB\x38\x00\x00\x00\x00\x00\x00\x00", 9},
{"\xFA\x00\x40\x00\x00", 5}, {"\xFA\x00\x40\x00\x00", 5}},
@@ -192,20 +196,100 @@
{"\xFB\x38\x10\x00\x00\x00\x00\x00\x01", 9}, {"\xFB\x38\x10\x00\x00\x00\x00\x00\x01", 9},
{"\xFB\x38\x10\x00\x00\x00\x00\x00\x01", 9}, {"\xFB\x38\x10\x00\x00\x00\x00\x00\x01", 9}},
+ /* 8388607 -- exponent 22 to test single exponent boundary */
+ {8388607, 8388607.0f,
+ {"\xFA\x4A\xFF\xFF\xFE", 5}, {"\xFB\x41\x5F\xFF\xFF\xC0\x00\x00\x00", 9},
+ {"\xFA\x4A\xFF\xFF\xFE", 5}, {"\x1A\x00\x7F\xFF\xFF", 5}},
+
+ /* 16777215 -- exponent 23 to test single exponent boundary */
+ {16777215, 16777215.0f,
+ {"\xFA\x4B\x7F\xFF\xFF", 5}, {"\xFB\x41\x6F\xFF\xFF\xE0\x00\x00\x00", 9},
+ {"\xFA\x4B\x7F\xFF\xFF", 5}, {"\x1A\x00\xFF\xFF\xFF", 5}},
+
/* 16777216 -- converts to single without loss */
- {16777216, 16777216,
+ {16777216, 16777216.0f,
{"\xFA\x4B\x80\x00\x00", 5}, {"\xFB\x41\x70\x00\x00\x00\x00\x00\x00", 9},
- {"\xFA\x4B\x80\x00\x00", 5}, {"\xFA\x4B\x80\x00\x00", 5}},
+ {"\xFA\x4B\x80\x00\x00", 5}, {"\x1A\x01\x00\x00\x00", 5}},
- /* 16777217 -- one more than above and fails conversion to single */
- {16777217, 16777216,
+ /* 16777217 -- one more than above and fails conversion to single because of precision */
+ {16777217, 0.0f,
{"\xFB\x41\x70\x00\x00\x10\x00\x00\x00", 9}, {"\xFB\x41\x70\x00\x00\x10\x00\x00\x00", 9},
- {"\xFB\x41\x70\x00\x00\x10\x00\x00\x00", 9}, {"\xFB\x41\x70\x00\x00\x10\x00\x00\x00", 9}},
+ {"\xFB\x41\x70\x00\x00\x10\x00\x00\x00", 9}, {"\x1A\x01\x00\x00\x01", 5}},
+
+ /* 33554430 -- exponent 24 to test single exponent boundary */
+ {33554430, 33554430.0f,
+ {"\xFA\x4B\xFF\xFF\xFF", 5}, {"\xFB\x41\x7F\xFF\xFF\xE0\x00\x00\x00", 9},
+ {"\xFA\x4B\xFF\xFF\xFF", 5}, {"\x1A\x01\xFF\xFF\xFE", 5}},
- /* 3.4028234663852886E+38 -- largest possible single normal */
+ /* 4294967295 -- 2^^32 - 1 UINT32_MAX */
+ {4294967295, 0,
+ {"\xFB\x41\xEF\xFF\xFF\xFF\xE0\x00\x00", 9}, {"\xFB\x41\xEF\xFF\xFF\xFF\xE0\x00\x00", 9},
+ {"\xFB\x41\xEF\xFF\xFF\xFF\xE0\x00\x00", 9}, {"\x1A\xFF\xFF\xFF\xFF", 5}},
+
+ /* 4294967296 -- 2^^32, UINT32_MAX + 1 */
+ {4294967296, 4294967296.0f,
+ {"\xFA\x4F\x80\x00\x00", 5}, {"\xFB\x41\xF0\x00\x00\x00\x00\x00\x00", 9},
+ {"\xFA\x4F\x80\x00\x00", 5}, {"\x1B\x00\x00\x00\x01\x00\x00\x00\x00", 9}},
+
+ /* 2251799813685248 -- exponent 51, 0 significand bits set, to test double exponent boundary */
+ {2251799813685248, 2251799813685248.0f,
+ {"\xFA\x59\x00\x00\x00", 5}, {"\xFB\x43\x20\x00\x00\x00\x00\x00\x00", 9},
+ {"\xFA\x59\x00\x00\x00", 5}, {"\x1B\x00\x08\x00\x00\x00\x00\x00\x00", 9}},
+
+ /* 4503599627370495 -- exponent 51, 52 significand bits set to test double exponent boundary*/
+ {4503599627370495, 0,
+ {"\xFB\x43\x2F\xFF\xFF\xFF\xFF\xFF\xFE", 9}, {"\xFB\x43\x2F\xFF\xFF\xFF\xFF\xFF\xFE", 9},
+ {"\xFB\x43\x2F\xFF\xFF\xFF\xFF\xFF\xFE", 9}, {"\x1B\x00\x0F\xFF\xFF\xFF\xFF\xFF\xFF", 9}},
+
+ /* 9007199254740991 -- exponent 52, 52 significand bits set to test double exponent boundary */
+ {9007199254740991, 0,
+ {"\xFB\x43\x3F\xFF\xFF\xFF\xFF\xFF\xFF", 9}, {"\xFB\x43\x3F\xFF\xFF\xFF\xFF\xFF\xFF", 9},
+ {"\xFB\x43\x3F\xFF\xFF\xFF\xFF\xFF\xFF", 9}, {"\x1B\x00\x1F\xFF\xFF\xFF\xFF\xFF\xFF", 9}},
+
+ /* 18014398509481982 -- exponent 53, 52 bits set in significand (double lacks precision to represent 18014398509481983) */
+ {18014398509481982, 0,
+ {"\xFB\x43\x4F\xFF\xFF\xFF\xFF\xFF\xFF", 9}, {"\xFB\x43\x4F\xFF\xFF\xFF\xFF\xFF\xFF", 9},
+ {"\xFB\x43\x4F\xFF\xFF\xFF\xFF\xFF\xFF", 9}, {"\x1B\x00\x3F\xFF\xFF\xFF\xFF\xFF\xFE", 9}},
+
+ /* 18014398509481984 -- next largest possible double above 18014398509481982 */
+ {18014398509481984, 18014398509481984.0f,
+ {"\xFA\x5A\x80\x00\x00", 5}, {"\xFB\x43\x50\x00\x00\x00\x00\x00\x00", 9},
+ {"\xFA\x5A\x80\x00\x00", 5}, {"\x1B\x00\x40\x00\x00\x00\x00\x00\x00", 9}},
+
+ /* 18446742974197924000.0.0 -- largest single that can convert to uint64 */
+ {18446742974197924000.0, 18446742974197924000.0f,
+ {"\xFA\x5F\x7F\xFF\xFF", 5}, {"\xFB\x43\xEF\xFF\xFF\xE0\x00\x00\x00", 9},
+ {"\xFA\x5F\x7F\xFF\xFF", 5}, {"\x1B\xFF\xFF\xFF\x00\x00\x00\x00\x00", 9}},
+
+ /* 18446744073709550000.0 -- largest double that can convert to uint64, almost UINT64_MAX (18446744073709551615) */
+ {18446744073709550000.0, 0,
+ {"\xFB\x43\xEF\xFF\xFF\xFF\xFF\xFF\xFF", 9}, {"\xFB\x43\xEF\xFF\xFF\xFF\xFF\xFF\xFF", 9},
+ {"\xFB\x43\xEF\xFF\xFF\xFF\xFF\xFF\xFF", 9}, {"\x1B\xFF\xFF\xFF\xFF\xFF\xFF\xF8\x00", 9}},
+
+ /* 18446744073709552000.0 -- just too large to convert to uint64, but converts to a single, just over UINT64_MAX */
+ {18446744073709552000.0, 18446744073709552000.0f,
+ {"\xFA\x5F\x80\x00\x00", 5}, {"\xFB\x43\xF0\x00\x00\x00\x00\x00\x00", 9},
+ {"\xFA\x5F\x80\x00\x00", 5}, {"\xFA\x5F\x80\x00\x00", 5}},
+
+ /* -4294967295 -- negative UINT32_MAX */
+ {-4294967295.0, 0,
+ {"\xFB\xC1\xEF\xFF\xFF\xFF\xE0\x00\x00", 9}, {"\xFB\xC1\xEF\xFF\xFF\xFF\xE0\x00\x00", 9},
+ {"\xFB\xC1\xEF\xFF\xFF\xFF\xE0\x00\x00", 9}, {"\x3A\xFF\xFF\xFF\xFE", 5}},
+
+ /* -9223372036854774784.0 -- most negative double that converts to int64 */
+ {-9223372036854774784.0, 0,
+ {"\xFB\xC3\xDF\xFF\xFF\xFF\xFF\xFF\xFF", 9}, {"\xFB\xC3\xDF\xFF\xFF\xFF\xFF\xFF\xFF", 9},
+ {"\xFB\xC3\xDF\xFF\xFF\xFF\xFF\xFF\xFF", 9}, {"\x3B\x7F\xFF\xFF\xFF\xFF\xFF\xFB\xFF", 9}},
+
+ /* -18446742974197924000.0.0 -- large negative that converts to float, but too large for int64 */
+ {-18446742974197924000.0, -18446742974197924000.0f,
+ {"\xFA\xDF\x7F\xFF\xFF", 5}, {"\xFB\xC3\xEF\xFF\xFF\xE0\x00\x00\x00", 9},
+ {"\xFA\xDF\x7F\xFF\xFF", 5}, {"\xFA\xDF\x7F\xFF\xFF", 5}},
+
+ /* 3.4028234663852886E+38 -- largest possible single */
{3.4028234663852886E+38, 3.40282347E+38f,
- {"\xFA\x7F\x7F\xFF\xFF", 5}, {"\xFB\x47\xEF\xFF\xFF\xE0\x00\x00\x00", 9},
- {"\xFA\x7F\x7F\xFF\xFF", 5}, {"\xFA\x7F\x7F\xFF\xFF", 5}},
+ {"\xFA\x7F\x7F\xFF\xFF", 5}, {"\xFB\x47\xEF\xFF\xFF\xE0\x00\x00\x00", 9},
+ {"\xFA\x7F\x7F\xFF\xFF", 5}, {"\xFA\x7F\x7F\xFF\xFF", 5}},
/* 3.402823466385289E+38 -- slightly larger than largest possible single */
{3.402823466385289E+38, 0.0f,
@@ -242,9 +326,12 @@
};
+/* Can't use types double and float here because there's no way in C to
+ * construct arbitrary payloads for those types.
+ */
struct NaNTestCase {
- uint64_t uDouble;
- uint32_t uSingle;
+ uint64_t uDouble; /* Converted to double in test */
+ uint32_t uSingle; /* Converted to single in test */
UsefulBufC Preferred;
UsefulBufC NotPreferred;
UsefulBufC CDE;
@@ -292,14 +379,13 @@
/* Payload with all bits set */
{0x7fffffffffffffff, 0x00000000,
{"\xFB\x7F\xFF\xFF\xFF\xFF\xFF\xFF\xFF", 9}, {"\xFB\x7F\xFF\xFF\xFF\xFF\xFF\xFF\xFF", 9},
- {"\xF9\x7E\x00", 3}, {"\xFB\x7F\xFF\xFF\xFF\xFF\xFF\xFF\xFF", 9}},
+ {"\xF9\x7E\x00", 3}, {"\xF9\x7E\x00", 3}},
/* List terminator */
{0, 0, {NULL, 0}, {NULL, 0}, {NULL, 0}, {NULL, 0} }
};
-
/* Public function. See float_tests.h
*
* This is the main test of floating-point encoding / decoding. It is
@@ -311,7 +397,7 @@
FloatValuesTests(void)
{
unsigned int uTestIndex;
- const struct DoubleTestCase *pTestCase;
+ const struct FloatTestCase *pTestCase;
const struct NaNTestCase *pNaNTestCase;
MakeUsefulBufOnStack( TestOutBuffer, 20);
UsefulBufC TestOutput;
@@ -325,12 +411,11 @@
#endif
/* Test a variety of doubles */
- for(uTestIndex = 0; DoubleTestCases[uTestIndex].Preferred.len != 0; uTestIndex++) {
- pTestCase = &DoubleTestCases[uTestIndex];
+ for(uTestIndex = 0; FloatTestCases[uTestIndex].Preferred.len != 0; uTestIndex++) {
+ pTestCase = &FloatTestCases[uTestIndex];
- // if(pTestCase->dNumber == 1.1754943508222874E-38) {
- if(uTestIndex == 19) {
- uErr = 99; /* For setting break points for particular tests */
+ if(uTestIndex == 34) {
+ uDecoded = 1;
}
/* Number Encode of Preferred */
@@ -357,6 +442,47 @@
return MakeTestResultCode(uTestIndex, 2, 200);
}
+ /* Number Encode of CDE */
+ QCBOREncode_Init(&EnCtx, TestOutBuffer);
+ QCBOREncode_SerializationCDE(&EnCtx);
+ QCBOREncode_AddDouble(&EnCtx, pTestCase->dNumber);
+ uErr = QCBOREncode_Finish(&EnCtx, &TestOutput);
+
+ if(uErr != QCBOR_SUCCESS) {
+ return MakeTestResultCode(uTestIndex, 20, uErr);;
+ }
+ if(UsefulBuf_Compare(TestOutput, pTestCase->CDE)) {
+ return MakeTestResultCode(uTestIndex, 21, 200);
+ }
+
+ /* Number Encode of dCBOR */
+ QCBOREncode_Init(&EnCtx, TestOutBuffer);
+ QCBOREncode_SerializationdCBOR(&EnCtx);
+ QCBOREncode_AddDouble(&EnCtx, pTestCase->dNumber);
+ uErr = QCBOREncode_Finish(&EnCtx, &TestOutput);
+
+ if(uErr != QCBOR_SUCCESS) {
+ return MakeTestResultCode(uTestIndex, 22, uErr);;
+ }
+ if(UsefulBuf_Compare(TestOutput, pTestCase->DCBOR)) {
+ return MakeTestResultCode(uTestIndex, 23, 200);
+ }
+
+ if(pTestCase->fNumber != 0) {
+ QCBOREncode_Init(&EnCtx, TestOutBuffer);
+ QCBOREncode_SerializationdCBOR(&EnCtx);
+ QCBOREncode_AddFloat(&EnCtx, pTestCase->fNumber);
+ uErr = QCBOREncode_Finish(&EnCtx, &TestOutput);
+
+ if(uErr != QCBOR_SUCCESS) {
+ return MakeTestResultCode(uTestIndex, 24, uErr);;
+ }
+ if(UsefulBuf_Compare(TestOutput, pTestCase->DCBOR)) {
+ return MakeTestResultCode(uTestIndex, 25, 200);
+ }
+ }
+
+
/* Number Decode of Preferred */
QCBORDecode_Init(&DCtx, pTestCase->Preferred, 0);
uErr = QCBORDecode_GetNext(&DCtx, &Item);
@@ -382,32 +508,32 @@
* indicates single-precision in the encoded CBOR. */
if(pTestCase->Preferred.len == 5) {
if(Item.uDataType != QCBOR_TYPE_FLOAT) {
- return MakeTestResultCode(uTestIndex, 4, 0);
+ return MakeTestResultCode(uTestIndex, 41, 0);
}
if(isnan(pTestCase->dNumber)) {
if(!isnan(Item.val.fnum)) {
- return MakeTestResultCode(uTestIndex, 5, 0);
+ return MakeTestResultCode(uTestIndex, 51, 0);
}
} else {
if(Item.val.fnum != pTestCase->fNumber) {
- return MakeTestResultCode(uTestIndex, 6, 0);
+ return MakeTestResultCode(uTestIndex, 61, 0);
}
}
} else {
if(Item.uDataType != QCBOR_TYPE_DOUBLE) {
- return MakeTestResultCode(uTestIndex, 4, 0);
+ return MakeTestResultCode(uTestIndex, 42, 0);
}
if(isnan(pTestCase->dNumber)) {
if(!isnan(Item.val.dfnum)) {
- return MakeTestResultCode(uTestIndex, 5, 0);
+ return MakeTestResultCode(uTestIndex, 52, 0);
}
} else {
if(Item.val.dfnum != pTestCase->dNumber) {
- return MakeTestResultCode(uTestIndex, 6, 0);
+ return MakeTestResultCode(uTestIndex, 62, 0);
}
}
}
-#endif /* QCBOR_DISABLE_FLOAT_HW_USE */
+#endif /* ! QCBOR_DISABLE_FLOAT_HW_USE */
/* Number Decode of Not Preferred */
QCBORDecode_Init(&DCtx, pTestCase->NotPreferred, 0);
@@ -441,6 +567,7 @@
/* NaN Encode of Preferred */
QCBOREncode_Init(&EnCtx, TestOutBuffer);
+ QCBOREncode_Allow(&EnCtx, QCBOR_ENCODE_ALLOW_NAN_PAYLOAD);
QCBOREncode_AddDouble(&EnCtx, UsefulBufUtil_CopyUint64ToDouble(pNaNTestCase->uDouble));
uErr = QCBOREncode_Finish(&EnCtx, &TestOutput);
if(uErr != QCBOR_SUCCESS) {
@@ -489,6 +616,7 @@
/* NaN Encode of Not Preferred */
QCBOREncode_Init(&EnCtx, TestOutBuffer);
+ QCBOREncode_Allow(&EnCtx, QCBOR_ENCODE_ALLOW_NAN_PAYLOAD);
QCBOREncode_AddDoubleNoPreferred(&EnCtx, UsefulBufUtil_CopyUint64ToDouble(pNaNTestCase->uDouble));
uErr = QCBOREncode_Finish(&EnCtx, &TestOutput);
if(uErr != QCBOR_SUCCESS) {
@@ -498,8 +626,9 @@
return MakeTestResultCode(uTestIndex+100, 11, 200);
}
- /* NaN Decode of Preferred */
+ /* NaN Decode of Not Preferred */
QCBORDecode_Init(&DCtx, pNaNTestCase->Preferred, 0);
+ QCBOREncode_Allow(&EnCtx, QCBOR_ENCODE_ALLOW_NAN_PAYLOAD);
uErr = QCBORDecode_GetNext(&DCtx, &Item);
if(uErr != QCBOR_SUCCESS) {
return MakeTestResultCode(uTestIndex+100, 12, uErr);
@@ -535,6 +664,7 @@
/* NaN Decode of Not Preferred */
QCBORDecode_Init(&DCtx, pNaNTestCase->NotPreferred, 0);
+ QCBOREncode_Allow(&EnCtx, QCBOR_ENCODE_ALLOW_NAN_PAYLOAD);
uErr = QCBORDecode_GetNext(&DCtx, &Item);
if(uErr != QCBOR_SUCCESS) {
return MakeTestResultCode(uTestIndex+100, 13, uErr);
@@ -543,6 +673,21 @@
if(uDecoded != pNaNTestCase->uDouble) {
return MakeTestResultCode(uTestIndex+100, 13, 200);
}
+
+
+ /* NaN Encode of DCBOR */
+ QCBOREncode_Init(&EnCtx, TestOutBuffer);
+ QCBOREncode_Allow(&EnCtx, QCBOR_ENCODE_ALLOW_NAN_PAYLOAD);
+ QCBOREncode_SerializationdCBOR(&EnCtx);
+ QCBOREncode_AddDouble(&EnCtx, UsefulBufUtil_CopyUint64ToDouble(pNaNTestCase->uDouble));
+ uErr = QCBOREncode_Finish(&EnCtx, &TestOutput);
+ if(uErr != QCBOR_SUCCESS) {
+ return MakeTestResultCode(uTestIndex+100, 14, uErr);;
+ }
+ if(UsefulBuf_Compare(TestOutput, pNaNTestCase->DCBOR)) {
+ return MakeTestResultCode(uTestIndex+100, 14, 200);
+ }
+
}
return 0;
diff --git a/test/qcbor_decode_tests.c b/test/qcbor_decode_tests.c
index 8e33858..c8ef698 100644
--- a/test/qcbor_decode_tests.c
+++ b/test/qcbor_decode_tests.c
@@ -6632,6 +6632,9 @@
int32_t IntegerConvertTest(void)
{
+ uint64_t uInt;
+
+
const int nNumTests = C_ARRAY_COUNT(NumberConversions,
struct NumberConversion);
@@ -6662,7 +6665,6 @@
return (int32_t)(3333+nIndex);
}
- uint64_t uInt;
QCBORDecode_GetUInt64ConvertAll(&DCtx, 0xffff, &uInt);
if(QCBORDecode_GetError(&DCtx) != pF->uErrorUint64) {
return (int32_t)(4000+nIndex);
diff --git a/test/qcbor_encode_tests.c b/test/qcbor_encode_tests.c
index c639a84..7594006 100644
--- a/test/qcbor_encode_tests.c
+++ b/test/qcbor_encode_tests.c
@@ -692,13 +692,18 @@
/* Improvement: this test should be broken down into several so it is more
* managable. Tags and labels could be more sensible */
QCBOREncodeContext ECtx;
- int nReturn = 0;
+ UsefulBufC Enc;
+ size_t size;
+ int nReturn;
+ QCBORError uExpectedErr;
+
+ nReturn = 0;
QCBOREncode_Init(&ECtx, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
+ QCBOREncode_Allow(&ECtx, QCBOR_ENCODE_ALLOW_ALL);
AddAll(&ECtx);
- UsefulBufC Enc;
if(QCBOREncode_Finish(&ECtx, &Enc)) {
nReturn = -1;
goto Done;
@@ -706,15 +711,16 @@
if(CheckResults(Enc, spExpectedEncodedAll)) {
nReturn = -2;
+ goto Done;
}
/* Also test size calculation */
QCBOREncode_Init(&ECtx, SizeCalculateUsefulBuf);
+ QCBOREncode_Allow(&ECtx, QCBOR_ENCODE_ALLOW_ALL);
- AddAll (&ECtx);
+ AddAll(&ECtx);
- size_t size;
if(QCBOREncode_FinishGetSize(&ECtx, &size)) {
nReturn = -10;
goto Done;
@@ -722,8 +728,70 @@
if(size != sizeof(spExpectedEncodedAll)) {
nReturn = -11;
+ goto Done;
}
+#ifndef QCBOR_DISABLE_ENCODE_USAGE_GUARDS
+ uExpectedErr = QCBOR_ERR_NOT_ALLOWED;
+#else
+ uExpectedErr = QCBOR_SUCCESS;
+#endif
+
+ /* Test the QCBOR_ERR_NOT_ALLOWED error codes */
+ QCBOREncode_Init(&ECtx, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
+ QCBOREncode_AddNegativeUInt64(&ECtx, 1);
+ if(QCBOREncode_Finish(&ECtx, &Enc) != uExpectedErr) {
+ nReturn = -21;
+ goto Done;
+ }
+
+#ifndef USEFULBUF_DISABLE_ALL_FLOAT
+ QCBOREncode_Init(&ECtx, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
+ /* 0x7ff8000000000001ULL is a NaN with a payload. */
+ QCBOREncode_AddDouble(&ECtx, UsefulBufUtil_CopyUint64ToDouble(0x7ff8000000000001ULL));
+ if(QCBOREncode_Finish(&ECtx, &Enc) != uExpectedErr) {
+ nReturn = -22;
+ goto Done;
+ }
+
+ QCBOREncode_Init(&ECtx, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
+ /* 0x7ff8000000000001ULL is a NaN with a payload. */
+ QCBOREncode_AddDoubleNoPreferred(&ECtx, UsefulBufUtil_CopyUint64ToDouble(0x7ff8000000000001ULL));
+ if(QCBOREncode_Finish(&ECtx, &Enc) != uExpectedErr) {
+ nReturn = -22;
+ goto Done;
+ }
+
+
+ /* 0x7ffc000000000000ULL is a NaN with a payload. */
+ QCBOREncode_AddDouble(&ECtx, UsefulBufUtil_CopyUint64ToDouble(0x7ff8000000000001ULL));
+ if(QCBOREncode_Finish(&ECtx, &Enc) != uExpectedErr) {
+ nReturn = -23;
+ goto Done;
+ }
+
+ /* 0x7ff80001UL is a NaN with a payload. */
+ QCBOREncode_AddFloat(&ECtx, UsefulBufUtil_CopyUint32ToFloat(0x7ff80001UL));
+ if(QCBOREncode_Finish(&ECtx, &Enc) != uExpectedErr) {
+ nReturn = -24;
+ goto Done;
+ }
+
+ /* 0x7ff80001UL is a NaN with a payload. */
+ QCBOREncode_AddFloatNoPreferred(&ECtx, UsefulBufUtil_CopyUint32ToFloat(0x7ff80001UL));
+ if(QCBOREncode_Finish(&ECtx, &Enc) != uExpectedErr) {
+ nReturn = -24;
+ goto Done;
+ }
+
+ /* 0x7ffc0000UL is a NaN with a payload. */
+ QCBOREncode_AddFloat(&ECtx, UsefulBufUtil_CopyUint32ToFloat(0x7ffc0000UL));
+ if(QCBOREncode_Finish(&ECtx, &Enc) != uExpectedErr) {
+ nReturn = -25;
+ goto Done;
+ }
+#endif /* ! USEFULBUF_DISABLE_ALL_FLOAT */
+
Done:
return nReturn;
}
@@ -3363,3 +3431,167 @@
return 0;
}
+
+
+#if !defined(USEFULBUF_DISABLE_ALL_FLOAT) && !defined(QCBOR_DISABLE_PREFERRED_FLOAT)
+
+#include <math.h> /* For INFINITY and NAN and isnan() */
+
+
+/* Public function. See qcbor_encode_tests.h */
+int32_t CDETest(void)
+{
+ QCBOREncodeContext EC;
+ UsefulBufC Encoded;
+ QCBORError uExpectedErr;
+
+ QCBOREncode_Init(&EC, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
+
+ QCBOREncode_SerializationCDE(&EC);
+
+ /* Items added to test sorting and preferred encoding of numbers and floats */
+ QCBOREncode_OpenMap(&EC);
+ QCBOREncode_AddFloatToMap(&EC, "k", 1.0f);
+ QCBOREncode_AddInt64ToMap(&EC, "a", 1);
+ QCBOREncode_AddDoubleToMap(&EC, "x", 2.0);
+ QCBOREncode_AddDoubleToMap(&EC, "r", 3.4028234663852886E+38);
+ QCBOREncode_AddDoubleToMap(&EC, "b", NAN);
+ QCBOREncode_AddUndefToMap(&EC, "t"); /* Test because dCBOR disallows */
+
+ QCBOREncode_CloseMap(&EC);
+
+ uExpectedErr = QCBOREncode_Finish(&EC, &Encoded);
+ if(uExpectedErr != QCBOR_SUCCESS) {
+ return 2;
+ }
+
+ static const uint8_t spExpectedCDE[] = {
+ 0xA6, 0x61, 0x61, 0x01, 0x61, 0x62, 0xF9, 0x7E,
+ 0x00, 0x61, 0x6B, 0xF9, 0x3C, 0x00, 0x61, 0x72,
+ 0xFA, 0x7F, 0x7F, 0xFF, 0xFF, 0x61, 0x74, 0xF7,
+ 0x61, 0x78, 0xF9, 0x40, 0x00};
+
+ if(UsefulBuf_Compare(UsefulBuf_FROM_BYTE_ARRAY_LITERAL(spExpectedCDE),
+ Encoded)) {
+ return 1;
+ }
+
+
+#ifndef QCBOR_DISABLE_ENCODE_USAGE_GUARDS
+ uExpectedErr = QCBOR_ERR_NOT_PREFERRED;
+#else
+ uExpectedErr = QCBOR_SUCCESS;
+#endif
+
+
+ /* Next, make sure methods that encode non-CDE error out */
+ QCBOREncode_Init(&EC, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
+ QCBOREncode_SerializationCDE(&EC);
+ QCBOREncode_OpenMapIndefiniteLength(&EC);
+ QCBOREncode_CloseMap(&EC);
+ if(QCBOREncode_GetErrorState(&EC) != uExpectedErr) {
+ return 100;
+ }
+
+
+ QCBOREncode_Init(&EC, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
+ QCBOREncode_SerializationCDE(&EC);
+ QCBOREncode_AddDoubleNoPreferred(&EC, 0);
+ if(QCBOREncode_GetErrorState(&EC) != uExpectedErr) {
+ return 101;
+ }
+
+ QCBOREncode_Init(&EC, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
+ QCBOREncode_SerializationCDE(&EC);
+ QCBOREncode_AddFloatNoPreferred(&EC, 0);
+ if(QCBOREncode_GetErrorState(&EC) != uExpectedErr) {
+ return 101;
+ }
+
+ return 0;
+}
+
+/* Public function. See qcbor_encode_tests.h */
+int32_t DCBORTest(void)
+{
+ QCBOREncodeContext EC;
+ UsefulBufC Encoded;
+ QCBORError uExpectedErr;
+
+ QCBOREncode_Init(&EC, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
+
+ QCBOREncode_SerializationdCBOR(&EC);
+
+ /* Items added to test sorting and preferred encoding of numbers and floats */
+ QCBOREncode_OpenMap(&EC);
+ QCBOREncode_AddFloatToMap(&EC, "k", 1.0f);
+ QCBOREncode_AddInt64ToMap(&EC, "a", 1);
+ QCBOREncode_AddDoubleToMap(&EC, "x", 2.0);
+ QCBOREncode_AddDoubleToMap(&EC, "r", 3.4028234663852886E+38);
+ QCBOREncode_AddDoubleToMap(&EC, "b", NAN);
+
+ QCBOREncode_CloseMap(&EC);
+
+ QCBOREncode_Finish(&EC, &Encoded);
+
+ static const uint8_t spExpecteddCBOR[] = {
+ 0xA5, 0x61, 0x61, 0x01, 0x61, 0x62, 0xF9, 0x7E,
+ 0x00, 0x61, 0x6B, 0x01, 0x61, 0x72, 0xFA, 0x7F,
+ 0x7F, 0xFF, 0xFF, 0x61, 0x78, 0x02};
+
+ if(UsefulBuf_Compare(UsefulBuf_FROM_BYTE_ARRAY_LITERAL(spExpecteddCBOR),
+ Encoded)) {
+ return 1;
+ }
+
+
+#ifndef QCBOR_DISABLE_ENCODE_USAGE_GUARDS
+ uExpectedErr = QCBOR_ERR_NOT_PREFERRED;
+#else
+ uExpectedErr = QCBOR_SUCCESS;
+#endif
+
+ /* Next, make sure methods that encode of non-CDE error out */
+
+ /* Indefinite-length map */
+ QCBOREncode_Init(&EC, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
+ QCBOREncode_SerializationdCBOR(&EC);
+ QCBOREncode_OpenMapIndefiniteLength(&EC);
+ QCBOREncode_CloseMap(&EC);
+ if(QCBOREncode_GetErrorState(&EC) != uExpectedErr) {
+ return 100;
+ }
+
+ /* Indefinite-length array */
+ QCBOREncode_Init(&EC, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
+ QCBOREncode_SerializationdCBOR(&EC);
+ QCBOREncode_OpenArrayIndefiniteLength(&EC);
+ QCBOREncode_CloseMap(&EC);
+ if(QCBOREncode_GetErrorState(&EC) != uExpectedErr) {
+ return 101;
+ }
+
+ /* The "undef" special value */
+ QCBOREncode_Init(&EC, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
+ QCBOREncode_SerializationdCBOR(&EC);
+ QCBOREncode_AddUndef(&EC);
+ QCBOREncode_CloseMap(&EC);
+ if(QCBOREncode_GetErrorState(&EC) != uExpectedErr) {
+ return 102;
+ }
+
+ /* 65-bit negative integers */
+ QCBOREncode_Init(&EC, UsefulBuf_FROM_BYTE_ARRAY(spBigBuf));
+ QCBOREncode_SerializationdCBOR(&EC);
+ QCBOREncode_AddNegativeUInt64(&EC, 1);
+ if(QCBOREncode_GetErrorState(&EC) != uExpectedErr) {
+ return 103;
+ }
+
+ /* Improvement: when indefinite length string encoding is supported
+ * test it here too. */
+
+ return 0;
+
+}
+#endif /* ! USEFULBUF_DISABLE_ALL_FLOAT && ! QCBOR_DISABLE_PREFERRED_FLOAT */
diff --git a/test/qcbor_encode_tests.h b/test/qcbor_encode_tests.h
index 5271fd4..7935862 100644
--- a/test/qcbor_encode_tests.h
+++ b/test/qcbor_encode_tests.h
@@ -1,6 +1,6 @@
/*==============================================================================
Copyright (c) 2016-2018, The Linux Foundation.
- Copyright (c) 2018-2023, Laurence Lundblade.
+ Copyright (c) 2018-2024, Laurence Lundblade.
All rights reserved.
Redistribution and use in source and binary forms, with or without
@@ -195,5 +195,14 @@
/* Test map sorting */
int32_t SortMapTest(void);
+#if !defined(USEFULBUF_DISABLE_ALL_FLOAT) && !defined(QCBOR_DISABLE_PREFERRED_FLOAT)
+
+/* Test CBOR Deterministic Encoding */
+int32_t CDETest(void);
+
+/* Test "dCBOR" mode */
+int32_t DCBORTest(void);
+
+#endif /* ! USEFULBUF_DISABLE_ALL_FLOAT && ! QCBOR_DISABLE_PREFERRED_FLOAT */
#endif /* defined(__QCBOR__qcbor_encode_tests__) */
diff --git a/test/run_tests.c b/test/run_tests.c
index 30e942e..bfc9dd9 100644
--- a/test/run_tests.c
+++ b/test/run_tests.c
@@ -1,7 +1,7 @@
/*==============================================================================
run_tests.c -- test aggregator and results reporting
- Copyright (c) 2018-2023, Laurence Lundblade. All rights reserved.
+ Copyright (c) 2018-2024, Laurence Lundblade. All rights reserved.
Copyright (c) 2021, Arm Limited. All rights reserved.
SPDX-License-Identifier: BSD-3-Clause
@@ -67,89 +67,94 @@
static test_entry s_tests[] = {
- TEST_ENTRY(OpenCloseBytesTest),
- TEST_ENTRY(EnterBstrTest),
- TEST_ENTRY(IntegerConvertTest),
- TEST_ENTRY(EnterMapTest),
- TEST_ENTRY(QCBORHeadTest),
- TEST_ENTRY(EmptyMapsAndArraysTest),
- TEST_ENTRY(NotWellFormedTests),
- TEST_ENTRY(ParseMapAsArrayTest),
+ TEST_ENTRY(OpenCloseBytesTest),
+ TEST_ENTRY(EnterBstrTest),
+ TEST_ENTRY(IntegerConvertTest),
+ TEST_ENTRY(EnterMapTest),
+ TEST_ENTRY(QCBORHeadTest),
+ TEST_ENTRY(EmptyMapsAndArraysTest),
+ TEST_ENTRY(NotWellFormedTests),
+ TEST_ENTRY(ParseMapAsArrayTest),
#ifndef QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS
- TEST_ENTRY(IndefiniteLengthNestTest),
- TEST_ENTRY(IndefiniteLengthArrayMapTest),
- TEST_ENTRY(NestedMapTestIndefLen),
+ TEST_ENTRY(IndefiniteLengthNestTest),
+ TEST_ENTRY(IndefiniteLengthArrayMapTest),
+ TEST_ENTRY(NestedMapTestIndefLen),
#endif /* QCBOR_DISABLE_INDEFINITE_LENGTH_ARRAYS */
- TEST_ENTRY(ParseSimpleTest),
- TEST_ENTRY(DecodeFailureTests),
- TEST_ENTRY(EncodeRawTest),
- TEST_ENTRY(RTICResultsTest),
- TEST_ENTRY(MapEncodeTest),
- TEST_ENTRY(ArrayNestingTest1),
- TEST_ENTRY(ArrayNestingTest2),
+ TEST_ENTRY(ParseSimpleTest),
+ TEST_ENTRY(DecodeFailureTests),
+ TEST_ENTRY(EncodeRawTest),
+ TEST_ENTRY(RTICResultsTest),
+ TEST_ENTRY(MapEncodeTest),
+ TEST_ENTRY(ArrayNestingTest1),
+ TEST_ENTRY(ArrayNestingTest2),
#ifndef QCBOR_DISABLE_ENCODE_USAGE_GUARDS
- TEST_ENTRY(ArrayNestingTest3),
+ TEST_ENTRY(ArrayNestingTest3),
#endif /* QCBOR_DISABLE_ENCODE_USAGE_GUARDS */
- TEST_ENTRY(EncodeDateTest),
- TEST_ENTRY(SimpleValuesTest1),
- TEST_ENTRY(IntegerValuesTest1),
- TEST_ENTRY(AllAddMethodsTest),
- TEST_ENTRY(ParseTooDeepArrayTest),
- TEST_ENTRY(ComprehensiveInputTest),
- TEST_ENTRY(ParseMapTest),
- TEST_ENTRY(BasicEncodeTest),
- TEST_ENTRY(NestedMapTest),
- TEST_ENTRY(BignumParseTest),
+ TEST_ENTRY(EncodeDateTest),
+ TEST_ENTRY(SimpleValuesTest1),
+ TEST_ENTRY(IntegerValuesTest1),
+ TEST_ENTRY(AllAddMethodsTest),
+ TEST_ENTRY(ParseTooDeepArrayTest),
+ TEST_ENTRY(ComprehensiveInputTest),
+ TEST_ENTRY(ParseMapTest),
+ TEST_ENTRY(BasicEncodeTest),
+ TEST_ENTRY(NestedMapTest),
+ TEST_ENTRY(BignumParseTest),
#ifndef QCBOR_DISABLE_TAGS
- TEST_ENTRY(OptTagParseTest),
- TEST_ENTRY(DateParseTest),
- TEST_ENTRY(DecodeTaggedTypeTests),
+ TEST_ENTRY(OptTagParseTest),
+ TEST_ENTRY(DateParseTest),
+ TEST_ENTRY(DecodeTaggedTypeTests),
#endif /* QCBOR_DISABLE_TAGS */
- TEST_ENTRY(SpiffyDateDecodeTest),
- TEST_ENTRY(ShortBufferParseTest2),
- TEST_ENTRY(ShortBufferParseTest),
- TEST_ENTRY(ParseDeepArrayTest),
- TEST_ENTRY(SimpleArrayTest),
- TEST_ENTRY(IntegerValuesParseTest),
+ TEST_ENTRY(SpiffyDateDecodeTest),
+ TEST_ENTRY(ShortBufferParseTest2),
+ TEST_ENTRY(ShortBufferParseTest),
+ TEST_ENTRY(ParseDeepArrayTest),
+ TEST_ENTRY(SimpleArrayTest),
+ TEST_ENTRY(IntegerValuesParseTest),
#ifndef QCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS
- TEST_ENTRY(AllocAllStringsTest),
- TEST_ENTRY(MemPoolTest),
- TEST_ENTRY(IndefiniteLengthStringTest),
- TEST_ENTRY(SpiffyIndefiniteLengthStringsTests),
- TEST_ENTRY(SetUpAllocatorTest),
- TEST_ENTRY(CBORTestIssue134),
+ TEST_ENTRY(AllocAllStringsTest),
+ TEST_ENTRY(MemPoolTest),
+ TEST_ENTRY(IndefiniteLengthStringTest),
+ TEST_ENTRY(SpiffyIndefiniteLengthStringsTests),
+ TEST_ENTRY(SetUpAllocatorTest),
+ TEST_ENTRY(CBORTestIssue134),
#endif /* #ifndef QCBOR_DISABLE_INDEFINITE_LENGTH_STRINGS */
#ifndef USEFULBUF_DISABLE_ALL_FLOAT
#ifndef QCBOR_DISABLE_PREFERRED_FLOAT
TEST_ENTRY(HalfPrecisionAgainstRFCCodeTest),
TEST_ENTRY(FloatValuesTests),
#endif /* QCBOR_DISABLE_PREFERRED_FLOAT */
- TEST_ENTRY(GeneralFloatEncodeTests),
- TEST_ENTRY(GeneralFloatDecodeTests),
+ TEST_ENTRY(GeneralFloatEncodeTests),
+ TEST_ENTRY(GeneralFloatDecodeTests),
#endif /* USEFULBUF_DISABLE_ALL_FLOAT */
- TEST_ENTRY(BstrWrapTest),
- TEST_ENTRY(BstrWrapErrorTest),
- TEST_ENTRY(BstrWrapNestTest),
- TEST_ENTRY(CoseSign1TBSTest),
- TEST_ENTRY(StringDecoderModeFailTest),
- TEST_ENTRY_DISABLED(BigComprehensiveInputTest),
- TEST_ENTRY_DISABLED(TooLargeInputTest),
- TEST_ENTRY(EncodeErrorTests),
- TEST_ENTRY(SimpleValuesIndefiniteLengthTest1),
- TEST_ENTRY(EncodeLengthThirtyoneTest),
- TEST_ENTRY(CBORSequenceDecodeTests),
- TEST_ENTRY(IntToTests),
- TEST_ENTRY(PeekAndRewindTest),
+ TEST_ENTRY(BstrWrapTest),
+ TEST_ENTRY(BstrWrapErrorTest),
+ TEST_ENTRY(BstrWrapNestTest),
+ TEST_ENTRY(CoseSign1TBSTest),
+ TEST_ENTRY(StringDecoderModeFailTest),
+ TEST_ENTRY_DISABLED(BigComprehensiveInputTest),
+ TEST_ENTRY_DISABLED(TooLargeInputTest),
+ TEST_ENTRY(EncodeErrorTests),
+ TEST_ENTRY(SimpleValuesIndefiniteLengthTest1),
+ TEST_ENTRY(EncodeLengthThirtyoneTest),
+ TEST_ENTRY(CBORSequenceDecodeTests),
+ TEST_ENTRY(IntToTests),
+ TEST_ENTRY(PeekAndRewindTest),
#ifndef QCBOR_DISABLE_EXP_AND_MANTISSA
- TEST_ENTRY(ExponentAndMantissaDecodeTests),
+ TEST_ENTRY(ExponentAndMantissaDecodeTests),
#ifndef QCBOR_DISABLE_TAGS
- TEST_ENTRY(ExponentAndMantissaDecodeFailTests),
+ TEST_ENTRY(ExponentAndMantissaDecodeFailTests),
#endif /* QCBOR_DISABLE_TAGS */
- TEST_ENTRY(ExponentAndMantissaEncodeTests),
+ TEST_ENTRY(ExponentAndMantissaEncodeTests),
#endif /* QCBOR_DISABLE_EXP_AND_MANTISSA */
- TEST_ENTRY(ParseEmptyMapInMapTest),
- TEST_ENTRY(BoolTest),
- TEST_ENTRY(SortMapTest)
+ TEST_ENTRY(BoolTest),
+ TEST_ENTRY(SortMapTest),
+#if !defined(USEFULBUF_DISABLE_ALL_FLOAT) && !defined(QCBOR_DISABLE_PREFERRED_FLOAT)
+ TEST_ENTRY(CDETest),
+ TEST_ENTRY(DCBORTest),
+#endif /* ! USEFULBUF_DISABLE_ALL_FLOAT && ! QCBOR_DISABLE_PREFERRED_FLOAT */
+ TEST_ENTRY(ParseEmptyMapInMapTest),
+
};