No type punning in UsefulBuf; bug fix in UsefulBuf; UsefulBuf tests running; get encode tests running
diff --git a/README.md b/README.md
index 39c4576..2f30108 100644
--- a/README.md
+++ b/README.md
@@ -47,14 +47,28 @@
The files ieee754.c and ieee754.h are support for half-precision floating point. The encoding side of the floating point functionality is about
500 bytes. If it is never called because no floating point numbers are ever encoded, all 500 bytes will be dead stripped and not
-impact code size. The decoding side is about 150 bytes of object code. It is never dead stripped because it always linked, however it
-doesn't add very much to the size.
+impact code size. The decoding side is about 150 bytes of object code. It is never dead stripped because it directly referenced by
+the core decoder , however it doesn't add very much to the size.
The test directory includes some tests that are nearly as portable as the main implementation. If your development environment
doesn't support UNIX style command line and make, you should be able to make a simple project and add the test files to it.
Then just call run_tests() to invole them all.
+## Changes from CAF Version
+* QCBOREncode_Init takes a UsefulBuf instead of a pointer and size
+* QCBOREncode_Finish takes a UsefulBufC and EncodedCBOR is remove
+* bstr wrapping of arrays/maps is replaced with OpenBstrwrap
+* AddRaw can now only add whole arrays or maps, not partial maps and arrays (simplification; was a dangerous feature)
+* Finish cannot be called repeatedly on a partial decode (some tests used this, but it is not really a good thing to rely on)
+* Float support is restored
+* Minimal length float is restored
+* indefinite length arrays/maps are supported
+* indefinite length strings are supported
+* Addition functions in UsefulBuf
+* UsefulOutBuf_OutUBuf changed to work differently
+* UsefulOutBuf_Init works differently
+
diff --git a/inc/UsefulBuf.h b/inc/UsefulBuf.h
index aeb20eb..d7fd4c0 100644
--- a/inc/UsefulBuf.h
+++ b/inc/UsefulBuf.h
@@ -268,7 +268,7 @@
@return 1 if it is either NULL or empty, 0 if not.
*/
-static inline int UsefulBuf_IsNULLOrEmptyXC(UsefulBufC UB) {
+static inline int UsefulBuf_IsNULLOrEmptyC(UsefulBufC UB) {
return UsefulBuf_IsEmptyC(UB) || UsefulBuf_IsNULLC(UB);
}
@@ -372,6 +372,26 @@
*/
UsefulBufC UsefulBuf_Copy(UsefulBuf Dest, const UsefulBufC Src);
+
+/**
+ @brief Copy one UsefulBuf into another at an offset
+
+ @param[in] Dest Destiation buffer to copy into
+ @param[in] uOffset The byte offset in Dest at which to copy to
+ @param[in] Src The bytes to copy
+
+ @return Pointer and length of the copy
+
+ This fails and returns NULLUsefulBufC Src.len + uOffset > Dest.len.
+
+ Like memcpy, there is no check for NULL. If NULL is passed
+ this will crash.
+
+ There is an assumption that there is valid data in Dest up to
+ uOffset as the resulting UsefulBufC returned starts
+ at the beginning of Dest and goes to Src.len + uOffset.
+
+ */
UsefulBufC UsefulBuf_CopyOffset(UsefulBuf Dest, size_t uOffset, const UsefulBufC Src);
@@ -489,7 +509,7 @@
-#if NOT_DEPRECATED
+#if 1 // NOT_DEPRECATED
/** Deprecated macro; use UsefulBuf_FromSZLiteral instead */
#define SZLiteralToUsefulBufC(szString) \
((UsefulBufC) {(szString), sizeof(szString)-1})
@@ -647,10 +667,10 @@
/** Convenience marco to make a UsefulOutBuf on the stack and
initialize it with stack buffer
*/
-#define MakeUsefulOutBufOnStack(name, size) \
+#define UsefulOutBuf_MakeOnStack(name, size) \
uint8_t __pBuf##name[(size)];\
UsefulOutBuf name;\
- UsefulOutBuf_Init(&(name), __pBuf##name, (size));
+ UsefulOutBuf_Init(&(name), (UsefulBuf){__pBuf##name, (size)});
@@ -756,7 +776,6 @@
UsefulBuf.
*/
-
static inline void UsefulOutBuf_InsertData(UsefulOutBuf *me, const void *pBytes, size_t uLen, size_t uPos)
{
UsefulBufC Data = {pBytes, uLen};
@@ -881,9 +900,7 @@
*/
static inline void UsefulOutBuf_InsertFloat(UsefulOutBuf *me, float f, size_t uPos)
{
- // Have to cast a pointer and deref so the bit pattern is what put
- // passed. This is to avoid 3.1415 getting converted to 3.
- UsefulOutBuf_InsertUint32(me, *(uint32_t *)&f, uPos);
+ UsefulOutBuf_InsertUint32(me, UsefulBufUtil_CopyFloatToUint32(f), uPos);
}
@@ -901,8 +918,7 @@
*/
static inline void UsefulOutBuf_InsertDouble(UsefulOutBuf *me, double d, size_t uPos)
{
- // See UsefulOutBuf_InsertFloat
- UsefulOutBuf_InsertUint64(me, *(uint64_t *)&d, uPos);
+ UsefulOutBuf_InsertUint64(me, UsefulBufUtil_CopyDoubleToUint64(d), uPos);
}
@@ -1105,18 +1121,18 @@
/**
- @brief Returns the resulting valid data in a UsefulBuf
+ @brief Returns the resulting valid data in a UsefulOutBuf
- @param[in] me Pointer to the UsefulOutBuf
+ @param[in] me Pointer to the UsefulOutBuf.
- @return TODO:
+ @return The valid data in UsefulOutBuf.
- If you want a pointer and length to the resulting data, dereference
- O.
+ The storage for the returned data is Storage parameter passed
+ to UsefulOutBuf_Init(). See also UsefulOutBuf_CopyOut().
- This can be called anytime and many times to get intermediate
- results. It doesn't change the data or reset the current position
- so you can keep adding data.
+ This can be called anytime and many times to get intermediate
+ results. It doesn't change the data or reset the current position
+ so you can keep adding data.
*/
UsefulBufC UsefulOutBuf_OutUBuf(UsefulOutBuf *me);
@@ -1126,16 +1142,14 @@
@brief Copies the valid data out into a supplied buffer
@param[in] me Pointer to the UsefulOutBuf
- @param[out] pBuf buffer to copy data into
- @param[in] uBufSize size of pBuf
- @param[out] puCopied number of valid bytes copied into pBuf
+ @param[out] Dest The destination buffer to copy into
- @return Same as UsefulOutBuf_GetError()
+ @return Pointer and length of copied data.
This is the same as UsefulOutBuf_OutUBuf() except it copies the data.
- */
+*/
-int UsefulOutBuf_CopyOut(UsefulOutBuf *me, void *pBuf, size_t uBufSize, size_t *puCopied);
+UsefulBufC UsefulOutBuf_CopyOut(UsefulOutBuf *me, UsefulBuf Dest);
@@ -1451,7 +1465,7 @@
{
uint32_t uResult = UsefulInputBuf_GetUint32(me);
- return uResult ? *(float *)&uResult : 0;
+ return uResult ? UsefulBufUtil_CopyUint32ToFloat(uResult) : 0;
}
@@ -1471,7 +1485,7 @@
{
uint64_t uResult = UsefulInputBuf_GetUint64(me);
- return uResult ? *(double *)&uResult : 0;
+ return uResult ? UsefulBufUtil_CopyUint64ToDouble(uResult) : 0;
}
diff --git a/src/UsefulBuf.c b/src/UsefulBuf.c
index 3aa6406..b64c0b5 100644
--- a/src/UsefulBuf.c
+++ b/src/UsefulBuf.c
@@ -85,8 +85,9 @@
*/
UsefulBufC UsefulBuf_Copy(UsefulBuf Dest, const UsefulBufC Src)
{
- if(Src.len > Dest.len)
+ if(Src.len > Dest.len) {
return NULLUsefulBufC;
+ }
memcpy(Dest.ptr, Src.ptr, Src.len);
@@ -94,6 +95,9 @@
}
+/*
+ Public function -- see UsefulBuf.h
+ */
UsefulBufC UsefulBuf_CopyOffset(UsefulBuf Dest, size_t uOffset, const UsefulBufC Src)
{
if(Src.len > Dest.len - uOffset) {
@@ -105,6 +109,7 @@
return((UsefulBufC){Dest.ptr, Src.len});
}
+
/*
Public function -- see UsefulBuf.h
*/
@@ -123,10 +128,8 @@
-
-
/*
- returns SIZE_MAX when there is no match
+ Public function -- see UsefulBuf.h
*/
size_t UsefulBuf_FindBytes(UsefulBufC BytesToSearch, UsefulBufC BytesToFind)
{
@@ -147,49 +150,26 @@
/*
Public function -- see UsefulBuf.h
- The core of UsefulOutBuf -- put some bytes in the buffer without writing off the end of it.
-
- THIS FUNCTION DOES POINTER MATH
+ Code Reviewers: THIS FUNCTION DOES POINTER MATH
*/
-#if NODEF
-void UsefulOutBuf_InitOld(UsefulOutBuf *me, void *pStorage, size_t uStorageSize)
-{
- me->magic = USEFUL_OUT_BUF_MAGIC;
- UsefulOutBuf_Reset(me);
-
- me->UB.ptr = pStorage;
- me->size = uStorageSize;
-
- // The following check fails on ThreadX
-#if 0
- // Sanity check on the pointer and size to be sure we are not
- // passed a buffer that goes off the end of the address space.
- // Given this test, we know that all unsigned lengths less than
- // me->size are valid and won't wrap in any pointer additions
- // based off of pStorage in the rest of this code.
- const uintptr_t ptrM = UINTPTR_MAX - uStorageSize;
- if(pStorage && (uintptr_t)pStorage > ptrM) // Check #0
- me->err = 1;
-#endif
-}
-#endif
-
void UsefulOutBuf_Init(UsefulOutBuf *me, UsefulBuf Storage)
{
me->magic = USEFUL_OUT_BUF_MAGIC;
UsefulOutBuf_Reset(me);
me->UB = Storage;
- // The following check fails on ThreadX
#if 0
- // TODO: fix this for new way of doing storage
+ // This check is off by default.
+
+ // The following check fails on ThreadX
+
// Sanity check on the pointer and size to be sure we are not
// passed a buffer that goes off the end of the address space.
// Given this test, we know that all unsigned lengths less than
// me->size are valid and won't wrap in any pointer additions
// based off of pStorage in the rest of this code.
- const uintptr_t ptrM = UINTPTR_MAX - uStorageSize;
- if(pStorage && (uintptr_t)pStorage > ptrM) // Check #0
+ const uintptr_t ptrM = UINTPTR_MAX - Storage.len;
+ if(Storage.ptr && (uintptr_t)Storage.ptr > ptrM) // Check #0
me->err = 1;
#endif
}
@@ -266,7 +246,7 @@
/* 2. Check the Insertion Position */
// This, with Check #1, also confirms that uInsertionPos <= me->size
- if(uInsertionPos > me->UB.len) { // Check #3
+ if(uInsertionPos > me->data_len) { // Check #3
// Off the end of the valid data in the buffer.
me->err = 1;
return;
@@ -333,37 +313,22 @@
return NULLUsefulBufC;
}
- return(UsefulBufC){me->UB.ptr,me->data_len};
-}
-
-
-UsefulBufC UsefulOutBuf_CopyOut2(UsefulOutBuf *me, UsefulBuf pDest)
-{
- UsefulBufC Tmp = UsefulOutBuf_OutUBuf(me);
- if(UsefulBuf_IsNULLC(Tmp)) {
- return NULLUsefulBufC;
- }
-
- return UsefulBuf_Copy(pDest, Tmp);
+ return(UsefulBufC){me->UB.ptr,me->data_len};
}
/*
Public function -- see UsefulBuf.h
-
- Copy out the data accumulated in the output buffer.
+ Copy out the data accumulated in to the output buffer.
*/
-int UsefulOutBuf_CopyOut(UsefulOutBuf *me, void *pBuf, size_t uBufSize, size_t *puCopied)
+UsefulBufC UsefulOutBuf_CopyOut(UsefulOutBuf *me, UsefulBuf pDest)
{
- UsefulBufC B = UsefulOutBuf_CopyOut2(me, (UsefulBuf){pBuf, uBufSize});
- if(UsefulBuf_IsNULLC(B)) {
- return 1; // was in error state or was corrupted or pBuf too small
- }
-
- *puCopied = B.len;
-
- return 0;
+ UsefulBufC Tmp = UsefulOutBuf_OutUBuf(me);
+ if(UsefulBuf_IsNULLC(Tmp)) {
+ return NULLUsefulBufC;
+ }
+ return UsefulBuf_Copy(pDest, Tmp);
}
diff --git a/test/UsefulBuf_Tests.c b/test/UsefulBuf_Tests.c
index 84442f1..05d04a2 100644
--- a/test/UsefulBuf_Tests.c
+++ b/test/UsefulBuf_Tests.c
@@ -27,8 +27,33 @@
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 "UsefulBuf.h"
-#include <string.h>
/* Basic exercise...
@@ -43,11 +68,11 @@
{
const char *szReturn = NULL;
- char outbuf[50];
+ UsefulBuf_MakeStackUB(outbuf,50);
UsefulOutBuf UOB;
- UsefulOutBuf_Init(&UOB, outbuf, sizeof(outbuf));
+ UsefulOutBuf_Init(&UOB, outbuf);
if(!UsefulOutBuf_AtStart(&UOB)) {
szReturn = "Not at start";
@@ -81,20 +106,18 @@
UsefulOutBuf_AppendByte(&UOB, '\0');
- UsefulBuf U;
- int nErr = UsefulOutBuf_OutUBuf(&UOB, &U);
+ UsefulBufC U = UsefulOutBuf_OutUBuf(&UOB);
const char *expected = "heffalump unbounce bluster hunny";
- if(nErr || U.len-1 != strlen(expected) || strcmp(expected, U.ptr) || UsefulOutBuf_GetError(&UOB)) {
+ if(UsefulBuf_IsNULLC(U) || U.len-1 != strlen(expected) || strcmp(expected, U.ptr) || UsefulOutBuf_GetError(&UOB)) {
szReturn = "OutUBuf";
}
- char buf[50];
- size_t xxx;
- nErr = UsefulOutBuf_CopyOut(&UOB, buf, sizeof(buf), &xxx);
+ UsefulBuf_MakeStackUB(buf, 50);
+ UsefulBufC Out = UsefulOutBuf_CopyOut(&UOB, buf);
- if(nErr || xxx-1 != strlen(expected) || strcmp(expected, buf)) {
+ if(UsefulBuf_IsNULLC(Out) || Out.len-1 != strlen(expected) || strcmp(expected, Out.ptr)) {
szReturn = "CopyOut";
}
@@ -123,6 +146,8 @@
// append the bytes
UsefulOutBuf_AppendData(pUOB, (const uint8_t *)"bluster", num);
+
+ // TODO: test UsefulOutBuf_AppendString
// check error status after
if(UsefulOutBuf_GetError(pUOB) != expected)
@@ -137,7 +162,7 @@
*/
static int InsertTest(UsefulOutBuf *pUOB, size_t num, size_t pos, int expected)
{
- //reset
+ // reset
UsefulOutBuf_Reset(pUOB);
// check
@@ -146,6 +171,8 @@
UsefulOutBuf_InsertData(pUOB, (const uint8_t *)"bluster", num, pos);
+ // TODO: test UsefulOutBuf_InsertString
+
if(UsefulOutBuf_GetError(pUOB) != expected)
return 1;
@@ -166,11 +193,11 @@
const char *BoundaryConditionsTest()
{
- char outbuf[2];
+ UsefulBuf_MakeStackUB(outbuf,2);
UsefulOutBuf UOB;
- UsefulOutBuf_Init(&UOB, outbuf, sizeof(outbuf));
+ UsefulOutBuf_Init(&UOB, outbuf);
// append 0 byte to a 2 byte buffer --> success
if(AppendTest(&UOB, 0, 0))
@@ -205,9 +232,9 @@
return "Bad insertion point not caught";
- char outBuf2[10];
+ UsefulBuf_MakeStackUB(outBuf2,10);
- UsefulOutBuf_Init(&UOB, outBuf2, sizeof(outBuf2));
+ UsefulOutBuf_Init(&UOB, outBuf2);
UsefulOutBuf_Reset(&UOB);
// put data in the buffer
@@ -220,26 +247,25 @@
}
- UsefulOutBuf_Init(&UOB, NULL, SIZE_MAX - 5);
+ UsefulOutBuf_Init(&UOB, (UsefulBuf){NULL, SIZE_MAX - 5});
UsefulOutBuf_AppendData(&UOB, "123456789", SIZE_MAX -6);
if(UsefulOutBuf_GetError(&UOB)) {
return "insert in huge should have succeeded";
}
- UsefulOutBuf_Init(&UOB, NULL, SIZE_MAX - 5);
+ UsefulOutBuf_Init(&UOB, (UsefulBuf){NULL, SIZE_MAX - 5});
UsefulOutBuf_AppendData(&UOB, "123456789", SIZE_MAX -5);
if(UsefulOutBuf_GetError(&UOB)) {
return "insert in huge should have succeeded";
}
- UsefulOutBuf_Init(&UOB, NULL, SIZE_MAX - 5);
+ UsefulOutBuf_Init(&UOB, (UsefulBuf){NULL, SIZE_MAX - 5});
UsefulOutBuf_AppendData(&UOB, "123456789", SIZE_MAX - 4);
if(!UsefulOutBuf_GetError(&UOB)) {
return "lengths near max size";
}
return NULL;
-
}
@@ -250,16 +276,17 @@
const char *TestBasicSanity()
{
- char outbuf[10];
+ UsefulBuf_MakeStackUB(outbuf,10);
UsefulOutBuf UOB;
// First -- make sure that the room left function returns the right amount
- UsefulOutBuf_Init(&UOB, outbuf, sizeof(outbuf));
+ UsefulOutBuf_Init(&UOB, outbuf);
- if(UsefulOutBuf_RoomLeft(&UOB) != sizeof(outbuf))
+ if(UsefulOutBuf_RoomLeft(&UOB) != 10)
return "room left failed";
+ // TODO: test UsefulOutBuf_WillItFit
// Next -- make sure that the magic number checking is working right
UOB.magic = 8888; // make magic bogus
@@ -272,9 +299,9 @@
// Next make sure that the valid data length check is working right
- UsefulOutBuf_Init(&UOB, outbuf, sizeof(outbuf));
+ UsefulOutBuf_Init(&UOB, outbuf);
- UOB.UB.len = UOB.size+1; // make size bogus
+ UOB.data_len = UOB.UB.len+1; // make size bogus
UsefulOutBuf_AppendData(&UOB, (const uint8_t *)"bluster", 7);
if(!UsefulOutBuf_GetError(&UOB))
@@ -289,22 +316,22 @@
{
char *szFoo = "foo";
- UsefulBufC Foo = SZToUsefulBufC(szFoo);
+ UsefulBufC Foo = UsefulBuf_FromSZ(szFoo);
if(Foo.len != 3 || strncmp(Foo.ptr, szFoo, 3))
return "SZToUsefulBufC failed";
- UsefulBufC Too = SZLiteralToUsefulBufC("Toooo");
+ UsefulBufC Too = UsefulBuf_FromSZLiteral("Toooo");
if(Too.len != 5 || strncmp(Too.ptr, "Toooo", 5))
- return "SZLiteralToUsefulBufC failed";
+ return "UsefulBuf_FromSZLiteral failed";
uint8_t pB[] = {0x42, 0x6f, 0x6f};
- UsefulBufC Boo = ByteArrayLiteralToUsefulBufC(pB);
+ UsefulBufC Boo = UsefulBuf_FromByteArrayLiteral(pB);
if(Boo.len != 3 || strncmp(Boo.ptr, "Boo", 3))
- return "ByteArrayLiteralToUsefulBufC failed";
+ return "UsefulBuf_FromByteArrayLiteral failed";
char *sz = "not const"; // some data for the test
UsefulBuf B = (UsefulBuf){sz, sizeof(sz)};
- UsefulBufC BC = UsefulBufConst(B);
+ UsefulBufC BC = UsefulBuf_Const(B);
if(BC.len != sizeof(sz) || BC.ptr != sz)
return "UsefulBufConst failed";
@@ -319,28 +346,41 @@
if(!UsefulBuf_IsNULL(UB)){
return "IsNull failed";
}
-
- UsefulBufC UBC = UsefulBuf_Const(UB);
-
- if(!UsefulBuf_IsNULL(UBC)){
- return "IsNull const failed";
- }
-
- if(!UsefulBuf_IsEmpty(UBC)){
+
+ if(!UsefulBuf_IsEmpty(UB)){
return "IsEmpty failed";
}
- if(!UsefulBuf_IsNULLOrEmpty(UBC)){
+ if(!UsefulBuf_IsNULLOrEmpty(UB)) {
return "IsNULLOrEmpty failed";
}
+ UsefulBufC UBC = UsefulBuf_Const(UB);
+
+ if(!UsefulBuf_IsNULLC(UBC)){
+ return "IsNull const failed";
+ }
+
+ if(!UsefulBuf_IsEmptyC(UBC)){
+ return "IsEmptyC failed";
+ }
+
+ if(!UsefulBuf_IsNULLOrEmptyC(UBC)){
+ return "IsNULLOrEmptyC failed";
+ }
+
+ UsefulBuf UB2 = UsefulBuf_Unconst(UBC);
+ if(!UsefulBuf_IsEmpty(UB2)) {
+ return "Back to UB is Empty failed";
+ }
+
UB.ptr = "x"; // just some valid pointer
if(UsefulBuf_IsNULL(UB)){
return "IsNull failed";
}
- if(!UsefulBuf_IsEmpty(UBC)){
+ if(!UsefulBuf_IsEmptyC(UBC)){
return "IsEmpty failed";
}
@@ -354,14 +394,23 @@
UsefulBuf_Set(&Temp, '+');
// Try to copy into a buf that is too small and see failure
- MakeUsefulBufOnStack(Temp2, 99);
- if(!UsefulBuf_Copy(&Temp2, UsefulBuf_Const(Temp))) {
+ UsefulBuf_MakeStackUB(Temp2, 99);
+ if(!UsefulBuf_IsNULLC(UsefulBuf_Copy(Temp2, UsefulBuf_Const(Temp)))) {
return "Copy should have failed";
}
-
+
+ // TODO: complete this test
+ // UsefulBuf_CopyOffset();
+ // TODO: complete this test
+ // UsefulBuf_CopyPtr();
+ // TODO: complete this test
+ // UsefulBuf_Head();
+ // TODO: complete this test
+ // UsefulBuf_CopyPtr();
+
// Try to copy into a NULL/empty buf and see failure
UsefulBuf UBNull = NULLUsefulBuf;
- if(!UsefulBuf_Copy(&UBNull, UsefulBuf_Const(Temp))) {
+ if(!UsefulBuf_IsNULLC(UsefulBuf_Copy(UBNull, UsefulBuf_Const(Temp)))) {
return "Copy to NULL should have failed";
}
@@ -370,7 +419,7 @@
// Copy successfully to a buffer
MakeUsefulBufOnStack(Temp3, 101);
- if(UsefulBuf_Copy(&Temp3, UsefulBuf_Const(Temp))) {
+ if(UsefulBuf_IsNULLC(UsefulBuf_Copy(Temp3, UsefulBuf_Const(Temp)))) {
return "Copy should not have failed";
}
@@ -417,7 +466,7 @@
};
UsefulBufC ExpectedBigger = ByteArrayLiteralToUsefulBufC(pExpectedBigger);
- // Expect -1 with the first arg is smaller
+ // Expect -1 when the first arg is smaller
if(UsefulBuf_Compare(Expected, ExpectedBigger) >= 0){
return "Compare with bigger";
}
@@ -436,7 +485,7 @@
'+', '+', '+', '+', '+', '+', '+', '+', '+', '*',
};
UsefulBufC ExpectedSmaller = ByteArrayLiteralToUsefulBufC(pExpectedSmaller);
- // Expect +1 with the first arg is larger
+ // Expect +1 when the first arg is larger
if(UsefulBuf_Compare(Expected, ExpectedSmaller) <= 0){
return "Compare with smaller";
}
@@ -456,7 +505,7 @@
};
UsefulBufC ExpectedLonger = ByteArrayLiteralToUsefulBufC(pExpectedLonger);
- // Expect -1 with the first arg is smaller
+ // Expect -1 when the first arg is smaller
if(UsefulBuf_Compare(Expected, ExpectedLonger) >= 0){
return "Compare with longer";
}
@@ -481,14 +530,10 @@
}
- if(UsefulBuf_Copy(&Temp, NULLUsefulBufC)) {
+ if(UsefulBuf_IsNULLC(UsefulBuf_Copy(Temp, NULLUsefulBufC))) {
return "Copy null/empty failed";
}
- if(UsefulBuf_Compare(UsefulBuf_Const(Temp), NULLUsefulBufC)) {
- return "Copy Null failed";
- }
-
// Look for +++++... in +++++... and find it at the beginning
if(0 != UsefulBuf_FindBytes(ExpectedLonger, ExpectedShorter)){
return "Failed to find";
@@ -518,9 +563,7 @@
const char * UBIntegerFormatTests()
{
- char outbuf[100];
-
- UsefulOutBuf UOB;
+ UsefulOutBuf_MakeOnStack(UOB,100);
const uint32_t u32 = 0x0A0B0C0D; // from https://en.wikipedia.org/wiki/Endianness
const uint64_t u64 = 1984738472938472;
@@ -529,17 +572,16 @@
const float f = (float)314.15;
const double d = 2.1e10;
- UsefulOutBuf_Init(&UOB, outbuf, sizeof(outbuf));
- UsefulOutBuf_AppendUint32(&UOB, u32);
- UsefulOutBuf_AppendUint64(&UOB, u64);
- UsefulOutBuf_AppendUint16(&UOB, u16);
+ UsefulOutBuf_AppendUint32(&UOB, u32); // Also tests UsefulOutBuf_InsertUint64 and UsefulOutBuf_GetEndPosition
+ UsefulOutBuf_AppendUint64(&UOB, u64); // Also tests UsefulOutBuf_InsertUint32
+ UsefulOutBuf_AppendUint16(&UOB, u16); // Also tests UsefulOutBuf_InsertUint16
UsefulOutBuf_AppendByte(&UOB, u8);
- UsefulOutBuf_AppendFloat(&UOB, f);
- UsefulOutBuf_AppendDouble(&UOB, d);
+ UsefulOutBuf_AppendFloat(&UOB, f); // Also tests UsefulOutBuf_InsertFloat
+ UsefulOutBuf_AppendDouble(&UOB, d); // Also tests UsefulOutBuf_InsertDouble
- UsefulBuf O;
- if(UsefulOutBuf_OutUBuf(&UOB, &O))
+ UsefulBufC O = UsefulOutBuf_OutUBuf(&UOB);
+ if(UsefulBuf_IsNULLC(O))
return "Couldn't output integers";
// from https://en.wikipedia.org/wiki/Endianness
@@ -550,7 +592,11 @@
UsefulInputBuf UIB;
- UsefulInputBuf_Init(&UIB, UsefulBuf_Const(O));
+ UsefulInputBuf_Init(&UIB, O);
+
+ if(UsefulInputBuf_Tell(&UIB) != 0) {
+ return "UsefulInputBuf_Tell failed";
+ }
if(UsefulInputBuf_GetUint32(&UIB) != u32) {
return "u32 out then in failed";
@@ -570,7 +616,35 @@
if(UsefulInputBuf_GetDouble(&UIB) != d) {
return "double out then in failed";
}
+
+ // TODO: test UsefulInputBuf_Seek
+ // TODO: test UsefulInputBuf_BytesUnconsumed
+ // TODO: test UsefulInputBuf_BytesAvailable
+ // TODO: test UsefulInputBuf_GetBytes
+ // TODO: test UsefulInputBuf_GetUsefulBuf
+ // TODO: test UsefulInputBuf_GetError
+ return NULL;
+}
+
+
+const char *UBCopyUtilTest()
+{
+ if(UsefulBufUtil_CopyFloatToUint32(65536.0F) != 0x47800000) {
+ return "CopyFloatToUint32 failed";
+ }
+
+ if(UsefulBufUtil_CopyDoubleToUint64(4e-40F) != 0X37C16C2800000000ULL) {
+ return "CopyDoubleToUint64 failed";
+ }
+
+ if(UsefulBufUtil_CopyUint64ToDouble(0X37C16C2800000000ULL) != 4e-40F) {
+ return "CopyUint64ToDouble failed";
+ }
+
+ if(UsefulBufUtil_CopyUint32ToFloat(0x47800000) != 65536.0F) {
+ return "CopyUint32ToFloat failed";
+ }
return NULL;
}
diff --git a/test/UsefulBuf_Tests.h b/test/UsefulBuf_Tests.h
index e80be69..7b0eab1 100644
--- a/test/UsefulBuf_Tests.h
+++ b/test/UsefulBuf_Tests.h
@@ -27,20 +27,47 @@
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.
+ ==============================================================================*/
+
#ifndef UsefulBuf_UsefulBuf_Tests_h
#define UsefulBuf_UsefulBuf_Tests_h
-const char * NonAdversarialUOBTest();
+const char * NonAdversarialUOBTest(void);
-const char * TestBasicSanity();
+const char * TestBasicSanity(void);
-const char * BoundaryConditionsTest();
+const char * BoundaryConditionsTest(void);
-const char * UBMacroConversionsTest();
+const char * UBMacroConversionsTest(void);
-const char * UBUtilTests();
+const char * UBUtilTests(void);
-const char * UBIntegerFormatTests();
+const char * UBIntegerFormatTests(void);
+const char * UBCopyUtilTest(void);
#endif
diff --git a/test/qcbor_encode_tests.c b/test/qcbor_encode_tests.c
index a486614..4a79bbd 100644
--- a/test/qcbor_encode_tests.c
+++ b/test/qcbor_encode_tests.c
@@ -27,12 +27,35 @@
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_encode_tests.h"
-#include <stdio.h>
#include <strings.h>
-#include <float.h>
-#include <math.h>
#include <stdlib.h>
@@ -41,9 +64,9 @@
// TODO: test QCBOR_MAX_ITEMS_IN_ARRAY (this is very large...)
-//
+#ifdef PRINT_FUNCTIONS_FOR_DEBUGGINGXX
+#include <stdio.h>
-#ifdef PRINT_FUNCTIONS_FOR_DEBUGGING
// ifdef these out to not have compiler warnings
static void printencoded(const uint8_t *pEncoded, size_t nLen)
{
@@ -57,30 +80,247 @@
fflush(stdout);
}
-
-static void printencodedE(EncodedCBOR E)
-{
- printf("Num Items: %d\n", E.uItems);
- printencoded(E.Bytes.ptr, E.Bytes.len);
-}
#endif
+#include <stdio.h>
+
+int Compare(UsefulBufC U1, UsefulBufC U2) {
+ int i;
+ for(i = 0; i < U1.len; i++) {
+ if(((uint8_t *)U1.ptr)[i] != ((uint8_t *)U2.ptr)[i]) {
+ printf("%d 0x%x 0x%x\n", i, ((uint8_t *)U1.ptr)[i], ((uint8_t *)U2.ptr)[i]);
+ return 1;
+ }
+ }
+ return 0;
+
+}
+
+
+/*#define CheckResults(Enc, Expected) \
+ UsefulBuf_Compare(Enc, (UsefulBufC){Expected, sizeof(Expected)}) */
#define CheckResults(Enc, Expected) \
- UsefulBuf_Compare(UsefulBufConst(Enc.Bytes), (UsefulBufC){Expected, sizeof(Expected)})
-
+ Compare(Enc, (UsefulBufC){Expected, sizeof(Expected)})
static const uint8_t pExpectedEncodedAll[] = {
- 0x98, 0x29, 0x66, 0x55, 0x49, 0x4e, 0x54, 0x36, 0x32, 0xd8, 0x64, 0x1a, 0x05, 0x5d, 0x23, 0x15, 0x65, 0x49, 0x4e, 0x54, 0x36, 0x34, 0xd8, 0x4c, 0x1b, 0x00, 0x00, 0x00, 0x12, 0x16, 0xaf, 0x2b, 0x15, 0x00, 0x38, 0x2b, 0xa4, 0x63, 0x4c, 0x42, 0x4c, 0x18, 0x4d, 0x23, 0x18, 0x58, 0x78, 0x1a, 0x4e, 0x45, 0x47, 0x4c, 0x42, 0x4c, 0x54, 0x48, 0x41, 0x54, 0x20, 0x49, 0x53, 0x20, 0x4b, 0x49, 0x4e, 0x44, 0x20, 0x4f, 0x46, 0x20, 0x4c, 0x4f, 0x4e, 0x47, 0x3b, 0x00, 0x00, 0x02, 0x2d, 0x9a, 0xc6, 0x94, 0x55, 0x3a, 0x05, 0xf5, 0xe0, 0xff, 0x3a, 0x2f, 0xaf, 0x07, 0xff, 0x65, 0x4a, 0x61, 0x69, 0x6d, 0x65, 0xd8, 0x58, 0xfa, 0x40, 0x49, 0x0f, 0xd0, 0x66, 0x53, 0x74, 0x72, 0x65, 0x65, 0x74, 0xd8, 0x63, 0xfb, 0x40, 0x21, 0x4f, 0x01, 0x96, 0xd8, 0xf4, 0xf9, 0xfa, 0x3f, 0x80, 0x00, 0x00, 0xfb, 0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x63, 0x66, 0x6f, 0x6f, 0xfa, 0x45, 0x98, 0xb8, 0x00, 0x39, 0x03, 0xe6, 0xfa, 0x44, 0x79, 0xc0, 0x00, 0x66, 0x66, 0x6f, 0x6f, 0x66, 0x6f, 0x6f, 0xfb, 0x41, 0x58, 0xf7, 0x7d, 0xc0, 0x00, 0x00, 0x00, 0x39, 0xaf, 0xc6, 0xfb, 0x40, 0xf5, 0xba, 0x70, 0x00, 0x00, 0x00, 0x00, 0xc1, 0x1a, 0x8e, 0x15, 0x1c, 0x8a, 0xa3, 0x74, 0x4c, 0x6f, 0x6e, 0x67, 0x4c, 0x69, 0x76, 0x65, 0x44, 0x65, 0x6e, 0x69, 0x73, 0x52, 0x69, 0x74, 0x63, 0x68, 0x69, 0x65, 0xc1, 0x1a, 0x53, 0x72, 0x4e, 0x00, 0x66, 0x74, 0x69, 0x6d, 0x65, 0x28, 0x29, 0xc1, 0x1a, 0x58, 0x0d, 0x41, 0x72, 0x39, 0x07, 0xb0, 0xc1, 0x1a, 0x58, 0x0d, 0x3f, 0x76, 0x42, 0xff, 0x00, 0xa3, 0x66, 0x62, 0x69, 0x6e, 0x62, 0x69, 0x6e, 0xda, 0x00, 0x01, 0x86, 0xa0, 0x41, 0x00, 0x66, 0x62, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x43, 0x01, 0x02, 0x03, 0x00, 0x44, 0x04, 0x02, 0x03, 0xfe, 0x6f, 0x62, 0x61, 0x72, 0x20, 0x62, 0x61, 0x72, 0x20, 0x66, 0x6f, 0x6f, 0x20, 0x62, 0x61, 0x72, 0x64, 0x6f, 0x6f, 0x66, 0x0a, 0xd8, 0x20, 0x78, 0x6b, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x73, 0x74, 0x61, 0x63, 0x6b, 0x6f, 0x76, 0x65, 0x72, 0x66, 0x6c, 0x6f, 0x77, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x71, 0x75, 0x65, 0x73, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x32, 0x38, 0x30, 0x35, 0x39, 0x36, 0x39, 0x37, 0x2f, 0x68, 0x6f, 0x77, 0x2d, 0x64, 0x6f, 0x2d, 0x69, 0x2d, 0x74, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x2d, 0x62, 0x65, 0x74, 0x77, 0x65, 0x65, 0x6e, 0x2d, 0x64, 0x65, 0x62, 0x75, 0x67, 0x2d, 0x61, 0x6e, 0x64, 0x2d, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2d, 0x62, 0x75, 0x69, 0x6c, 0x64, 0x73, 0x2d, 0x69, 0x6e, 0x2d, 0x78, 0x63, 0x6f, 0x64, 0x65, 0x2d, 0x36, 0x2d, 0x37, 0x2d, 0x38, 0xd8, 0x22, 0x78, 0x1c, 0x59, 0x57, 0x35, 0x35, 0x49, 0x47, 0x4e, 0x68, 0x63, 0x6d, 0x35, 0x68, 0x62, 0x43, 0x42, 0x77, 0x62, 0x47, 0x56, 0x68, 0x63, 0x33, 0x56, 0x79, 0x5a, 0x51, 0x3d, 0x3d, 0xd8, 0x23, 0x67, 0x5b, 0x5e, 0x61, 0x62, 0x63, 0x5d, 0x2b, 0xd8, 0x24, 0x79, 0x01, 0x57, 0x4d, 0x49, 0x4d, 0x45, 0x2d, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x31, 0x2e, 0x30, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x61, 0x72, 0x74, 0x2f, 0x6d, 0x69, 0x78, 0x65, 0x64, 0x3b, 0x0a, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x3d, 0x22, 0x58, 0x58, 0x58, 0x58, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x20, 0x74, 0x65, 0x78, 0x74, 0x22, 0x0a, 0x0a, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x61, 0x72, 0x74, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x20, 0x69, 0x6e, 0x20, 0x4d, 0x49, 0x4d, 0x45, 0x20, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x0a, 0x0a, 0x2d, 0x2d, 0x58, 0x58, 0x58, 0x58, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x20, 0x74, 0x65, 0x78, 0x74, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0x0a, 0x0a, 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x74, 0x65, 0x78, 0x74, 0x0a, 0x0a, 0x2d, 0x2d, 0x58, 0x58, 0x58, 0x58, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x20, 0x74, 0x65, 0x78, 0x74, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0x3b, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x44, 0x69, 0x73, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x3b, 0x0a, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74, 0x78, 0x74, 0x22, 0x0a, 0x0a, 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x74, 0x65, 0x78, 0x74, 0x0a, 0x0a, 0x2d, 0x2d, 0x58, 0x58, 0x58, 0x58, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x2d, 0xae, 0x65, 0x23, 0x23, 0x23, 0x23, 0x23, 0x6f, 0x66, 0x6f, 0x6f, 0x20, 0x62, 0x61, 0x72, 0x20, 0x66, 0x6f, 0x6f, 0x20, 0x66, 0x6f, 0x6f, 0x64, 0x5f, 0x5f, 0x5f, 0x5f, 0x67, 0x66, 0x6f, 0x6f, 0x20, 0x62, 0x61, 0x72, 0x66, 0x28, 0x29, 0x28, 0x29, 0x28, 0x29, 0xd9, 0x03, 0xe8, 0x6b, 0x72, 0x61, 0x62, 0x20, 0x72, 0x61, 0x62, 0x20, 0x6f, 0x6f, 0x66, 0x16, 0x6f, 0x66, 0x6f, 0x6f, 0x20, 0x66, 0x6f, 0x6f, 0x20, 0x66, 0x6f, 0x6f, 0x20, 0x66, 0x6f, 0x6f, 0x62, 0x5e, 0x5e, 0x69, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x66, 0x18, 0x63, 0x6d, 0x66, 0x66, 0x66, 0x66, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x66, 0x63, 0x52, 0x46, 0x43, 0xd8, 0x20, 0x78, 0x31, 0x68, 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x74, 0x6f, 0x6f, 0x6c, 0x73, 0x2e, 0x69, 0x65, 0x74, 0x66, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x2f, 0x72, 0x66, 0x63, 0x37, 0x30, 0x34, 0x39, 0x23, 0x73, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x2d, 0x32, 0x2e, 0x34, 0x2e, 0x35, 0x18, 0x89, 0xd8, 0x20, 0x6f, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x63, 0x62, 0x6f, 0x72, 0x2e, 0x6d, 0x65, 0x2f, 0x68, 0x77, 0x68, 0x65, 0x6e, 0x69, 0x6d, 0x36, 0x34, 0xd8, 0x22, 0x6c, 0x63, 0x47, 0x78, 0x6c, 0x59, 0x58, 0x4e, 0x31, 0x63, 0x6d, 0x55, 0x75, 0x18, 0x40, 0xd8, 0x22, 0x68, 0x63, 0x33, 0x56, 0x79, 0x5a, 0x53, 0x34, 0x3d, 0x64, 0x70, 0x6f, 0x70, 0x6f, 0xd8, 0x23, 0x68, 0x31, 0x30, 0x30, 0x5c, 0x73, 0x2a, 0x6d, 0x6b, 0x38, 0x32, 0xd8, 0x23, 0x66, 0x70, 0x65, 0x72, 0x6c, 0x5c, 0x42, 0x63, 0x4e, 0x65, 0x64, 0xd8, 0x24, 0x79, 0x01, 0x57, 0x4d, 0x49, 0x4d, 0x45, 0x2d, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x31, 0x2e, 0x30, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x61, 0x72, 0x74, 0x2f, 0x6d, 0x69, 0x78, 0x65, 0x64, 0x3b, 0x0a, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x3d, 0x22, 0x58, 0x58, 0x58, 0x58, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x20, 0x74, 0x65, 0x78, 0x74, 0x22, 0x0a, 0x0a, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x61, 0x72, 0x74, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x20, 0x69, 0x6e, 0x20, 0x4d, 0x49, 0x4d, 0x45, 0x20, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x0a, 0x0a, 0x2d, 0x2d, 0x58, 0x58, 0x58, 0x58, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x20, 0x74, 0x65, 0x78, 0x74, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0x0a, 0x0a, 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x74, 0x65, 0x78, 0x74, 0x0a, 0x0a, 0x2d, 0x2d, 0x58, 0x58, 0x58, 0x58, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x20, 0x74, 0x65, 0x78, 0x74, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0x3b, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x44, 0x69, 0x73, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x3b, 0x0a, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74, 0x78, 0x74, 0x22, 0x0a, 0x0a, 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x74, 0x65, 0x78, 0x74, 0x0a, 0x0a, 0x2d, 0x2d, 0x58, 0x58, 0x58, 0x58, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x2d, 0x0a, 0xd8, 0x24, 0x79, 0x01, 0x57, 0x4d, 0x49, 0x4d, 0x45, 0x2d, 0x56, 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x31, 0x2e, 0x30, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x61, 0x72, 0x74, 0x2f, 0x6d, 0x69, 0x78, 0x65, 0x64, 0x3b, 0x0a, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x3d, 0x22, 0x58, 0x58, 0x58, 0x58, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x20, 0x74, 0x65, 0x78, 0x74, 0x22, 0x0a, 0x0a, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x61, 0x72, 0x74, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x20, 0x69, 0x6e, 0x20, 0x4d, 0x49, 0x4d, 0x45, 0x20, 0x66, 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x0a, 0x0a, 0x2d, 0x2d, 0x58, 0x58, 0x58, 0x58, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x20, 0x74, 0x65, 0x78, 0x74, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0x0a, 0x0a, 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x74, 0x65, 0x78, 0x74, 0x0a, 0x0a, 0x2d, 0x2d, 0x58, 0x58, 0x58, 0x58, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x20, 0x74, 0x65, 0x78, 0x74, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0x3b, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x44, 0x69, 0x73, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x3b, 0x0a, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74, 0x78, 0x74, 0x22, 0x0a, 0x0a, 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x74, 0x65, 0x78, 0x74, 0x0a, 0x0a, 0x2d, 0x2d, 0x58, 0x58, 0x58, 0x58, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x2d, 0xc0, 0x74, 0x32, 0x30, 0x30, 0x33, 0x2d, 0x31, 0x32, 0x2d, 0x31, 0x33, 0x54, 0x31, 0x38, 0x3a, 0x33, 0x30, 0x3a, 0x30, 0x32, 0x5a, 0xa2, 0x68, 0x42, 0x65, 0x64, 0x20, 0x74, 0x69, 0x6d, 0x65, 0xc0, 0x78, 0x1c, 0x32, 0x30, 0x30, 0x33, 0x2d, 0x31, 0x32, 0x2d, 0x31, 0x33, 0x54, 0x31, 0x38, 0x3a, 0x33, 0x30, 0x3a, 0x30, 0x32, 0x2e, 0x32, 0x35, 0x2b, 0x30, 0x31, 0x3a, 0x30, 0x30, 0x18, 0x58, 0xc0, 0x78, 0x1c, 0x32, 0x30, 0x30, 0x33, 0x2d, 0x31, 0x32, 0x2d, 0x31, 0x33, 0x54, 0x31, 0x38, 0x3a, 0x33, 0x30, 0x3a, 0x30, 0x32, 0x2e, 0x32, 0x35, 0x2b, 0x30, 0x31, 0x3a, 0x30, 0x30, 0xf7, 0xa3, 0x64, 0x64, 0x61, 0x72, 0x65, 0xd8, 0x42, 0xf5, 0x62, 0x75, 0x75, 0xf4, 0x1a, 0x00, 0x0b, 0x41, 0x62, 0xf6, 0x80, 0xa3, 0x78, 0x1c, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x20, 0x61, 0x6e, 0x64, 0x20, 0x74, 0x61, 0x67, 0x67, 0x65, 0x64, 0x20, 0x65, 0x6d, 0x70, 0x74, 0x79, 0x20, 0x61, 0x72, 0x72, 0x61, 0x79, 0xd9, 0x04, 0x45, 0x80, 0x65, 0x61, 0x6c, 0x61, 0x62, 0x6c, 0x80, 0x18, 0x2a, 0x80, 0xa1, 0x68, 0x69, 0x6e, 0x20, 0x61, 0x20, 0x6d, 0x61, 0x70, 0xa1, 0x19, 0x15, 0xb4, 0xa1, 0x6e, 0x69, 0x6e, 0x20, 0x61, 0x20, 0x69, 0x6e, 0x20, 0x61, 0x20, 0x69, 0x6e, 0x20, 0x61, 0xd9, 0x23, 0x7f, 0xa0, 0xa5, 0x62, 0x73, 0x31, 0xd8, 0x58, 0xf8, 0xff, 0x62, 0x73, 0x32, 0xe0, 0x62, 0x73, 0x33, 0xd8, 0x58, 0xf8, 0x21, 0x1a, 0x05, 0x44, 0x8c, 0x06, 0xd8, 0x58, 0xf8, 0xff, 0x18, 0x59, 0xd8, 0x58, 0xf3,
-
- 0xd8, 0x25, 0x50, 0x53, 0x4d, 0x41, 0x52, 0x54, 0x43, 0x53, 0x4c, 0x54, 0x54, 0x43, 0x46, 0x49, 0x43, 0x41, 0x32, 0xa2, 0x64, 0x55, 0x55, 0x55, 0x55, 0xd8, 0x25, 0x50, 0x53, 0x4d, 0x41, 0x52, 0x54, 0x43, 0x53, 0x4c, 0x54, 0x54, 0x43, 0x46, 0x49, 0x43, 0x41, 0x32, 0x18, 0x63, 0xd8, 0x25, 0x50, 0x53, 0x4d, 0x41, 0x52, 0x54, 0x43, 0x53, 0x4c, 0x54, 0x54, 0x43, 0x46, 0x49, 0x43, 0x41, 0x32,
-
- 0xf5, 0xf4, 0xa2, 0x71, 0x47, 0x65, 0x6f, 0x72, 0x67, 0x65, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x6d, 0x61, 0x6e, 0xf5, 0x19, 0x10, 0x41, 0xf5,
-
- 0xC2, 0x49, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xC3, 0x49, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xA4, 0x63, 0x42, 0x4E, 0x2B, 0xC2, 0x49, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x40, 0xC2, 0x49, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x63, 0x42, 0x4E, 0x2D, 0xC3, 0x49, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38, 0x3F, 0xC3, 0x49, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00
-
+ 0x98, 0x29, 0x66, 0x55, 0x49, 0x4e, 0x54, 0x36, 0x32, 0xd8,
+ 0x64, 0x1a, 0x05, 0x5d, 0x23, 0x15, 0x65, 0x49, 0x4e, 0x54,
+ 0x36, 0x34, 0xd8, 0x4c, 0x1b, 0x00, 0x00, 0x00, 0x12, 0x16,
+ 0xaf, 0x2b, 0x15, 0x00, 0x38, 0x2b, 0xa4, 0x63, 0x4c, 0x42,
+ 0x4c, 0x18, 0x4d, 0x23, 0x18, 0x58, 0x78, 0x1a, 0x4e, 0x45,
+ 0x47, 0x4c, 0x42, 0x4c, 0x54, 0x48, 0x41, 0x54, 0x20, 0x49,
+ 0x53, 0x20, 0x4b, 0x49, 0x4e, 0x44, 0x20, 0x4f, 0x46, 0x20,
+ 0x4c, 0x4f, 0x4e, 0x47, 0x3b, 0x00, 0x00, 0x02, 0x2d, 0x9a,
+ 0xc6, 0x94, 0x55, 0x3a, 0x05, 0xf5, 0xe0, 0xff, 0x3a, 0x2f,
+ 0xaf, 0x07, 0xff, 0x65, 0x4a, 0x61, 0x69, 0x6d, 0x65, 0xd8,
+ 0x58, 0xfa, 0x40, 0x49, 0x0f, 0xd0, 0x66, 0x53, 0x74, 0x72,
+ 0x65, 0x65, 0x74, 0xd8, 0x63, 0xfb, 0x40, 0x21, 0x4f, 0x01,
+ 0x96, 0xd8, 0xf4, 0xf9, 0xfa, 0x3f, 0x80, 0x00, 0x00, 0xfb,
+ 0x3f, 0xf0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa4, 0x63,
+ 0x66, 0x6f, 0x6f, 0xfa, 0x45, 0x98, 0xb8, 0x00, 0x39, 0x03,
+ 0xe6, 0xfa, 0x44, 0x79, 0xc0, 0x00, 0x66, 0x66, 0x6f, 0x6f,
+ 0x66, 0x6f, 0x6f, 0xfb, 0x41, 0x58, 0xf7, 0x7d, 0xc0, 0x00,
+ 0x00, 0x00, 0x39, 0xaf, 0xc6, 0xfb, 0x40, 0xf5, 0xba, 0x70,
+ 0x00, 0x00, 0x00, 0x00, 0xc1, 0x1a, 0x8e, 0x15, 0x1c, 0x8a,
+ 0xa3, 0x74, 0x4c, 0x6f, 0x6e, 0x67, 0x4c, 0x69, 0x76, 0x65,
+ 0x44, 0x65, 0x6e, 0x69, 0x73, 0x52, 0x69, 0x74, 0x63, 0x68,
+ 0x69, 0x65, 0xc1, 0x1a, 0x53, 0x72, 0x4e, 0x00, 0x66, 0x74,
+ 0x69, 0x6d, 0x65, 0x28, 0x29, 0xc1, 0x1a, 0x58, 0x0d, 0x41,
+ 0x72, 0x39, 0x07, 0xb0, 0xc1, 0x1a, 0x58, 0x0d, 0x3f, 0x76,
+ 0x42, 0xff, 0x00, 0xa3, 0x66, 0x62, 0x69, 0x6e, 0x62, 0x69,
+ 0x6e, 0xda, 0x00, 0x01, 0x86, 0xa0, 0x41, 0x00, 0x66, 0x62,
+ 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x43, 0x01, 0x02, 0x03, 0x00,
+ 0x44, 0x04, 0x02, 0x03, 0xfe, 0x6f, 0x62, 0x61, 0x72, 0x20,
+ 0x62, 0x61, 0x72, 0x20, 0x66, 0x6f, 0x6f, 0x20, 0x62, 0x61,
+ 0x72, 0x64, 0x6f, 0x6f, 0x66, 0x0a, 0xd8, 0x20, 0x78, 0x6b,
+ 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f, 0x73, 0x74, 0x61,
+ 0x63, 0x6b, 0x6f, 0x76, 0x65, 0x72, 0x66, 0x6c, 0x6f, 0x77,
+ 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x71, 0x75, 0x65, 0x73, 0x74,
+ 0x69, 0x6f, 0x6e, 0x73, 0x2f, 0x32, 0x38, 0x30, 0x35, 0x39,
+ 0x36, 0x39, 0x37, 0x2f, 0x68, 0x6f, 0x77, 0x2d, 0x64, 0x6f,
+ 0x2d, 0x69, 0x2d, 0x74, 0x6f, 0x67, 0x67, 0x6c, 0x65, 0x2d,
+ 0x62, 0x65, 0x74, 0x77, 0x65, 0x65, 0x6e, 0x2d, 0x64, 0x65,
+ 0x62, 0x75, 0x67, 0x2d, 0x61, 0x6e, 0x64, 0x2d, 0x72, 0x65,
+ 0x6c, 0x65, 0x61, 0x73, 0x65, 0x2d, 0x62, 0x75, 0x69, 0x6c,
+ 0x64, 0x73, 0x2d, 0x69, 0x6e, 0x2d, 0x78, 0x63, 0x6f, 0x64,
+ 0x65, 0x2d, 0x36, 0x2d, 0x37, 0x2d, 0x38, 0xd8, 0x22, 0x78,
+ 0x1c, 0x59, 0x57, 0x35, 0x35, 0x49, 0x47, 0x4e, 0x68, 0x63,
+ 0x6d, 0x35, 0x68, 0x62, 0x43, 0x42, 0x77, 0x62, 0x47, 0x56,
+ 0x68, 0x63, 0x33, 0x56, 0x79, 0x5a, 0x51, 0x3d, 0x3d, 0xd8,
+ 0x23, 0x67, 0x5b, 0x5e, 0x61, 0x62, 0x63, 0x5d, 0x2b, 0xd8,
+ 0x24, 0x79, 0x01, 0x57, 0x4d, 0x49, 0x4d, 0x45, 0x2d, 0x56,
+ 0x65, 0x72, 0x73, 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x31, 0x2e,
+ 0x30, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d,
+ 0x54, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x6d, 0x75, 0x6c, 0x74,
+ 0x69, 0x70, 0x61, 0x72, 0x74, 0x2f, 0x6d, 0x69, 0x78, 0x65,
+ 0x64, 0x3b, 0x0a, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72,
+ 0x79, 0x3d, 0x22, 0x58, 0x58, 0x58, 0x58, 0x62, 0x6f, 0x75,
+ 0x6e, 0x64, 0x61, 0x72, 0x79, 0x20, 0x74, 0x65, 0x78, 0x74,
+ 0x22, 0x0a, 0x0a, 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73,
+ 0x20, 0x61, 0x20, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x61,
+ 0x72, 0x74, 0x20, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65,
+ 0x20, 0x69, 0x6e, 0x20, 0x4d, 0x49, 0x4d, 0x45, 0x20, 0x66,
+ 0x6f, 0x72, 0x6d, 0x61, 0x74, 0x2e, 0x0a, 0x0a, 0x2d, 0x2d,
+ 0x58, 0x58, 0x58, 0x58, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61,
+ 0x72, 0x79, 0x20, 0x74, 0x65, 0x78, 0x74, 0x0a, 0x43, 0x6f,
+ 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x54, 0x79, 0x70, 0x65,
+ 0x3a, 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61,
+ 0x69, 0x6e, 0x0a, 0x0a, 0x74, 0x68, 0x69, 0x73, 0x20, 0x69,
+ 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x62, 0x6f, 0x64, 0x79,
+ 0x20, 0x74, 0x65, 0x78, 0x74, 0x0a, 0x0a, 0x2d, 0x2d, 0x58,
+ 0x58, 0x58, 0x58, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72,
+ 0x79, 0x20, 0x74, 0x65, 0x78, 0x74, 0x0a, 0x43, 0x6f, 0x6e,
+ 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a,
+ 0x20, 0x74, 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69,
+ 0x6e, 0x3b, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74,
+ 0x2d, 0x44, 0x69, 0x73, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69,
+ 0x6f, 0x6e, 0x3a, 0x20, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68,
+ 0x6d, 0x65, 0x6e, 0x74, 0x3b, 0x0a, 0x66, 0x69, 0x6c, 0x65,
+ 0x6e, 0x61, 0x6d, 0x65, 0x3d, 0x22, 0x74, 0x65, 0x73, 0x74,
+ 0x2e, 0x74, 0x78, 0x74, 0x22, 0x0a, 0x0a, 0x74, 0x68, 0x69,
+ 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x61,
+ 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x20,
+ 0x74, 0x65, 0x78, 0x74, 0x0a, 0x0a, 0x2d, 0x2d, 0x58, 0x58,
+ 0x58, 0x58, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79,
+ 0x20, 0x74, 0x65, 0x78, 0x74, 0x2d, 0x2d, 0xae, 0x65, 0x23,
+ 0x23, 0x23, 0x23, 0x23, 0x6f, 0x66, 0x6f, 0x6f, 0x20, 0x62,
+ 0x61, 0x72, 0x20, 0x66, 0x6f, 0x6f, 0x20, 0x66, 0x6f, 0x6f,
+ 0x64, 0x5f, 0x5f, 0x5f, 0x5f, 0x67, 0x66, 0x6f, 0x6f, 0x20,
+ 0x62, 0x61, 0x72, 0x66, 0x28, 0x29, 0x28, 0x29, 0x28, 0x29,
+ 0xd9, 0x03, 0xe8, 0x6b, 0x72, 0x61, 0x62, 0x20, 0x72, 0x61,
+ 0x62, 0x20, 0x6f, 0x6f, 0x66, 0x16, 0x6f, 0x66, 0x6f, 0x6f,
+ 0x20, 0x66, 0x6f, 0x6f, 0x20, 0x66, 0x6f, 0x6f, 0x20, 0x66,
+ 0x6f, 0x6f, 0x62, 0x5e, 0x5e, 0x69, 0x6f, 0x6f, 0x6f, 0x6f,
+ 0x6f, 0x6f, 0x6f, 0x6f, 0x66, 0x18, 0x63, 0x6d, 0x66, 0x66,
+ 0x66, 0x66, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f, 0x6f,
+ 0x66, 0x63, 0x52, 0x46, 0x43, 0xd8, 0x20, 0x78, 0x31, 0x68,
+ 0x74, 0x74, 0x70, 0x73, 0x3a, 0x2f, 0x2f, 0x74, 0x6f, 0x6f,
+ 0x6c, 0x73, 0x2e, 0x69, 0x65, 0x74, 0x66, 0x2e, 0x6f, 0x72,
+ 0x67, 0x2f, 0x68, 0x74, 0x6d, 0x6c, 0x2f, 0x72, 0x66, 0x63,
+ 0x37, 0x30, 0x34, 0x39, 0x23, 0x73, 0x65, 0x63, 0x74, 0x69,
+ 0x6f, 0x6e, 0x2d, 0x32, 0x2e, 0x34, 0x2e, 0x35, 0x18, 0x89,
+ 0xd8, 0x20, 0x6f, 0x68, 0x74, 0x74, 0x70, 0x3a, 0x2f, 0x2f,
+ 0x63, 0x62, 0x6f, 0x72, 0x2e, 0x6d, 0x65, 0x2f, 0x68, 0x77,
+ 0x68, 0x65, 0x6e, 0x69, 0x6d, 0x36, 0x34, 0xd8, 0x22, 0x6c,
+ 0x63, 0x47, 0x78, 0x6c, 0x59, 0x58, 0x4e, 0x31, 0x63, 0x6d,
+ 0x55, 0x75, 0x18, 0x40, 0xd8, 0x22, 0x68, 0x63, 0x33, 0x56,
+ 0x79, 0x5a, 0x53, 0x34, 0x3d, 0x64, 0x70, 0x6f, 0x70, 0x6f,
+ 0xd8, 0x23, 0x68, 0x31, 0x30, 0x30, 0x5c, 0x73, 0x2a, 0x6d,
+ 0x6b, 0x38, 0x32, 0xd8, 0x23, 0x66, 0x70, 0x65, 0x72, 0x6c,
+ 0x5c, 0x42, 0x63, 0x4e, 0x65, 0x64, 0xd8, 0x24, 0x79, 0x01,
+ 0x57, 0x4d, 0x49, 0x4d, 0x45, 0x2d, 0x56, 0x65, 0x72, 0x73,
+ 0x69, 0x6f, 0x6e, 0x3a, 0x20, 0x31, 0x2e, 0x30, 0x0a, 0x43,
+ 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x54, 0x79, 0x70,
+ 0x65, 0x3a, 0x20, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x61,
+ 0x72, 0x74, 0x2f, 0x6d, 0x69, 0x78, 0x65, 0x64, 0x3b, 0x0a,
+ 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x3d, 0x22,
+ 0x58, 0x58, 0x58, 0x58, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61,
+ 0x72, 0x79, 0x20, 0x74, 0x65, 0x78, 0x74, 0x22, 0x0a, 0x0a,
+ 0x54, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20,
+ 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x61, 0x72, 0x74, 0x20,
+ 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x20, 0x69, 0x6e,
+ 0x20, 0x4d, 0x49, 0x4d, 0x45, 0x20, 0x66, 0x6f, 0x72, 0x6d,
+ 0x61, 0x74, 0x2e, 0x0a, 0x0a, 0x2d, 0x2d, 0x58, 0x58, 0x58,
+ 0x58, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x20,
+ 0x74, 0x65, 0x78, 0x74, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65,
+ 0x6e, 0x74, 0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74,
+ 0x65, 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0x0a,
+ 0x0a, 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74,
+ 0x68, 0x65, 0x20, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x74, 0x65,
+ 0x78, 0x74, 0x0a, 0x0a, 0x2d, 0x2d, 0x58, 0x58, 0x58, 0x58,
+ 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x20, 0x74,
+ 0x65, 0x78, 0x74, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e,
+ 0x74, 0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65,
+ 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0x3b, 0x0a,
+ 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x44, 0x69,
+ 0x73, 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3a,
+ 0x20, 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e,
+ 0x74, 0x3b, 0x0a, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d,
+ 0x65, 0x3d, 0x22, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74, 0x78,
+ 0x74, 0x22, 0x0a, 0x0a, 0x74, 0x68, 0x69, 0x73, 0x20, 0x69,
+ 0x73, 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x74, 0x74, 0x61,
+ 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x74, 0x65, 0x78,
+ 0x74, 0x0a, 0x0a, 0x2d, 0x2d, 0x58, 0x58, 0x58, 0x58, 0x62,
+ 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x20, 0x74, 0x65,
+ 0x78, 0x74, 0x2d, 0x2d, 0x0a, 0xd8, 0x24, 0x79, 0x01, 0x57,
+ 0x4d, 0x49, 0x4d, 0x45, 0x2d, 0x56, 0x65, 0x72, 0x73, 0x69,
+ 0x6f, 0x6e, 0x3a, 0x20, 0x31, 0x2e, 0x30, 0x0a, 0x43, 0x6f,
+ 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x54, 0x79, 0x70, 0x65,
+ 0x3a, 0x20, 0x6d, 0x75, 0x6c, 0x74, 0x69, 0x70, 0x61, 0x72,
+ 0x74, 0x2f, 0x6d, 0x69, 0x78, 0x65, 0x64, 0x3b, 0x0a, 0x62,
+ 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x3d, 0x22, 0x58,
+ 0x58, 0x58, 0x58, 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72,
+ 0x79, 0x20, 0x74, 0x65, 0x78, 0x74, 0x22, 0x0a, 0x0a, 0x54,
+ 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x61, 0x20, 0x6d,
+ 0x75, 0x6c, 0x74, 0x69, 0x70, 0x61, 0x72, 0x74, 0x20, 0x6d,
+ 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x20, 0x69, 0x6e, 0x20,
+ 0x4d, 0x49, 0x4d, 0x45, 0x20, 0x66, 0x6f, 0x72, 0x6d, 0x61,
+ 0x74, 0x2e, 0x0a, 0x0a, 0x2d, 0x2d, 0x58, 0x58, 0x58, 0x58,
+ 0x62, 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x20, 0x74,
+ 0x65, 0x78, 0x74, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e,
+ 0x74, 0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65,
+ 0x78, 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0x0a, 0x0a,
+ 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73, 0x20, 0x74, 0x68,
+ 0x65, 0x20, 0x62, 0x6f, 0x64, 0x79, 0x20, 0x74, 0x65, 0x78,
+ 0x74, 0x0a, 0x0a, 0x2d, 0x2d, 0x58, 0x58, 0x58, 0x58, 0x62,
+ 0x6f, 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x20, 0x74, 0x65,
+ 0x78, 0x74, 0x0a, 0x43, 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74,
+ 0x2d, 0x54, 0x79, 0x70, 0x65, 0x3a, 0x20, 0x74, 0x65, 0x78,
+ 0x74, 0x2f, 0x70, 0x6c, 0x61, 0x69, 0x6e, 0x3b, 0x0a, 0x43,
+ 0x6f, 0x6e, 0x74, 0x65, 0x6e, 0x74, 0x2d, 0x44, 0x69, 0x73,
+ 0x70, 0x6f, 0x73, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x3a, 0x20,
+ 0x61, 0x74, 0x74, 0x61, 0x63, 0x68, 0x6d, 0x65, 0x6e, 0x74,
+ 0x3b, 0x0a, 0x66, 0x69, 0x6c, 0x65, 0x6e, 0x61, 0x6d, 0x65,
+ 0x3d, 0x22, 0x74, 0x65, 0x73, 0x74, 0x2e, 0x74, 0x78, 0x74,
+ 0x22, 0x0a, 0x0a, 0x74, 0x68, 0x69, 0x73, 0x20, 0x69, 0x73,
+ 0x20, 0x74, 0x68, 0x65, 0x20, 0x61, 0x74, 0x74, 0x61, 0x63,
+ 0x68, 0x6d, 0x65, 0x6e, 0x74, 0x20, 0x74, 0x65, 0x78, 0x74,
+ 0x0a, 0x0a, 0x2d, 0x2d, 0x58, 0x58, 0x58, 0x58, 0x62, 0x6f,
+ 0x75, 0x6e, 0x64, 0x61, 0x72, 0x79, 0x20, 0x74, 0x65, 0x78,
+ 0x74, 0x2d, 0x2d, 0xc0, 0x74, 0x32, 0x30, 0x30, 0x33, 0x2d,
+ 0x31, 0x32, 0x2d, 0x31, 0x33, 0x54, 0x31, 0x38, 0x3a, 0x33,
+ 0x30, 0x3a, 0x30, 0x32, 0x5a, 0xa2, 0x68, 0x42, 0x65, 0x64,
+ 0x20, 0x74, 0x69, 0x6d, 0x65, 0xc0, 0x78, 0x1c, 0x32, 0x30,
+ 0x30, 0x33, 0x2d, 0x31, 0x32, 0x2d, 0x31, 0x33, 0x54, 0x31,
+ 0x38, 0x3a, 0x33, 0x30, 0x3a, 0x30, 0x32, 0x2e, 0x32, 0x35,
+ 0x2b, 0x30, 0x31, 0x3a, 0x30, 0x30, 0x18, 0x58, 0xc0, 0x78,
+ 0x1c, 0x32, 0x30, 0x30, 0x33, 0x2d, 0x31, 0x32, 0x2d, 0x31,
+ 0x33, 0x54, 0x31, 0x38, 0x3a, 0x33, 0x30, 0x3a, 0x30, 0x32,
+ 0x2e, 0x32, 0x35, 0x2b, 0x30, 0x31, 0x3a, 0x30, 0x30, 0xf7,
+ 0xa3, 0x64, 0x64, 0x61, 0x72, 0x65, 0xd8, 0x42, 0xf5, 0x62,
+ 0x75, 0x75, 0xf4, 0x1a, 0x00, 0x0b, 0x41, 0x62, 0xf6, 0x80,
+ 0xa3, 0x78, 0x1c, 0x6c, 0x61, 0x62, 0x65, 0x6c, 0x20, 0x61,
+ 0x6e, 0x64, 0x20, 0x74, 0x61, 0x67, 0x67, 0x65, 0x64, 0x20,
+ 0x65, 0x6d, 0x70, 0x74, 0x79, 0x20, 0x61, 0x72, 0x72, 0x61,
+ 0x79, 0xd9, 0x04, 0x45, 0x80, 0x65, 0x61, 0x6c, 0x61, 0x62,
+ 0x6c, 0x80, 0x18, 0x2a, 0x80, 0xa1, 0x68, 0x69, 0x6e, 0x20,
+ 0x61, 0x20, 0x6d, 0x61, 0x70, 0xa1, 0x19, 0x15, 0xb4, 0xa1,
+ 0x6e, 0x69, 0x6e, 0x20, 0x61, 0x20, 0x69, 0x6e, 0x20, 0x61,
+ 0x20, 0x69, 0x6e, 0x20, 0x61, 0xd9, 0x23, 0x7f, 0xa0, 0xa5,
+ 0x62, 0x73, 0x31, 0xd8, 0x58, 0xf8, 0xff, 0x62, 0x73, 0x32,
+ 0xe0, 0x62, 0x73, 0x33, 0xd8, 0x58, 0xf8, 0x21, 0x1a, 0x05,
+ 0x44, 0x8c, 0x06, 0xd8, 0x58, 0xf8, 0xff, 0x18, 0x59, 0xd8,
+ 0x58, 0xf3, 0xd8, 0x25, 0x50, 0x53, 0x4d, 0x41, 0x52, 0x54,
+ 0x43, 0x53, 0x4c, 0x54, 0x54, 0x43, 0x46, 0x49, 0x43, 0x41,
+ 0x32, 0xa2, 0x64, 0x55, 0x55, 0x55, 0x55, 0xd8, 0x25, 0x50,
+ 0x53, 0x4d, 0x41, 0x52, 0x54, 0x43, 0x53, 0x4c, 0x54, 0x54,
+ 0x43, 0x46, 0x49, 0x43, 0x41, 0x32, 0x18, 0x63, 0xd8, 0x25,
+ 0x50, 0x53, 0x4d, 0x41, 0x52, 0x54, 0x43, 0x53, 0x4c, 0x54,
+ 0x54, 0x43, 0x46, 0x49, 0x43, 0x41, 0x32, 0xf5, 0xf4, 0xa2,
+ 0x71, 0x47, 0x65, 0x6f, 0x72, 0x67, 0x65, 0x20, 0x69, 0x73,
+ 0x20, 0x74, 0x68, 0x65, 0x20, 0x6d, 0x61, 0x6e, 0xf5, 0x19,
+ 0x10, 0x41, 0xf5, 0xC2, 0x49, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0xC3, 0x49, 0x01, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x00, 0xA4, 0x63, 0x42, 0x4E, 0x2B,
+ 0xC2, 0x49, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x18, 0x40, 0xC2, 0x49, 0x01, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00, 0x00, 0x00, 0x63, 0x42, 0x4E, 0x2D, 0xC3, 0x49,
+ 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x38,
+ 0x3F, 0xC3, 0x49, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
+ 0x00, 0x00
};
@@ -114,7 +354,7 @@
uint8_t pEncoded[3000];
size_t nEncodedLen = sizeof(pEncoded);
- QCBOREncode_Init(&ECtx, pEncoded, nEncodedLen);
+ QCBOREncode_Init(&ECtx, (UsefulBuf){pEncoded, nEncodedLen});
QCBOREncode_OpenArray(&ECtx);
@@ -172,7 +412,7 @@
QCBOREncode_AddURI(&ECtx, SZLiteralToUsefulBufC("http://stackoverflow.com/questions/28059697/how-do-i-toggle-between-debug-and-release-builds-in-xcode-6-7-8"));
QCBOREncode_AddB64Text(&ECtx, SZLiteralToUsefulBufC("YW55IGNhcm5hbCBwbGVhc3VyZQ=="));
QCBOREncode_AddRegex(&ECtx, SZLiteralToUsefulBufC("[^abc]+"));
- QCBOREncode_AddMIMEData(&ECtx, SZToUsefulBufC(szMIME));
+ QCBOREncode_AddMIMEData(&ECtx, UsefulBuf_FromSZ(szMIME));
// text blobs in maps
QCBOREncode_OpenMap(&ECtx);
@@ -188,8 +428,8 @@
QCBOREncode_AddB64TextToMapN(&ECtx, 64, SZLiteralToUsefulBufC("c3VyZS4="));
QCBOREncode_AddRegexToMap(&ECtx, "popo", SZLiteralToUsefulBufC("100\\s*mk")); // x code string literal bug
QCBOREncode_AddRegexToMapN(&ECtx, -51, SZLiteralToUsefulBufC("perl\\B")); // x code string literal bug
- QCBOREncode_AddMIMEDataToMap(&ECtx, "Ned", SZToUsefulBufC(szMIME));
- QCBOREncode_AddMIMEDataToMapN(&ECtx, 10, SZToUsefulBufC(szMIME));
+ QCBOREncode_AddMIMEDataToMap(&ECtx, "Ned", UsefulBuf_FromSZ(szMIME));
+ QCBOREncode_AddMIMEDataToMapN(&ECtx, 10, UsefulBuf_FromSZ(szMIME));
QCBOREncode_CloseMap(&ECtx);
// Date strings
@@ -213,7 +453,7 @@
// opening arrays in a map
QCBOREncode_OpenMap(&ECtx);
- QCBOREncode_OpenArray_3(&ECtx, "label and tagged empty array", QCBOR_NO_INT_LABEL, 1093, 0);
+ QCBOREncode_OpenArray_3(&ECtx, "label and tagged empty array", QCBOR_NO_INT_LABEL, 1093);
QCBOREncode_CloseArray(&ECtx);
QCBOREncode_OpenArrayInMap(&ECtx, "alabl");
QCBOREncode_CloseArray(&ECtx);
@@ -225,7 +465,7 @@
QCBOREncode_OpenMap(&ECtx);
QCBOREncode_OpenMapInMap(&ECtx, "in a map");
QCBOREncode_OpenMapInMapN(&ECtx, 5556);
- QCBOREncode_OpenMap_3(&ECtx, "in a in a in a", QCBOR_NO_INT_LABEL, 9087, 0);
+ QCBOREncode_OpenMap_3(&ECtx, "in a in a in a", QCBOR_NO_INT_LABEL, 9087);
QCBOREncode_CloseMap(&ECtx);
QCBOREncode_CloseMap(&ECtx);
QCBOREncode_CloseMap(&ECtx);
@@ -273,7 +513,7 @@
QCBOREncode_CloseArray(&ECtx);
- EncodedCBOR Enc;
+ UsefulBufC Enc;
if(QCBOREncode_Finish2(&ECtx, &Enc)) {
nReturn = -1;
@@ -282,7 +522,7 @@
//printencodedE(Enc);
- if(CheckResults(Enc,pExpectedEncodedAll))
+ if(CheckResults(Enc, pExpectedEncodedAll))
nReturn = -1;
Done:
@@ -335,7 +575,7 @@
uint8_t pEncoded[1000];
size_t nEncodedLen = sizeof(pEncoded);
- QCBOREncode_Init(&ECtx, pEncoded, nEncodedLen);
+ QCBOREncode_Init(&ECtx, (UsefulBuf){pEncoded, nEncodedLen});
QCBOREncode_OpenArray(&ECtx);
QCBOREncode_AddInt64(&ECtx, -9223372036854775807LL - 1);
@@ -388,7 +628,7 @@
QCBOREncode_CloseArray(&ECtx);
- EncodedCBOR Enc;
+ UsefulBufC Enc;
if(QCBOREncode_Finish2(&ECtx, &Enc)) {
nReturn = -1;
}
@@ -396,7 +636,7 @@
if(CheckResults(Enc, pExpectedEncodedInts))
return -1;
- if(Enc.Bytes.len != sizeof(pExpectedEncodedInts) || bcmp(pEncoded, pExpectedEncodedInts, Enc.Bytes.len))
+ if(Enc.len != sizeof(pExpectedEncodedInts) || bcmp(pEncoded, pExpectedEncodedInts, Enc.len))
nReturn = -1;
//printencoded(pEncoded, nEncodedLen);
@@ -418,7 +658,7 @@
uint8_t pEncoded[100];
size_t nEncodedLen = sizeof(pEncoded);
- QCBOREncode_Init(&ECtx, pEncoded, nEncodedLen);
+ QCBOREncode_Init(&ECtx, (UsefulBuf) {pEncoded, nEncodedLen});
QCBOREncode_OpenArray(&ECtx);
QCBOREncode_AddSimple(&ECtx, CBOR_SIMPLEV_TRUE);
@@ -433,12 +673,12 @@
QCBOREncode_CloseArray(&ECtx);
- EncodedCBOR ECBOR;
+ UsefulBufC ECBOR;
if(QCBOREncode_Finish2(&ECtx, &ECBOR)) {
nReturn = -1;
}
- if(ECBOR.Bytes.len != sizeof(pExpectedEncodedSimple) || bcmp(pEncoded, pExpectedEncodedSimple, ECBOR.Bytes.len))
+ if(ECBOR.len != sizeof(pExpectedEncodedSimple) || bcmp(pEncoded, pExpectedEncodedSimple, ECBOR.len))
nReturn = -1;
// printencoded(pEncoded, nEncodedLen);
@@ -446,6 +686,8 @@
return(nReturn);
}
+#if 0
+
static uint8_t pExpectedEncodedFloat[] = {
0x98, 0x1e, 0xfa, 0x00, 0x00, 0x00, 0x00, 0xfa,
@@ -538,6 +780,8 @@
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,
@@ -560,7 +804,7 @@
uint8_t pEncoded[1000];
size_t nEncodedLen = sizeof(pEncoded);
- QCBOREncode_Init(&ECtx, pEncoded, nEncodedLen);
+ QCBOREncode_Init(&ECtx, (UsefulBuf){pEncoded, nEncodedLen});
QCBOREncode_OpenArray(&ECtx);
@@ -594,23 +838,22 @@
}
-
int ArrayNestingTest1()
{
QCBOREncodeContext ECtx;
int i;
int nReturn = 0;
- uint8_t pEncoded[100];
- size_t nEncodedLen = sizeof(pEncoded);
+ UsefulBuf_MakeStackUB(Encode, 100);
- QCBOREncode_Init(&ECtx, pEncoded, nEncodedLen);
+ QCBOREncode_Init(&ECtx, Encode);
for(i = QCBOR_MAX_ARRAY_NESTING; i; i--) {
QCBOREncode_OpenArray(&ECtx);
}
for(i = QCBOR_MAX_ARRAY_NESTING; i; i--) {
QCBOREncode_CloseArray(&ECtx);
}
+ size_t nEncodedLen;
if(QCBOREncode_Finish(&ECtx, &nEncodedLen)) {
printf("ArrayNestingTest1 Failed\n");
nReturn = -1;
@@ -628,16 +871,17 @@
int i;
int nReturn = 0;
- uint8_t pEncoded[100];
- size_t nEncodedLen = sizeof(pEncoded);
+ UsefulBuf_MakeStackUB(Encode, 100);
- QCBOREncode_Init(&ECtx, pEncoded, nEncodedLen);
+ QCBOREncode_Init(&ECtx, Encode);
for(i = QCBOR_MAX_ARRAY_NESTING+1; i; i--) {
QCBOREncode_OpenArray(&ECtx);
}
for(i = QCBOR_MAX_ARRAY_NESTING; i; i--) {
QCBOREncode_CloseArray(&ECtx);
}
+
+ size_t nEncodedLen;
if(QCBOREncode_Finish(&ECtx, &nEncodedLen) != QCBOR_ERR_ARRAY_NESTING_TOO_DEEP) {
nReturn = -1;
}
@@ -653,16 +897,16 @@
int i;
int nReturn = 0;
- uint8_t pEncoded[100];
- size_t nEncodedLen = sizeof(pEncoded);
-
- QCBOREncode_Init(&ECtx, pEncoded, nEncodedLen);
+ UsefulBuf_MakeStackUB(Encode, 100);
+
+ QCBOREncode_Init(&ECtx, Encode);
for(i = QCBOR_MAX_ARRAY_NESTING; i; i--) {
QCBOREncode_OpenArray(&ECtx);
}
for(i = QCBOR_MAX_ARRAY_NESTING+1 ; i; i--) {
QCBOREncode_CloseArray(&ECtx);
}
+ size_t nEncodedLen;
if(QCBOREncode_Finish(&ECtx, &nEncodedLen) != QCBOR_ERR_TOO_MANY_CLOSES) {
nReturn = -1;
}
@@ -670,6 +914,7 @@
return(nReturn);
}
+#if 0
static uint8_t s_pFiveArrarys[] = {0x81, 0x81, 0x81, 0x81, 0x80};
@@ -753,7 +998,7 @@
return(nReturn);
}
-
+#endif
@@ -769,7 +1014,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_OpenMap(&ECtx);
QCBOREncode_AddInt64ToMap(&ECtx, "first integer", 42);
QCBOREncode_OpenArrayInMap(&ECtx, "an array of two strings");
@@ -831,7 +1076,6 @@
}
-
/*
@brief Encode the RTIC results
@@ -861,7 +1105,7 @@
// Context for the encoder
QCBOREncodeContext ECtx;
- QCBOREncode_Init(&ECtx, pOut, *pnLen);
+ QCBOREncode_Init(&ECtx, (UsefulBuf){pOut, *pnLen});
// All the RTIC results are grouped in a CBOR Map which will get turned into a JSON Object
// Contents are label / value pairs
@@ -932,6 +1176,9 @@
return 0;
}
+
+#if 0
+
static const uint8_t pBStrArrayExpected[] = { 0x45, 0x81, 0x63, 0x66, 0x6F, 0x6F };
static const uint8_t pBStrMapExpected[] = {
@@ -982,6 +1229,6 @@
return 0;
}
-
+#endif
diff --git a/test/qcbor_encode_tests.h b/test/qcbor_encode_tests.h
index 038465c..0926fa1 100644
--- a/test/qcbor_encode_tests.h
+++ b/test/qcbor_encode_tests.h
@@ -50,7 +50,7 @@
Encode lots of integer values, particularly around the boundary and make sure they
Match the expected binary output. Primarily an encoding test.
*/
-int IntegerValuesTest1();
+int IntegerValuesTest1(void);
@@ -58,70 +58,70 @@
Create nested arrays to the max depth allowed and make sure it succeeds.
This is an encoding test.
*/
-int ArrayNestingTest1();
+int ArrayNestingTest1(void);
/*
Create nested arrays to one more than the meax depth and make sure it fails.
This is an encoding test.
*/
-int ArrayNestingTest2();
+int ArrayNestingTest2(void);
/*
Encoding test.
Create arrays to max depth and close one extra time and look for correct error code
*/
-int ArrayNestingTest3();
+int ArrayNestingTest3(void);
/*
This tests the QCBOREncode_AddRaw() function by adding two chunks or RAWCBOR to an
array and comparing with expected values. This is an encoding test.
*/
-int EncodeRawTest();
+int EncodeRawTest(void);
/*
This creates a somewhat complicated CBOR MAP and verifies it against expected
data. This is an encoding test.
*/
-int MapEncodeTest();
+int MapEncodeTest(void);
/*
Encodes a goodly number of floats and doubles and checks encoding is right
*/
-int FloatValuesTest1();
+int FloatValuesTest1(void);
/*
Encodes true, false and the like
*/
-int SimpleValuesTest1();
+int SimpleValuesTest1(void);
/*
Encodes most data formats that are supported */
-int EncodeDateTest();
+int EncodeDateTest(void);
/*
Encodes particular data structure that a particular app will need...
*/
-int RTICResultsTest();
+int RTICResultsTest(void);
/*
Calls all public encode methods in qcbor.h once.
*/
-int AllAddMethodsTest();
+int AllAddMethodsTest(void);
/*
The binary string wrapping of maps and arrays used by COSE
*/
-int BStrWrapTests();
+int BStrWrapTests(void);
diff --git a/test/run_tests.c b/test/run_tests.c
index 2f22062..c86baa5 100644
--- a/test/run_tests.c
+++ b/test/run_tests.c
@@ -38,6 +38,8 @@
#include "bstrwrap_tests.h"
#include "mempool_test.h"
#include "qcbor_decode_tests.h"
+#include "qcbor_encode_tests.h"
+#include "UsefulBuf_Tests.h"
// Used to test the test runner
int fail_test()
@@ -87,6 +89,8 @@
typedef int (test_fun_t)(void);
+typedef const char * (test_fun2_t)(void);
+
#define TEST_ENTRY(test_name) {#test_name, test_name}
typedef struct {
@@ -94,7 +98,32 @@
test_fun_t *test_fun;
} test_entry;
+typedef struct {
+ const char *szTestName;
+ test_fun2_t *test_fun;
+} test_entry2;
+
+test_entry2 s_tests2[] = {
+ TEST_ENTRY(UBCopyUtilTest),
+ TEST_ENTRY(NonAdversarialUOBTest),
+ TEST_ENTRY(TestBasicSanity),
+ TEST_ENTRY(BoundaryConditionsTest),
+ TEST_ENTRY(UBMacroConversionsTest),
+ TEST_ENTRY(UBUtilTests),
+ TEST_ENTRY(UBIntegerFormatTests)
+};
+
+
test_entry s_tests[] = {
+ TEST_ENTRY(RTICResultsTest),
+ TEST_ENTRY(MapEncodeTest),
+ TEST_ENTRY(ArrayNestingTest1),
+ TEST_ENTRY(ArrayNestingTest2),
+ TEST_ENTRY(ArrayNestingTest3),
+ TEST_ENTRY(EncodeDateTest),
+ TEST_ENTRY(SimpleValuesTest1),
+ TEST_ENTRY(IntegerValuesTest1),
+ TEST_ENTRY(AllAddMethodsTest),
TEST_ENTRY(ParseTooDeepArrayTest),
TEST_ENTRY(ComprehensiveInputTest),
TEST_ENTRY(ParseMapTest),
@@ -130,6 +159,31 @@
int nTestsFailed = 0;
int nTestsRun = 0;
UsefulBuf_MakeStackUB(StringStorage, 5);
+
+ test_entry2 *t2;
+ const test_entry2 *s_tests2_end = s_tests2 + sizeof(s_tests2)/sizeof(test_entry2);
+
+ for(t2 = s_tests2; t2 < s_tests2_end; t2++) {
+ const char * x = (t2->test_fun)();
+ nTestsRun++;
+ if(output) {
+ (*output)(t2->szTestName, poutCtx);
+ }
+
+ if(x) {
+ if(output) {
+ (*output)(" FAILED (returned ", poutCtx);
+ (*output)(x, poutCtx);
+ (*output)(")\n", poutCtx);
+ }
+ nTestsFailed++;
+ } else {
+ if(output) {
+ (*output)( " PASSED\n", poutCtx);
+ }
+ }
+ }
+
test_entry *t;
const test_entry *s_tests_end = s_tests + sizeof(s_tests)/sizeof(test_entry);