bug fix in indefinite length array decoding; all but one tests are passing and this test kind of has a problem
diff --git a/QCBOR.xcodeproj/project.pbxproj b/QCBOR.xcodeproj/project.pbxproj
index dfcdcf4..7e1a110 100644
--- a/QCBOR.xcodeproj/project.pbxproj
+++ b/QCBOR.xcodeproj/project.pbxproj
@@ -8,6 +8,8 @@
 
 /* Begin PBXBuildFile section */
 		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 */; };
 		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 */; };
@@ -34,6 +36,10 @@
 
 /* Begin PBXFileReference section */
 		0F58EB9B216A388E002FD6D1 /* qcbor_decode_malloc.c */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.c; name = qcbor_decode_malloc.c; path = src/qcbor_decode_malloc.c; sourceTree = "<group>"; };
+		0F58EB9D216B91AA002FD6D1 /* mempool_test.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = mempool_test.h; path = test/mempool_test.h; sourceTree = "<group>"; };
+		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>"; };
 		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>"; };
@@ -112,6 +118,8 @@
 		E776E095214AE0B600E67947 /* test */ = {
 			isa = PBXGroup;
 			children = (
+				0FA9BEB5216CE6CA00BA646B /* qcbor_decode_tests.c */,
+				0FA9BEB6216CE6CA00BA646B /* qcbor_decode_tests.h */,
 				E73B57632161F8F70080D658 /* run_tests.c */,
 				E73B57642161F8F80080D658 /* run_tests.h */,
 				E73B575A2161CA7C0080D658 /* half_precision_test.c */,
@@ -122,6 +130,8 @@
 				E73B5754216071900080D658 /* bstrwrap_tests.h */,
 				E73B5755216071900080D658 /* bstrwrap_tests.c */,
 				E776E09B214AEEEA00E67947 /* basic_test.h */,
+				0F58EB9D216B91AA002FD6D1 /* mempool_test.h */,
+				0F58EB9E216B91AA002FD6D1 /* mempool_test.c */,
 			);
 			name = test;
 			sourceTree = "<group>";
@@ -189,10 +199,12 @@
 				E73B57652161F8F80080D658 /* run_tests.c in Sources */,
 				E776E091214AE07500E67947 /* qcbor_decode.c in Sources */,
 				E73B575E2161CA7C0080D658 /* half_precision_test.c in Sources */,
+				0FA9BEB7216CE6CA00BA646B /* qcbor_decode_tests.c in Sources */,
 				E776E090214AE07500E67947 /* UsefulBuf.c in Sources */,
 				E776E097214AE0C700E67947 /* cmd_line_main.c in Sources */,
 				E73B5756216071900080D658 /* bstrwrap_tests.c in Sources */,
 				E776E09D214AEEEA00E67947 /* basic_test.c in Sources */,
+				0F58EB9F216B91AA002FD6D1 /* mempool_test.c in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
diff --git a/src/qcbor_decode.c b/src/qcbor_decode.c
index 7189c20..410af46 100644
--- a/src/qcbor_decode.c
+++ b/src/qcbor_decode.c
@@ -150,6 +150,9 @@
    // Pop up nesting levels if the counts at the levels are zero
    while(DecodeNesting_IsNested(pNesting) && 0 == pNesting->pCurrent->uCount) {
       pNesting->pCurrent--;
+      if(!DecodeNesting_IsIndefiniteLength(pNesting)) {
+         pNesting->pCurrent->uCount--;
+      }
    }
 }
 
@@ -532,6 +535,25 @@
          pDecodedItem->val.epochDate.nSeconds = Item.val.uint64;
          break;
          
+      case QCBOR_TYPE_FLOAT:
+         // TODO: can we save code by widening a float to a double here? Then drop into double-handling code
+         if(Item.val.fnum > INT64_MAX) {
+            nReturn = QCBOR_ERR_DATE_OVERFLOW;
+            goto Done;
+         }
+         pDecodedItem->val.epochDate.nSeconds = Item.val.fnum;
+         pDecodedItem->val.epochDate.fSecondsFraction = Item.val.fnum - pDecodedItem->val.epochDate.nSeconds;
+         break;
+
+      case QCBOR_TYPE_DOUBLE:
+         if(Item.val.dfnum > INT64_MAX) {
+            nReturn = QCBOR_ERR_DATE_OVERFLOW;
+            goto Done;
+         }
+         pDecodedItem->val.epochDate.nSeconds = Item.val.dfnum;
+         pDecodedItem->val.epochDate.fSecondsFraction = Item.val.dfnum - pDecodedItem->val.epochDate.nSeconds;
+         break;
+         
       default:
          nReturn = QCBOR_ERR_BAD_OPT_TAG;
    }
@@ -869,7 +891,7 @@
 /* Loops processing breaks until a non-break is encountered
  or an error is encountered
  */
-static int LoopOverBreaks(QCBORDecodeContext *me, QCBORItem *pDecodedItem)
+static int GetNext_GetNonBreak(QCBORDecodeContext *me, QCBORItem *pDecodedItem)
 {
    int nReturn = QCBOR_SUCCESS;
    
@@ -912,7 +934,7 @@
    int nReturn;
    
    // Loop getting items until one that is not a break is fetched
-   nReturn = LoopOverBreaks(me, pDecodedItem);
+   nReturn = GetNext_GetNonBreak(me, pDecodedItem);
    if(nReturn) {
       goto Done;
    }
@@ -923,13 +945,19 @@
    // decrementing and decsending
    pDecodedItem->uNestingLevel = DecodeNesting_GetLevel(&(me->nesting));
    
-   // Always decrement the count at the current level no matter what type
-   // except for breaks as breaks are always processed above
-   DecodeNesting_DecrementCount(&(me->nesting));
-   
-   // If the new item is array or map, the nesting level descends
    if(IsMapOrArray(pDecodedItem->uDataType)) {
+      // If the new item is array or map, the nesting level descends
       nReturn = DecodeNesting_Descend(&(me->nesting), pDecodedItem);
+      // Maps and arrays do count in as items in the map/array that encloses
+      // them so a decrement needs to be done for them too, but that is done
+      // only when all the items in them have been processed, not when they
+      // are opened.
+   } else {
+      // Decrement the count of items in the enclosing map/array
+      // If the count in the enclosing map/array goes to zero, that
+      // triggers a decrement for in the map/array above that and
+      // and ascend in mnesting level.
+      DecodeNesting_DecrementCount(&(me->nesting));
    }
    
 Done:
@@ -949,7 +977,7 @@
    // the last item in them is consumed; they are not handled here.
    if(DecodeNesting_IsNested(&(me->nesting))) {
       QCBORItem Item;
-      nReturn = LoopOverBreaks(me, &Item);
+      nReturn = GetNext_GetNonBreak(me, &Item);
       if(nReturn) {
          goto Done;
       }
@@ -1043,8 +1071,8 @@
    if(pMem) {
       // Realloc case
       // TODO: review this pointer math
-      if((uint8_t *)pMem + uNewSize <= me->pEnd && (uint8_t *)pMem > me->pStart) {
-         me->pFree = pMem + uNewSize;
+      if((uint8_t *)pMem + uNewSize <= me->pEnd) {//} && (uint8_t *)pMem > me->pStart) {
+         me->pFree = (uint8_t *)pMem + uNewSize;
          pReturn = pMem;
       }
    } else {
diff --git a/test/basic_test.c b/test/basic_test.c
index 8241302..645cce6 100644
--- a/test/basic_test.c
+++ b/test/basic_test.c
@@ -89,41 +89,73 @@
     if(QCBOREncode_Finish2(&EC, &Encoded2)) {
         return -3;
     }
-    
+    /*
+     [                // 0    1:3
+        451,          // 1    1:2
+        {             // 1    1:2   2:1
+          66: true    // 2    1:1
+        },
+        {             // 1    1:1   2:1
+          -70000: {   // 2    1:1   2:1   3:1
+            66: true  // 3    XXXXXX
+          }
+        }
+     ]
+     
+     
+     
+      83                # array(3)
+         19 01C3        # unsigned(451)
+         A1             # map(1)
+            18 42       # unsigned(66)
+            F5          # primitive(21)
+         A1             # map(1)
+            3A 0001116F # negative(69999)
+            A1          # map(1)
+               18 42    # unsigned(66)
+               F5       # primitive(21)
+     */
     
     // Decode it and see if it is OK
     QCBORDecode_Init(&DC, Encoded2, QCBOR_DECODE_MODE_NORMAL);
 
+    // 0    1:3
     QCBORDecode_GetNext(&DC, &Item);
     if(Item.uDataType != QCBOR_TYPE_ARRAY || Item.val.uCount != 3) {
         return -1;
     }
-    
+   
+    // 1    1:2
     QCBORDecode_GetNext(&DC, &Item);
     if(Item.uDataType != QCBOR_TYPE_INT64 || Item.val.uint64 != 451) {
         return -1;
     }
 
+    // 1    1:2   2:1
     QCBORDecode_GetNext(&DC, &Item);
     if(Item.uDataType != QCBOR_TYPE_MAP || Item.val.uCount != 1) {
         return -1;
     }
-    
+   
+    // 2    1:1
     QCBORDecode_GetNext(&DC, &Item);
     if(Item.uDataType != QCBOR_TYPE_TRUE) {
         return -1;
     }
 
+    // 1    1:1   2:1
     QCBORDecode_GetNext(&DC, &Item);
     if(Item.uDataType != QCBOR_TYPE_MAP || Item.val.uCount != 1) {
         return -1;
     }
-    
+   
+    // 2    1:1   2:1   3:1
     QCBORDecode_GetNext(&DC, &Item);
     if(Item.uDataType != QCBOR_TYPE_MAP || Item.val.uCount != 1 || Item.uLabelType != QCBOR_TYPE_INT64 || Item.label.int64 != -70000) {
         return -1;
     }
 
+    // 3    XXXXXX
     QCBORDecode_GetNext(&DC, &Item);
     if(Item.uDataType != QCBOR_TYPE_TRUE || Item.uLabelType != QCBOR_TYPE_INT64 || Item.label.int64 != 66) {
         return -1;
@@ -148,9 +180,13 @@
 
 static const uint8_t pIndefiniteArray[] = {0x9f, 0x01, 0x82, 0x02, 0x03, 0xff};
 
+// [1, [2, 3]]
+
+
 //0x9f018202039f0405ffff
 
-int indefinite_length_decode_test() {
+int indefinite_length_decode_test()
+{
     UsefulBufC IndefLen = UsefulBuf_FromByteArrayLiteral(pIndefiniteArray);
     
     
diff --git a/test/mempool_test.c b/test/mempool_test.c
index 3eec5e8..e94e1a2 100644
--- a/test/mempool_test.c
+++ b/test/mempool_test.c
@@ -7,3 +7,73 @@
 //
 
 #include "mempool_test.h"
+#include "qcbor.h"
+
+int mempool_test(void)
+{
+    QCBORDecodeContext DC;
+    
+    const uint8_t pMinimalCBOR[] = {0xa0}; // One empty map
+    
+    QCBORDecode_Init(&DC, UsefulBuf_FromByteArrayLiteral(pMinimalCBOR),0);
+    
+    UsefulBuf_MakeStackUB(Pool, 100);
+    
+    QCBORDecode_SetMemPool(&DC, Pool, 0);
+    
+    // Cheat a little to get to the string allocator object
+    // so we can call it directly to test it
+    QCBORStringAllocator *pAlloc = (QCBORStringAllocator *)DC.pStringAllocator;
+    
+    // Ask for too much in one go
+    // 90 < 100, but there is some overhead taken out of the 100
+    UsefulBuf Allocated = (*pAlloc->fAllocate)(pAlloc->pAllocaterContext, NULL, 90);
+    if(!UsefulBuf_IsNULL(Allocated)) {
+        return -1;
+    }
+    
+    
+    
+    QCBORDecode_SetMemPool(&DC, Pool, 0);
+    
+    // Cheat a little to get to the string allocator object
+    // so we can call it directly to test it
+    pAlloc = (QCBORStringAllocator *)DC.pStringAllocator;
+
+    Allocated = (*pAlloc->fAllocate)(pAlloc->pAllocaterContext, NULL, 30);
+    if(UsefulBuf_IsNULL(Allocated)) { // expected to succeed
+        return -1;
+    }
+    UsefulBuf Allocated2 = (*pAlloc->fAllocate)(pAlloc->pAllocaterContext, NULL, 30);
+    if(!UsefulBuf_IsNULL(Allocated2)) { // expected to fail
+        return -1;
+    }
+    (*pAlloc->fFree)(pAlloc->pAllocaterContext, Allocated.ptr);
+    Allocated = (*pAlloc->fAllocate)(pAlloc->pAllocaterContext, NULL, 30);
+    if(UsefulBuf_IsNULL(Allocated)) { // succeed because of the free
+        return -1;
+    }
+    
+    
+    QCBORDecode_SetMemPool(&DC, Pool, 0);
+    
+    // Cheat a little to get to the string allocator object
+    // so we can call it directly to test it
+    pAlloc = (QCBORStringAllocator *)DC.pStringAllocator;
+    Allocated = (*pAlloc->fAllocate)(pAlloc->pAllocaterContext, NULL, 20);
+    if(UsefulBuf_IsNULL(Allocated)) { // expected to succeed
+        return -1;
+    }
+    Allocated2 = (*pAlloc->fAllocate)(pAlloc->pAllocaterContext, Allocated.ptr, 25);
+    if(UsefulBuf_IsNULL(Allocated2)) { // expected to fail
+        return -1;
+    }
+    if(Allocated2.ptr != Allocated.ptr || Allocated2.len != 25) {
+        return -1;
+    }
+    
+    
+    
+    
+    return 0;
+}
diff --git a/test/mempool_test.h b/test/mempool_test.h
index 02e1cdc..95e43d2 100644
--- a/test/mempool_test.h
+++ b/test/mempool_test.h
@@ -9,6 +9,6 @@
 #ifndef mempool_test_h
 #define mempool_test_h
 
-#include <stdio.h>
+int mempool_test(void);
 
 #endif /* mempool_test_h */
diff --git a/test/qcbor_decode_tests.c b/test/qcbor_decode_tests.c
index 2328912..ce0139d 100644
--- a/test/qcbor_decode_tests.c
+++ b/test/qcbor_decode_tests.c
@@ -27,12 +27,37 @@
 IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ==============================================================================*/
 
+/*==============================================================================
+ Modifications beyond the version released on CAF are under the MIT license:
+ 
+ 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.
+ ==============================================================================*/
+
 #include "qcbor.h"
 #include "qcbor_decode_tests.h"
 #include <stdio.h>
 #include <strings.h>
-#include <float.h>
-#include <math.h>
+#include <math.h> // for fabs()
 #include <stdlib.h>
 
 
@@ -462,7 +487,7 @@
    // calucate the length so buffer can be allocated correctly,
    // and last with the buffer to do the actual encoding
    do {
-      QCBOREncode_Init(&ECtx, *pEncoded, *pEncodedLen);
+       QCBOREncode_Init(&ECtx, (UsefulBuf){*pEncoded, *pEncodedLen});
       QCBOREncode_OpenArray(&ECtx);
       QCBOREncode_AddInt64(&ECtx, nInt1);
       QCBOREncode_AddInt64(&ECtx, nInt2);
@@ -490,7 +515,6 @@
 }
 
 
-
 /*
  {"first integer": 42,
   "an array of two strings": ["string1", "string2"], 
@@ -561,6 +585,7 @@
 
 
 
+
 int SimpleArrayTest()
 {
    uint8_t *pEncoded;
@@ -591,6 +616,7 @@
 }
 
 
+
 static uint8_t s_pDeepArrays[] = {0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x80};
 
 int ParseDeepArrayTest()
@@ -616,7 +642,6 @@
 }
 
 
-
 static uint8_t s_pTooDeepArrays[] = {0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x81, 0x80};
 
 int ParseTooDeepArrayTest()
@@ -648,21 +673,6 @@
 
 
 
-static uint8_t s_indefiniteLenString[] = { 0x7f, 0x65, 0x73, 0x74, 0x72, 0x65, 0x61, 0x64, 0x6d, 0x69, 0x6e, 0x67, 0xff};
-
-
-int UnsupportedCBORDecodeTest()
-{
-   QCBORDecodeContext DCtx;
-   QCBORItem Item;
-   
-   QCBORDecode_Init(&DCtx, (UsefulBufC){s_indefiniteLenString, sizeof(s_indefiniteLenString)}, QCBOR_DECODE_MODE_NORMAL);
-   if(QCBORDecode_GetNext(&DCtx, &Item) != QCBOR_ERR_UNSUPPORTED)
-      return -1;
-   
-   return 0;
-}
-
 
 
 int ShortBufferParseTest()
@@ -690,6 +700,7 @@
 }
 
 
+
 int ShortBufferParseTest2()
 {
    uint8_t *pEncoded;
@@ -719,7 +730,6 @@
 }
 
 
-
 static int ParseMapTest1()
 {
    QCBORDecodeContext DCtx;
@@ -824,6 +834,8 @@
 
 /*
  This test parses pValidMapEncoded and checks for extra bytes along the way
+ // TODO: this test doesn't work the same way... what to do do
+ // The error handling is different because of the way Finish works.
  */
 static int ExtraBytesTest()
 {
@@ -844,7 +856,7 @@
       Item.val.uCount != 3)
       return -1;
 
-   if(QCBORDecode_Finish(&DCtx) != QCBOR_ERR_EXTRA_BYTES) {
+   if(QCBORDecode_Finish(&DCtx) != QCBOR_ERR_ARRAY_OR_MAP_STILL_OPEN) {
       return -1;
    }
    
@@ -992,7 +1004,7 @@
    int nCBORError;
    
    
-   QCBORDecode_Init(&DCtx, ByteArrayLiteralToUsefulBufC(s_pSimpleValues), QCBOR_DECODE_MODE_NORMAL);
+   QCBORDecode_Init(&DCtx, UsefulBuf_FromByteArrayLiteral(s_pSimpleValues), QCBOR_DECODE_MODE_NORMAL);
    
    
    if((nCBORError = QCBORDecode_GetNext(&DCtx, &Item)))
@@ -1022,7 +1034,7 @@
       return -1;
 
    // A break
-   if(QCBORDecode_GetNext(&DCtx, &Item) != QCBOR_ERR_UNSUPPORTED)
+   if(QCBORDecode_GetNext(&DCtx, &Item) != QCBOR_ERR_BAD_BREAK)
       return -1;
 
    if((nCBORError = QCBORDecode_GetNext(&DCtx, &Item)))
@@ -1133,7 +1145,7 @@
       QCBORItem Item;
       int nCBORError;
       
-      QCBORDecode_Init(&DCtx, ByteArrayLiteralToUsefulBufC(s_pSimpleValues), QCBOR_DECODE_MODE_NORMAL);
+      QCBORDecode_Init(&DCtx, UsefulBuf_FromByteArrayLiteral(s_pSimpleValues), QCBOR_DECODE_MODE_NORMAL);
 
       if((nCBORError = QCBORDecode_GetNext(&DCtx, &Item)))
          return nCBORError;
@@ -1210,7 +1222,6 @@
    return 0;
 }
 
-
 static uint8_t s_DateTestInput[] = {
    0xc0, // tag for string date
    0x6a, '1','9','8','5','-','0','4','-','1','2', // Date string
@@ -1250,13 +1261,13 @@
    QCBORItem Item;
    int nCBORError;
    
-   QCBORDecode_Init(&DCtx, ByteArrayLiteralToUsefulBufC(s_DateTestInput), QCBOR_DECODE_MODE_NORMAL);
+   QCBORDecode_Init(&DCtx, UsefulBuf_FromByteArrayLiteral(s_DateTestInput), QCBOR_DECODE_MODE_NORMAL);
    
    // String date
    if((nCBORError = QCBORDecode_GetNext(&DCtx, &Item)))
       return -1;
    if(Item.uDataType != QCBOR_TYPE_DATE_STRING ||
-      UsefulBuf_Compare(Item.val.dateString, SZLiteralToUsefulBufC("1985-04-12"))){
+      UsefulBuf_Compare(Item.val.dateString, UsefulBuf_FromSZ("1985-04-12"))){
       return -1;
    }
 
@@ -1304,7 +1315,6 @@
    return 0;
 }
 
-
 static uint8_t s_OptTestInput[] = {
    0xd9, 0xd9, 0xf7, // CBOR magic number
    0x81,
@@ -1318,7 +1328,7 @@
    int nCBORError;
    
    
-   QCBORDecode_Init(&DCtx, ByteArrayLiteralToUsefulBufC(s_OptTestInput), QCBOR_DECODE_MODE_NORMAL);
+   QCBORDecode_Init(&DCtx, UsefulBuf_FromByteArrayLiteral(s_OptTestInput), QCBOR_DECODE_MODE_NORMAL);
    
    //
    if((nCBORError = QCBORDecode_GetNext(&DCtx, &Item)))
@@ -1365,7 +1375,7 @@
    QCBORItem Item;
    int nCBORError;
    
-   QCBORDecode_Init(&DCtx, ByteArrayLiteralToUsefulBufC(s_BigNumInput), QCBOR_DECODE_MODE_NORMAL);
+   QCBORDecode_Init(&DCtx, UsefulBuf_FromByteArrayLiteral(s_BigNumInput), QCBOR_DECODE_MODE_NORMAL);
    
    
    //
@@ -1379,7 +1389,7 @@
    if((nCBORError = QCBORDecode_GetNext(&DCtx, &Item)))
       return -1;
    if(Item.uDataType != QCBOR_TYPE_POSBIGNUM ||
-      UsefulBuf_Compare(Item.val.bigNum, ByteArrayLiteralToUsefulBufC(sBigNum))){
+      UsefulBuf_Compare(Item.val.bigNum, UsefulBuf_FromByteArrayLiteral(sBigNum))){
       return -1;
    }
 
@@ -1387,7 +1397,7 @@
    if((nCBORError = QCBORDecode_GetNext(&DCtx, &Item)))
       return -1;
    if(Item.uDataType != QCBOR_TYPE_NEGBIGNUM ||
-      UsefulBuf_Compare(Item.val.bigNum, ByteArrayLiteralToUsefulBufC(sBigNum))){
+      UsefulBuf_Compare(Item.val.bigNum, UsefulBuf_FromByteArrayLiteral(sBigNum))){
       return -1;
    }
    
@@ -1402,7 +1412,7 @@
       return -1;
    if(Item.uDataType != QCBOR_TYPE_POSBIGNUM ||
       Item.uLabelType != QCBOR_TYPE_TEXT_STRING ||
-      UsefulBuf_Compare(Item.val.bigNum, ByteArrayLiteralToUsefulBufC(sBigNum))){
+      UsefulBuf_Compare(Item.val.bigNum, UsefulBuf_FromByteArrayLiteral(sBigNum))){
       return -1;
    }
 
@@ -1411,7 +1421,7 @@
    if(Item.uDataType != QCBOR_TYPE_POSBIGNUM ||
       Item.uLabelType != QCBOR_TYPE_INT64 ||
       Item.label.int64 != 64 ||
-      UsefulBuf_Compare(Item.val.bigNum, ByteArrayLiteralToUsefulBufC(sBigNum))){
+      UsefulBuf_Compare(Item.val.bigNum, UsefulBuf_FromByteArrayLiteral(sBigNum))){
       return -1;
    }
    
@@ -1419,7 +1429,7 @@
       return -1;
    if(Item.uDataType != QCBOR_TYPE_NEGBIGNUM ||
       Item.uLabelType != QCBOR_TYPE_TEXT_STRING ||
-      UsefulBuf_Compare(Item.val.bigNum, ByteArrayLiteralToUsefulBufC(sBigNum))){
+      UsefulBuf_Compare(Item.val.bigNum, UsefulBuf_FromByteArrayLiteral(sBigNum))){
       return -1;
    }
    
@@ -1428,7 +1438,7 @@
    if(Item.uDataType != QCBOR_TYPE_NEGBIGNUM ||
       Item.uLabelType != QCBOR_TYPE_INT64 ||
       Item.label.int64 != -64 ||
-      UsefulBuf_Compare(Item.val.bigNum, ByteArrayLiteralToUsefulBufC(sBigNum))){
+      UsefulBuf_Compare(Item.val.bigNum, UsefulBuf_FromByteArrayLiteral(sBigNum))){
       return -1;
    }
    
@@ -1500,7 +1510,7 @@
 {
    QCBORDecodeContext DCtx;
    
-   QCBORDecode_Init(&DCtx, ByteArrayLiteralToUsefulBufC(s_CSRInput), QCBOR_DECODE_MODE_NORMAL);
+   QCBORDecode_Init(&DCtx, UsefulBuf_FromByteArrayLiteral(s_CSRInput), QCBOR_DECODE_MODE_NORMAL);
    
    if(CheckItemWithIntLabel(&DCtx, QCBOR_TYPE_MAP, 0, 0, NULL)) return -1;
 
@@ -1530,5 +1540,6 @@
 
 
 
+
    
 
diff --git a/test/qcbor_decode_tests.h b/test/qcbor_decode_tests.h
index 759406f..8efd871 100644
--- a/test/qcbor_decode_tests.h
+++ b/test/qcbor_decode_tests.h
@@ -52,7 +52,7 @@
  Parse a well-known set of integers including those around the boundaries and
  make sure the expected values come out
  */
-int IntegerValuesParseTest();
+int IntegerValuesParseTest(void);
 
 
 
@@ -62,7 +62,7 @@
  Decode a simple CBOR encoded array and make sure it returns all the correct values.
  This is a decode test.
  */
-int SimpleArrayTest();
+int SimpleArrayTest(void);
 
 
 /*
@@ -70,21 +70,21 @@
  reported nesting level is correct.  This uses test vector
  of CBOR encoded data with a depth of 10.  This a parse test.
  */
-int ParseDeepArrayTest();
+int ParseDeepArrayTest(void);
 
 
 /*
  See that the correct error is reported when parsing
  an array of depth 11, one too large.
  */
-int ParseTooDeepArrayTest();
+int ParseTooDeepArrayTest(void);
 
 
 /*
   Try to parse some legit CBOR types that this parsers
   doesn't support.
  */
-int UnsupportedCBORDecodeTest();
+int UnsupportedCBORDecodeTest(void);
 
 
 /* 
@@ -92,70 +92,70 @@
   it over and over with one more byte less each time. It should fail
   every time on incorrect CBOR input. This is a hostile input decode test.
  */
-int ShortBufferParseTest();
+int ShortBufferParseTest(void);
 
 
 /* 
    Same as ShortBufferParseTest, but with a different encoded CBOR input.
    It is another hostile input test
  */
-int ShortBufferParseTest2();
+int ShortBufferParseTest2(void);
 
 
 /*
   Parses the somewhat complicated CBOR MAP and makes sure all the correct
   values parse out.  About 15 values are tested. This is a decode test.
  */
-int ParseMapTest();
+int ParseMapTest(void);
 
 
 
-int FloatValuesTest1();
+int FloatValuesTest1(void);
 
 
 
-int SimpleValuesTest1();
+int SimpleValuesTest1(void);
 
 
 
-int ParseSimpleTest();
+int ParseSimpleTest(void);
 
 
 
 /*
  Tests a number of failure cases on bad CBOR to get the right error code
  */
-int FailureTests();
+int FailureTests(void);
 
 
 /*
  Generate all possible input strings up to length x and tries to parse them completely
  */
-int ComprehensiveInputTest();
+int ComprehensiveInputTest(void);
 
 
 /*
  Thest the date types -- epoch and strings
  */
-int DateParseTest();
+int DateParseTest(void);
 
 
 /*
   Test optional tags like the CBOR magic number.
  */
-int OptTagParseTest();
+int OptTagParseTest(void);
 
 
 /*
  Parse some big numbers, positive and negative
  */
-int BignumParseTest();
+int BignumParseTest(void);
 
 
 /*
  Parse some nested maps
  */
-int NestedMapTest();
+int NestedMapTest(void);
 
 
 
diff --git a/test/run_tests.c b/test/run_tests.c
index c3379f3..2f22062 100644
--- a/test/run_tests.c
+++ b/test/run_tests.c
@@ -36,6 +36,8 @@
 #include "half_precision_test.h"
 #include "basic_test.h"
 #include "bstrwrap_tests.h"
+#include "mempool_test.h"
+#include "qcbor_decode_tests.h"
 
 // Used to test the test runner
 int fail_test()
@@ -93,9 +95,23 @@
 } test_entry;
 
 test_entry s_tests[] = {
-    TEST_ENTRY(indefinite_length_decode_string_test),
+    TEST_ENTRY(ParseTooDeepArrayTest),
+    TEST_ENTRY(ComprehensiveInputTest),
+    TEST_ENTRY(ParseMapTest),
     TEST_ENTRY(indefinite_length_decode_test),
     TEST_ENTRY(basic_test_one),
+    TEST_ENTRY(NestedMapTest),
+    TEST_ENTRY(BignumParseTest),
+    TEST_ENTRY(OptTagParseTest),
+    TEST_ENTRY(DateParseTest),
+    TEST_ENTRY(ParseSimpleTest),
+    TEST_ENTRY(ShortBufferParseTest2),
+    TEST_ENTRY(ShortBufferParseTest),
+    TEST_ENTRY(ParseDeepArrayTest),
+    TEST_ENTRY(SimpleArrayTest),
+    TEST_ENTRY(IntegerValuesParseTest),
+    TEST_ENTRY(mempool_test),
+    TEST_ENTRY(indefinite_length_decode_string_test),
     TEST_ENTRY(half_precision_encode_basic),
     TEST_ENTRY(half_precision_decode_basic),
     TEST_ENTRY(half_precision_to_float_transitive_test),