re organize tests for floating point mostly into one place; CAF floating point tests are passing
diff --git a/QCBOR.xcodeproj/project.pbxproj b/QCBOR.xcodeproj/project.pbxproj
index 7e1a110..3674eac 100644
--- a/QCBOR.xcodeproj/project.pbxproj
+++ b/QCBOR.xcodeproj/project.pbxproj
@@ -10,9 +10,11 @@
0F58EB9C216A388E002FD6D1 /* qcbor_decode_malloc.c in Sources */ = {isa = PBXBuildFile; fileRef = 0F58EB9B216A388E002FD6D1 /* qcbor_decode_malloc.c */; };
0F58EB9F216B91AA002FD6D1 /* mempool_test.c in Sources */ = {isa = PBXBuildFile; fileRef = 0F58EB9E216B91AA002FD6D1 /* mempool_test.c */; };
0FA9BEB7216CE6CA00BA646B /* qcbor_decode_tests.c in Sources */ = {isa = PBXBuildFile; fileRef = 0FA9BEB5216CE6CA00BA646B /* qcbor_decode_tests.c */; };
+ 0FA9BEBA216DC7AD00BA646B /* qcbor_encode_tests.c in Sources */ = {isa = PBXBuildFile; fileRef = 0FA9BEB8216DC7AD00BA646B /* qcbor_encode_tests.c */; };
+ 0FA9BEBD216DE31700BA646B /* UsefulBuf_Tests.c in Sources */ = {isa = PBXBuildFile; fileRef = 0FA9BEBC216DE31700BA646B /* UsefulBuf_Tests.c */; };
E73B5756216071900080D658 /* bstrwrap_tests.c in Sources */ = {isa = PBXBuildFile; fileRef = E73B5755216071900080D658 /* bstrwrap_tests.c */; };
E73B57592161CA690080D658 /* ieee754.c in Sources */ = {isa = PBXBuildFile; fileRef = E73B57582161CA690080D658 /* ieee754.c */; };
- E73B575E2161CA7C0080D658 /* half_precision_test.c in Sources */ = {isa = PBXBuildFile; fileRef = E73B575A2161CA7C0080D658 /* half_precision_test.c */; };
+ E73B575E2161CA7C0080D658 /* float_tests.c in Sources */ = {isa = PBXBuildFile; fileRef = E73B575A2161CA7C0080D658 /* float_tests.c */; };
E73B575F2161CA7C0080D658 /* half_to_double_from_rfc7049.c in Sources */ = {isa = PBXBuildFile; fileRef = E73B575D2161CA7C0080D658 /* half_to_double_from_rfc7049.c */; };
E73B57652161F8F80080D658 /* run_tests.c in Sources */ = {isa = PBXBuildFile; fileRef = E73B57632161F8F70080D658 /* run_tests.c */; };
E776E08F214AE07500E67947 /* qcbor_encode.c in Sources */ = {isa = PBXBuildFile; fileRef = E776E08C214AE07400E67947 /* qcbor_encode.c */; };
@@ -40,19 +42,23 @@
0F58EB9E216B91AA002FD6D1 /* mempool_test.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = mempool_test.c; path = test/mempool_test.c; sourceTree = "<group>"; };
0FA9BEB5216CE6CA00BA646B /* qcbor_decode_tests.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = qcbor_decode_tests.c; path = test/qcbor_decode_tests.c; sourceTree = "<group>"; };
0FA9BEB6216CE6CA00BA646B /* qcbor_decode_tests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = qcbor_decode_tests.h; path = test/qcbor_decode_tests.h; sourceTree = "<group>"; };
+ 0FA9BEB8216DC7AD00BA646B /* qcbor_encode_tests.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 3; lastKnownFileType = sourcecode.c.c; name = qcbor_encode_tests.c; path = test/qcbor_encode_tests.c; sourceTree = "<group>"; tabWidth = 3; };
+ 0FA9BEB9216DC7AD00BA646B /* qcbor_encode_tests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = qcbor_encode_tests.h; path = test/qcbor_encode_tests.h; sourceTree = "<group>"; };
+ 0FA9BEBB216DE31700BA646B /* UsefulBuf_Tests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = UsefulBuf_Tests.h; path = test/UsefulBuf_Tests.h; sourceTree = "<group>"; };
+ 0FA9BEBC216DE31700BA646B /* UsefulBuf_Tests.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 3; lastKnownFileType = sourcecode.c.c; name = UsefulBuf_Tests.c; path = test/UsefulBuf_Tests.c; sourceTree = "<group>"; tabWidth = 3; };
E73B5754216071900080D658 /* bstrwrap_tests.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = bstrwrap_tests.h; path = test/bstrwrap_tests.h; sourceTree = "<group>"; };
E73B5755216071900080D658 /* bstrwrap_tests.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = bstrwrap_tests.c; path = test/bstrwrap_tests.c; sourceTree = "<group>"; };
E73B57572161CA680080D658 /* ieee754.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ieee754.h; path = src/ieee754.h; sourceTree = "<group>"; };
E73B57582161CA690080D658 /* ieee754.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = ieee754.c; path = src/ieee754.c; sourceTree = "<group>"; };
- E73B575A2161CA7C0080D658 /* half_precision_test.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = half_precision_test.c; path = test/half_precision_test.c; sourceTree = "<group>"; };
+ E73B575A2161CA7C0080D658 /* float_tests.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = float_tests.c; path = test/float_tests.c; sourceTree = "<group>"; };
E73B575B2161CA7C0080D658 /* half_to_double_from_rfc7049.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = half_to_double_from_rfc7049.h; path = test/half_to_double_from_rfc7049.h; sourceTree = "<group>"; };
- E73B575C2161CA7C0080D658 /* half_precision_test.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = half_precision_test.h; path = test/half_precision_test.h; sourceTree = "<group>"; };
+ E73B575C2161CA7C0080D658 /* float_tests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = float_tests.h; path = test/float_tests.h; sourceTree = "<group>"; };
E73B575D2161CA7C0080D658 /* half_to_double_from_rfc7049.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = half_to_double_from_rfc7049.c; path = test/half_to_double_from_rfc7049.c; sourceTree = "<group>"; };
E73B57632161F8F70080D658 /* run_tests.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = run_tests.c; path = test/run_tests.c; sourceTree = "<group>"; };
E73B57642161F8F80080D658 /* run_tests.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = run_tests.h; path = test/run_tests.h; sourceTree = "<group>"; };
E776E07C214ADF7F00E67947 /* QCBOR */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = QCBOR; sourceTree = BUILT_PRODUCTS_DIR; };
E776E08C214AE07400E67947 /* qcbor_encode.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 3; lastKnownFileType = sourcecode.c.c; name = qcbor_encode.c; path = src/qcbor_encode.c; sourceTree = "<group>"; tabWidth = 3; };
- E776E08D214AE07500E67947 /* UsefulBuf.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = UsefulBuf.c; path = src/UsefulBuf.c; sourceTree = "<group>"; };
+ E776E08D214AE07500E67947 /* UsefulBuf.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 3; lastKnownFileType = sourcecode.c.c; name = UsefulBuf.c; path = src/UsefulBuf.c; sourceTree = "<group>"; tabWidth = 3; };
E776E08E214AE07500E67947 /* qcbor_decode.c */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 3; lastKnownFileType = sourcecode.c.c; name = qcbor_decode.c; path = src/qcbor_decode.c; sourceTree = "<group>"; tabWidth = 3; };
E776E093214AE08B00E67947 /* qcbor.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 3; lastKnownFileType = sourcecode.c.h; name = qcbor.h; path = inc/qcbor.h; sourceTree = "<group>"; tabWidth = 3; };
E776E094214AE09700E67947 /* UsefulBuf.h */ = {isa = PBXFileReference; fileEncoding = 4; indentWidth = 3; lastKnownFileType = sourcecode.c.h; name = UsefulBuf.h; path = inc/UsefulBuf.h; sourceTree = "<group>"; tabWidth = 3; };
@@ -118,12 +124,16 @@
E776E095214AE0B600E67947 /* test */ = {
isa = PBXGroup;
children = (
+ 0FA9BEBC216DE31700BA646B /* UsefulBuf_Tests.c */,
+ 0FA9BEBB216DE31700BA646B /* UsefulBuf_Tests.h */,
+ 0FA9BEB8216DC7AD00BA646B /* qcbor_encode_tests.c */,
+ 0FA9BEB9216DC7AD00BA646B /* qcbor_encode_tests.h */,
0FA9BEB5216CE6CA00BA646B /* qcbor_decode_tests.c */,
0FA9BEB6216CE6CA00BA646B /* qcbor_decode_tests.h */,
E73B57632161F8F70080D658 /* run_tests.c */,
E73B57642161F8F80080D658 /* run_tests.h */,
- E73B575A2161CA7C0080D658 /* half_precision_test.c */,
- E73B575C2161CA7C0080D658 /* half_precision_test.h */,
+ E73B575A2161CA7C0080D658 /* float_tests.c */,
+ E73B575C2161CA7C0080D658 /* float_tests.h */,
E73B575D2161CA7C0080D658 /* half_to_double_from_rfc7049.c */,
E73B575B2161CA7C0080D658 /* half_to_double_from_rfc7049.h */,
E776E09C214AEEEA00E67947 /* basic_test.c */,
@@ -198,12 +208,14 @@
E73B575F2161CA7C0080D658 /* half_to_double_from_rfc7049.c in Sources */,
E73B57652161F8F80080D658 /* run_tests.c in Sources */,
E776E091214AE07500E67947 /* qcbor_decode.c in Sources */,
- E73B575E2161CA7C0080D658 /* half_precision_test.c in Sources */,
+ E73B575E2161CA7C0080D658 /* float_tests.c in Sources */,
0FA9BEB7216CE6CA00BA646B /* qcbor_decode_tests.c in Sources */,
E776E090214AE07500E67947 /* UsefulBuf.c in Sources */,
+ 0FA9BEBA216DC7AD00BA646B /* qcbor_encode_tests.c in Sources */,
E776E097214AE0C700E67947 /* cmd_line_main.c in Sources */,
E73B5756216071900080D658 /* bstrwrap_tests.c in Sources */,
E776E09D214AEEEA00E67947 /* basic_test.c in Sources */,
+ 0FA9BEBD216DE31700BA646B /* UsefulBuf_Tests.c in Sources */,
0F58EB9F216B91AA002FD6D1 /* mempool_test.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
@@ -325,6 +337,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
+ GCC_OPTIMIZATION_LEVEL = s;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Debug;
@@ -333,6 +346,7 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
+ GCC_OPTIMIZATION_LEVEL = s;
PRODUCT_NAME = "$(TARGET_NAME)";
};
name = Release;
diff --git a/test/half_precision_test.c b/test/float_tests.c
similarity index 86%
rename from test/half_precision_test.c
rename to test/float_tests.c
index 936d70f..1bff43c 100644
--- a/test/half_precision_test.c
+++ b/test/float_tests.c
@@ -1,5 +1,5 @@
/*==============================================================================
- half_precision_test.c -- tests for converstion to/from half-precision
+ float_tests.c -- tests for float and conversion to/from half-precision
Copyright 2018 Laurence Lundblade
@@ -28,11 +28,110 @@
// Created by Laurence Lundblade on 9/19/18.
-#include "half_precision_test.h"
+#include "float_tests.h"
#include "qcbor.h"
#include "half_to_double_from_rfc7049.h"
#include <math.h> // For INFINITY and NAN and isnan()
+
+
+
+static uint8_t pExpectedEncodedFloat[] = {
+ 0x98, 0x1e, 0xfa, 0x00, 0x00, 0x00, 0x00, 0xfa,
+ 0x3f, 0x80, 0x00, 0x00, 0xfa, 0x3f, 0x8c, 0xcc,
+ 0xcd, 0xfa, 0x3f, 0xc0, 0x00, 0x00, 0xfa, 0x47,
+ 0x7f, 0xe0, 0x00, 0xfa, 0x47, 0xc3, 0x50, 0x00,
+ 0xfa, 0x7f, 0x7f, 0xff, 0xff, 0xfa, 0x7f, 0x80,
+ 0x00, 0x00, 0xfa, 0x33, 0x80, 0x00, 0x00, 0xfa,
+ 0x38, 0x80, 0x00, 0x00, 0xfa, 0xc0, 0x80, 0x00,
+ 0x00, 0xfa, 0xc0, 0x83, 0x33, 0x33, 0xfa, 0x7f,
+ 0xc0, 0x00, 0x00, 0xfa, 0x7f, 0x80, 0x00, 0x00,
+ 0xfa, 0xff, 0x80, 0x00, 0x00, 0xfb, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb, 0x3f,
+ 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb,
+ 0x3f, 0xf1, 0x99, 0x99, 0x99, 0x99, 0x99, 0x9a,
+ 0xfb, 0x3f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0xfb, 0x40, 0xef, 0xfc, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xfb, 0x40, 0xf8, 0x6a, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xfb, 0x47, 0xef, 0xff, 0xff,
+ 0xe0, 0x00, 0x00, 0x00, 0xfb, 0x7e, 0x37, 0xe4,
+ 0x3c, 0x88, 0x00, 0x75, 0x9c, 0xfb, 0x3e, 0x70,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb, 0x3f,
+ 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb,
+ 0xc0, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0xfb, 0xc0, 0x10, 0x66, 0x66, 0x66, 0x66, 0x66,
+ 0x66, 0xfb, 0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0xfb, 0x7f, 0xf0, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0xfb, 0xff, 0xf0, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00};
+
+
+int FloatValuesTest1()
+{
+ QCBOREncodeContext ECtx;
+ int nReturn = 0;
+
+ UsefulBuf_MakeStackUB(EncodedStorage, 1000);
+
+ QCBOREncode_Init(&ECtx, EncodedStorage);
+ QCBOREncode_OpenArray(&ECtx);
+
+ // These are all samples published
+ // in RFC 7049.
+ QCBOREncode_AddFloat(&ECtx, 0.0);
+ QCBOREncode_AddFloat(&ECtx, 1.0);
+ QCBOREncode_AddFloat(&ECtx, 1.1); // appx
+ QCBOREncode_AddFloat(&ECtx, 1.5);
+ QCBOREncode_AddFloat(&ECtx, 65504.0);
+ QCBOREncode_AddFloat(&ECtx, 100000.0);
+ QCBOREncode_AddFloat(&ECtx, 3.4028234663852886e+38);
+ QCBOREncode_AddFloat(&ECtx, 1.0e+300); // Infinity?
+ QCBOREncode_AddFloat(&ECtx, 5.960464477539063e-8);
+ QCBOREncode_AddFloat(&ECtx, 0.00006103515625);
+ QCBOREncode_AddFloat(&ECtx, -4.0);
+ QCBOREncode_AddFloat(&ECtx, -4.1); // appx
+
+ QCBOREncode_AddFloat(&ECtx, NAN);
+ QCBOREncode_AddFloat(&ECtx, INFINITY);
+ QCBOREncode_AddFloat(&ECtx, -INFINITY);
+
+
+ QCBOREncode_AddDouble(&ECtx, 0.0);
+ QCBOREncode_AddDouble(&ECtx, 1.0);
+ QCBOREncode_AddDouble(&ECtx, 1.1); // appx
+ QCBOREncode_AddDouble(&ECtx, 1.5);
+ QCBOREncode_AddDouble(&ECtx, 65504.0);
+ QCBOREncode_AddDouble(&ECtx, 100000.0);
+ QCBOREncode_AddDouble(&ECtx, 3.4028234663852886e+38);
+ QCBOREncode_AddDouble(&ECtx, 1.0e+300); // Infinity?
+ QCBOREncode_AddDouble(&ECtx, 5.960464477539063e-8);
+ QCBOREncode_AddDouble(&ECtx, 0.00006103515625);
+ QCBOREncode_AddDouble(&ECtx, -4.0);
+ QCBOREncode_AddDouble(&ECtx, -4.1); // appx
+
+ QCBOREncode_AddDouble(&ECtx, NAN);
+ QCBOREncode_AddDouble(&ECtx, INFINITY);
+ QCBOREncode_AddDouble(&ECtx, -INFINITY);
+
+ QCBOREncode_CloseArray(&ECtx);
+
+ UsefulBufC Encoded;
+ if(QCBOREncode_Finish2(&ECtx, &Encoded)) {
+ nReturn = -1;
+ }
+
+ if(UsefulBuf_Compare(Encoded, UsefulBuf_FromByteArrayLiteral(pExpectedEncodedFloat))) {
+ nReturn = -2;
+ }
+
+ //printencoded(pEncoded, nEncodedLen);
+
+ return(nReturn);
+}
+
+
+
+
static const uint8_t ExpectedHalf[] = {
0xB1,
0x64,
diff --git a/test/half_precision_test.h b/test/float_tests.h
similarity index 89%
rename from test/half_precision_test.h
rename to test/float_tests.h
index 1367db5..5bb638b 100644
--- a/test/half_precision_test.h
+++ b/test/float_tests.h
@@ -1,5 +1,5 @@
/*==============================================================================
- half_precision_test.h -- tests for converstion to/from half-precision
+ float_tests.h -- tests for float and conversion to/from half-precision
Copyright 2018 Laurence Lundblade
@@ -28,8 +28,10 @@
// Created by Laurence Lundblade on 9/19/18.
-#ifndef half_precision_test_h
-#define half_precision_test_h
+#ifndef float_tests_h
+#define float_tests_h
+
+int FloatValuesTest1(void);
int half_precision_encode_basic(void);
@@ -42,4 +44,4 @@
int half_precision_to_float_vs_rfc_test(void);
-#endif /* half_precision_test_h */
+#endif /* float_tests_h */
diff --git a/test/qcbor_encode_tests.c b/test/qcbor_encode_tests.c
index 4a79bbd..39e3fc5 100644
--- a/test/qcbor_encode_tests.c
+++ b/test/qcbor_encode_tests.c
@@ -686,102 +686,8 @@
return(nReturn);
}
-#if 0
-static uint8_t pExpectedEncodedFloat[] = {
- 0x98, 0x1e, 0xfa, 0x00, 0x00, 0x00, 0x00, 0xfa,
- 0x3f, 0x80, 0x00, 0x00, 0xfa, 0x3f, 0x8c, 0xcc,
- 0xcd, 0xfa, 0x3f, 0xc0, 0x00, 0x00, 0xfa, 0x47,
- 0x7f, 0xe0, 0x00, 0xfa, 0x47, 0xc3, 0x50, 0x00,
- 0xfa, 0x7f, 0x7f, 0xff, 0xff, 0xfa, 0x7f, 0x80,
- 0x00, 0x00, 0xfa, 0x33, 0x80, 0x00, 0x00, 0xfa,
- 0x38, 0x80, 0x00, 0x00, 0xfa, 0xc0, 0x80, 0x00,
- 0x00, 0xfa, 0xc0, 0x83, 0x33, 0x33, 0xfa, 0x7f,
- 0xc0, 0x00, 0x00, 0xfa, 0x7f, 0x80, 0x00, 0x00,
- 0xfa, 0xff, 0x80, 0x00, 0x00, 0xfb, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb, 0x3f,
- 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb,
- 0x3f, 0xf1, 0x99, 0x99, 0x99, 0x99, 0x99, 0x9a,
- 0xfb, 0x3f, 0xf8, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0xfb, 0x40, 0xef, 0xfc, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xfb, 0x40, 0xf8, 0x6a, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xfb, 0x47, 0xef, 0xff, 0xff,
- 0xe0, 0x00, 0x00, 0x00, 0xfb, 0x7e, 0x37, 0xe4,
- 0x3c, 0x88, 0x00, 0x75, 0x9c, 0xfb, 0x3e, 0x70,
- 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb, 0x3f,
- 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xfb,
- 0xc0, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
- 0xfb, 0xc0, 0x10, 0x66, 0x66, 0x66, 0x66, 0x66,
- 0x66, 0xfb, 0x7f, 0xf8, 0x00, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0xfb, 0x7f, 0xf0, 0x00, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0xfb, 0xff, 0xf0, 0x00, 0x00,
- 0x00, 0x00, 0x00, 0x00};
-
-
-int FloatValuesTest1()
-{
- QCBOREncodeContext ECtx;
- int nReturn = 0;
-
- uint8_t pEncoded[1000];
- size_t nEncodedLen = sizeof(pEncoded);
-
- QCBOREncode_Init(&ECtx, pEncoded, nEncodedLen);
- QCBOREncode_OpenArray(&ECtx);
-
- // These are all samples published
- // in RFC 7049.
- QCBOREncode_AddFloat(&ECtx, 0.0);
- QCBOREncode_AddFloat(&ECtx, 1.0);
- QCBOREncode_AddFloat(&ECtx, 1.1); // appx
- QCBOREncode_AddFloat(&ECtx, 1.5);
- QCBOREncode_AddFloat(&ECtx, 65504.0);
- QCBOREncode_AddFloat(&ECtx, 100000.0);
- QCBOREncode_AddFloat(&ECtx, 3.4028234663852886e+38);
- QCBOREncode_AddFloat(&ECtx, 1.0e+300); // Infinity?
- QCBOREncode_AddFloat(&ECtx, 5.960464477539063e-8);
- QCBOREncode_AddFloat(&ECtx, 0.00006103515625);
- QCBOREncode_AddFloat(&ECtx, -4.0);
- QCBOREncode_AddFloat(&ECtx, -4.1); // appx
-
- QCBOREncode_AddFloat(&ECtx, NAN);
- QCBOREncode_AddFloat(&ECtx, INFINITY);
- QCBOREncode_AddFloat(&ECtx, -INFINITY);
-
-
- QCBOREncode_AddDouble(&ECtx, 0.0);
- QCBOREncode_AddDouble(&ECtx, 1.0);
- QCBOREncode_AddDouble(&ECtx, 1.1); // appx
- QCBOREncode_AddDouble(&ECtx, 1.5);
- QCBOREncode_AddDouble(&ECtx, 65504.0);
- QCBOREncode_AddDouble(&ECtx, 100000.0);
- QCBOREncode_AddDouble(&ECtx, 3.4028234663852886e+38);
- QCBOREncode_AddDouble(&ECtx, 1.0e+300); // Infinity?
- QCBOREncode_AddDouble(&ECtx, 5.960464477539063e-8);
- QCBOREncode_AddDouble(&ECtx, 0.00006103515625);
- QCBOREncode_AddDouble(&ECtx, -4.0);
- QCBOREncode_AddDouble(&ECtx, -4.1); // appx
-
- QCBOREncode_AddDouble(&ECtx, NAN);
- QCBOREncode_AddDouble(&ECtx, INFINITY);
- QCBOREncode_AddDouble(&ECtx, -INFINITY);
-
- QCBOREncode_CloseArray(&ECtx);
- if(QCBOREncode_Finish(&ECtx, &nEncodedLen)) {
- nReturn = -1;
- }
-
- if(nEncodedLen != sizeof(pExpectedEncodedFloat) || bcmp(pEncoded, pExpectedEncodedFloat, nEncodedLen))
- nReturn = -1;
-
- //printencoded(pEncoded, nEncodedLen);
-
- return(nReturn);
-}
-
-#endif
-
static uint8_t pExpectedEncodedDates[] = {
0x83, 0xc0, 0x74, 0x32, 0x30, 0x31, 0x33, 0x2d, 0x30, 0x33, 0x2d, 0x32, 0x31, 0x54,
0x32, 0x30, 0x3a, 0x30, 0x34, 0x3a, 0x30, 0x30,
diff --git a/test/run_tests.c b/test/run_tests.c
index ae184d8..38341a8 100644
--- a/test/run_tests.c
+++ b/test/run_tests.c
@@ -33,7 +33,7 @@
#include "UsefulBuf.h"
#include <stdbool.h>
-#include "half_precision_test.h"
+#include "float_tests.h"
#include "basic_test.h"
#include "bstrwrap_tests.h"
#include "mempool_test.h"
@@ -115,6 +115,7 @@
test_entry s_tests[] = {
+ TEST_ENTRY(FloatValuesTest1),
TEST_ENTRY(RTICResultsTest),
TEST_ENTRY(MapEncodeTest),
TEST_ENTRY(ArrayNestingTest1),