testing, fixes and doc clean up
diff --git a/inc/qcbor/qcbor_decode.h b/inc/qcbor/qcbor_decode.h
index 96ba644..d725582 100644
--- a/inc/qcbor/qcbor_decode.h
+++ b/inc/qcbor/qcbor_decode.h
@@ -298,7 +298,7 @@
* avoid over/underflow) to get the value transmitted - val.uint64 - 1.
* See QCBOREncode_AddNegativeUInt64() for a longer explanation
* and warning. */
-#define QCBOR_TYPE_NEG_INT 28
+#define QCBOR_TYPE_65BIT_NEG_INT 28
#define QCBOR_TYPE_BREAK 31 /* Used internally; never returned */
diff --git a/inc/qcbor/qcbor_encode.h b/inc/qcbor/qcbor_encode.h
index e2880ea..9289ca7 100644
--- a/inc/qcbor/qcbor_encode.h
+++ b/inc/qcbor/qcbor_encode.h
@@ -570,7 +570,7 @@
*
* Negative integers are normally decoded in QCBOR with type \ref
* QCBOR_TYPE_INT64. Integers in the range of -9223372036854775809 to
- * -18446744073709551616 are returned as \ref QCBOR_TYPE_NEG_INT.
+ * -18446744073709551616 are returned as \ref QCBOR_TYPE_65BIT_NEG_INT.
*
* WARNING: some CBOR decoders will be unable to decode
* -9223372036854775809 to -18446744073709551616. Most CPUs do not
diff --git a/src/qcbor_decode.c b/src/qcbor_decode.c
index 7d49ca2..332314b 100644
--- a/src/qcbor_decode.c
+++ b/src/qcbor_decode.c
@@ -885,7 +885,7 @@
} else {
pDecodedItem->val.uint64 = uArgument;
- pDecodedItem->uDataType = QCBOR_TYPE_NEG_INT;
+ pDecodedItem->uDataType = QCBOR_TYPE_65BIT_NEG_INT;
}
}
@@ -4919,13 +4919,10 @@
}
break;
- case QCBOR_TYPE_NEG_INT:
- // TODO: test this
- if(pItem->val.uint64 < INT64_MAX) {
- *pnValue = -((int64_t)pItem->val.uint64)-1;
- } else {
- return QCBOR_ERR_CONVERSION_UNDER_OVER_FLOW;
- }
+ case QCBOR_TYPE_65BIT_NEG_INT:
+ /* This type occurs if the value won't fit into int64_t
+ * so this is always an error. */
+ return QCBOR_ERR_CONVERSION_UNDER_OVER_FLOW;
break;
default:
@@ -5304,7 +5301,7 @@
}
break;
- case QCBOR_TYPE_NEG_INT:
+ case QCBOR_TYPE_65BIT_NEG_INT:
return QCBOR_ERR_NUMBER_SIGN_CONVERSION;
default:
@@ -5644,10 +5641,7 @@
return QCBOR_ERR_HW_FLOAT_DISABLED;
#endif /* QCBOR_DISABLE_FLOAT_HW_USE */
- // TODO: testing...
- // TODO: check for conversion flats
-
- case QCBOR_TYPE_NEG_INT:
+ case QCBOR_TYPE_65BIT_NEG_INT:
*pdValue = -(double)pItem->val.uint64 - 1;
break;
diff --git a/test/qcbor_decode_tests.c b/test/qcbor_decode_tests.c
index cd3d0ea..3f2fd81 100644
--- a/test/qcbor_decode_tests.c
+++ b/test/qcbor_decode_tests.c
@@ -158,13 +158,13 @@
if((nCBORError = QCBORDecode_GetNext(pDCtx, &Item)))
return (int32_t)nCBORError;
- if(Item.uDataType != QCBOR_TYPE_NEG_INT ||
+ if(Item.uDataType != QCBOR_TYPE_65BIT_NEG_INT ||
Item.val.uint64 != 18446744073709551615ULL)
return -1;
if((nCBORError = QCBORDecode_GetNext(pDCtx, &Item)))
return (int32_t)nCBORError;
- if(Item.uDataType != QCBOR_TYPE_NEG_INT ||
+ if(Item.uDataType != QCBOR_TYPE_65BIT_NEG_INT ||
Item.val.uint64 != 18446744073709551614ULL)
return -1;