merge mem pool tests into decode tests
diff --git a/QCBOR.xcodeproj/project.pbxproj b/QCBOR.xcodeproj/project.pbxproj
index 025f9e8..36f89be 100644
--- a/QCBOR.xcodeproj/project.pbxproj
+++ b/QCBOR.xcodeproj/project.pbxproj
@@ -8,7 +8,6 @@
/* 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 */; };
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 */; };
@@ -37,8 +36,6 @@
/* 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>"; };
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; };
@@ -135,8 +132,6 @@
E73B575B2161CA7C0080D658 /* half_to_double_from_rfc7049.h */,
E776E09C214AEEEA00E67947 /* basic_test.c */,
E776E09B214AEEEA00E67947 /* basic_test.h */,
- 0F58EB9D216B91AA002FD6D1 /* mempool_test.h */,
- 0F58EB9E216B91AA002FD6D1 /* mempool_test.c */,
);
name = test;
sourceTree = "<group>";
@@ -210,7 +205,6 @@
E776E097214AE0C700E67947 /* cmd_line_main.c in Sources */,
E776E09D214AEEEA00E67947 /* basic_test.c in Sources */,
0FA9BEBD216DE31700BA646B /* UsefulBuf_Tests.c in Sources */,
- 0F58EB9F216B91AA002FD6D1 /* mempool_test.c in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
diff --git a/test/mempool_test.c b/test/mempool_test.c
deleted file mode 100644
index e94e1a2..0000000
--- a/test/mempool_test.c
+++ /dev/null
@@ -1,79 +0,0 @@
-//
-// mempool_test.c
-// QCBOR
-//
-// Created by Laurence Lundblade on 10/8/18.
-// Copyright © 2018 Laurence Lundblade. All rights reserved.
-//
-
-#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
deleted file mode 100644
index 95e43d2..0000000
--- a/test/mempool_test.h
+++ /dev/null
@@ -1,14 +0,0 @@
-//
-// mempool_test.h
-// QCBOR
-//
-// Created by Laurence Lundblade on 10/8/18.
-// Copyright © 2018 Laurence Lundblade. All rights reserved.
-//
-
-#ifndef mempool_test_h
-#define mempool_test_h
-
-int mempool_test(void);
-
-#endif /* mempool_test_h */
diff --git a/test/qcbor_decode_tests.c b/test/qcbor_decode_tests.c
index ce0139d..41532b7 100644
--- a/test/qcbor_decode_tests.c
+++ b/test/qcbor_decode_tests.c
@@ -1537,6 +1537,74 @@
}
+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/qcbor_decode_tests.h b/test/qcbor_decode_tests.h
index 8efd871..e6f1b68 100644
--- a/test/qcbor_decode_tests.h
+++ b/test/qcbor_decode_tests.h
@@ -158,5 +158,8 @@
int NestedMapTest(void);
+int mempool_test(void);
+
+
#endif /* defined(__QCBOR__qcbort_decode_tests__) */
diff --git a/test/run_tests.c b/test/run_tests.c
index 38341a8..a9317a2 100644
--- a/test/run_tests.c
+++ b/test/run_tests.c
@@ -35,8 +35,6 @@
#include "float_tests.h"
#include "basic_test.h"
-#include "bstrwrap_tests.h"
-#include "mempool_test.h"
#include "qcbor_decode_tests.h"
#include "qcbor_encode_tests.h"
#include "UsefulBuf_Tests.h"