General float encode tests when preferred serialization is off
diff --git a/test/float_tests.c b/test/float_tests.c
index d43039d..5e58794 100644
--- a/test/float_tests.c
+++ b/test/float_tests.c
@@ -10,13 +10,14 @@
Created on 9/19/18
=============================================================================*/
+#include "qcbor/qcbor_encode.h"
+#include <math.h> // For INFINITY and NAN and isnan()
+
#ifndef QCBOR_DISABLE_PREFERRED_FLOAT
#include "float_tests.h"
-#include "qcbor/qcbor_encode.h"
#include "qcbor/qcbor_decode.h"
#include "half_to_double_from_rfc7049.h"
-#include <math.h> // For INFINITY and NAN and isnan()
@@ -448,6 +449,7 @@
return 0;
}
+#endif /* QCBOR_DISABLE_PREFERRED_FLOAT */
/*
@@ -455,6 +457,7 @@
{100: 0.0, 101: 3.1415926, "euler": 2.718281828459045, 105: 0.0,
102: 0.0, 103: 3.141592502593994, "euler2": 2.7182817459106445, 106: 0.0}]
*/
+#ifndef QCBOR_DISABLE_PREFERRED_FLOAT
static const uint8_t spExpectedFloats[] = {
0x8B,
0xF9, 0x00, 0x00,
@@ -484,6 +487,37 @@
0xFA, 0x40, 0x2D, 0xF8, 0x54,
0x18, 0x6A,
0xFA, 0x00, 0x00, 0x00, 0x00};
+#else
+static const uint8_t spExpectedFloats[] = {
+ 0x8B,
+ 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xFB, 0x40, 0x09, 0x1E, 0xB8, 0x51, 0xEB, 0x85, 0x1F,
+ 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xFB, 0x7F, 0xF8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xFB, 0x7F, 0xF0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xFA, 0x00, 0x00, 0x00, 0x00,
+ 0xFA, 0x40, 0x48, 0xF5, 0xC3,
+ 0xFA, 0x00, 0x00, 0x00, 0x00,
+ 0xFA, 0x7F, 0xC0, 0x00, 0x00,
+ 0xFA, 0x7F, 0x80, 0x00, 0x00,
+ 0xA8,
+ 0x18, 0x64,
+ 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x18, 0x65,
+ 0xFB, 0x40, 0x09, 0x21, 0xFB, 0x4D, 0x12, 0xD8, 0x4A,
+ 0x65, 0x65, 0x75, 0x6C, 0x65, 0x72,
+ 0xFB, 0x40, 0x05, 0xBF, 0x0A, 0x8B, 0x14, 0x57, 0x69,
+ 0x18, 0x69,
+ 0xFB, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x18, 0x66,
+ 0xFA, 0x00, 0x00, 0x00, 0x00,
+ 0x18, 0x67,
+ 0xFA, 0x40, 0x49, 0x0F, 0xDA,
+ 0x66, 0x65, 0x75, 0x6C, 0x65, 0x72, 0x32,
+ 0xFA, 0x40, 0x2D, 0xF8, 0x54,
+ 0x18, 0x6A,
+ 0xFA, 0x00, 0x00, 0x00, 0x00};
+#endif /* QCBOR_DISABLE_PREFERRED_FLOAT */
int32_t GeneralFloatEncodeTests()
{
@@ -523,11 +557,11 @@
UsefulBufC Encoded;
QCBORError uErr = QCBOREncode_Finish(&EC, &Encoded);
if(uErr) {
- return -1;
+ return -1;
}
if(UsefulBuf_Compare(Encoded, UsefulBuf_FROM_BYTE_ARRAY_LITERAL(spExpectedFloats))) {
- return -3;
+ return -3;
}
return 0;
@@ -578,6 +612,5 @@
}
#endif
-#endif /* QCBOR_DISABLE_PREFERRED_FLOAT */