Progress on floating point, but not done: a lot more tests, a few bug fixes; also copyright notice for floating point files; also some work on test framework
diff --git a/src/UsefulBuf.c b/src/UsefulBuf.c
index d98ebd5..a1305d2 100644
--- a/src/UsefulBuf.c
+++ b/src/UsefulBuf.c
@@ -241,7 +241,7 @@
/* 3. Slide existing data to the right */
uint8_t *pSourceOfMove = ((uint8_t *)me->UB.ptr) + uInsertionPos; // PtrMath #1
- size_t uNumBytesToMove = me->UB.len - uInsertionPos; // PtrMath #2
+ size_t uNumBytesToMove = me->data_len - uInsertionPos; // PtrMath #2
uint8_t *pDestinationOfMove = pSourceOfMove + NewData.len; // PtrMath #3
size_t uRoomInDestination = me->UB.len - (uInsertionPos + NewData.len); // PtrMath #4
diff --git a/src/ieee754.c b/src/ieee754.c
index a5a65a3..bcad14d 100644
--- a/src/ieee754.c
+++ b/src/ieee754.c
@@ -1,3 +1,29 @@
+/*==============================================================================
+ Copyright 2018 Laurence Lundblade
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+
+ (This is the MIT license)
+ ==============================================================================*/
+
//
// ieee754.c
// Indefinite
@@ -139,7 +165,7 @@
// Public function; see ieee754.h
-int16_t IEEE754_FloatToHalf(float f)
+uint16_t IEEE754_FloatToHalf(float f)
{
// Pull the three parts out of the single-precision float
const uint32_t uSingle = CopyFloatToUint32(f);
@@ -204,7 +230,7 @@
// Public function; see ieee754.h
-int16_t IEEE754_DoubleToHalf(double d)
+uint16_t IEEE754_DoubleToHalf(double d)
{
// Pull the three parts out of the double-precision float
const uint64_t uDouble = CopyDoubleToUint64(d);
diff --git a/src/ieee754.h b/src/ieee754.h
index ced4bcb..ba2b030 100644
--- a/src/ieee754.h
+++ b/src/ieee754.h
@@ -1,3 +1,28 @@
+/*==============================================================================
+ Copyright 2018 Laurence Lundblade
+
+ Permission is hereby granted, free of charge, to any person obtaining
+ a copy of this software and associated documentation files (the
+ "Software"), to deal in the Software without restriction, including
+ without limitation the rights to use, copy, modify, merge, publish,
+ distribute, sublicense, and/or sell copies of the Software, and to
+ permit persons to whom the Software is furnished to do so, subject to
+ the following conditions:
+
+ The above copyright notice and this permission notice shall be included
+ in all copies or substantial portions of the Software.
+
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ SOFTWARE.
+
+ (This is the MIT license)
+ ==============================================================================*/
//
// ieee754.h
// Indefinite
@@ -53,11 +78,11 @@
*/
-int16_t IEEE754_FloatToHalf(float f);
+uint16_t IEEE754_FloatToHalf(float f);
float IEEE754_HalfToFloat(uint16_t uHalfPrecision);
-int16_t IEEE754_DoubleToHalf(double d);
+uint16_t IEEE754_DoubleToHalf(double d);
double IEEE754_HalfToDouble(uint16_t uHalfPrecision);
diff --git a/src/qcbor_decode.c b/src/qcbor_decode.c
index 6aee680..806287d 100644
--- a/src/qcbor_decode.c
+++ b/src/qcbor_decode.c
@@ -302,11 +302,11 @@
nReturn = QCBOR_ERR_UNSUPPORTED;
break;
- case SINGLE_PREC_FLOAT:
+ case HALF_PREC_FLOAT:
pDecodedItem->val.fnum = IEEE754_HalfToFloat((uint16_t)uNumber);
pDecodedItem->uDataType = QCBOR_TYPE_FLOAT;
break;
- case HALF_PREC_FLOAT:
+ case SINGLE_PREC_FLOAT:
pDecodedItem->val.fnum = UsefulBufUtil_CopyUint32ToFloat((uint32_t)uNumber);
break;
case DOUBLE_PREC_FLOAT: