commit c228a215550155e487653dd75f41f391ef0fbaf2
parent 23147205c7b477873aaf34e17744361e2f0ee61c
Author: Remy Noulin <loader2x@gmail.com>
Date: Sun, 26 Jun 2022 15:22:24 +0200
add quote and escape functions to escape control characters in strings and jsons (escapeG), all returned values in libsheepy.c and libsheepySmall.c are checked in the tests
release/json/libsheepyCSmallArray.h | 6 +-
release/json/libsheepyCSmallDict.h | 3 +
release/json/libsheepyCSmallJson.h | 3 +
release/json/libsheepyCSmallString.h | 3 +
release/libsheepy.c | 917 +++++-
release/libsheepy.h | 20 +-
release/libsheepyObject.h | 3 +
release/libsheepySmall.c | 210 ++
release/libsheepySmall.h | 6 +
src/json/libsheepyCSmallArray.c | 10 +
src/json/libsheepyCSmallArray.h | 6 +-
src/json/libsheepyCSmallDict.c | 10 +
src/json/libsheepyCSmallDict.h | 3 +
src/json/libsheepyCSmallJson.c | 28 +
src/json/libsheepyCSmallJson.h | 3 +
src/json/libsheepyCSmallString.c | 10 +
src/json/libsheepyCSmallString.h | 3 +
src/libsheepy.c | 917 +++++-
src/libsheepy.h | 20 +-
src/libsheepyCuTest.c | 5906 ++++++++++++++++++++++-----------
src/libsheepyObject.h | 3 +
src/libsheepySmall.c | 210 ++
src/libsheepySmall.h | 6 +
src/libsheepySmallCuTest.c | 7 +-
src/libsheepySmallTest.c | 7 +-
src/libsheepyTest.c | 5920 +++++++++++++++++++++++-----------
26 files changed, 10619 insertions(+), 3621 deletions(-)
Diffstat:
26 files changed, 10619 insertions(+), 3621 deletions(-)
diff --git a/release/json/libsheepyCSmallArray.h b/release/json/libsheepyCSmallArray.h
@@ -42,6 +42,7 @@ typedef void (*terminateSmallArrayFt) (smallArrayt **self);
typedef char* (*toStringSmallArrayFt) (smallArrayt *self);
typedef smallArrayt* (*duplicateSmallArrayFt) (smallArrayt *self);
+typedef char* (*escapeSmallArrayFt) (smallArrayt *self);
/**
* free index but not the elements
@@ -82,12 +83,12 @@ typedef const char* (*helpSmallArrayFt) (smallArrayt *self);
* resetG(array); // free iteraror element
*
*/
-typedef void (*resetSmallArrayFt) (smallArrayt *self);
+typedef void (*resetSmallArrayFt) (smallArrayt *self);
/**
* get the sobject, data in the container
*/
-typedef sArrayt* (*getsoSmallArrayFt) (smallArrayt *self);
+typedef sArrayt* (*getsoSmallArrayFt) (smallArrayt *self);
/**
* set the sobject, data in the container
@@ -1415,6 +1416,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
* setSizeRingFt setSize
*/
#define SMALLARRAYFUNCTIONST \
+ escapeSmallArrayFt escape;\
disposeSmallArrayFt dispose;\
helpSmallArrayFt help;\
resetSmallArrayFt reset;\
diff --git a/release/json/libsheepyCSmallDict.h b/release/json/libsheepyCSmallDict.h
@@ -45,6 +45,8 @@ typedef smallDictt* (*duplicateSmallDictFt) (smallDictt *self);
// smallDict functions
+typedef char* (*escapeSmallDictFt) (smallDictt *self);
+
/**
* free index but not the elements
* self becomes empty.
@@ -743,6 +745,7 @@ typedef bool (*areAllEBytesSmallDictFt) (smallDictt *self);
* setSizeRingFt setSize
*/
#define SMALLDICTFUNCTIONST \
+ escapeSmallDictFt escape;\
disposeSmallDictFt dispose;\
helpSmallDictFt help;\
resetSmallDictFt reset;\
diff --git a/release/json/libsheepyCSmallJson.h b/release/json/libsheepyCSmallJson.h
@@ -64,6 +64,8 @@ typedef void (*terminateSmallJsonFt) (smallJsont **self);
typedef char* (*toStringSmallJsonFt) (smallJsont *self);
typedef smallJsont* (*duplicateSmallJsonFt) (smallJsont *self);
+typedef char* (*escapeSmallJsonFt) (smallJsont *self);
+
/**
* free index but not the elements
* self becomes empty.
@@ -2613,6 +2615,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
*/
#define SMALLJSONFUNCTIONST \
helpSmallJsonFt help;\
+ escapeSmallJsonFt escape;\
disposeSmallJsonFt dispose;\
resetSmallJsonFt reset;\
getsoSmallJsonFt getso;\
diff --git a/release/json/libsheepyCSmallString.h b/release/json/libsheepyCSmallString.h
@@ -42,6 +42,8 @@ typedef char* (*toStringSmallStringFt) (smallStringt *self);
typedef smallStringt* (*duplicateSmallStringFt) (smallStringt *self);
// smallString functions
+typedef char* (*escapeSmallStringFt) (smallStringt *self);
+
/**
* free self but not the smallString buffer
*
@@ -1005,6 +1007,7 @@ typedef int (*appendFileSmallStringSmallStringFt)(smallStringt *self, smallStrin
*/
#define SMALLSTRINGFUNCTIONST \
helpSmallStringFt help;\
+ escapeSmallStringFt escape;\
getSmallStringFt get;\
setSmallStringFt set;\
setBoolSmallStringFt setBool;\
diff --git a/release/libsheepy.c b/release/libsheepy.c
@@ -343,6 +343,19 @@ char *bStripCtrlS(char *string);
char *stripColorsS(const char *string);
char *iStripColorsS(char **string);
char *bStripColorsS(char *string);
+char* quoteS(const char *s, char delim);
+char* bQuoteS(char *dest, const char *s, char delim);
+char* bLQuoteS(char *dest, size_t destSize, const char *s, char delim);
+size_t quoteLenS(const char *s, char delim);
+char* escapeS(const char *s, char delim);
+char* bEscapeS(char *dest, const char *s, char delim);
+char* bLEscapeS(char *dest, size_t destSize, const char *s, char delim);
+size_t escapeLenS(const char *s, char delim);
+char nibbleToHex(u8 n);
+char* cEscapeS(const char *S);
+char* bCEscapeS(char *dest, const char *S);
+char* bLCEscapeS(char *dest, size_t destSize, const char *S);
+size_t cEscapeLenS(const char *s);
bool isNumber(const char *string);
bool isInt(const char *string);
int64_t parseInt(const char *string);
@@ -9674,7 +9687,7 @@ char *iStripColorsS(char **string) {
i++;
}
- (*string)[j] = 0;;
+ (*string)[j] = 0;
return(*string);
}
@@ -9752,10 +9765,910 @@ char *bStripColorsS(char *string) {
i++;
}
- string[j] = 0;;
+ string[j] = 0;
return(string);
}
+
+/**
+ * add backslash '\' before delim('\'' or '"') and backslash
+ * the backslashes in the result avoid splitting the string
+ * when it is in a source file or a json string
+ * \param
+ * s string to escape
+ * \param
+ * delim string delimiter ' or "
+ * \return
+ * new string with escape backslash (free this buffer)
+ * null when s is null
+ */
+char* quoteS(const char *s, char delim) {
+ char *r = NULL;
+
+ // steps
+ // sanity check
+ // compute result string length to allocate the buffer once
+ // copy s and add the bashslashes
+ // terminate the result string
+
+ // sanity check
+ if (!s) {
+ return(null);
+ }
+ char delims[3] = {delim, '\\', 0/*terminate accept string for strpbrk*/};
+
+ // compute result string length to allocate the buffer once
+ size_t count = 0;
+ const char *tmp = s;
+ tmp = strpbrk(tmp, delims);
+ while (tmp) {
+ inc count;
+ inc tmp;
+ tmp = strpbrk(tmp, delims);
+ }
+
+ if (!count) {
+ return(strdup(s));
+ }
+
+ r = malloc(strlen(s) + 1 + count);
+ if (not r) {
+ return(null);
+ }
+
+ // copy s and add the bashslashes
+ size_t i = 0;
+ while (*s) {
+ if (*s == delims[0] or *s == delims[1]) {
+ r[i++] = '\\';
+ }
+ r[i++] = *s;
+ inc s;
+ }
+
+ // terminate the result string
+ r[i] = 0;
+ return(r);
+}
+
+
+/**
+ * add backslash '\' before delim('\'' or '"') and backslash
+ * the backslashes in the result avoid splitting the string
+ * when it is in a source file or a json string
+ * \param
+ * dest destination buffer, it should be big enough
+ * \param
+ * s string to escape
+ * \param
+ * delim string delimiter ' or "
+ * \return
+ * new string with escape backslash (free this buffer)
+ * null when s is null
+ */
+char* bQuoteS(char *dest, const char *s, char delim) {
+
+ // steps
+ // sanity check
+ // copy s and add the bashslashes
+ // terminate the result string
+
+ // sanity check
+ if (!s or !dest) {
+ return(null);
+ }
+ char delims[3] = {delim, '\\', 0/*terminate accept string for strpbrk*/};
+
+ // copy s and add the bashslashes
+ size_t i = 0;
+ while (*s) {
+ if (*s == delims[0] or *s == delims[1]) {
+ dest[i++] = '\\';
+ }
+ dest[i++] = *s;
+ inc s;
+ }
+
+ // terminate the result string
+ dest[i] = 0;
+ return(dest);
+}
+
+
+/**
+ * add backslash '\' before delim('\'' or '"') and backslash
+ * the backslashes in the result avoid splitting the string
+ * when it is in a source file or a json string
+ * \param
+ * dest destination buffer
+ * \param
+ * destSize destination buffer size
+ * \param
+ * s string to escape
+ * \param
+ * delim string delimiter ' or "
+ * \return
+ * new string with escape backslash (free this buffer)
+ * null when s is null
+ */
+char* bLQuoteS(char *dest, size_t destSize, const char *s, char delim) {
+
+ // steps
+ // sanity check
+ // copy s and add the bashslashes
+ // terminate the result string
+
+ // sanity check
+ if (!s or !dest or !destSize) {
+ return(null);
+ }
+ char delims[3] = {delim, '\\', 0/*terminate accept string for strpbrk*/};
+
+ // copy s and add the bashslashes
+ size_t i = 0;
+ while (*s) {
+ bool isBackslash = no;
+ if (*s == delims[0] or *s == delims[1]) {
+ dest[i++] = '\\';
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ break;
+ }
+ isBackslash = yes;
+ }
+ dest[i++] = *s;
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ // remove backslash
+ if (isBackslash) {
+ dec i;
+ }
+ break;
+ }
+ inc s;
+ }
+
+ // terminate the result string
+ dest[i] = 0;
+ return(dest);
+}
+
+
+/**
+ * return the length of the escaped string (without the terminating \0)
+ */
+size_t quoteLenS(const char *s, char delim) {
+ size_t r = 0;;
+
+ if (!s) {
+ return(0);
+ }
+ char delims[3] = {delim, '\\', 0/*terminate accept string for strpbrk*/};
+
+ // compute result string length to allocate the buffer once
+ const char *tmp = s;
+ tmp = strpbrk(tmp, delims);
+ while (tmp) {
+ inc r;
+ inc tmp;
+ tmp = strpbrk(tmp, delims);
+ }
+
+ r += strlen(s);
+ return(r);
+}
+
+
+/**
+ * escape string according the json specification (RFC 8259)
+ * if there is \uNNNN in the string, the backslash is escaped and it will
+ * be parsed as the string '\uNNNN' be the json parsers
+ * the unicode characters should be converted to UTF8 codepoints instead of
+ * using \uNNNN
+ * the result can be included in a json string and the parsing
+ * will be correct
+ * \param
+ * s string to escape
+ * \param
+ * delim string delimiter ' or "
+ * \return
+ * new string with escape backslash (free this buffer)
+ * null when s is null
+ */
+char* escapeS(const char *s, char delim) {
+ char *r = NULL;
+
+ // steps
+ // sanity check
+ // compute result string length to allocate the buffer once
+ // copy s and add the bashslashes
+ // terminate the result string
+
+ // sanity check
+ if (!s) {
+ return(null);
+ }
+ char delims[] = {delim, '\\', '\b', '\f', '\n', '\r', '\t', 0/*terminate accept string for strpbrk*/};
+
+ // compute result string length to allocate the buffer once
+ size_t count = 0;
+ const char *tmp = s;
+ tmp = strpbrk(tmp, delims);
+ while (tmp) {
+ inc count;
+ inc tmp;
+ tmp = strpbrk(tmp, delims);
+ }
+
+ if (!count) {
+ return(strdup(s));
+ }
+ r = malloc(strlen(s) + 1 + count);
+ if (not r) {
+ return(null);
+ }
+
+ // copy s and add the bashslashes
+ size_t i = 0;
+ while (*s) {
+ arange(j, delims) {
+ if (*s == delims[j]) {
+ r[i++] = '\\';
+ break;
+ }
+ }
+ switch (*s) {
+ case '\b':
+ r[i++] = 'b';
+ break;
+ case '\f':
+ r[i++] = 'f';
+ break;
+ case '\n':
+ r[i++] = 'n';
+ break;
+ case '\r':
+ r[i++] = 'r';
+ break;
+ case '\t':
+ r[i++] = 't';
+ break;
+ default:
+ r[i++] = *s;
+ break;
+ }
+ inc s;
+ }
+
+ // terminate the result string
+ r[i] = 0;
+ return(r);
+}
+
+
+/**
+ * escape string according the json specification (RFC 8259)
+ * if there is \uNNNN in the string, the backslash is escaped and it will
+ * be parsed as the string '\uNNNN' be the json parsers
+ * the unicode characters should be converted to UTF8 codepoints instead of
+ * using \uNNNN
+ * the result can be included in a json string and the parsing
+ * will be correct
+ * \param
+ * dest destination buffer
+ * \param
+ * s string to escape
+ * \param
+ * delim string delimiter ' or "
+ * \return
+ * new string with escape backslash (free this buffer)
+ * null when s is null
+ */
+char* bEscapeS(char *dest, const char *s, char delim) {
+
+ // steps
+ // sanity check
+ // copy s and add the bashslashes
+ // terminate the result string
+
+ // sanity check
+ if (!s or !dest) {
+ return(null);
+ }
+ char delims[] = {delim, '\\', '\b', '\f', '\n', '\r', '\t', 0/*terminate accept string for strpbrk*/};
+
+ // copy s and add the bashslashes
+ size_t i = 0;
+ while (*s) {
+ arange(j, delims) {
+ if (*s == delims[j]) {
+ dest[i++] = '\\';
+ break;
+ }
+ }
+ switch(*s) {
+ case '\b':
+ dest[i++] = 'b';
+ break;
+ case '\f':
+ dest[i++] = 'f';
+ break;
+ case '\n':
+ dest[i++] = 'n';
+ break;
+ case '\r':
+ dest[i++] = 'r';
+ break;
+ case '\t':
+ dest[i++] = 't';
+ break;
+ default:
+ dest[i++] = *s;
+ break;
+ }
+ inc s;
+ }
+
+ // terminate the result string
+ dest[i] = 0;
+ return(dest);
+}
+
+
+/**
+ * escape string according the json specification (RFC 8259)
+ * if there is \uNNNN in the string, the backslash is escaped and it will
+ * be parsed as the string '\uNNNN' be the json parsers
+ * the unicode characters should be converted to UTF8 codepoints instead of
+ * using \uNNNN
+ * the result can be included in a json string and the parsing
+ * will be correct
+ * \param
+ * dest destination buffer
+ * \param
+ * destSize destination buffer size
+ * \param
+ * s string to escape
+ * \param
+ * delim string delimiter ' or "
+ * \return
+ * new string with escape backslash (free this buffer)
+ * null when s is null
+ */
+char* bLEscapeS(char *dest, size_t destSize, const char *s, char delim) {
+
+ // steps
+ // sanity check
+ // copy s and add the bashslashes
+ // terminate the result string
+
+ // sanity check
+ if (!s or !dest or !destSize) {
+ return(null);
+ }
+ char delims[] = {delim, '\\', '\b', '\f', '\n', '\r', '\t', 0/*terminate accept string for strpbrk*/};
+
+ // copy s and add the bashslashes
+ size_t i = 0;
+ while (*s) {
+ bool isBackslash = no;
+ arange(j, delims) {
+ if (*s == delims[j]) {
+ dest[i++] = '\\';
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ goto end;
+ }
+ isBackslash = yes;
+ break;
+ }
+ }
+ switch(*s) {
+ case '\b':
+ dest[i++] = 'b';
+ break;
+ case '\f':
+ dest[i++] = 'f';
+ break;
+ case '\n':
+ dest[i++] = 'n';
+ break;
+ case '\r':
+ dest[i++] = 'r';
+ break;
+ case '\t':
+ dest[i++] = 't';
+ break;
+ default:
+ dest[i++] = *s;
+ break;
+ }
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ // remove backslash
+ if (isBackslash) {
+ dec i;
+ }
+ break;
+ }
+ inc s;
+ }
+
+ // terminate the result string
+ end:
+ dest[i] = 0;
+ return(dest);
+}
+
+
+/**
+ * return the length of the escaped string (without the terminating \0)
+ */
+size_t escapeLenS(const char *s, char delim) {
+ size_t r = 0;;
+
+ if (!s) {
+ return(0);
+ }
+ char delims[] = {delim, '\\', '\b', '\f', '\n', '\r', '\t', 0/*terminate accept string for strpbrk*/};
+
+ // compute result string length to allocate the buffer once
+ const char *tmp = s;
+ tmp = strpbrk(tmp, delims);
+ while (tmp) {
+ inc r;
+ inc tmp;
+ tmp = strpbrk(tmp, delims);
+ }
+
+ r += strlen(s);
+ return(r);
+}
+
+
+/**
+ * convert number between 0 and 15 to hexadecimal character '0' to 'F'
+ */
+char nibbleToHex(u8 n) {
+
+ if (n > 15) {
+ return 'X';
+ }
+ elif (n < 10) {
+ return((char)(n + '0'));
+ }
+ else {
+ return((char)((n-10) + 'A'));
+}
+ }
+
+
+/**
+ * escape string to become a valid C source string
+ * control characters, backslash and double quotes are escaped.
+ * control characters without an escaped representation (\a) are represented as
+ * hexidecimal literal '\xNN'
+ * the result can be included in C source code and the parsing will be
+ * correct
+ * \param
+ * S string to escape
+ * \return
+ * new escaped string (free this buffer)
+ * null when S is null
+ */
+char* cEscapeS(const char *S) {
+ char *r = NULL;
+
+ // u8 because nibbles are needed for control characters without an escaped representation
+ const u8 *s = (const u8*)S;
+
+ // steps
+ // sanity check
+ // compute result string length to allocate the buffer once
+ // search control characters without an escaped representation
+ // copy s and add the bashslashes
+ // terminate the result string
+
+ // sanity check
+ if (!s) {
+ return(null);
+ }
+ char delims[] = {'"', '\\', '\a', '\b', '\t', '\n', '\v', '\f', '\r', 0/*terminate accept string for strpbrk*/};
+
+ // compute result string length to allocate the buffer once
+ size_t count = 0;
+ const char *tmp = S;
+ tmp = strpbrk(tmp, delims);
+ while (tmp) {
+ inc count;
+ inc tmp;
+ tmp = strpbrk(tmp, delims);
+ }
+
+ // search control characters without an escaped representation
+ tmp = S;
+ while (*tmp) {
+ if (*tmp > 0x1F) {
+ goto cont;
+ }
+ bool found = no;
+ arange(j, delims) {
+ if (*tmp == delims[j]) {
+ found = yes;
+ break;
+ }
+ }
+ if (not found) {
+ // allocate space for ""\xNN""
+ // it is 8 bytes but one byte is counted with strlen(s)
+ count += 7;
+ }
+ cont:
+ inc tmp;
+ }
+
+ if (!count) {
+ return(strdup(S));
+ }
+ r = malloc(strlen(S) + 1 + count);
+ if (not r) {
+ return(null);
+ }
+
+ // copy s and add the bashslashes
+ size_t i = 0;
+ while (*s) {
+ arange(j, delims) {
+ if (*s == delims[j]) {
+ r[i++] = '\\';
+ break;
+ }
+ }
+ switch(*s) {
+ case '\a':
+ r[i++] = 'a';
+ break;
+ case '\b':
+ r[i++] = 'b';
+ break;
+ case '\t':
+ r[i++] = 't';
+ break;
+ case '\n':
+ r[i++] = 'n';
+ break;
+ case '\v':
+ r[i++] = 'v';
+ break;
+ case '\f':
+ r[i++] = 'f';
+ break;
+ case '\r':
+ r[i++] = 'r';
+ break;
+ default:
+ if (*s > 0x1F) {
+ r[i++] = (char)*s;
+ }
+ else {
+ // byte 0x3 becomes ""\x03""
+ r[i++] = '"';
+ r[i++] = '"';
+ r[i++] = '\\';
+ r[i++] = 'x';
+ r[i++] = nibbleToHex(*s >> 4);
+ r[i++] = nibbleToHex(*s & 0xF);
+ r[i++] = '"';
+ r[i++] = '"';
+ }
+ break;
+ }
+ inc s;
+ }
+
+ // terminate the result string
+ r[i] = 0;
+ return(r);
+}
+
+
+/**
+ * escape string to become a valid C source string
+ * control characters, backslash and double quotes are escaped.
+ * control characters without an escaped representation (\a) are represented as
+ * hexidecimal literal '\xNN'
+ * the result can be included in C source code and the parsing will be
+ * correct
+ * \param
+ * dest destination buffer
+ * \param
+ * S string to escape
+ * \return
+ * new escaped string (free this buffer)
+ * null when S is null
+ */
+char* bCEscapeS(char *dest, const char *S) {
+
+ // u8 because nibbles are needed for control characters without an escaped representation
+ const u8 *s = (const u8*)S;
+
+ // steps
+ // sanity check
+ // copy s and add the bashslashes
+ // terminate the result string
+
+ // sanity check
+ if (!s or !dest) {
+ return(null);
+ }
+ char delims[] = {'"', '\\', '\a', '\b', '\t', '\n', '\v', '\f', '\r', 0/*terminate accept string for strpbrk*/};
+
+ // copy s and add the bashslashes
+ size_t i = 0;
+ while (*s) {
+ arange(j, delims) {
+ if (*s == delims[j]) {
+ dest[i++] = '\\';
+ break;
+ }
+ }
+ switch(*s) {
+ case '\a':
+ dest[i++] = 'a';
+ break;
+ case '\b':
+ dest[i++] = 'b';
+ break;
+ case '\t':
+ dest[i++] = 't';
+ break;
+ case '\n':
+ dest[i++] = 'n';
+ break;
+ case '\v':
+ dest[i++] = 'v';
+ break;
+ case '\f':
+ dest[i++] = 'f';
+ break;
+ case '\r':
+ dest[i++] = 'r';
+ break;
+ default:
+ if (*s > 0x1F) {
+ dest[i++] = (char)*s;
+ }
+ else {
+ // byte 0x3 becomes ""\x03""
+ dest[i++] = '"';
+ dest[i++] = '"';
+ dest[i++] = '\\';
+ dest[i++] = 'x';
+ dest[i++] = nibbleToHex(*s >> 4);
+ dest[i++] = nibbleToHex(*s & 0xF);
+ dest[i++] = '"';
+ dest[i++] = '"';
+ }
+ break;
+ }
+ inc s;
+ }
+
+ // terminate the result string
+ dest[i] = 0;
+ return(dest);
+}
+
+
+/**
+ * escape string to become a valid C source string
+ * control characters, backslash and double quotes are escaped.
+ * control characters without an escaped representation (\a) are represented as
+ * hexidecimal literal '\xNN'
+ * the result can be included in C source code and the parsing will be
+ * correct
+ * \param
+ * dest destination buffer
+ * \param
+ * destSize destination buffer size
+ * \param
+ * S string to escape
+ * \return
+ * new escaped string (free this buffer)
+ * null when S is null
+ */
+char* bLCEscapeS(char *dest, size_t destSize, const char *S) {
+
+ // u8 because nibbles are needed for control characters without an escaped representation
+ const u8 *s = (const u8*)S;
+
+ // steps
+ // sanity check
+ // copy s and add the bashslashes
+ // terminate the result string
+
+ // sanity check
+ if (!s or !dest or !destSize) {
+ return(null);
+ }
+ char delims[] = {'"', '\\', '\a', '\b', '\t', '\n', '\v', '\f', '\r', 0/*terminate accept string for strpbrk*/};
+
+ // copy s and add the bashslashes
+ size_t i = 0;
+ while (*s) {
+ arange(j, delims) {
+ if (*s == delims[j]) {
+ dest[i++] = '\\';
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ goto end;
+ }
+ break;
+ }
+ }
+ switch(*s) {
+ case '\a':
+ dest[i++] = 'a';
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ // remove backslash
+ dest[i-1] = 0;
+ goto end;
+ }
+ break;
+ case '\b':
+ dest[i++] = 'b';
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ // remove backslash
+ dest[i-1] = 0;
+ goto end;
+ }
+ break;
+ case '\t':
+ dest[i++] = 't';
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ // remove backslash
+ dest[i-1] = 0;
+ goto end;
+ }
+ break;
+ case '\n':
+ dest[i++] = 'n';
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ // remove backslash
+ dest[i-1] = 0;
+ goto end;
+ }
+ break;
+ case '\v':
+ dest[i++] = 'v';
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ // remove backslash
+ dest[i-1] = 0;
+ goto end;
+ }
+ break;
+ case '\f':
+ dest[i++] = 'f';
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ // remove backslash
+ dest[i-1] = 0;
+ goto end;
+ }
+ break;
+ case '\r':
+ dest[i++] = 'r';
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ // remove backslash
+ dest[i-1] = 0;
+ goto end;
+ }
+ break;
+ default:
+ if (*s > 0x1F) {
+ dest[i++] = (char)*s;
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ if (*s == '"' || *s == '\\') {
+ // remove backslash
+ dest[i-1] = 0;
+ }
+ goto end;
+ }
+ }
+ else {
+ // check if there is enough space
+ if (i+8 >= destSize) {
+ goto end;
+ }
+ // byte 0x3 becomes ""\x03""
+ dest[i++] = '"';
+ dest[i++] = '"';
+ dest[i++] = '\\';
+ dest[i++] = 'x';
+ dest[i++] = nibbleToHex(*s >> 4);
+ dest[i++] = nibbleToHex(*s & 0xF);
+ dest[i++] = '"';
+ dest[i++] = '"';
+ }
+ break;
+ }
+ inc s;
+ }
+
+ // terminate the result string
+ end:
+ dest[i] = 0;
+ return(dest);
+}
+
+
+/**
+ * return the length of the escaped string (without the terminating \0)
+ */
+size_t cEscapeLenS(const char *s) {
+ size_t r = 0;;
+
+ if (!s) {
+ return(0);
+ }
+ char delims[] = {'"', '\\', '\a', '\b', '\t', '\n', '\v', '\f', '\r', 0/*terminate accept string for strpbrk*/};
+
+ // compute result string length to allocate the buffer once
+ const char *tmp = s;
+ tmp = strpbrk(tmp, delims);
+ while (tmp) {
+ inc r;
+ inc tmp;
+ tmp = strpbrk(tmp, delims);
+ }
+
+ // search control characters without an escaped representation
+ tmp = s;
+ while (*tmp) {
+ if (*tmp > 0x1F) {
+ goto cont;
+ }
+ bool found = no;
+ arange(j, delims) {
+ if (*tmp == delims[j]) {
+ found = yes;
+ break;
+ }
+ }
+ if (not found) {
+ // allocate space for ""\xNN""
+ // it is 8 bytes but one byte is counted with strlen(s)
+ r += 7;
+ }
+ cont:
+ inc tmp;
+ }
+
+ r += strlen(s);
+ return(r);
+}
+
+
/**
* is Number (integer or float) String
*
diff --git a/release/libsheepy.h b/release/libsheepy.h
@@ -98,7 +98,7 @@
// version accoring to the version package: Release.Major.minor.patch
// https://noulin.net/version/file/README.md.html
-#define LIBSHEEPY_VERSION "2.2.9.1"
+#define LIBSHEEPY_VERSION "2.2.10"
#ifndef SH_PREFIX
#define SH_PREFIX(NAME) NAME
@@ -2054,6 +2054,24 @@ char *stripColorsS(const char *string) MUST_CHECK;
char *iStripColorsS(char **string) MUST_CHECK;
char *bStripColorsS(char *string) MUST_CHECK;
+// escape quotes and backslashes in string
+char* quoteS(const char *s, char delim) MUST_CHECK;
+char* bQuoteS(char *dest, const char *s, char delim) MUST_CHECK;
+char* bLQuoteS(char *dest, size_t destSize, const char *s, char delim) MUST_CHECK;
+size_t quoteLenS(const char *s, char delim) MUST_CHECK;
+// escape string to become a parsable json string
+char* escapeS(const char *s, char delim /*string delimiter ' or "*/) MUST_CHECK;
+char* bEscapeS(char *dest, const char *s, char delim /*string delimiter ' or "*/) MUST_CHECK;
+char* bLEscapeS(char *dest, size_t destSize, const char *s, char delim /*string delimiter ' or "*/) MUST_CHECK;
+size_t escapeLenS(const char *s, char delim /*string delimiter ' or "*/) MUST_CHECK;
+// convert nibble to hexadecimal digit character
+char nibbleToHex(u8 n) MUST_CHECK;
+// escape string to become compilable in a C source code
+char* cEscapeS(const char *S) MUST_CHECK;
+char* bCEscapeS(char *dest, const char *S) MUST_CHECK;
+char* bLCEscapeS(char *dest, size_t destSize, const char *S) MUST_CHECK;
+size_t cEscapeLenS(const char *s) MUST_CHECK;
+
// true when string is a number (integer or float)
bool isNumber(const char *string) MUST_CHECK;
diff --git a/release/libsheepyObject.h b/release/libsheepyObject.h
@@ -7491,6 +7491,9 @@ void finishManyOF(void *paramType, ...);
// generated with utils/oGMacros
+#define escapeO(self) (self)->f->escape(self)
+#define escapeG escapeO
+
#define disposeO(self) (self)->f->dispose(self)
#define disposeG disposeO
diff --git a/release/libsheepySmall.c b/release/libsheepySmall.c
@@ -64,6 +64,11 @@ char* sStringToStringTiny(sStringt* obj);
char* sArrayToStringTiny(sArrayt* obj);
char* sUndefinedToStringTiny(sUndefinedt* obj UNUSED);
char* sBytesToStringTiny(sBytest* obj);
+char* sEscapeTiny(smallt *obj);
+char* sEscape(smallt *obj);
+char* sDictEscapeTiny(sDictt* obj);
+char* sStringEscapeTiny(sStringt* obj);
+char* sArrayEscapeTiny(sArrayt* obj);
char* sTypesTiny(smallt* obj);
sBytest* sTypesToBytesTiny(smallt *obj);
const char** sDictTypeStrings(sDictt* obj);
@@ -882,6 +887,211 @@ char* sBytesToStringTiny(sBytest* obj) {
}
/**
+ * stringify a small object
+ *
+ * Escape characters to produce a parsable json
+ *
+ * the returned string has to be freed
+ *
+ * \param
+ * obj object
+ * \return
+ * string representing the object
+ */
+char* sEscapeTiny(smallt *obj) {
+ char *r = NULL;
+
+ switch(obj->type) {
+ case UNDEFINED:
+ r = sUndefinedToStringTiny((sUndefinedt *)obj);
+ break;
+ case BOOL:
+ r = sBoolToStringTiny((sBoolt *)obj);
+ break;
+ case CONTAINER:
+ r = sContainerToStringTiny((sContainert *)obj);
+ break;
+ case DICT:
+ r = sDictEscapeTiny((sDictt *)obj);
+ break;
+ case DOUBLE:
+ r = sDoubleToStringTiny((sDoublet *)obj);
+ break;
+ case INT:
+ r = sIntToStringTiny((sIntt *)obj);
+ break;
+ case STRING:
+ r = sStringEscapeTiny((sStringt *)obj);
+ break;
+ case ARRAY:
+ r = sArrayEscapeTiny((sArrayt* )obj);
+ break;
+ case BYTES:
+ r = sBytesToStringTiny((sBytest* )obj);
+ break;
+ default:
+ logME(libsheepyErrorMask, "Unsupported object type.");
+ }
+ return(r);
+}
+
+/**
+ * stringify object
+ *
+ * the returned string has to be freed
+ *
+ * \param
+ * obj object
+ * \return
+ * string representing the object
+ * NULL when obj is NULL
+ */
+char* sEscape(smallt *obj) {
+
+ if (obj) {
+ return(sEscapeTiny(obj));
+ }
+ return(NULL);
+}
+
+/**
+ * stringify dictionary
+ *
+ * the returned string has to be freed
+ *
+ * \param
+ * obj object
+ * \return
+ * string representing the object
+ */
+char* sDictEscapeTiny(sDictt* obj) {
+ char *s = NULL;
+
+ if (!obj->count) {
+ return(strdup("{}"));
+ }
+
+ char *r = strdup("{");
+
+ bool hasAtLeastOneElement = no;
+
+ forEachSDict(obj, e) {
+ if (e->key) {
+ hasAtLeastOneElement = yes;
+ pErrorNULL(iAppendS(&r, "\""));
+ pErrorNULL(iAppendNFreeS(&r, escapeS(e->key, '\"')));
+ pErrorNULL(iAppendS(&r, "\""));
+ if (isSType(e->data, STRING)) {
+ // add quotes for strings
+ pErrorNULL(iAppendS(&r, ":\""));
+ s = sEscapeTiny(e->data);
+ pErrorNULL(iAppendS(&r, s));
+ free(s);
+ pErrorNULL(iAppendS(&r, "\","));
+ }
+ else if (isSType(e->data, CONTAINER)) {
+ // add quotes for strings
+ pErrorNULL(iAppendS(&r, ":\""));
+ s = sToStringTiny(e->data);
+ pErrorNULL(iAppendS(&r, s));
+ free(s);
+ pErrorNULL(iAppendS(&r, "\","));
+ }
+ else {
+ pErrorNULL(iAppendS(&r, ":"));
+ s = sToStringTiny(e->data);
+ pErrorNULL(iAppendS(&r, s));
+ free(s);
+ pErrorNULL(iAppendS(&r, ","));
+ }
+ }
+ }
+
+ if (hasAtLeastOneElement) {
+ pErrorNULL(setS(r, -1, '}'));
+ }
+ else {
+ pErrorNULL(iAppendS(&r, "}"));
+ }
+ return(r);
+}
+
+/**
+ * stringify string
+ *
+ * the returned string has to be freed
+ *
+ * \param
+ * obj object
+ * \return
+ * string representing the object
+ */
+char* sStringEscapeTiny(sStringt* obj) {
+
+ return(escapeS(sStringGetTiny(obj), '\"'));
+}
+
+/**
+ * stringify array
+ *
+ * the returned string has to be freed
+ *
+ * \param
+ * obj object
+ * \return
+ * string representing the object
+ */
+char* sArrayEscapeTiny(sArrayt* obj) {
+ char *s = NULL;
+
+ if (!obj->count) {
+ return(strdup("[]"));
+ }
+
+ char *r = strdup("[");
+ uint32_t cnt = 0;;
+ bool emptySlot = false;;
+ forEachSArray(obj, o) {
+ if (!o) {
+ // empty slot
+ emptySlot = true;;
+ continue;
+ }
+ emptySlot = false;;
+ cnt++;
+ if (isSType(o, STRING)) {
+ // add quotes for strings
+ pErrorNULL(iAppendS(&r, "\""));
+ s = sEscapeTiny(o);
+ pErrorNULL(iAppendS(&r, s));
+ free(s);
+ pErrorNULL(iAppendS(&r, "\""));
+ }
+ else if (isSType(o, CONTAINER)) {
+ // add quotes for strings
+ pErrorNULL(iAppendS(&r, "\""));
+ s = sToStringTiny(o);
+ pErrorNULL(iAppendS(&r, s));
+ free(s);
+ pErrorNULL(iAppendS(&r, "\""));
+ }
+ else {
+ s = sToStringTiny(o);
+ pErrorNULL(iAppendS(&r, s));
+ free(s);
+ }
+ pErrorNULL(iAppendS(&r, ","));
+ }
+ if (!cnt && emptySlot) {
+ pErrorNULL(iAppendS(&r, "]"));
+ }
+ else {
+ pErrorNULL(setS(r, -1, ']'));
+ }
+ return(r);
+}
+
+/**
* get list of object types string
*
* only the types in the first level are listed
diff --git a/release/libsheepySmall.h b/release/libsheepySmall.h
@@ -241,6 +241,12 @@ char* sArrayToStringTiny(sArrayt* obj) MUST_CHECK;
char* sUndefinedToStringTiny(sUndefinedt* obj) MUST_CHECK;
char* sBytesToStringTiny(sBytest* obj) MUST_CHECK;
+char* sEscapeTiny(smallt *obj) MUST_CHECK;
+char* sEscape(smallt *obj) MUST_CHECK;
+char* sDictEscapeTiny(sDictt* obj) MUST_CHECK;
+char* sStringEscapeTiny(sStringt* obj) MUST_CHECK;
+char* sArrayEscapeTiny(sArrayt* obj) MUST_CHECK;
+
char* sTypesTiny(smallt* obj) MUST_CHECK;
sBytest* sTypesToBytesTiny(smallt *obj) MUST_CHECK;
const char** sDictTypeStrings(sDictt* obj) MUST_CHECK;
diff --git a/src/json/libsheepyCSmallArray.c b/src/json/libsheepyCSmallArray.c
@@ -53,6 +53,7 @@ internal void freeSmallArray(smallArrayt *self);
internal void terminateSmallArray(smallArrayt **self);
internal char* toStringSmallArray(smallArrayt *self);
internal smallArrayt* duplicateSmallArray(smallArrayt *self);
+internal char* escapeSmallArray(smallArrayt *self);
internal void disposeSmallArray(smallArrayt *self);
internal void smashSmallArray(smallArrayt **self);
#if (NFreeStackCheck)
@@ -953,6 +954,7 @@ void registerMethodsSmallArray(smallArrayFunctionst *f) {
f->toString = toStringSmallArray;
f->duplicate = duplicateSmallArray;
+ f->escape = escapeSmallArray;
f->dispose = disposeSmallArray;
f->reset = resetSmallArray;
f->smash = smashSmallArray;
@@ -1566,6 +1568,14 @@ internal smallArrayt* duplicateSmallArray(smallArrayt *self) {
return(dup);
}
+internal char* escapeSmallArray(smallArrayt *self) {
+
+ if (!self->a) {
+ return(strdup("[]"));
+ }
+ return(sEscape((smallt *)self->a));
+}
+
internal void disposeSmallArray(smallArrayt *self) {
if (self->a) {
diff --git a/src/json/libsheepyCSmallArray.h b/src/json/libsheepyCSmallArray.h
@@ -42,6 +42,7 @@ typedef void (*terminateSmallArrayFt) (smallArrayt **self);
typedef char* (*toStringSmallArrayFt) (smallArrayt *self);
typedef smallArrayt* (*duplicateSmallArrayFt) (smallArrayt *self);
+typedef char* (*escapeSmallArrayFt) (smallArrayt *self);
/**
* free index but not the elements
@@ -82,12 +83,12 @@ typedef const char* (*helpSmallArrayFt) (smallArrayt *self);
* resetG(array); // free iteraror element
*
*/
-typedef void (*resetSmallArrayFt) (smallArrayt *self);
+typedef void (*resetSmallArrayFt) (smallArrayt *self);
/**
* get the sobject, data in the container
*/
-typedef sArrayt* (*getsoSmallArrayFt) (smallArrayt *self);
+typedef sArrayt* (*getsoSmallArrayFt) (smallArrayt *self);
/**
* set the sobject, data in the container
@@ -1415,6 +1416,7 @@ typedef bool (*areAllEBytesSmallArrayFt) (smallArrayt *self);
* setSizeRingFt setSize
*/
#define SMALLARRAYFUNCTIONST \
+ escapeSmallArrayFt escape;\
disposeSmallArrayFt dispose;\
helpSmallArrayFt help;\
resetSmallArrayFt reset;\
diff --git a/src/json/libsheepyCSmallDict.c b/src/json/libsheepyCSmallDict.c
@@ -49,6 +49,7 @@ internal void freeSmallDict(smallDictt *self);
internal void terminateSmallDict(smallDictt **self);
internal char* toStringSmallDict(smallDictt *self);
internal smallDictt* duplicateSmallDict(smallDictt *self);
+internal char* escapeSmallDict(smallDictt *self);
internal void disposeSmallDict(smallDictt *self);
internal void smashSmallDict(smallDictt **self);
#if (NFreeStackCheck)
@@ -657,6 +658,7 @@ void registerMethodsSmallDict(smallDictFunctionst *f) {
f->toString = toStringSmallDict;
f->duplicate = duplicateSmallDict;
+ f->escape = escapeSmallDict;
f->dispose = disposeSmallDict;
f->reset = resetSmallDict;
f->smash = smashSmallDict;
@@ -1093,6 +1095,14 @@ internal smallDictt* duplicateSmallDict(smallDictt *self) {
return(dup);
}
+internal char* escapeSmallDict(smallDictt *self) {
+
+ if (!self->d) {
+ return(strdup("{}"));
+ }
+ return(sEscapeTiny((smallt *)self->d));
+}
+
internal void disposeSmallDict(smallDictt *self) {
if (self->d) {
diff --git a/src/json/libsheepyCSmallDict.h b/src/json/libsheepyCSmallDict.h
@@ -45,6 +45,8 @@ typedef smallDictt* (*duplicateSmallDictFt) (smallDictt *self);
// smallDict functions
+typedef char* (*escapeSmallDictFt) (smallDictt *self);
+
/**
* free index but not the elements
* self becomes empty.
@@ -743,6 +745,7 @@ typedef bool (*areAllEBytesSmallDictFt) (smallDictt *self);
* setSizeRingFt setSize
*/
#define SMALLDICTFUNCTIONST \
+ escapeSmallDictFt escape;\
disposeSmallDictFt dispose;\
helpSmallDictFt help;\
resetSmallDictFt reset;\
diff --git a/src/json/libsheepyCSmallJson.c b/src/json/libsheepyCSmallJson.c
@@ -56,6 +56,7 @@ internal void freeSmallJson(smallJsont *self);
internal void terminateSmallJson(smallJsont **self);
internal char* toStringSmallJson(smallJsont *self);
internal smallJsont* duplicateSmallJson(smallJsont *self);
+internal char* escapeSmallJson(smallJsont *self);
internal void disposeSmallJson(smallJsont *self);
internal void smashSmallJson(smallJsont **self);
#if (NFreeStackCheck)
@@ -1736,6 +1737,7 @@ void registerMethodsSmallJson(smallJsonFunctionst *f) {
f->toString = toStringSmallJson;
f->duplicate = duplicateSmallJson;
+ f->escape = escapeSmallJson;
f->dispose = disposeSmallJson;
f->reset = resetSmallJson;
f->smash = smashSmallJson;
@@ -2816,6 +2818,32 @@ internal smallJsont* duplicateSmallJson(smallJsont *self) {
return(dup);
}
+internal char* escapeSmallJson(smallJsont *self) {
+
+ switch(self->topIsA) {
+ case SMALLJSON_IS_EMPTY:
+ return(strdup("{}"));
+ case TOP_IS_UNDEFINED:
+ return(sToString((smallt *)self->topU));
+ case TOP_IS_BOOL:
+ return(sToString((smallt *)self->topB));
+ case TOP_IS_DOUBLE:
+ return(sToString((smallt *)self->topD));
+ case TOP_IS_INT:
+ return(sToString((smallt *)self->topI));
+ case TOP_IS_STRING:
+ return(sEscape((smallt *)self->topS));
+ case TOP_IS_DICT:
+ return(sEscape((smallt *)self->top));
+ case TOP_IS_ARRAY:
+ return(sEscape((smallt *)self->topA));
+ default:;
+ logC("Unsupported type in smallJson object!");
+ }
+ // return never taken, avoid warning
+ return(NULL);
+}
+
internal void disposeSmallJson(smallJsont *self) {
switch(self->topIsA) {
diff --git a/src/json/libsheepyCSmallJson.h b/src/json/libsheepyCSmallJson.h
@@ -64,6 +64,8 @@ typedef void (*terminateSmallJsonFt) (smallJsont **self);
typedef char* (*toStringSmallJsonFt) (smallJsont *self);
typedef smallJsont* (*duplicateSmallJsonFt) (smallJsont *self);
+typedef char* (*escapeSmallJsonFt) (smallJsont *self);
+
/**
* free index but not the elements
* self becomes empty.
@@ -2613,6 +2615,7 @@ typedef bool (*areAllEBytesSmallJsonFt) (smallJsont *self);
*/
#define SMALLJSONFUNCTIONST \
helpSmallJsonFt help;\
+ escapeSmallJsonFt escape;\
disposeSmallJsonFt dispose;\
resetSmallJsonFt reset;\
getsoSmallJsonFt getso;\
diff --git a/src/json/libsheepyCSmallString.c b/src/json/libsheepyCSmallString.c
@@ -56,6 +56,7 @@ internal void finishSmallString(smallStringt **self);
internal void finishSmallString(smallStringt **self);
#endif
internal const char* helpSmallString(smallStringt UNUSED *self);
+internal char* escapeSmallString(smallStringt *self);
internal char* getSmallString(smallStringt *self);
internal smallStringt* setSmallString(smallStringt *self, const char *string);
internal smallStringt* setCharSmallString(smallStringt *self, char c);
@@ -546,6 +547,7 @@ void registerMethodsSmallString(smallStringFunctionst *f) {
f->smash = smashSmallString;
f->finish = finishSmallString;
f->help = helpSmallString;
+ f->escape = escapeSmallString;
f->get = getSmallString;
f->set = setSmallString;
f->setChar = setCharSmallString;
@@ -961,6 +963,14 @@ internal const char* helpSmallString(smallStringt UNUSED *self) {
return(helpTextSmallString);
}
+internal char* escapeSmallString(smallStringt *self) {
+
+ if (!self->data) {
+ return(NULL);
+ }
+ return(sStringEscapeTiny(self->data));
+}
+
internal char* getSmallString(smallStringt *self) {
if (!self->data) {
diff --git a/src/json/libsheepyCSmallString.h b/src/json/libsheepyCSmallString.h
@@ -42,6 +42,8 @@ typedef char* (*toStringSmallStringFt) (smallStringt *self);
typedef smallStringt* (*duplicateSmallStringFt) (smallStringt *self);
// smallString functions
+typedef char* (*escapeSmallStringFt) (smallStringt *self);
+
/**
* free self but not the smallString buffer
*
@@ -1005,6 +1007,7 @@ typedef int (*appendFileSmallStringSmallStringFt)(smallStringt *self, smallStrin
*/
#define SMALLSTRINGFUNCTIONST \
helpSmallStringFt help;\
+ escapeSmallStringFt escape;\
getSmallStringFt get;\
setSmallStringFt set;\
setBoolSmallStringFt setBool;\
diff --git a/src/libsheepy.c b/src/libsheepy.c
@@ -345,6 +345,19 @@ char *bStripCtrlS(char *string);
char *stripColorsS(const char *string);
char *iStripColorsS(char **string);
char *bStripColorsS(char *string);
+char* quoteS(const char *s, char delim);
+char* bQuoteS(char *dest, const char *s, char delim);
+char* bLQuoteS(char *dest, size_t destSize, const char *s, char delim);
+size_t quoteLenS(const char *s, char delim);
+char* escapeS(const char *s, char delim);
+char* bEscapeS(char *dest, const char *s, char delim);
+char* bLEscapeS(char *dest, size_t destSize, const char *s, char delim);
+size_t escapeLenS(const char *s, char delim);
+char nibbleToHex(u8 n);
+char* cEscapeS(const char *S);
+char* bCEscapeS(char *dest, const char *S);
+char* bLCEscapeS(char *dest, size_t destSize, const char *S);
+size_t cEscapeLenS(const char *s);
bool isNumber(const char *string);
bool isInt(const char *string);
int64_t parseInt(const char *string);
@@ -9730,7 +9743,7 @@ char *iStripColorsS(char **string) {
i++;
}
- (*string)[j] = 0;;
+ (*string)[j] = 0;
return(*string);
}
@@ -9808,10 +9821,910 @@ char *bStripColorsS(char *string) {
i++;
}
- string[j] = 0;;
+ string[j] = 0;
return(string);
}
+
+/**
+ * add backslash '\' before delim('\'' or '"') and backslash
+ * the backslashes in the result avoid splitting the string
+ * when it is in a source file or a json string
+ * \param
+ * s string to escape
+ * \param
+ * delim string delimiter ' or "
+ * \return
+ * new string with escape backslash (free this buffer)
+ * null when s is null
+ */
+char* quoteS(const char *s, char delim) {
+ char *r = NULL;
+
+ // steps
+ // sanity check
+ // compute result string length to allocate the buffer once
+ // copy s and add the bashslashes
+ // terminate the result string
+
+ // sanity check
+ if (!s) {
+ return(null);
+ }
+ char delims[3] = {delim, '\\', 0/*terminate accept string for strpbrk*/};
+
+ // compute result string length to allocate the buffer once
+ size_t count = 0;
+ const char *tmp = s;
+ tmp = strpbrk(tmp, delims);
+ while (tmp) {
+ inc count;
+ inc tmp;
+ tmp = strpbrk(tmp, delims);
+ }
+
+ if (!count) {
+ return(strdup(s));
+ }
+
+ r = malloc(strlen(s) + 1 + count);
+ if (not r) {
+ return(null);
+ }
+
+ // copy s and add the bashslashes
+ size_t i = 0;
+ while (*s) {
+ if (*s == delims[0] or *s == delims[1]) {
+ r[i++] = '\\';
+ }
+ r[i++] = *s;
+ inc s;
+ }
+
+ // terminate the result string
+ r[i] = 0;
+ return(r);
+}
+
+
+/**
+ * add backslash '\' before delim('\'' or '"') and backslash
+ * the backslashes in the result avoid splitting the string
+ * when it is in a source file or a json string
+ * \param
+ * dest destination buffer, it should be big enough
+ * \param
+ * s string to escape
+ * \param
+ * delim string delimiter ' or "
+ * \return
+ * new string with escape backslash (free this buffer)
+ * null when s is null
+ */
+char* bQuoteS(char *dest, const char *s, char delim) {
+
+ // steps
+ // sanity check
+ // copy s and add the bashslashes
+ // terminate the result string
+
+ // sanity check
+ if (!s or !dest) {
+ return(null);
+ }
+ char delims[3] = {delim, '\\', 0/*terminate accept string for strpbrk*/};
+
+ // copy s and add the bashslashes
+ size_t i = 0;
+ while (*s) {
+ if (*s == delims[0] or *s == delims[1]) {
+ dest[i++] = '\\';
+ }
+ dest[i++] = *s;
+ inc s;
+ }
+
+ // terminate the result string
+ dest[i] = 0;
+ return(dest);
+}
+
+
+/**
+ * add backslash '\' before delim('\'' or '"') and backslash
+ * the backslashes in the result avoid splitting the string
+ * when it is in a source file or a json string
+ * \param
+ * dest destination buffer
+ * \param
+ * destSize destination buffer size
+ * \param
+ * s string to escape
+ * \param
+ * delim string delimiter ' or "
+ * \return
+ * new string with escape backslash (free this buffer)
+ * null when s is null
+ */
+char* bLQuoteS(char *dest, size_t destSize, const char *s, char delim) {
+
+ // steps
+ // sanity check
+ // copy s and add the bashslashes
+ // terminate the result string
+
+ // sanity check
+ if (!s or !dest or !destSize) {
+ return(null);
+ }
+ char delims[3] = {delim, '\\', 0/*terminate accept string for strpbrk*/};
+
+ // copy s and add the bashslashes
+ size_t i = 0;
+ while (*s) {
+ bool isBackslash = no;
+ if (*s == delims[0] or *s == delims[1]) {
+ dest[i++] = '\\';
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ break;
+ }
+ isBackslash = yes;
+ }
+ dest[i++] = *s;
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ // remove backslash
+ if (isBackslash) {
+ dec i;
+ }
+ break;
+ }
+ inc s;
+ }
+
+ // terminate the result string
+ dest[i] = 0;
+ return(dest);
+}
+
+
+/**
+ * return the length of the escaped string (without the terminating \0)
+ */
+size_t quoteLenS(const char *s, char delim) {
+ size_t r = 0;;
+
+ if (!s) {
+ return(0);
+ }
+ char delims[3] = {delim, '\\', 0/*terminate accept string for strpbrk*/};
+
+ // compute result string length to allocate the buffer once
+ const char *tmp = s;
+ tmp = strpbrk(tmp, delims);
+ while (tmp) {
+ inc r;
+ inc tmp;
+ tmp = strpbrk(tmp, delims);
+ }
+
+ r += strlen(s);
+ return(r);
+}
+
+
+/**
+ * escape string according the json specification (RFC 8259)
+ * if there is \uNNNN in the string, the backslash is escaped and it will
+ * be parsed as the string '\uNNNN' be the json parsers
+ * the unicode characters should be converted to UTF8 codepoints instead of
+ * using \uNNNN
+ * the result can be included in a json string and the parsing
+ * will be correct
+ * \param
+ * s string to escape
+ * \param
+ * delim string delimiter ' or "
+ * \return
+ * new string with escape backslash (free this buffer)
+ * null when s is null
+ */
+char* escapeS(const char *s, char delim) {
+ char *r = NULL;
+
+ // steps
+ // sanity check
+ // compute result string length to allocate the buffer once
+ // copy s and add the bashslashes
+ // terminate the result string
+
+ // sanity check
+ if (!s) {
+ return(null);
+ }
+ char delims[] = {delim, '\\', '\b', '\f', '\n', '\r', '\t', 0/*terminate accept string for strpbrk*/};
+
+ // compute result string length to allocate the buffer once
+ size_t count = 0;
+ const char *tmp = s;
+ tmp = strpbrk(tmp, delims);
+ while (tmp) {
+ inc count;
+ inc tmp;
+ tmp = strpbrk(tmp, delims);
+ }
+
+ if (!count) {
+ return(strdup(s));
+ }
+ r = malloc(strlen(s) + 1 + count);
+ if (not r) {
+ return(null);
+ }
+
+ // copy s and add the bashslashes
+ size_t i = 0;
+ while (*s) {
+ arange(j, delims) {
+ if (*s == delims[j]) {
+ r[i++] = '\\';
+ break;
+ }
+ }
+ switch (*s) {
+ case '\b':
+ r[i++] = 'b';
+ break;
+ case '\f':
+ r[i++] = 'f';
+ break;
+ case '\n':
+ r[i++] = 'n';
+ break;
+ case '\r':
+ r[i++] = 'r';
+ break;
+ case '\t':
+ r[i++] = 't';
+ break;
+ default:
+ r[i++] = *s;
+ break;
+ }
+ inc s;
+ }
+
+ // terminate the result string
+ r[i] = 0;
+ return(r);
+}
+
+
+/**
+ * escape string according the json specification (RFC 8259)
+ * if there is \uNNNN in the string, the backslash is escaped and it will
+ * be parsed as the string '\uNNNN' be the json parsers
+ * the unicode characters should be converted to UTF8 codepoints instead of
+ * using \uNNNN
+ * the result can be included in a json string and the parsing
+ * will be correct
+ * \param
+ * dest destination buffer
+ * \param
+ * s string to escape
+ * \param
+ * delim string delimiter ' or "
+ * \return
+ * new string with escape backslash (free this buffer)
+ * null when s is null
+ */
+char* bEscapeS(char *dest, const char *s, char delim) {
+
+ // steps
+ // sanity check
+ // copy s and add the bashslashes
+ // terminate the result string
+
+ // sanity check
+ if (!s or !dest) {
+ return(null);
+ }
+ char delims[] = {delim, '\\', '\b', '\f', '\n', '\r', '\t', 0/*terminate accept string for strpbrk*/};
+
+ // copy s and add the bashslashes
+ size_t i = 0;
+ while (*s) {
+ arange(j, delims) {
+ if (*s == delims[j]) {
+ dest[i++] = '\\';
+ break;
+ }
+ }
+ switch(*s) {
+ case '\b':
+ dest[i++] = 'b';
+ break;
+ case '\f':
+ dest[i++] = 'f';
+ break;
+ case '\n':
+ dest[i++] = 'n';
+ break;
+ case '\r':
+ dest[i++] = 'r';
+ break;
+ case '\t':
+ dest[i++] = 't';
+ break;
+ default:
+ dest[i++] = *s;
+ break;
+ }
+ inc s;
+ }
+
+ // terminate the result string
+ dest[i] = 0;
+ return(dest);
+}
+
+
+/**
+ * escape string according the json specification (RFC 8259)
+ * if there is \uNNNN in the string, the backslash is escaped and it will
+ * be parsed as the string '\uNNNN' be the json parsers
+ * the unicode characters should be converted to UTF8 codepoints instead of
+ * using \uNNNN
+ * the result can be included in a json string and the parsing
+ * will be correct
+ * \param
+ * dest destination buffer
+ * \param
+ * destSize destination buffer size
+ * \param
+ * s string to escape
+ * \param
+ * delim string delimiter ' or "
+ * \return
+ * new string with escape backslash (free this buffer)
+ * null when s is null
+ */
+char* bLEscapeS(char *dest, size_t destSize, const char *s, char delim) {
+
+ // steps
+ // sanity check
+ // copy s and add the bashslashes
+ // terminate the result string
+
+ // sanity check
+ if (!s or !dest or !destSize) {
+ return(null);
+ }
+ char delims[] = {delim, '\\', '\b', '\f', '\n', '\r', '\t', 0/*terminate accept string for strpbrk*/};
+
+ // copy s and add the bashslashes
+ size_t i = 0;
+ while (*s) {
+ bool isBackslash = no;
+ arange(j, delims) {
+ if (*s == delims[j]) {
+ dest[i++] = '\\';
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ goto end;
+ }
+ isBackslash = yes;
+ break;
+ }
+ }
+ switch(*s) {
+ case '\b':
+ dest[i++] = 'b';
+ break;
+ case '\f':
+ dest[i++] = 'f';
+ break;
+ case '\n':
+ dest[i++] = 'n';
+ break;
+ case '\r':
+ dest[i++] = 'r';
+ break;
+ case '\t':
+ dest[i++] = 't';
+ break;
+ default:
+ dest[i++] = *s;
+ break;
+ }
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ // remove backslash
+ if (isBackslash) {
+ dec i;
+ }
+ break;
+ }
+ inc s;
+ }
+
+ // terminate the result string
+ end:
+ dest[i] = 0;
+ return(dest);
+}
+
+
+/**
+ * return the length of the escaped string (without the terminating \0)
+ */
+size_t escapeLenS(const char *s, char delim) {
+ size_t r = 0;;
+
+ if (!s) {
+ return(0);
+ }
+ char delims[] = {delim, '\\', '\b', '\f', '\n', '\r', '\t', 0/*terminate accept string for strpbrk*/};
+
+ // compute result string length to allocate the buffer once
+ const char *tmp = s;
+ tmp = strpbrk(tmp, delims);
+ while (tmp) {
+ inc r;
+ inc tmp;
+ tmp = strpbrk(tmp, delims);
+ }
+
+ r += strlen(s);
+ return(r);
+}
+
+
+/**
+ * convert number between 0 and 15 to hexadecimal character '0' to 'F'
+ */
+char nibbleToHex(u8 n) {
+
+ if (n > 15) {
+ return 'X';
+ }
+ elif (n < 10) {
+ return((char)(n + '0'));
+ }
+ else {
+ return((char)((n-10) + 'A'));
+}
+ }
+
+
+/**
+ * escape string to become a valid C source string
+ * control characters, backslash and double quotes are escaped.
+ * control characters without an escaped representation (\a) are represented as
+ * hexidecimal literal '\xNN'
+ * the result can be included in C source code and the parsing will be
+ * correct
+ * \param
+ * S string to escape
+ * \return
+ * new escaped string (free this buffer)
+ * null when S is null
+ */
+char* cEscapeS(const char *S) {
+ char *r = NULL;
+
+ // u8 because nibbles are needed for control characters without an escaped representation
+ const u8 *s = (const u8*)S;
+
+ // steps
+ // sanity check
+ // compute result string length to allocate the buffer once
+ // search control characters without an escaped representation
+ // copy s and add the bashslashes
+ // terminate the result string
+
+ // sanity check
+ if (!s) {
+ return(null);
+ }
+ char delims[] = {'"', '\\', '\a', '\b', '\t', '\n', '\v', '\f', '\r', 0/*terminate accept string for strpbrk*/};
+
+ // compute result string length to allocate the buffer once
+ size_t count = 0;
+ const char *tmp = S;
+ tmp = strpbrk(tmp, delims);
+ while (tmp) {
+ inc count;
+ inc tmp;
+ tmp = strpbrk(tmp, delims);
+ }
+
+ // search control characters without an escaped representation
+ tmp = S;
+ while (*tmp) {
+ if (*tmp > 0x1F) {
+ goto cont;
+ }
+ bool found = no;
+ arange(j, delims) {
+ if (*tmp == delims[j]) {
+ found = yes;
+ break;
+ }
+ }
+ if (not found) {
+ // allocate space for ""\xNN""
+ // it is 8 bytes but one byte is counted with strlen(s)
+ count += 7;
+ }
+ cont:
+ inc tmp;
+ }
+
+ if (!count) {
+ return(strdup(S));
+ }
+ r = malloc(strlen(S) + 1 + count);
+ if (not r) {
+ return(null);
+ }
+
+ // copy s and add the bashslashes
+ size_t i = 0;
+ while (*s) {
+ arange(j, delims) {
+ if (*s == delims[j]) {
+ r[i++] = '\\';
+ break;
+ }
+ }
+ switch(*s) {
+ case '\a':
+ r[i++] = 'a';
+ break;
+ case '\b':
+ r[i++] = 'b';
+ break;
+ case '\t':
+ r[i++] = 't';
+ break;
+ case '\n':
+ r[i++] = 'n';
+ break;
+ case '\v':
+ r[i++] = 'v';
+ break;
+ case '\f':
+ r[i++] = 'f';
+ break;
+ case '\r':
+ r[i++] = 'r';
+ break;
+ default:
+ if (*s > 0x1F) {
+ r[i++] = (char)*s;
+ }
+ else {
+ // byte 0x3 becomes ""\x03""
+ r[i++] = '"';
+ r[i++] = '"';
+ r[i++] = '\\';
+ r[i++] = 'x';
+ r[i++] = nibbleToHex(*s >> 4);
+ r[i++] = nibbleToHex(*s & 0xF);
+ r[i++] = '"';
+ r[i++] = '"';
+ }
+ break;
+ }
+ inc s;
+ }
+
+ // terminate the result string
+ r[i] = 0;
+ return(r);
+}
+
+
+/**
+ * escape string to become a valid C source string
+ * control characters, backslash and double quotes are escaped.
+ * control characters without an escaped representation (\a) are represented as
+ * hexidecimal literal '\xNN'
+ * the result can be included in C source code and the parsing will be
+ * correct
+ * \param
+ * dest destination buffer
+ * \param
+ * S string to escape
+ * \return
+ * new escaped string (free this buffer)
+ * null when S is null
+ */
+char* bCEscapeS(char *dest, const char *S) {
+
+ // u8 because nibbles are needed for control characters without an escaped representation
+ const u8 *s = (const u8*)S;
+
+ // steps
+ // sanity check
+ // copy s and add the bashslashes
+ // terminate the result string
+
+ // sanity check
+ if (!s or !dest) {
+ return(null);
+ }
+ char delims[] = {'"', '\\', '\a', '\b', '\t', '\n', '\v', '\f', '\r', 0/*terminate accept string for strpbrk*/};
+
+ // copy s and add the bashslashes
+ size_t i = 0;
+ while (*s) {
+ arange(j, delims) {
+ if (*s == delims[j]) {
+ dest[i++] = '\\';
+ break;
+ }
+ }
+ switch(*s) {
+ case '\a':
+ dest[i++] = 'a';
+ break;
+ case '\b':
+ dest[i++] = 'b';
+ break;
+ case '\t':
+ dest[i++] = 't';
+ break;
+ case '\n':
+ dest[i++] = 'n';
+ break;
+ case '\v':
+ dest[i++] = 'v';
+ break;
+ case '\f':
+ dest[i++] = 'f';
+ break;
+ case '\r':
+ dest[i++] = 'r';
+ break;
+ default:
+ if (*s > 0x1F) {
+ dest[i++] = (char)*s;
+ }
+ else {
+ // byte 0x3 becomes ""\x03""
+ dest[i++] = '"';
+ dest[i++] = '"';
+ dest[i++] = '\\';
+ dest[i++] = 'x';
+ dest[i++] = nibbleToHex(*s >> 4);
+ dest[i++] = nibbleToHex(*s & 0xF);
+ dest[i++] = '"';
+ dest[i++] = '"';
+ }
+ break;
+ }
+ inc s;
+ }
+
+ // terminate the result string
+ dest[i] = 0;
+ return(dest);
+}
+
+
+/**
+ * escape string to become a valid C source string
+ * control characters, backslash and double quotes are escaped.
+ * control characters without an escaped representation (\a) are represented as
+ * hexidecimal literal '\xNN'
+ * the result can be included in C source code and the parsing will be
+ * correct
+ * \param
+ * dest destination buffer
+ * \param
+ * destSize destination buffer size
+ * \param
+ * S string to escape
+ * \return
+ * new escaped string (free this buffer)
+ * null when S is null
+ */
+char* bLCEscapeS(char *dest, size_t destSize, const char *S) {
+
+ // u8 because nibbles are needed for control characters without an escaped representation
+ const u8 *s = (const u8*)S;
+
+ // steps
+ // sanity check
+ // copy s and add the bashslashes
+ // terminate the result string
+
+ // sanity check
+ if (!s or !dest or !destSize) {
+ return(null);
+ }
+ char delims[] = {'"', '\\', '\a', '\b', '\t', '\n', '\v', '\f', '\r', 0/*terminate accept string for strpbrk*/};
+
+ // copy s and add the bashslashes
+ size_t i = 0;
+ while (*s) {
+ arange(j, delims) {
+ if (*s == delims[j]) {
+ dest[i++] = '\\';
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ goto end;
+ }
+ break;
+ }
+ }
+ switch(*s) {
+ case '\a':
+ dest[i++] = 'a';
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ // remove backslash
+ dest[i-1] = 0;
+ goto end;
+ }
+ break;
+ case '\b':
+ dest[i++] = 'b';
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ // remove backslash
+ dest[i-1] = 0;
+ goto end;
+ }
+ break;
+ case '\t':
+ dest[i++] = 't';
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ // remove backslash
+ dest[i-1] = 0;
+ goto end;
+ }
+ break;
+ case '\n':
+ dest[i++] = 'n';
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ // remove backslash
+ dest[i-1] = 0;
+ goto end;
+ }
+ break;
+ case '\v':
+ dest[i++] = 'v';
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ // remove backslash
+ dest[i-1] = 0;
+ goto end;
+ }
+ break;
+ case '\f':
+ dest[i++] = 'f';
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ // remove backslash
+ dest[i-1] = 0;
+ goto end;
+ }
+ break;
+ case '\r':
+ dest[i++] = 'r';
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ // remove backslash
+ dest[i-1] = 0;
+ goto end;
+ }
+ break;
+ default:
+ if (*s > 0x1F) {
+ dest[i++] = (char)*s;
+ if (i >= destSize) {
+ // end of dest buffer is reached
+ dec i;
+ if (*s == '"' || *s == '\\') {
+ // remove backslash
+ dest[i-1] = 0;
+ }
+ goto end;
+ }
+ }
+ else {
+ // check if there is enough space
+ if (i+8 >= destSize) {
+ goto end;
+ }
+ // byte 0x3 becomes ""\x03""
+ dest[i++] = '"';
+ dest[i++] = '"';
+ dest[i++] = '\\';
+ dest[i++] = 'x';
+ dest[i++] = nibbleToHex(*s >> 4);
+ dest[i++] = nibbleToHex(*s & 0xF);
+ dest[i++] = '"';
+ dest[i++] = '"';
+ }
+ break;
+ }
+ inc s;
+ }
+
+ // terminate the result string
+ end:
+ dest[i] = 0;
+ return(dest);
+}
+
+
+/**
+ * return the length of the escaped string (without the terminating \0)
+ */
+size_t cEscapeLenS(const char *s) {
+ size_t r = 0;;
+
+ if (!s) {
+ return(0);
+ }
+ char delims[] = {'"', '\\', '\a', '\b', '\t', '\n', '\v', '\f', '\r', 0/*terminate accept string for strpbrk*/};
+
+ // compute result string length to allocate the buffer once
+ const char *tmp = s;
+ tmp = strpbrk(tmp, delims);
+ while (tmp) {
+ inc r;
+ inc tmp;
+ tmp = strpbrk(tmp, delims);
+ }
+
+ // search control characters without an escaped representation
+ tmp = s;
+ while (*tmp) {
+ if (*tmp > 0x1F) {
+ goto cont;
+ }
+ bool found = no;
+ arange(j, delims) {
+ if (*tmp == delims[j]) {
+ found = yes;
+ break;
+ }
+ }
+ if (not found) {
+ // allocate space for ""\xNN""
+ // it is 8 bytes but one byte is counted with strlen(s)
+ r += 7;
+ }
+ cont:
+ inc tmp;
+ }
+
+ r += strlen(s);
+ return(r);
+}
+
+
/**
* is Number (integer or float) String
*
diff --git a/src/libsheepy.h b/src/libsheepy.h
@@ -98,7 +98,7 @@
// version accoring to the version package: Release.Major.minor.patch
// https://noulin.net/version/file/README.md.html
-#define LIBSHEEPY_VERSION "2.2.9.1"
+#define LIBSHEEPY_VERSION "2.2.10"
#ifndef SH_PREFIX
#define SH_PREFIX(NAME) NAME
@@ -2054,6 +2054,24 @@ char *stripColorsS(const char *string) MUST_CHECK;
char *iStripColorsS(char **string) MUST_CHECK;
char *bStripColorsS(char *string) MUST_CHECK;
+// escape quotes and backslashes in string
+char* quoteS(const char *s, char delim) MUST_CHECK;
+char* bQuoteS(char *dest, const char *s, char delim) MUST_CHECK;
+char* bLQuoteS(char *dest, size_t destSize, const char *s, char delim) MUST_CHECK;
+size_t quoteLenS(const char *s, char delim) MUST_CHECK;
+// escape string to become a parsable json string
+char* escapeS(const char *s, char delim /*string delimiter ' or "*/) MUST_CHECK;
+char* bEscapeS(char *dest, const char *s, char delim /*string delimiter ' or "*/) MUST_CHECK;
+char* bLEscapeS(char *dest, size_t destSize, const char *s, char delim /*string delimiter ' or "*/) MUST_CHECK;
+size_t escapeLenS(const char *s, char delim /*string delimiter ' or "*/) MUST_CHECK;
+// convert nibble to hexadecimal digit character
+char nibbleToHex(u8 n) MUST_CHECK;
+// escape string to become compilable in a C source code
+char* cEscapeS(const char *S) MUST_CHECK;
+char* bCEscapeS(char *dest, const char *S) MUST_CHECK;
+char* bLCEscapeS(char *dest, size_t destSize, const char *S) MUST_CHECK;
+size_t cEscapeLenS(const char *s) MUST_CHECK;
+
// true when string is a number (integer or float)
bool isNumber(const char *string) MUST_CHECK;
diff --git a/src/libsheepyCuTest.c b/src/libsheepyCuTest.c
@@ -155,13 +155,15 @@ void openProgLogFileT(CuTest *tc UNUSED) {
ck_assert(!r);
// set progname and open file
- setProgName("openProgLogFileT");
+ r = setProgName("openProgLogFileT");
+ ck_assert(r);
r = openProgLogFile();
ck_assert(r);
freeProgName();
closeLogFiles();
- rmAll("openProgLogFileT.log");
+ int R = rmAll("openProgLogFileT.log");
+ ck_assert_int_ne(R, 0);
}
@@ -225,20 +227,35 @@ void setLogFileT(CuTest *tc UNUSED) {
ck_assert_ptr_eq(f, NULL);
closeLogFiles();
- rmAll("test1.log");
- rmAll("test2.log");
- rmAll("test3.log");
- rmAll("test4.log");
- rmAll("test5.log");
- rmAll("test6.log");
- rmAll("test7.log");
- rmAll("test8.log");
- rmAll("test9.log");
- rmAll("test10.log");
- rmAll("test11.log");
- rmAll("test12.log");
- rmAll("test13.log");
- rmAll("test14.log");
+ int R;
+ R = rmAll("test1.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test2.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test3.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test4.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test5.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test6.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test7.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test8.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test9.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test10.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test11.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test12.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test13.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test14.log");
+ ck_assert_int_ne(R, 0);
// NULL
ck_assert_ptr_eq(setLogFile(NULL), NULL);
@@ -439,7 +456,8 @@ void _pLogT(CuTest *tc UNUSED) {
pLog(LOG_INFO+20, "pLog test");
closeLogFiles();
- rmAll("test.log");
+ int R = rmAll("test.log");
+ ck_assert_int_ne(R, 0);
}
@@ -849,23 +867,30 @@ void shDirnameT(CuTest *tc UNUSED) {
void bDirnameT(CuTest *tc UNUSED) {
char s[100] = "release/libsheepy.a";
+ char *r = null;
// path
- bDirname(s);
+ r = bDirname(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "release");
// one item path
- strCpy(s, "sheepy.lib");
- bDirname(s);
+ r = strCpy(s, "sheepy.lib");
+ ck_assert_ptr_eq(r, s);
+ r = bDirname(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "./");
// empty
- strCpy(s, " ");
- bDirname(s);
+ r = strCpy(s, " ");
+ ck_assert_ptr_eq(r, s);
+ r = bDirname(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "./");
// NULL
- ck_assert_ptr_eq(bDirname(NULL), NULL);
+ r = bDirname(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -873,35 +898,45 @@ void bDirnameT(CuTest *tc UNUSED) {
void bLDirnameT(CuTest *tc UNUSED) {
char s[100] = "release/libsheepy.a";
+ char *r = null;
// path
- bLDirname(s, sizeof s);
+ r = bLDirname(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "release");
// buffer shorter than path
strcpy(s, "release/anotherdir/libsheepy.a");
- bLDirname(s, 10);
+ r = bLDirname(s, 10);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "release");
strcpy(s, "release/anotherdir/libsheepy.a");
- bLDirname(s, 9);
+ r = bLDirname(s, 9);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "release/");
// one item path
- strCpy(s, "sheepy.lib");
- bLDirname(s, sizeof s);
+ r = strCpy(s, "sheepy.lib");
+ ck_assert_ptr_eq(r, s);
+ r = bLDirname(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "./");
// empty
- strCpy(s, " ");
- bLDirname(s, sizeof s);
+ r = strCpy(s, " ");
+ ck_assert_ptr_eq(r, s);
+ r = bLDirname(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "./");
// size 0 - no change in s
- bLDirname(s, 0);
+ r = bLDirname(s, 0);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "./");
// NULL
- ck_assert_ptr_eq(bLDirname(NULL, 0), NULL);
+ r = bLDirname(NULL, 0);
+ ck_assert_ptr_eq(r, null);
}
@@ -923,15 +958,20 @@ void iExpandHomeT(CuTest *tc UNUSED) {
// no ~/
char *s = strdup("sheepy");
- iExpandHome(&s);
+ char *r = null;
+
+ r = iExpandHome(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepy");
free(s);
// NULL path
s = NULL;
- iExpandHome(&s);
+ r = iExpandHome(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_ptr_eq(s, NULL);
// NULL var
- iExpandHome(NULL);
+ r = iExpandHome(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -940,10 +980,14 @@ void bExpandHomeT(CuTest *tc UNUSED) {
// no ~/
char s[100] = "sheepy";
- bExpandHome(s);
+ char *r = null;
+
+ r = bExpandHome(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepy");
// NULL
- ck_assert_ptr_eq(bExpandHome(NULL), NULL);
+ r = bExpandHome(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -952,16 +996,22 @@ void bLExpandHomeT(CuTest *tc UNUSED) {
// no ~/
char s[100] = "sheepy";
- bLExpandHome(s, sizeof s);
+ char *r = null;
+
+ r = bLExpandHome(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepy");
// shorter buffer size
- bLExpandHome(s, 3);
+ r = bLExpandHome(s, 3);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
// size 0
- bLExpandHome(s, 0);
+ r = bLExpandHome(s, 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
// NULL
- ck_assert_ptr_eq(bLExpandHome(NULL, sizeof s), NULL);
+ r = bLExpandHome(NULL, sizeof s);
+ ck_assert_ptr_eq(r, null);
}
@@ -1053,102 +1103,125 @@ void iNormalizePathT(CuTest *tc UNUSED) {
// test
char *s = strdup("test/.././file.txt");
- iNormalizePath(&s);
+ char *r = null;
+
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "file.txt");
free(s);
// remove end /
s = strdup("/home/");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/home");
free(s);
// cancel path and keep leading /
s = strdup("/home/..");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
free(s);
// cancel path
s = strdup("home/..");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
free(s);
// multiple /
s = strdup("/home///stuff");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/home/stuff");
free(s);
// remove . and .. and keep leading /
s = strdup("/a/./b/../../c/");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/c");
free(s);
// keep leading /
s = strdup("/../");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
free(s);
// keep leading ..
s = strdup(".././/");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "..");
free(s);
// remove .
s = strdup("./");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
free(s);
// keep / before .
s = strdup("/.");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
free(s);
// remove .
s = strdup(".");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
free(s);
// / not changed
s = strdup("/");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
free(s);
// // becomes /
s = strdup("//");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
free(s);
// remove leading .
s = strdup("/./werwer");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/werwer");
free(s);
// keep leading .. and remove .. in path
s = strdup(".././test/../test/file");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "../test/file");
free(s);
s = strdup("../d1/./d2/../f1");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "../d1/f1");
free(s);
s = strdup("a/b/c/../d/../e");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a/b/e");
free(s);
// dont remove .. when there are only .. in front
s = strdup("../../test/test/file");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "../../test/test/file");
free(s);
// empty path
s = strdup("");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
free(s);
// empty NULL path
s = NULL;
- ck_assert_ptr_eq(iNormalizePath(&s), NULL);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, null);
// NULL path
- ck_assert_ptr_eq(iNormalizePath(NULL), NULL);
+ r = iNormalizePath(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -1157,80 +1230,102 @@ void bNormalizePathT(CuTest *tc UNUSED) {
// test
char s[100] = "test/.././file.txt";
- bNormalizePath(s);
+ char *r = null;
+
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "file.txt");
// remove end /
strcpy(s, "/home/");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/home");
// cancel path and keep leading /
strcpy(s, "/home/..");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
// cancel path
strcpy(s, "home/..");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// multiple /
strcpy(s, "/home///stuff");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/home/stuff");
// remove . and .. and keep leading /
strcpy(s, "/a/./b/../../c/");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/c");
// keep leading /
strcpy(s, "/../");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
// keep leading ..
strcpy(s, ".././/");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "..");
// remove .
strcpy(s, "./");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// keep / before .
strcpy(s, "/.");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
// remove .
strcpy(s, ".");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// / not changed
strcpy(s, "/");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
// // becomes /
strcpy(s, "//");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
// remove leading .
strcpy(s, "/./werwer");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/werwer");
// keep leading .. and remove .. in path
strcpy(s, ".././test/../test/file");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "../test/file");
strcpy(s, "../d1/./d2/../f1");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "../d1/f1");
strcpy(s, "a/b/c/../d/../e");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a/b/e");
// dont remove .. when there are only .. in front
strcpy(s, "../../test/test/file");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "../../test/test/file");
// empty path
strcpy(s, "");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// NULL path
- ck_assert_ptr_eq(bNormalizePath(NULL), NULL);
+ r = bNormalizePath(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -1239,88 +1334,112 @@ void bLNormalizePathT(CuTest *tc UNUSED) {
// test
char s[100] = "test/.././file.txt";
- bLNormalizePath(s, sizeof s);
+ char *r = null;
+
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "file.txt");
// remove end /
strcpy(s, "/home/");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/home");
// cancel path and keep leading /
strcpy(s, "/home/..");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
// cancel path
strcpy(s, "home/..");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// multiple /
strcpy(s, "/home///stuff");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/home/stuff");
// remove . and .. and keep leading /
strcpy(s, "/a/./b/../../c/");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/c");
// keep leading /
strcpy(s, "/../");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
// keep leading ..
strcpy(s, ".././/");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "..");
// remove .
strcpy(s, "./");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// keep / before .
strcpy(s, "/.");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
// remove .
strcpy(s, ".");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// / not changed
strcpy(s, "/");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
// // becomes /
strcpy(s, "//");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
// remove leading .
strcpy(s, "/./werwer");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/werwer");
// keep leading .. and remove .. in path
strcpy(s, ".././test/../test/file");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "../test/file");
strcpy(s, "../d1/./d2/../f1");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "../d1/f1");
strcpy(s, "a/b/c/../d/../e");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a/b/e");
// dont remove .. when there are only .. in front
strcpy(s, "../../test/test/file");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "../../test/test/file");
// empty path
strcpy(s, "");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// shorter buffer than path
strcpy(s, "a/b/c/../d/../e");
- bLNormalizePath(s, 4);
+ r = bLNormalizePath(s, 4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a/b");
strcpy(s, "a/b/c/../d/../e");
// size 0 - no change in path
- bLNormalizePath(s, 0);
+ r = bLNormalizePath(s, 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a/b/c/../d/../e");
// NULL path
- ck_assert_ptr_eq(bLNormalizePath(NULL, sizeof s), NULL);
+ r = bLNormalizePath(NULL, sizeof s);
+ ck_assert_ptr_eq(r, null);
}
@@ -1332,7 +1451,8 @@ void relPathT(CuTest *tc UNUSED) {
// relative to cwd
cwd = getCwd();
- iAppendS(&cwd, "/../sheepy");
+ r = iAppendS(&cwd, "/../sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = relPath(cwd, null);
ck_assert_str_eq(r, "../sheepy");
free(r);
@@ -1341,7 +1461,8 @@ void relPathT(CuTest *tc UNUSED) {
// relative to cwd and path starts with cwd but is a different path
// (no slash between cwd and "../sheepy")
cwd = getCwd();
- iAppendS(&cwd, "../sheepy");
+ r = iAppendS(&cwd, "../sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = relPath(cwd, null);
ck_assert_str_eq(r, "../src../sheepy");
free(r);
@@ -1349,7 +1470,8 @@ void relPathT(CuTest *tc UNUSED) {
// subdirectory to cwd
cwd = getCwd();
- iAppendS(&cwd, "/sheepy");
+ r = iAppendS(&cwd, "/sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = relPath(cwd, null);
ck_assert_str_eq(r, "sheepy");
free(r);
@@ -1364,7 +1486,8 @@ void relPathT(CuTest *tc UNUSED) {
// start = root
cwd = getCwd();
- iAppendS(&cwd, "/sheepy");
+ r = iAppendS(&cwd, "/sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = relPath(cwd, "/../");
ck_assert_str_eq(r, cwd+1);
free(r);
@@ -1387,7 +1510,8 @@ void relPathT(CuTest *tc UNUSED) {
// start is relative to cwd
cwd = getCwd();
- iAppendS(&cwd, "/../sheepy");
+ r = iAppendS(&cwd, "/../sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = relPath(cwd, "test/");
ck_assert_str_eq(r, "../../sheepy");
free(r);
@@ -1417,7 +1541,8 @@ void iRelPathT(CuTest *tc UNUSED) {
// relative to cwd
cwd = getCwd();
- iAppendS(&cwd, "/../sheepy");
+ r = iAppendS(&cwd, "/../sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = iRelPath(&cwd, null);
ck_assert_str_eq(r, "../sheepy");
free(r);
@@ -1425,14 +1550,16 @@ void iRelPathT(CuTest *tc UNUSED) {
// relative to cwd and path starts with cwd but is a different path
// (no slash between cwd and "../sheepy")
cwd = getCwd();
- iAppendS(&cwd, "../sheepy");
+ r = iAppendS(&cwd, "../sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = iRelPath(&cwd, null);
ck_assert_str_eq(r, "../src../sheepy");
free(r);
// subdirectory to cwd
cwd = getCwd();
- iAppendS(&cwd, "/sheepy");
+ r = iAppendS(&cwd, "/sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = iRelPath(&cwd, null);
ck_assert_str_eq(r, "sheepy");
free(r);
@@ -1445,7 +1572,8 @@ void iRelPathT(CuTest *tc UNUSED) {
// start = root
cwd = getCwd();
- iAppendS(&cwd, "/sheepy");
+ r = iAppendS(&cwd, "/sheepy");
+ ck_assert_ptr_eq(r, cwd);
char *expected = strdup(cwd+1);
r = iRelPath(&cwd, "/../");
ck_assert_str_eq(r, expected);
@@ -1472,7 +1600,8 @@ void iRelPathT(CuTest *tc UNUSED) {
// start is relative to cwd
cwd = getCwd();
- iAppendS(&cwd, "/../sheepy");
+ r = iAppendS(&cwd, "/../sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = iRelPath(&cwd, "test/");
ck_assert_str_eq(r, "../../sheepy");
free(r);
@@ -1509,7 +1638,8 @@ void bRelPathT(CuTest *tc UNUSED) {
// relative to cwd
cwd = getCwd();
- iAppendS(&cwd, "/../sheepy");
+ r = iAppendS(&cwd, "/../sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = bRelPath(b, cwd, null);
ck_assert_str_eq(r, "../sheepy");
free(cwd);
@@ -1517,14 +1647,16 @@ void bRelPathT(CuTest *tc UNUSED) {
// relative to cwd and path starts with cwd but is a different path
// (no slash between cwd and "../sheepy")
cwd = getCwd();
- iAppendS(&cwd, "../sheepy");
+ r = iAppendS(&cwd, "../sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = bRelPath(b, cwd, null);
ck_assert_str_eq(r, "../src../sheepy");
free(cwd);
// subdirectory to cwd
cwd = getCwd();
- iAppendS(&cwd, "/sheepy");
+ r = iAppendS(&cwd, "/sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = bRelPath(b, cwd, null);
ck_assert_str_eq(r, "sheepy");
free(cwd);
@@ -1537,7 +1669,8 @@ void bRelPathT(CuTest *tc UNUSED) {
// start = root
cwd = getCwd();
- iAppendS(&cwd, "/sheepy");
+ r = iAppendS(&cwd, "/sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = bRelPath(b, cwd, "/../");
ck_assert_str_eq(r, cwd+1);
free(cwd);
@@ -1556,7 +1689,8 @@ void bRelPathT(CuTest *tc UNUSED) {
// start is relative to cwd
cwd = getCwd();
- iAppendS(&cwd, "/../sheepy");
+ r = iAppendS(&cwd, "/../sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = bRelPath(b, cwd, "test/");
ck_assert_str_eq(r, "../../sheepy");
free(cwd);
@@ -1589,7 +1723,8 @@ void bLRelPathT(CuTest *tc UNUSED) {
// relative to cwd
cwd = getCwd();
- iAppendS(&cwd, "/../sheepy");
+ r = iAppendS(&cwd, "/../sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = bLRelPath(b, sizeof(b), cwd, null);
ck_assert_str_eq(r, "../sheepy");
free(cwd);
@@ -1597,14 +1732,16 @@ void bLRelPathT(CuTest *tc UNUSED) {
// relative to cwd and path starts with cwd but is a different path
// (no slash between cwd and "../sheepy")
cwd = getCwd();
- iAppendS(&cwd, "../sheepy");
+ r = iAppendS(&cwd, "../sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = bLRelPath(b, sizeof(b), cwd, null);
ck_assert_str_eq(r, "../src../sheepy");
free(cwd);
// subdirectory to cwd
cwd = getCwd();
- iAppendS(&cwd, "/sheepy");
+ r = iAppendS(&cwd, "/sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = bLRelPath(b, sizeof(b), cwd, null);
ck_assert_str_eq(r, "sheepy");
free(cwd);
@@ -1617,7 +1754,8 @@ void bLRelPathT(CuTest *tc UNUSED) {
// start = root
cwd = getCwd();
- iAppendS(&cwd, "/sheepy");
+ r = iAppendS(&cwd, "/sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = bLRelPath(b, sizeof(b), cwd, "/../");
ck_assert_str_eq(r, cwd+1);
free(cwd);
@@ -1636,7 +1774,8 @@ void bLRelPathT(CuTest *tc UNUSED) {
// start is relative to cwd
cwd = getCwd();
- iAppendS(&cwd, "/../sheepy");
+ r = iAppendS(&cwd, "/../sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = bLRelPath(b, sizeof(b), cwd, "test/");
ck_assert_str_eq(r, "../../sheepy");
free(cwd);
@@ -1716,7 +1855,8 @@ void chDirT(CuTest *tc UNUSED) {
ck_assert(chDir("dirTest.null"));
char *s = getCwd();
ck_assert((size_t)findS(s, "dirTest.null"));
- chDir(c);
+ bool r = chDir(c);
+ ck_assert(r);
freeManyS(c,s);
// non existing dir
ck_assert(!chDir("RandomNonExistingDir"));
@@ -1909,7 +2049,8 @@ void readFileToST(CuTest *tc UNUSED) {
free(l);
// write only file
- fileChmod("writeOnlyText.null", S_IWUSR | S_IWGRP | S_IWOTH);
+ bool r = fileChmod("writeOnlyText.null", S_IWUSR | S_IWGRP | S_IWOTH);
+ ck_assert(r);
ck_assert_ptr_eq(readFileToS("writeOnlyText.null"), NULL);
// blank path
@@ -1919,8 +2060,10 @@ void readFileToST(CuTest *tc UNUSED) {
ck_assert_ptr_eq(readFileToS(NULL), NULL);
// non existing path
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
ck_assert_ptr_eq(readFileToS("nonExistingFile"), NULL);
}
@@ -1954,31 +2097,41 @@ void readStreamToST(CuTest *tc UNUSED) {
void bReadFileToST(CuTest *tc UNUSED) {
char l[100];
+ void *r = null;
// text
- bReadFileToS("textTest.null", l);
+ r = bReadFileToS("textTest.null", l);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l, "LINE 1\nANOTHER line\n");
// empty text
- bReadFileToS("chmodTest.null", l);
+ r = bReadFileToS("chmodTest.null", l);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l, "");
// write only file
- ck_assert_ptr_eq(bReadFileToS("writeOnlyText.null", l), NULL);
+ r = bReadFileToS("writeOnlyText.null", l);
+ ck_assert_ptr_eq(r, null);
// blank path
- ck_assert_ptr_eq(bReadFileToS("", l), NULL);
+ r = bReadFileToS("", l);
+ ck_assert_ptr_eq(r, null);
// NULL path
- ck_assert_ptr_eq(bReadFileToS(NULL, l), NULL);
+ r = bReadFileToS(NULL, l);
+ ck_assert_ptr_eq(r, null);
// NULL buffer
- ck_assert_ptr_eq(bReadFileToS("wqe", NULL), NULL);
+ r = bReadFileToS("wqe", NULL);
+ ck_assert_ptr_eq(r, null);
// non existing path
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
- ck_assert_ptr_eq(bReadFileToS("nonExistingFile", l), NULL);
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
+ r = bReadFileToS("nonExistingFile", l);
+ ck_assert_ptr_eq(r, null);
}
@@ -2014,40 +2167,52 @@ void bReadStreamToST(CuTest *tc UNUSED) {
void bLReadFileToST(CuTest *tc UNUSED) {
char l[100];
+ void *r = null;
// text
- bLReadFileToS("textTest.null", l, sizeof l);
+ r = bLReadFileToS("textTest.null", l, sizeof l);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l, "LINE 1\nANOTHER line\n");
// shorter buffer
- bLReadFileToS("textTest.null", l, 3);
+ r = bLReadFileToS("textTest.null", l, 3);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l, "LI");
// empty text
- bLReadFileToS("chmodTest.null", l, sizeof l);
+ r = bLReadFileToS("chmodTest.null", l, sizeof l);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l, "");
// size 0 buffer - no change
strcpy(l, "libsheepy");
- bLReadFileToS("textTest.null", l, 0);
+ r = bLReadFileToS("textTest.null", l, 0);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l, "libsheepy");
// write only file
- ck_assert_ptr_eq(bLReadFileToS("writeOnlyText.null", l, sizeof l), NULL);
+ r = bLReadFileToS("writeOnlyText.null", l, sizeof l);
+ ck_assert_ptr_eq(r, null);
// blank path
- ck_assert_ptr_eq(bLReadFileToS("", l, sizeof l), NULL);
+ r = bLReadFileToS("", l, sizeof l);
+ ck_assert_ptr_eq(r, null);
// NULL path
- ck_assert_ptr_eq(bLReadFileToS(NULL, l, sizeof l), NULL);
+ r = bLReadFileToS(NULL, l, sizeof l);
+ ck_assert_ptr_eq(r, null);
// NULL buffer
- ck_assert_ptr_eq(bLReadFileToS("wqe", NULL, sizeof l), NULL);
+ r = bLReadFileToS("wqe", NULL, sizeof l);
+ ck_assert_ptr_eq(r, null);
// non existing path
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
- ck_assert_ptr_eq(bLReadFileToS("nonExistingFile", l, sizeof l), NULL);
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
+ r = bLReadFileToS("nonExistingFile", l, sizeof l);
+ ck_assert_ptr_eq(r, null);
}
@@ -2111,7 +2276,8 @@ void readFileT(CuTest *tc UNUSED) {
free(l);
// write only file
- fileChmod("writeOnlyText.null", S_IWUSR | S_IWGRP | S_IWOTH);
+ bool r = fileChmod("writeOnlyText.null", S_IWUSR | S_IWGRP | S_IWOTH);
+ ck_assert(r);
ck_assert_int_eq(readFile("writeOnlyText.null", (void **) &l), -1);
// blank path
@@ -2124,8 +2290,10 @@ void readFileT(CuTest *tc UNUSED) {
ck_assert_int_eq(readFile(NULL, (void **) &l), -1);
// non existing path
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
ck_assert_int_eq(readFile("nonExistingFile", (void **) &l), -1);
}
@@ -2160,8 +2328,10 @@ void bReadFileT(CuTest *tc UNUSED) {
ck_assert_int_eq(bReadFile(NULL, l), -1);
// non existing path
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
ck_assert_int_eq(bReadFile("nonExistingFile", l), -1);
}
@@ -2208,8 +2378,10 @@ void bLReadFileT(CuTest *tc UNUSED) {
ck_assert_int_eq(bLReadFile(NULL, l, sizeof l), -1);
// non existing path
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
ck_assert_int_eq(bLReadFile("nonExistingFile", l, sizeof l), -1);
}
@@ -2232,11 +2404,15 @@ void writeFileST(CuTest *tc UNUSED) {
ck_assert_str_eq(l, "LINE 1\nANOTHER line\n");
// non existing file
// make sure the file doesnt exist
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
ck_assert(writeFileS("nonExistingFile",l));
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
// blank file name
ck_assert(!writeFileS(" ",l));
// read only path
@@ -2267,13 +2443,17 @@ void writeFileT(CuTest *tc UNUSED) {
ck_assert_str_eq(l, "LINE 1\nANOTHER line\n");
// non existing file
// make sure the file doesnt exist
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
ck_assert(writeFile("nonExistingFile",l, strlen(l)+1));
// 0 length
ck_assert(writeFile("nonExistingFile", l, 0));
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
// blank file name
ck_assert(!writeFile(" ",l, 1));
// read only path
@@ -2362,8 +2542,10 @@ void appendFileST(CuTest *tc UNUSED) {
l = readFileToS("appendTextOutTest.null");
ck_assert_uint_eq(strlen(l),30);
ck_assert_str_eq(l, "appended line\nappended line 2\n");
- if (fileExists("appendTextOutTest.null"))
- rmAll("appendTextOutTest.null");
+ if (fileExists("appendTextOutTest.null")) {
+ int R = rmAll("appendTextOutTest.null");
+ ck_assert_int_ne(R, 0);
+ }
// blank file name
ck_assert(!appendFileS(" ",l));
// read only path
@@ -2395,8 +2577,10 @@ void appendFileT(CuTest *tc UNUSED) {
l = readFileToS("appendTextOutTest.null");
ck_assert_uint_eq(strlen(l),30);
ck_assert_str_eq(l, "appended line\nappended line 2\n");
- if (fileExists("appendTextOutTest.null"))
- rmAll("appendTextOutTest.null");
+ if (fileExists("appendTextOutTest.null")) {
+ int R = rmAll("appendTextOutTest.null");
+ ck_assert_int_ne(R, 0);
+ }
// blank file name
ck_assert(!appendFile(" ",l, strlen(l)));
// read only path
@@ -2550,7 +2734,8 @@ void readDirAllT(CuTest *tc UNUSED) {
void mkdirParentsT(CuTest *tc UNUSED) {
// directory
- rmAll("mkdirTest.null/null");
+ int R = rmAll("mkdirTest.null/null");
+ ck_assert_int_ne(R, 0);
ck_assert_int_eq(mkdirParents("mkdirTest.null/null"),1);
ck_assert_int_eq(mkdirParents("mkdirTest.null/null/"),1);
// not allowed
@@ -2567,7 +2752,8 @@ void mkdirParentsT(CuTest *tc UNUSED) {
void rmAllT(CuTest *tc UNUSED) {
// directory
- mkdirParents("rmAllTest.null/null");
+ int r = mkdirParents("rmAllTest.null/null");
+ ck_assert_int_ne(r, 0);
ck_assert_int_eq(rmAll("rmAllTest.null"),1);
// empty path
ck_assert_int_eq(rmAll(""),0);
@@ -2582,15 +2768,20 @@ void rmAllT(CuTest *tc UNUSED) {
void copyT(CuTest *tc UNUSED) {
// file
- rmAll("copyTest.null");
- rmAll("copy2Test.null");
+ int R = rmAll("copyTest.null");
+ printf("%d\n",R);
+ R = rmAll("copy2Test.null");
+ printf("%d\n",R);
ck_assert_int_eq(copy("chmodTest.null", "copyTest.null"),1);
ck_assert(fileExists("copyTest.null"));
// too little permissions
- fileChmod("copyTest.null", 0);
+ bool r = fileChmod("copyTest.null", 0);
+ ck_assert(r);
ck_assert_int_eq(copy("copyTest.null", "copy2Test.null"),0);
- fileChmod("copyTest.null", S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
- rmAll("copyTest.null");
+ r = fileChmod("copyTest.null", S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+ ck_assert(r);
+ R = rmAll("copyTest.null");
+ ck_assert_int_ne(R, 0);
// give dir another name
ck_assert_int_eq(copy("dirTest.null", "copyTest.null"),1);
// copy dir to non existing dir
@@ -2622,7 +2813,8 @@ void copyT(CuTest *tc UNUSED) {
ck_assert_str_eq(l[15], "copyTest.null/we/dirTest.null/two/four");
ck_assert_str_eq(l[16], "copyTest.null/we/dirTest.null/two/three");
listFreeS(l);
- rmAll("copyTest.null");
+ R = rmAll("copyTest.null");
+ ck_assert_int_ne(R, 0);
// copy dir to read only destination, no mkdir
ck_assert_int_eq(copy("mkdirTest.null/", "/newdir"),0);
// copy dir to read only destination, new dir
@@ -2672,7 +2864,8 @@ void shMoveT(CuTest *tc UNUSED) {
// dir
ck_assert_int_eq(shMove("mkdirTest.null", "rename2Test.null"), 1);
ck_assert_int_eq(shMove("rename2Test.null/mkdirTest.null", "."), 1);
- rmAll("rename2Test.null");
+ int R = rmAll("rename2Test.null");
+ ck_assert_int_ne(R, 0);
// non existing source
ck_assert_int_eq(shMove("rename2Test.null", "renameTest.null"), 0);
// already existing destination
@@ -2708,8 +2901,11 @@ void setHardwareRandomT(CuTest *tc UNUSED) {
void randomOpenCloseT(CuTest *tc UNUSED) {
+ int r;
+
// open /dev/urandom
- ck_assert_int_eq(randomUrandomOpen(),1);
+ r = randomUrandomOpen();
+ ck_assert_int_eq(r,1);
randomUrandomClose();
}
@@ -2718,7 +2914,8 @@ void randomOpenCloseT(CuTest *tc UNUSED) {
void randomWordT(CuTest *tc UNUSED) {
// get random value
- randomUrandomOpen();
+ int r = randomUrandomOpen();
+ ck_assert_int_eq(r,1);
ck_assert_int_ne(randomWord(),0);
randomUrandomClose();
// error when /dev/urandom is closed
@@ -2731,7 +2928,8 @@ void randomWordFromHWT(CuTest *tc UNUSED) {
// get random value
setHardwareRandom();
- randomWordFromHW();
+ uint64_t r = randomWordFromHW();
+ printf("%"PRIu64"\n", r);
// string
char *s = randomS(10);
@@ -2746,7 +2944,8 @@ void randomWordFromHWT(CuTest *tc UNUSED) {
void randomChoiceT(CuTest *tc UNUSED) {
// get random value
- randomUrandomOpen();
+ int r = randomUrandomOpen();
+ ck_assert_int_eq(r,1);
ck_assert_int_ne(randomChoice(10),10);
// invalid range (0)
ck_assert_int_eq(randomChoice(0),0);
@@ -2823,12 +3022,17 @@ void readST(CuTest *tc UNUSED) {
void bLReadST(CuTest *tc UNUSED) {
char s[21];
- bLReadS(s, 21);
+ char *r = null;
+
+ r = bLReadS(s, 21);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "aaaaaaaaaaaaaaaaaaaa");
// size 1
- ck_assert_ptr_eq(bLReadS(s, 1), NULL);
+ r = bLReadS(s, 1);
+ ck_assert_ptr_eq(r, null);
// NULL
- ck_assert_ptr_eq(bLReadS(NULL, 2), NULL);
+ r = bLReadS(NULL, 2);
+ ck_assert_ptr_eq(r, null);
}
@@ -3079,14 +3283,15 @@ void strCpyT(CuTest *tc UNUSED) {
// copy string
r = strCpy(s, "lib");
- ck_assert_ptr_ne(r, null);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "lib");
// NULL
s[0] = 0;
r = strCpy(s, NULL);
ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
- ck_assert_ptr_eq(strCpy(NULL, "lib"), NULL);
+ r = strCpy(NULL, "lib");
+ ck_assert_ptr_eq(r, null);
}
@@ -3119,30 +3324,37 @@ void strNCpyT(CuTest *tc UNUSED) {
void strLCpyT(CuTest *tc UNUSED) {
char s[1024];
+ char *r = null;
// copy string
- strLCpy(s, 100, "lib");
+ r = strLCpy(s, 100, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "lib");
// truncate src
s[0] = 0;
s[1] = 0;
s[2] = 0;
- strLCpy(s, 3, "lib");
+ r = strLCpy(s, 3, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "li");
s[0] = 'a';
s[1] = 'a';
s[2] = 'a';
s[3] = 0;
- strLCpy(s, 3, "lib");
+ r = strLCpy(s, 3, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "li");
// size 0 - no change in s
- strLCpy(s, 0, "libsheepy");
+ r = strLCpy(s, 0, "libsheepy");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "li");
// NULL
s[0] = 0;
- strLCpy(s, 1, NULL);
+ r = strLCpy(s, 1, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
- ck_assert_ptr_eq(strLCpy(NULL,1, "lib"), NULL);
+ r = strLCpy(NULL,1, "lib");
+ ck_assert_ptr_eq(r, null);
}
@@ -3150,19 +3362,25 @@ void strLCpyT(CuTest *tc UNUSED) {
void strCatT(CuTest *tc UNUSED) {
char s[1024];
+ char *r = null;
// append string
- strCpy(s, "lib");
- strCat(s, "sheepy");
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
+ r = strCat(s, "sheepy");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// empty string2
- strCat(s, "");
+ r = strCat(s, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// NULL string2
- strCat(s, NULL);
+ r = strCat(s, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "libsheepy");
// NULL parameter
- ck_assert_ptr_eq(strCat(NULL, "ad"), NULL);
+ r = strCat(NULL, "ad");
+ ck_assert_ptr_eq(r, null);
}
@@ -3170,13 +3388,17 @@ void strCatT(CuTest *tc UNUSED) {
void strNCatT(CuTest *tc UNUSED) {
char s[1024];
+ char *r = null;
// append string
- strCpy(s, "lib");
- strNCat(s, "sheepy", 100);
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
+ r = strNCat(s, "sheepy", 100);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// empty string2
- strNCat(s, "", 10);
+ r = strNCat(s, "", 10);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// truncate src
s[0] = 'a';
@@ -3185,15 +3407,19 @@ void strNCatT(CuTest *tc UNUSED) {
s[3] = 'a';
s[4] = 'a';
s[5] = 'a';
- strCpy(s, "lib");
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "lib");
- strNCat(s, "sheepy", 2);
+ r = strNCat(s, "sheepy", 2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsh");
// NULL string2
- strNCat(s, NULL, 1);
+ r = strNCat(s, NULL, 1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "libsh");
// NULL parameter
- ck_assert_ptr_eq(strNCat(NULL, "ad", 1), NULL);
+ r = strNCat(NULL, "ad", 1);
+ ck_assert_ptr_eq(r, null);
}
@@ -3201,16 +3427,21 @@ void strNCatT(CuTest *tc UNUSED) {
void strLCatT(CuTest *tc UNUSED) {
char s[1024];
+ char *r = null;
// append string
- strCpy(s, "lib");
- strLCat(s, 100, "sheepy");
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
+ r = strLCat(s, 100, "sheepy");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// empty string2
- strLCat(s, 20, "");
+ r = strLCat(s, 20, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// s strlen bigger than s size - keep s as it is
- strLCat(s, 6, "qwqwe");
+ r = strLCat(s, 6, "qwqwe");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// truncate src
s[0] = 'a';
@@ -3219,9 +3450,11 @@ void strLCatT(CuTest *tc UNUSED) {
s[3] = 'a';
s[4] = 'a';
s[5] = 'a';
- strCpy(s, "lib");
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "lib");
- strLNCat(s,100, "sheepy", 2);
+ r = strLNCat(s,100, "sheepy", 2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsh");
// truncate dst
s[0] = 'a';
@@ -3230,15 +3463,19 @@ void strLCatT(CuTest *tc UNUSED) {
s[3] = 'a';
s[4] = 'a';
s[5] = 'a';
- strCpy(s, "lib");
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "lib");
- strLCat(s, 6, "sheepy");
+ r = strLCat(s, 6, "sheepy");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsh");
// NULL string2
- strLCat(s, 1, NULL);
+ r = strLCat(s, 1, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "libsh");
// NULL parameter
- ck_assert_ptr_eq(strLCat(NULL, 1, "ad"), NULL);
+ r = strLCat(NULL, 1, "ad");
+ ck_assert_ptr_eq(r, null);
}
@@ -3246,16 +3483,21 @@ void strLCatT(CuTest *tc UNUSED) {
void strLNCatT(CuTest *tc UNUSED) {
char s[1024];
+ char *r = null;
// append string
- strCpy(s, "lib");
- strLNCat(s, 100, "sheepy", 100);
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
+ r = strLNCat(s, 100, "sheepy", 100);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// empty string2
- strLNCat(s, 20, "", 10);
+ r = strLNCat(s, 20, "", 10);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// s strlen bigger than s size - keep s as it is
- strLNCat(s, 6, "qwqwe", 1);
+ r = strLNCat(s, 6, "qwqwe", 1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// truncate dst
s[0] = 'a';
@@ -3264,15 +3506,19 @@ void strLNCatT(CuTest *tc UNUSED) {
s[3] = 'a';
s[4] = 'a';
s[5] = 'a';
- strCpy(s, "lib");
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "lib");
- strLNCat(s, 6, "sheepy", 4);
+ r = strLNCat(s, 6, "sheepy", 4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsh");
// NULL string2
- strLNCat(s, 1, NULL, 1);
+ r = strLNCat(s, 1, NULL, 1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "libsh");
// NULL parameter
- ck_assert_ptr_eq(strLNCat(NULL, 1, "ad", 1), NULL);
+ r = strLNCat(NULL, 1, "ad", 1);
+ ck_assert_ptr_eq(r, null);
}
@@ -3304,20 +3550,25 @@ void iCatST(CuTest *tc UNUSED) {
char *s;
char r[100];
+ char *r2 = null;
// cat strings
s = strdup("#@#");
- iCatS(r, s,"asd");
+ r2 = iCatS(r, s,"asd");
+ ck_assert_ptr_eq(r2, r);
ck_assert_str_eq(r, "#@#asd");
free(s);
// empty string
- iCatS(r, "");
+ r2 = iCatS(r, "");
+ ck_assert_ptr_eq(r2, r);
ck_assert(isEmptyS(r));
// cat empty string with string
- iCatS(r, "", "asd");
+ r2 = iCatS(r, "", "asd");
+ ck_assert_ptr_eq(r2, r);
ck_assert_str_eq(r, "asd");
// NULL
- ck_assert_ptr_eq(iCatS(NULL, "wef","wef"), NULL);
+ r2 = iCatS(NULL, "wef","wef");
+ ck_assert_ptr_eq(r2, null);
}
@@ -3326,26 +3577,33 @@ void bLCatST(CuTest *tc UNUSED) {
char *s;
char r[100];
+ char *r2 = null;
// cat strings
s = strdup("#@#");
- bLCatS(r, sizeof r, s,"asd");
+ r2 = bLCatS(r, sizeof r, s,"asd");
+ ck_assert_ptr_eq(r2, r);
ck_assert_str_eq(r, "#@#asd");
// shorter buffer
- bLCatS(r, 3, s,"asd");
+ r2 = bLCatS(r, 3, s,"asd");
+ ck_assert_ptr_eq(r2, r);
ck_assert_str_eq(r, "#@");
free(s);
// empty string
- bLCatS(r, sizeof r, "");
+ r2 = bLCatS(r, sizeof r, "");
+ ck_assert_ptr_eq(r2, r);
ck_assert(isEmptyS(r));
// cat empty string with string
- bLCatS(r, sizeof r, "", "asd");
+ r2 = bLCatS(r, sizeof r, "", "asd");
+ ck_assert_ptr_eq(r2, r);
ck_assert_str_eq(r, "asd");
// size 0 - no change in r
- bLCatS(r, 0, "", "asd");
+ r2 = bLCatS(r, 0, "", "asd");
+ ck_assert_ptr_eq(r2, r);
ck_assert_str_eq(r, "asd");
// NULL
- ck_assert_ptr_eq(bLCatS(NULL, sizeof r, "wef","wef"), NULL);
+ r2 = bLCatS(NULL, sizeof r, "wef","wef");
+ ck_assert_ptr_eq(r2, null);
}
@@ -3450,25 +3708,31 @@ void appendSCharT(CuTest *tc UNUSED) {
void iAppendST(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
// append string
s = strdup("lib");
- iAppendS(&s, "sheepy");
+ r = iAppendS(&s, "sheepy");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// empty string2
- iAppendS(&s, "");
+ r = iAppendS(&s, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// NULL string2
- iAppendS(&s, NULL);
+ r = iAppendS(&s, NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
free(s);
// NULL string
s = NULL;
- iAppendS(&s, "ad");
+ r = iAppendS(&s, "ad");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ad");
free(s);
// NULL parameter
- iAppendS(NULL, "ad");
+ r = iAppendS(NULL, "ad");
+ ck_assert_ptr_eq(r, null);
}
@@ -3476,22 +3740,27 @@ void iAppendST(CuTest *tc UNUSED) {
void iAppendCharST(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
// append string
s = strdup("lib");
- iAppendCharS(&s, 'C');
+ r = iAppendCharS(&s, 'C');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libC");
// empty string2
- iAppendCharS(&s, 0);
+ r = iAppendCharS(&s, 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libC");
free(s);
// NULL string
s = NULL;
- iAppendCharS(&s, 'C');
+ r = iAppendCharS(&s, 'C');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "C");
free(s);
// NULL parameter
- ck_assert_ptr_eq(iAppendCharS(NULL, 'C'), NULL);
+ r = iAppendCharS(NULL, 'C');
+ ck_assert_ptr_eq(r, null);
}
@@ -3499,26 +3768,32 @@ void iAppendCharST(CuTest *tc UNUSED) {
void iAppendNFreeST(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
// append string
s = strdup("lib");
- iAppendNFreeS(&s, strdup("sheepy"));
+ r = iAppendNFreeS(&s, strdup("sheepy"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// empty string2
- iAppendNFreeS(&s, strdup(""));
+ r = iAppendNFreeS(&s, strdup(""));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// NULL string2
- iAppendNFreeS(&s, NULL);
+ r = iAppendNFreeS(&s, NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
free(s);
// NULL string
s = NULL;
- iAppendNFreeS(&s, strdup("ad"));
+ r = iAppendNFreeS(&s, strdup("ad"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ad");
free(s);
// NULL parameter
s = strdup("ad");
- iAppendNFreeS(NULL, s);
+ r = iAppendNFreeS(NULL, s);
+ ck_assert_ptr_eq(r, null);
free(s);
}
@@ -3527,26 +3802,32 @@ void iAppendNFreeST(CuTest *tc UNUSED) {
void iAppendManyST(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
// append string
s = strdup("lib");
- iAppendManyS(&s, "sheepy","2");
+ r = iAppendManyS(&s, "sheepy","2");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy2");
// empty string2
- iAppendManyS(&s, "", "");
+ r = iAppendManyS(&s, "", "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy2");
// NULL string2
- iAppendManyS(&s, "a", NULL);
+ r = iAppendManyS(&s, "a", NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy2a");
//not allowed - iAppendManyS(&s, NULL);
free(s);
// NULL string (allocate)
s = NULL;
- iAppendManyS(&s, "ad", "");
+ r = iAppendManyS(&s, "ad", "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ad");
free(s);
// NULL parameter
- iAppendManyS(NULL, "ad", "");
+ r = iAppendManyS(NULL, "ad", "");
+ ck_assert_ptr_eq(r, null);
}
@@ -3554,20 +3835,25 @@ void iAppendManyST(CuTest *tc UNUSED) {
void bAppendManyST(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
// append string
strcpy(s, "lib");
- bAppendManyS(s, "sheepy","2");
+ r = bAppendManyS(s, "sheepy","2");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy2");
// empty string2
- bAppendManyS(s, "", "");
+ r = bAppendManyS(s, "", "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy2");
// NULL string2
- bAppendManyS(s, "a", NULL);
+ r = bAppendManyS(s, "a", NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy2a");
//not allowed - bAppendManyS(s, NULL);
// NULL parameter
- ck_assert_ptr_eq(bAppendManyS(NULL, "ad", ""), NULL);
+ r = bAppendManyS(NULL, "ad", "");
+ ck_assert_ptr_eq(r, null);
}
@@ -3575,27 +3861,34 @@ void bAppendManyST(CuTest *tc UNUSED) {
void bLAppendManyST(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
// append string
strcpy(s, "lib");
- bLAppendManyS(s, sizeof s, "sheepy","2");
+ r = bLAppendManyS(s, sizeof s, "sheepy","2");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy2");
// shorter buffer
strcpy(s, "lib");
- bLAppendManyS(s, 5, "sheepy","2");
+ r = bLAppendManyS(s, 5, "sheepy","2");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libs");
// empty string2
- bLAppendManyS(s, sizeof s, "", "");
+ r = bLAppendManyS(s, sizeof s, "", "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libs");
// NULL string2
- bLAppendManyS(s, sizeof s, "a", NULL);
+ r = bLAppendManyS(s, sizeof s, "a", NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsa");
// size 0 - no change
- bLAppendManyS(s, 0, "a", NULL);
+ r = bLAppendManyS(s, 0, "a", NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsa");
//not allowed - bLAppendManyS(s, sizeof s, NULL);
// NULL parameter
- ck_assert_ptr_eq(bLAppendManyS(NULL, sizeof s, "ad", ""), NULL);
+ r = bLAppendManyS(NULL, sizeof s, "ad", "");
+ ck_assert_ptr_eq(r, null);
}
@@ -3636,25 +3929,31 @@ void prependSCharT(CuTest *tc UNUSED) {
void iPrependST(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
// append string
s = strdup("lib");
- iPrependS(&s, "sheepy");
+ r = iPrependS(&s, "sheepy");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepylib");
// empty string2
- iPrependS(&s, "");
+ r = iPrependS(&s, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepylib");
// NULL string2
- iPrependS(&s, NULL);
+ r = iPrependS(&s, NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepylib");
free(s);
// NULL string
s = NULL;
- iPrependS(&s, "ad");
+ r = iPrependS(&s, "ad");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ad");
free(s);
// NULL parameter
- ck_assert_ptr_eq(iPrependS(NULL, "ad"), NULL);
+ r = iPrependS(NULL, "ad");
+ ck_assert_ptr_eq(r, null);
}
@@ -3662,22 +3961,27 @@ void iPrependST(CuTest *tc UNUSED) {
void iPrependCharST(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
// append string
s = strdup("lib");
- iPrependCharS(&s, 'C');
+ r = iPrependCharS(&s, 'C');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "Clib");
// empty string2
- iPrependCharS(&s, 0);
+ r = iPrependCharS(&s, 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "Clib");
free(s);
// NULL string
s = NULL;
- iPrependCharS(&s, 'C');
+ r = iPrependCharS(&s, 'C');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "C");
free(s);
// NULL parameter
- ck_assert_ptr_eq(iPrependCharS(NULL, 'a'), NULL);
+ r = iPrependCharS(NULL, 'a');
+ ck_assert_ptr_eq(r, null);
}
@@ -3685,26 +3989,32 @@ void iPrependCharST(CuTest *tc UNUSED) {
void iPrependNFreeST(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
// append string
s = strdup("lib");
- iPrependNFreeS(&s, strdup("sheepy"));
+ r = iPrependNFreeS(&s, strdup("sheepy"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepylib");
// empty string2
- iPrependNFreeS(&s, strdup(""));
+ r = iPrependNFreeS(&s, strdup(""));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepylib");
// NULL string2
- iPrependNFreeS(&s, NULL);
+ r = iPrependNFreeS(&s, NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepylib");
free(s);
// NULL string
s = NULL;
- iPrependNFreeS(&s, strdup("ad"));
+ r = iPrependNFreeS(&s, strdup("ad"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ad");
free(s);
// NULL parameter
s = strdup("ad");
- ck_assert_ptr_eq(iPrependNFreeS(NULL, s), NULL);
+ r = iPrependNFreeS(NULL, s);
+ ck_assert_ptr_eq(r, null);
free(s);
}
@@ -3713,23 +4023,29 @@ void iPrependNFreeST(CuTest *tc UNUSED) {
void bPrependST(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
// append string
strcpy(s, "lib");
- bPrependS(s, "sheepy");
+ r = bPrependS(s, "sheepy");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepylib");
// empty string2
- bPrependS(s, "");
+ r = bPrependS(s, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepylib");
// NULL string2
- bPrependS(s, NULL);
+ r = bPrependS(s, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepylib");
// empty string
bEmptyS(s);
- bPrependS(s, "ad");
+ r = bPrependS(s, "ad");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ad");
// NULL parameter
- ck_assert_ptr_eq(bPrependS(NULL, "ad"), NULL);
+ r = bPrependS(NULL, "ad");
+ ck_assert_ptr_eq(r, null);
}
@@ -3737,30 +4053,38 @@ void bPrependST(CuTest *tc UNUSED) {
void bLPrependST(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
// append string
strcpy(s, "lib");
- bLPrependS(s, sizeof s, "sheepy");
+ r = bLPrependS(s, sizeof s, "sheepy");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepylib");
// shorter buffer
strcpy(s, "lib");
- bLPrependS(s, 5, "sheepy");
+ r = bLPrependS(s, 5, "sheepy");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "shee");
// empty string2
- bLPrependS(s, sizeof s, "");
+ r = bLPrependS(s, sizeof s, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "shee");
// NULL string2
- bLPrependS(s, sizeof s, NULL);
+ r = bLPrependS(s, sizeof s, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "shee");
// empty string
bEmptyS(s);
- bLPrependS(s, sizeof s, "ad");
+ r = bLPrependS(s, sizeof s, "ad");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ad");
// size 0 - no change
- bLPrependS(s, 0, "ad");
+ r = bLPrependS(s, 0, "ad");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ad");
// NULL parameter
- ck_assert_ptr_eq(bLPrependS(NULL, sizeof s, "ad"), NULL);
+ r = bLPrependS(NULL, sizeof s, "ad");
+ ck_assert_ptr_eq(r, null);
}
@@ -3904,51 +4228,63 @@ void replaceCharCharST(CuTest *tc UNUSED) {
void iReplaceST(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
+
// replace string, multiple character new delimeter
s = strdup("#ee#ee#ad");
- iReplaceS_max(&s, "#","^^");
+ r = iReplaceS_max(&s, "#","^^");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee^^ee^^ad");
free(s);
// replace string, multiple character old delimeter
s = strdup("AA##ee##ee#");
- iReplaceS_max(&s, "##","|");
+ r = iReplaceS_max(&s, "##","|");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee|ee#");
free(s);
// replace one time at the start of string
s = strdup("#ee#ee#ad");
- iReplaceS(&s, "#","^^",1);
+ r = iReplaceS(&s, "#","^^",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee#ee#ad");
free(s);
// replace one time
s = strdup("AA##ee##ee#");
- iReplaceS(&s, "##","|",1);
+ r = iReplaceS(&s, "##","|",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee##ee#");
free(s);
// NULL new delimiter, one time: same as empty delimiter
s = strdup("AA##ee##ee#");
- iReplaceS(&s, "##",NULL,1);
+ r = iReplaceS(&s, "##",NULL,1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AAee##ee#");
free(s);
// empty string
emptyS(s);
- iReplaceS(&s, "##",NULL,1);
+ r = iReplaceS(&s, "##",NULL,1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// empty old delimiter
s = strdup("qwe");
- iReplaceS(&s, "","|",1);
+ r = iReplaceS(&s, "","|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
free(s);
// NULL old delimiter
s = strdup("qwe");
- iReplaceS(&s, NULL,"|",1);
+ r = iReplaceS(&s, NULL,"|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
free(s);
// NULL string
s = NULL;
- iReplaceS(&s, "##","|",1);
+ r = iReplaceS(&s, "##","|",1);
+ ck_assert_ptr_eq(r, null);
// NULL var
- iReplaceS(NULL, "##","|",1);
+ r = iReplaceS(NULL, "##","|",1);
+ ck_assert_ptr_eq(r, null);
}
@@ -3956,41 +4292,51 @@ void iReplaceST(CuTest *tc UNUSED) {
void iReplaceCharSST(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
+
// replace string, multiple character new delimeter
s = strdup("#ee#ee#ad");
- iReplaceCharSS(&s, '#',"^^", 0);
+ r = iReplaceCharSS(&s, '#',"^^", 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee^^ee^^ad");
free(s);
// replace one time at the start of string
s = strdup("#ee#ee#ad");
- iReplaceCharSS(&s, '#',"^^",1);
+ r = iReplaceCharSS(&s, '#',"^^",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee#ee#ad");
free(s);
// replace one time
s = strdup("AA#ee##ee#");
- iReplaceCharSS(&s, '#',"|",1);
+ r = iReplaceCharSS(&s, '#',"|",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee##ee#");
free(s);
// NULL new delimiter, one time: same as empty delimiter
s = strdup("AA#ee##ee#");
- iReplaceCharSS(&s, '#',NULL,1);
+ r = iReplaceCharSS(&s, '#',NULL,1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AAee##ee#");
free(s);
// empty string
emptyS(s);
- iReplaceCharSS(&s, '#',NULL,1);
+ r = iReplaceCharSS(&s, '#',NULL,1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// empty old delimiter
s = strdup("qwe");
- iReplaceCharSS(&s, 0,"|",1);
+ r = iReplaceCharSS(&s, 0,"|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
free(s);
// NULL string
s = NULL;
- iReplaceCharSS(&s, '#',"|",1);
+ r = iReplaceCharSS(&s, '#',"|",1);
+ ck_assert_ptr_eq(r, s);
// NULL var
- iReplaceCharSS(NULL, '#',"|",1);
+ r = iReplaceCharSS(NULL, '#',"|",1);
+ ck_assert_ptr_eq(r, null);
}
@@ -3998,46 +4344,57 @@ void iReplaceCharSST(CuTest *tc UNUSED) {
void iReplaceSCharST(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
+
// replace string, multiple character new delimeter
s = strdup("#ee#ee#ad");
- iReplaceSCharS(&s, "#",'^', 0);
+ r = iReplaceSCharS(&s, "#",'^', 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^ee^ee^ad");
free(s);
// replace string, multiple character old delimeter
s = strdup("AA##ee##ee#");
- iReplaceSCharS(&s, "##",'|', 0);
+ r = iReplaceSCharS(&s, "##",'|', 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee|ee#");
free(s);
// replace one time at the start of string
s = strdup("#ee#ee#ad");
- iReplaceSCharS(&s, "#",'^',1);
+ r = iReplaceSCharS(&s, "#",'^',1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^ee#ee#ad");
free(s);
// replace one time
s = strdup("AA##ee##ee#");
- iReplaceSCharS(&s, "##",'|',1);
+ r = iReplaceSCharS(&s, "##",'|',1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee##ee#");
free(s);
// empty string
emptyS(s);
- iReplaceSCharS(&s, "##", 0,1);
+ r = iReplaceSCharS(&s, "##", 0,1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// empty old delimiter
s = strdup("qwe");
- iReplaceSCharS(&s, "",'|',1);
+ r = iReplaceSCharS(&s, "",'|',1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
free(s);
// NULL old delimiter
s = strdup("qwe");
- iReplaceSCharS(&s, NULL,'|',1);
+ r = iReplaceSCharS(&s, NULL,'|',1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
free(s);
// NULL string
s = NULL;
- iReplaceSCharS(&s, "##",'|',1);
+ r = iReplaceSCharS(&s, "##",'|',1);
+ ck_assert_ptr_eq(r, null);
// NULL var
- iReplaceSCharS(NULL, "##",'|',1);
+ r = iReplaceSCharS(NULL, "##",'|',1);
+ ck_assert_ptr_eq(r, null);
}
@@ -4045,36 +4402,45 @@ void iReplaceSCharST(CuTest *tc UNUSED) {
void iReplaceCharCharST(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
+
// replace string, multiple character new delimeter
s = strdup("#ee#ee#ad");
- iReplaceCharCharS(&s, '#','^', 0);
+ r = iReplaceCharCharS(&s, '#','^', 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^ee^ee^ad");
free(s);
// replace one time at the start of string
s = strdup("#ee#ee#ad");
- iReplaceCharCharS(&s, '#','^',1);
+ r = iReplaceCharCharS(&s, '#','^',1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^ee#ee#ad");
free(s);
// replace one time
s = strdup("AA#ee##ee#");
- iReplaceCharCharS(&s, '#','|',1);
+ r = iReplaceCharCharS(&s, '#','|',1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee##ee#");
free(s);
// empty string
emptyS(s);
- iReplaceCharCharS(&s, '#', 0,1);
+ r = iReplaceCharCharS(&s, '#', 0,1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// empty old delimiter
s = strdup("qwe");
- iReplaceCharCharS(&s, 0,'|',1);
+ r = iReplaceCharCharS(&s, 0,'|',1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
free(s);
// NULL string
s = NULL;
- iReplaceCharCharS(&s, '#','|',1);
+ r = iReplaceCharCharS(&s, '#','|',1);
+ ck_assert_ptr_eq(r, s);
// NULL var
- iReplaceCharCharS(NULL, '#','|',1);
+ r = iReplaceCharCharS(NULL, '#','|',1);
+ ck_assert_ptr_eq(r, null);
}
@@ -4082,40 +4448,51 @@ void iReplaceCharCharST(CuTest *tc UNUSED) {
void bReplaceST(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
+
// replace string, multiple character new delimeter
strcpy(s, "#ee#ee#ad");
- bReplaceS_max(s, "#","^^");
+ r = bReplaceS_max(s, "#","^^");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee^^ee^^ad");
// replace string, multiple character old delimeter
strcpy(s, "AA##ee##ee#");
- bReplaceS_max(s, "##","|");
+ r = bReplaceS_max(s, "##","|");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee|ee#");
// replace one time at the start of string
strcpy(s, "#ee#ee#ad");
- bReplaceS(s, "#","^^",1);
+ r = bReplaceS(s, "#","^^",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee#ee#ad");
// replace one time
strcpy(s, "AA##ee##ee#");
- bReplaceS(s, "##","|",1);
+ r = bReplaceS(s, "##","|",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee##ee#");
// NULL new delimiter, one time: same as empty delimiter
strcpy(s, "AA##ee##ee#");
- bReplaceS(s, "##",NULL,1);
+ r = bReplaceS(s, "##",NULL,1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AAee##ee#");
// empty string
bEmptyS(s);
- bReplaceS(s, "##",NULL,1);
+ r = bReplaceS(s, "##",NULL,1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// empty old delimiter
strcpy(s, "qwe");
- bReplaceS(s, "","|",1);
+ r = bReplaceS(s, "","|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// NULL old delimiter
strcpy(s, "qwe");
- bReplaceS(s, NULL,"|",1);
+ r = bReplaceS(s, NULL,"|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// NULL var
- ck_assert_ptr_eq(bReplaceS(NULL, "##","|",1), NULL);
+ r = bReplaceS(NULL, "##","|",1);
+ ck_assert_ptr_eq(r, null);
}
@@ -4123,48 +4500,61 @@ void bReplaceST(CuTest *tc UNUSED) {
void bLReplaceST(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
+
// replace string, multiple character new delimeter
strcpy(s, "#ee#ee#ad");
- bLReplaceS_max(s, sizeof s, "#","^^");
+ r = bLReplaceS_max(s, sizeof s, "#","^^");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee^^ee^^ad");
// shorter buffer
strcpy(s, "#ee#ee#ad");
- bLReplaceS_max(s, 5, "#","^^");
+ r = bLReplaceS_max(s, 5, "#","^^");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee");
// replace string, multiple character old delimeter
strcpy(s, "AA##ee##ee#");
- bLReplaceS_max(s, sizeof s, "##","|");
+ r = bLReplaceS_max(s, sizeof s, "##","|");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee|ee#");
// replace one time at the start of string
strcpy(s, "#ee#ee#ad");
- bLReplaceS(s, sizeof s, "#","^^",1);
+ r = bLReplaceS(s, sizeof s, "#","^^",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee#ee#ad");
// replace one time
strcpy(s, "AA##ee##ee#");
- bLReplaceS(s, sizeof s, "##","|",1);
+ r = bLReplaceS(s, sizeof s, "##","|",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee##ee#");
// NULL new delimiter, one time: same as empty delimiter
strcpy(s, "AA##ee##ee#");
- bLReplaceS(s, sizeof s, "##",NULL,1);
+ r = bLReplaceS(s, sizeof s, "##",NULL,1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AAee##ee#");
// empty string
bEmptyS(s);
- bLReplaceS(s, sizeof s, "##",NULL,1);
+ r = bLReplaceS(s, sizeof s, "##",NULL,1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// empty old delimiter
strcpy(s, "qwe");
- bLReplaceS(s, sizeof s, "","|",1);
+ r = bLReplaceS(s, sizeof s, "","|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// NULL old delimiter
strcpy(s, "qwe");
- bLReplaceS(s, sizeof s, NULL,"|",1);
+ r = bLReplaceS(s, sizeof s, NULL,"|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// size 0 - no change
strcpy(s, "qwe");
- bLReplaceS(s, 0, "q","|",1);
+ r = bLReplaceS(s, 0, "q","|",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qwe");
// NULL var
- ck_assert_ptr_eq(bLReplaceS(NULL, sizeof s, "##","|",1), NULL);
+ r = bLReplaceS(NULL, sizeof s, "##","|",1);
+ ck_assert_ptr_eq(r, null);
}
@@ -4226,9 +4616,12 @@ void icReplaceST(CuTest *tc UNUSED) {
void iicReplaceST(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
+
// replace string, multiple character new delimeter
s = strdup("#EE#ee#ad");
- iicReplaceS(&s, "EE","VV", 0);
+ r = iicReplaceS(&s, "EE","VV", 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "#VV#VV#ad");
free(s);
// iicReplaceCharSS
@@ -4248,44 +4641,53 @@ void iicReplaceST(CuTest *tc UNUSED) {
free(s);
// replace string, multiple character old delimeter
s = strdup("AA##ee##ee#");
- iicReplaceS(&s, "##","|", 0);
+ r = iicReplaceS(&s, "##","|", 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee|ee#");
free(s);
// replace one time at the start of string
s = strdup("#ee#ee#ad");
- iicReplaceS(&s, "#","^^",1);
+ r = iicReplaceS(&s, "#","^^",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee#ee#ad");
free(s);
// replace one time
s = strdup("AA##ee##ee#");
- iicReplaceS(&s, "##","|",1);
+ r = iicReplaceS(&s, "##","|",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee##ee#");
free(s);
// NULL new delimiter, one time: same as empty delimiter
s = strdup("AA##ee##ee#");
- iicReplaceS(&s, "##",NULL,1);
+ r = iicReplaceS(&s, "##",NULL,1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AAee##ee#");
free(s);
// empty string
emptyS(s);
- iicReplaceS(&s, "##",NULL,1);
+ r = iicReplaceS(&s, "##",NULL,1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// empty old delimiter
s = strdup("qwe");
- iicReplaceS(&s, "","|",1);
+ r = iicReplaceS(&s, "","|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
free(s);
// NULL old delimiter
s = strdup("qwe");
- iicReplaceS(&s, NULL,"|",1);
+ r = iicReplaceS(&s, NULL,"|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
free(s);
// NULL string
s = NULL;
- iicReplaceS(&s, "##","|",1);
+ r = iicReplaceS(&s, "##","|",1);
+ ck_assert_ptr_eq(r, null);
// NULL var
- iicReplaceS(NULL, "##","|",1);
+ r = iicReplaceS(NULL, "##","|",1);
+ ck_assert_ptr_eq(r, null);
}
@@ -4294,40 +4696,51 @@ void iicReplaceST(CuTest *tc UNUSED) {
void bicReplaceST(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
+
// replace string, multiple character new delimeter
strcpy(s, "#EE#ee#ad");
- bicReplaceS(s, "ee","VV", 0);
+ r = bicReplaceS(s, "ee","VV", 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "#VV#VV#ad");
// replace string, multiple character old delimeter
strcpy(s, "AA##ee##ee#");
- bicReplaceS(s, "##","|", 0);
+ r = bicReplaceS(s, "##","|", 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee|ee#");
// replace one time at the start of string
strcpy(s, "#ee#ee#ad");
- bicReplaceS(s, "#","^^",1);
+ r = bicReplaceS(s, "#","^^",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee#ee#ad");
// replace one time
strcpy(s, "AA##ee##ee#");
- bicReplaceS(s, "##","|",1);
+ r = bicReplaceS(s, "##","|",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee##ee#");
// NULL new delimiter, one time: same as empty delimiter
strcpy(s, "AA##ee##ee#");
- bicReplaceS(s, "##",NULL,1);
+ r = bicReplaceS(s, "##",NULL,1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AAee##ee#");
// empty string
bEmptyS(s);
- bicReplaceS(s, "##",NULL,1);
+ r = bicReplaceS(s, "##",NULL,1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// empty old delimiter
strcpy(s, "qwe");
- bicReplaceS(s, "","|",1);
+ r = bicReplaceS(s, "","|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// NULL old delimiter
strcpy(s, "qwe");
- bicReplaceS(s, NULL,"|",1);
+ r = bicReplaceS(s, NULL,"|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// NULL var
- ck_assert_ptr_eq(bicReplaceS(NULL, "##","|",1), NULL);
+ r = bicReplaceS(NULL, "##","|",1);
+ ck_assert_ptr_eq(r, null);
}
@@ -4336,48 +4749,61 @@ void bicReplaceST(CuTest *tc UNUSED) {
void bLicReplaceST(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
+
// replace string, multiple character new delimeter
strcpy(s, "#ee#EE#ad");
- bLicReplaceS(s, sizeof s, "ee","vv", 0);
+ r = bLicReplaceS(s, sizeof s, "ee","vv", 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "#vv#vv#ad");
// shorter buffer
strcpy(s, "#ee#ee#ad");
- bLicReplaceS(s, 5, "#","^^", 0);
+ r = bLicReplaceS(s, 5, "#","^^", 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee");
// replace string, multiple character old delimeter
strcpy(s, "AA##ee##ee#");
- bLicReplaceS(s, sizeof s, "##","|", 0);
+ r = bLicReplaceS(s, sizeof s, "##","|", 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee|ee#");
// replace one time at the start of string
strcpy(s, "#ee#ee#ad");
- bLicReplaceS(s, sizeof s, "#","^^",1);
+ r = bLicReplaceS(s, sizeof s, "#","^^",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee#ee#ad");
// replace one time
strcpy(s, "AA##ee##ee#");
- bLicReplaceS(s, sizeof s, "##","|",1);
+ r = bLicReplaceS(s, sizeof s, "##","|",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee##ee#");
// NULL new delimiter, one time: same as empty delimiter
strcpy(s, "AA##ee##ee#");
- bLicReplaceS(s, sizeof s, "##",NULL,1);
+ r = bLicReplaceS(s, sizeof s, "##",NULL,1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AAee##ee#");
// empty string
bEmptyS(s);
- bLicReplaceS(s, sizeof s, "##",NULL,1);
+ r = bLicReplaceS(s, sizeof s, "##",NULL,1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// empty old delimiter
strcpy(s, "qwe");
- bLicReplaceS(s, sizeof s, "","|",1);
+ r = bLicReplaceS(s, sizeof s, "","|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// NULL old delimiter
strcpy(s, "qwe");
- bLicReplaceS(s, sizeof s, NULL,"|",1);
+ r = bLicReplaceS(s, sizeof s, NULL,"|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// size 0 - no change
strcpy(s, "qwe");
- bLicReplaceS(s, 0, "q","|",1);
+ r = bLicReplaceS(s, 0, "q","|",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qwe");
// NULL var
- ck_assert_ptr_eq(bLicReplaceS(NULL, sizeof s, "##","|",1), NULL);
+ r = bLicReplaceS(NULL, sizeof s, "##","|",1);
+ ck_assert_ptr_eq(r, null);
}
@@ -4440,19 +4866,24 @@ void replaceManyST(CuTest *tc UNUSED) {
void iReplaceManyST(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
+
// replace string, multiple character new delimeter
s = strdup("#ee#ee#ad");
- iReplaceManyS(&s, "#","^^","ad","AD");
+ r = iReplaceManyS(&s, "#","^^","ad","AD");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee^^ee^^AD");
free(s);
// replace string, empty new delimeter
s = strdup("#ee#ee#ad");
- iReplaceManyS(&s, "#","","ad","AD");
+ r = iReplaceManyS(&s, "#","","ad","AD");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eeeeAD");
free(s);
// not enough olds:news pairs
s = strdup("#ee#ee#ad");
- iReplaceManyS(&s, "#","","ad");
+ r = iReplaceManyS(&s, "#","","ad");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eeeead");
free(s);
// only 2 parameters
@@ -4463,51 +4894,61 @@ void iReplaceManyST(CuTest *tc UNUSED) {
/* free(s); */
// NULL new delimiter: same as only 2 parameters or not enough olds:news pairs
s = strdup("#ee#ee#ad");
- iReplaceManyS(&s, "#", NULL);
+ r = iReplaceManyS(&s, "#", NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "#ee#ee#ad");
free(s);
// empty string
emptyS(s);
- iReplaceManyS(&s, "#", "");
+ r = iReplaceManyS(&s, "#", "");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// empty string many pairs
emptyS(s);
- iReplaceManyS(&s, "#", "", "%", "");
+ r = iReplaceManyS(&s, "#", "", "%", "");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// many pairs empty olds
s = strdup("qw#e");
- iReplaceManyS(&s, "#", "", "", "");
+ r = iReplaceManyS(&s, "#", "", "", "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qwe");
free(s);
// NULL old delimiter
s = strdup("qw#e");
- iReplaceManyS(&s, NULL, "");
+ r = iReplaceManyS(&s, NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw#e");
free(s);
// NULL old delimiter not first - same as replace empty string
s = strdup("qw#e");
- iReplaceManyS(&s, "#","|", NULL, "");
+ r = iReplaceManyS(&s, "#","|", NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
free(s);
// empty old delimiter
s = strdup("qw#e");
- iReplaceManyS(&s, "","|", NULL, "");
+ r = iReplaceManyS(&s, "","|", NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw#e");
free(s);
// empty old delimiter not first
s = strdup("qw#e");
- iReplaceManyS(&s, "#","|", "", "*");
+ r = iReplaceManyS(&s, "#","|", "", "*");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
free(s);
// NULL string
s = NULL;
- iReplaceManyS(&s, "#","|", "$", "*");
+ r = iReplaceManyS(&s, "#","|", "$", "*");
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(s, NULL);
free(s);
// NULL var
- iReplaceManyS(NULL, "#","|", "$", "*");
+ r = iReplaceManyS(NULL, "#","|", "$", "*");
+ ck_assert_ptr_eq(r, null);
}
@@ -4515,17 +4956,22 @@ void iReplaceManyST(CuTest *tc UNUSED) {
void bReplaceManyST(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
+
// replace string, multiple character new delimeter
strcpy(s, "#ee#ee#ad");
- bReplaceManyS(s, "#","^^","ad","AD");
+ r = bReplaceManyS(s, "#","^^","ad","AD");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee^^ee^^AD");
// replace string, empty new delimeter
strcpy(s, "#ee#ee#ad");
- bReplaceManyS(s, "#","","ad","AD");
+ r = bReplaceManyS(s, "#","","ad","AD");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eeeeAD");
// not enough olds:news pairs
strcpy(s, "#ee#ee#ad");
- bReplaceManyS(s, "#","","ad");
+ r = bReplaceManyS(s, "#","","ad");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eeeead");
// only 2 parameters
// doesn't compile
@@ -4535,38 +4981,47 @@ void bReplaceManyST(CuTest *tc UNUSED) {
/* free(s); */
// NULL new delimiter: same as only 2 parameters or not enough olds:news pairs
strcpy(s, "#ee#ee#ad");
- bReplaceManyS(s, "#", NULL);
+ r = bReplaceManyS(s, "#", NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "#ee#ee#ad");
// empty string
bEmptyS(s);
- bReplaceManyS(s, "#", "");
+ r = bReplaceManyS(s, "#", "");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// empty string many pairs
bEmptyS(s);
- bReplaceManyS(s, "#", "", "%", "");
+ r = bReplaceManyS(s, "#", "", "%", "");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// many pairs empty olds
strcpy(s, "qw#e");
- bReplaceManyS(s, "#", "", "", "");
+ r = bReplaceManyS(s, "#", "", "", "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qwe");
// NULL old delimiter
strcpy(s, "qw#e");
- bReplaceManyS(s, NULL, "");
+ r = bReplaceManyS(s, NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw#e");
// NULL old delimiter not first - same as replace empty string
strcpy(s, "qw#e");
- bReplaceManyS(s, "#","|", NULL, "");
+ r = bReplaceManyS(s, "#","|", NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
// empty old delimiter
strcpy(s, "qw#e");
- bReplaceManyS(s, "","|", NULL, "");
+ r = bReplaceManyS(s, "","|", NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw#e");
// empty old delimiter not first
strcpy(s, "qw#e");
- bReplaceManyS(s, "#","|", "", "*");
+ r = bReplaceManyS(s, "#","|", "", "*");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
// NULL var
- ck_assert_ptr_eq(bReplaceManyS(NULL, "#","|", "$", "*"), NULL);
+ r = bReplaceManyS(NULL, "#","|", "$", "*");
+ ck_assert_ptr_eq(r, null);
}
@@ -4574,21 +5029,27 @@ void bReplaceManyST(CuTest *tc UNUSED) {
void bLReplaceManyST(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
+
// replace string, multiple character new delimeter
strcpy(s, "#ee#ee#ad");
- bLReplaceManyS(s, sizeof s, "#","^^","ad","AD");
+ r = bLReplaceManyS(s, sizeof s, "#","^^","ad","AD");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee^^ee^^AD");
// shorter buffer
strcpy(s, "#ee#ee#ad");
- bLReplaceManyS(s, 5, "#","^^","ad","AD");
+ r = bLReplaceManyS(s, 5, "#","^^","ad","AD");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee");
// replace string, empty new delimeter
strcpy(s, "#ee#ee#ad");
- bLReplaceManyS(s, sizeof s, "#","","ad","AD");
+ r = bLReplaceManyS(s, sizeof s, "#","","ad","AD");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eeeeAD");
// not enough olds:news pairs
strcpy(s, "#ee#ee#ad");
- bLReplaceManyS(s, sizeof s, "#","","ad");
+ r = bLReplaceManyS(s, sizeof s, "#","","ad");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eeeead");
// only 2 parameters
// doesn't compile
@@ -4598,41 +5059,51 @@ void bLReplaceManyST(CuTest *tc UNUSED) {
/* free(s); */
// NULL new delimiter: same as only 2 parameters or not enough olds:news pairs
strcpy(s, "#ee#ee#ad");
- bLReplaceManyS(s, sizeof s, "#", NULL);
+ r = bLReplaceManyS(s, sizeof s, "#", NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "#ee#ee#ad");
// empty string
bEmptyS(s);
- bLReplaceManyS(s, sizeof s, "#", "");
+ r = bLReplaceManyS(s, sizeof s, "#", "");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// empty string many pairs
bEmptyS(s);
- bLReplaceManyS(s, sizeof s, "#", "", "%", "");
+ r = bLReplaceManyS(s, sizeof s, "#", "", "%", "");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// many pairs empty olds
strcpy(s, "qw#e");
- bLReplaceManyS(s, sizeof s, "#", "", "", "");
+ r = bLReplaceManyS(s, sizeof s, "#", "", "", "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qwe");
// NULL old delimiter
strcpy(s, "qw#e");
- bLReplaceManyS(s, sizeof s, NULL, "");
+ r = bLReplaceManyS(s, sizeof s, NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw#e");
// NULL old delimiter not first - same as replace empty string
strcpy(s, "qw#e");
- bLReplaceManyS(s, sizeof s, "#","|", NULL, "");
+ r = bLReplaceManyS(s, sizeof s, "#","|", NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
// empty old delimiter
strcpy(s, "qw#e");
- bLReplaceManyS(s, sizeof s, "","|", NULL, "");
+ r = bLReplaceManyS(s, sizeof s, "","|", NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw#e");
// empty old delimiter not first
strcpy(s, "qw#e");
- bLReplaceManyS(s, sizeof s, "#","|", "", "*");
+ r = bLReplaceManyS(s, sizeof s, "#","|", "", "*");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
// size 0 - no change
- bLReplaceManyS(s, 0, "#","|", "", "*");
+ r = bLReplaceManyS(s, 0, "#","|", "", "*");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
// NULL var
- ck_assert_ptr_eq(bLReplaceManyS(NULL, sizeof s, "#","|", "$", "*"), NULL);
+ r = bLReplaceManyS(NULL, sizeof s, "#","|", "$", "*");
+ ck_assert_ptr_eq(r, null);
}
@@ -4695,19 +5166,24 @@ void icReplaceManyST(CuTest *tc UNUSED) {
void iicReplaceManyST(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
+
// replace string, multiple character new delimeter
s = strdup("#ee#ee#ad");
- iicReplaceManyS(&s, "#","^^","ad","vv");
+ r = iicReplaceManyS(&s, "#","^^","ad","vv");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee^^ee^^vv");
free(s);
// replace string, empty new delimeter
s = strdup("#ee#ee#ad");
- iicReplaceManyS(&s, "#","","ad","AD");
+ r = iicReplaceManyS(&s, "#","","ad","AD");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eeeeAD");
free(s);
// not enough olds:news pairs
s = strdup("#ee#ee#ad");
- iicReplaceManyS(&s, "#","","ad");
+ r = iicReplaceManyS(&s, "#","","ad");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eeeead");
free(s);
// only 2 parameters
@@ -4718,51 +5194,61 @@ void iicReplaceManyST(CuTest *tc UNUSED) {
/* free(s); */
// NULL new delimiter: same as only 2 parameters or not enough olds:news pairs
s = strdup("#ee#ee#ad");
- iicReplaceManyS(&s, "#", NULL);
+ r = iicReplaceManyS(&s, "#", NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "#ee#ee#ad");
free(s);
// empty string
emptyS(s);
- iicReplaceManyS(&s, "#", "");
+ r = iicReplaceManyS(&s, "#", "");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// empty string many pairs
emptyS(s);
- iicReplaceManyS(&s, "#", "", "%", "");
+ r = iicReplaceManyS(&s, "#", "", "%", "");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// many pairs empty olds
s = strdup("qw#e");
- iicReplaceManyS(&s, "#", "", "", "");
+ r = iicReplaceManyS(&s, "#", "", "", "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qwe");
free(s);
// NULL old delimiter
s = strdup("qw#e");
- iicReplaceManyS(&s, NULL, "");
+ r = iicReplaceManyS(&s, NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw#e");
free(s);
// NULL old delimiter not first - same as replace empty string
s = strdup("qw#e");
- iicReplaceManyS(&s, "#","|", NULL, "");
+ r = iicReplaceManyS(&s, "#","|", NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
free(s);
// empty old delimiter
s = strdup("qw#e");
- iicReplaceManyS(&s, "","|", NULL, "");
+ r = iicReplaceManyS(&s, "","|", NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw#e");
free(s);
// empty old delimiter not first
s = strdup("qw#e");
- iicReplaceManyS(&s, "#","|", "", "*");
+ r = iicReplaceManyS(&s, "#","|", "", "*");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
free(s);
// NULL string
s = NULL;
- iicReplaceManyS(&s, "#","|", "$", "*");
+ r = iicReplaceManyS(&s, "#","|", "$", "*");
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(s, NULL);
free(s);
// NULL var
- iicReplaceManyS(NULL, "#","|", "$", "*");
+ r = iicReplaceManyS(NULL, "#","|", "$", "*");
+ ck_assert_ptr_eq(r, null);
}
@@ -4771,17 +5257,22 @@ void iicReplaceManyST(CuTest *tc UNUSED) {
void bicReplaceManyST(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
+
// replace string, multiple character new delimeter
strcpy(s, "#ee#ee#ad");
- bicReplaceManyS(s, "#","^^","AD","vv");
+ r = bicReplaceManyS(s, "#","^^","AD","vv");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee^^ee^^vv");
// replace string, empty new delimeter
strcpy(s, "#ee#ee#ad");
- bicReplaceManyS(s, "#","","ad","AD");
+ r = bicReplaceManyS(s, "#","","ad","AD");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eeeeAD");
// not enough olds:news pairs
strcpy(s, "#ee#ee#ad");
- bicReplaceManyS(s, "#","","ad");
+ r = bicReplaceManyS(s, "#","","ad");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eeeead");
// only 2 parameters
// doesn't compile
@@ -4791,38 +5282,47 @@ void bicReplaceManyST(CuTest *tc UNUSED) {
/* free(s); */
// NULL new delimiter: same as only 2 parameters or not enough olds:news pairs
strcpy(s, "#ee#ee#ad");
- bicReplaceManyS(s, "#", NULL);
+ r = bicReplaceManyS(s, "#", NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "#ee#ee#ad");
// empty string
bEmptyS(s);
- bicReplaceManyS(s, "#", "");
+ r = bicReplaceManyS(s, "#", "");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// empty string many pairs
bEmptyS(s);
- bicReplaceManyS(s, "#", "", "%", "");
+ r = bicReplaceManyS(s, "#", "", "%", "");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// many pairs empty olds
strcpy(s, "qw#e");
- bicReplaceManyS(s, "#", "", "", "");
+ r = bicReplaceManyS(s, "#", "", "", "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qwe");
// NULL old delimiter
strcpy(s, "qw#e");
- bicReplaceManyS(s, NULL, "");
+ r = bicReplaceManyS(s, NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw#e");
// NULL old delimiter not first - same as replace empty string
strcpy(s, "qw#e");
- bicReplaceManyS(s, "#","|", NULL, "");
+ r = bicReplaceManyS(s, "#","|", NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
// empty old delimiter
strcpy(s, "qw#e");
- bicReplaceManyS(s, "","|", NULL, "");
+ r = bicReplaceManyS(s, "","|", NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw#e");
// empty old delimiter not first
strcpy(s, "qw#e");
- bicReplaceManyS(s, "#","|", "", "*");
+ r = bicReplaceManyS(s, "#","|", "", "*");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
// NULL var
- ck_assert_ptr_eq(bicReplaceManyS(NULL, "#","|", "$", "*"), NULL);
+ r = bicReplaceManyS(NULL, "#","|", "$", "*");
+ ck_assert_ptr_eq(r, null);
}
@@ -4831,21 +5331,27 @@ void bicReplaceManyST(CuTest *tc UNUSED) {
void bLicReplaceManyST(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
+
// replace string, multiple character new delimeter
strcpy(s, "#ee#ee#ad");
- bLicReplaceManyS(s, sizeof s, "#","^^","AD","vv");
+ r = bLicReplaceManyS(s, sizeof s, "#","^^","AD","vv");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee^^ee^^vv");
// shorter buffer
strcpy(s, "#ee#ee#ad");
- bLicReplaceManyS(s, 5, "#","^^","ad","AD");
+ r = bLicReplaceManyS(s, 5, "#","^^","ad","AD");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee");
// replace string, empty new delimeter
strcpy(s, "#ee#ee#ad");
- bLicReplaceManyS(s, sizeof s, "#","","ad","AD");
+ r = bLicReplaceManyS(s, sizeof s, "#","","ad","AD");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eeeeAD");
// not enough olds:news pairs
strcpy(s, "#ee#ee#ad");
- bLicReplaceManyS(s, sizeof s, "#","","ad");
+ r = bLicReplaceManyS(s, sizeof s, "#","","ad");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eeeead");
// only 2 parameters
// doesn't compile
@@ -4855,41 +5361,51 @@ void bLicReplaceManyST(CuTest *tc UNUSED) {
/* free(s); */
// NULL new delimiter: same as only 2 parameters or not enough olds:news pairs
strcpy(s, "#ee#ee#ad");
- bLicReplaceManyS(s, sizeof s, "#", NULL);
+ r = bLicReplaceManyS(s, sizeof s, "#", NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "#ee#ee#ad");
// empty string
bEmptyS(s);
- bLicReplaceManyS(s, sizeof s, "#", "");
+ r = bLicReplaceManyS(s, sizeof s, "#", "");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// empty string many pairs
bEmptyS(s);
- bLicReplaceManyS(s, sizeof s, "#", "", "%", "");
+ r = bLicReplaceManyS(s, sizeof s, "#", "", "%", "");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// many pairs empty olds
strcpy(s, "qw#e");
- bLicReplaceManyS(s, sizeof s, "#", "", "", "");
+ r = bLicReplaceManyS(s, sizeof s, "#", "", "", "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qwe");
// NULL old delimiter
strcpy(s, "qw#e");
- bLicReplaceManyS(s, sizeof s, NULL, "");
+ r = bLicReplaceManyS(s, sizeof s, NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw#e");
// NULL old delimiter not first - same as replace empty string
strcpy(s, "qw#e");
- bLicReplaceManyS(s, sizeof s, "#","|", NULL, "");
+ r = bLicReplaceManyS(s, sizeof s, "#","|", NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
// empty old delimiter
strcpy(s, "qw#e");
- bLicReplaceManyS(s, sizeof s, "","|", NULL, "");
+ r = bLicReplaceManyS(s, sizeof s, "","|", NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw#e");
// empty old delimiter not first
strcpy(s, "qw#e");
- bLicReplaceManyS(s, sizeof s, "#","|", "", "*");
+ r = bLicReplaceManyS(s, sizeof s, "#","|", "", "*");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
// size 0 - no change
- bLicReplaceManyS(s, 0, "#","|", "", "*");
+ r = bLicReplaceManyS(s, 0, "#","|", "", "*");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
// NULL var
- ck_assert_ptr_eq(bLicReplaceManyS(NULL, sizeof s, "#","|", "$", "*"), NULL);
+ r = bLicReplaceManyS(NULL, sizeof s, "#","|", "$", "*");
+ ck_assert_ptr_eq(r, null);
}
@@ -5382,11 +5898,13 @@ void bStripCtrlST(CuTest *tc UNUSED) {
char s[40];
// string with control char
- strLCpy(s, sizeof(s), "\tsheepy\n");
+ r = strLCpy(s, sizeof(s), "\tsheepy\n");
+ ck_assert_ptr_eq(r, s);
r = bStripCtrlS(s);
ck_assert_str_eq(r, "sheepy");
// no control char
- strLCpy(s, sizeof(s), "sheepy");
+ r = strLCpy(s, sizeof(s), "sheepy");
+ ck_assert_ptr_eq(r, s);
r = bStripCtrlS(s);
ck_assert_str_eq(r, "sheepy");
// null string
@@ -5397,6 +5915,282 @@ void bStripCtrlST(CuTest *tc UNUSED) {
}
+void quoteST(CuTest *tc UNUSED) {
+
+ char *r;
+
+ // no change
+ r = quoteS("abc", '"');
+ ck_assert_str_eq(r, "abc");
+ free(r);
+ // add backslashes
+ r = quoteS("\"abc\\", '"');
+ ck_assert_str_eq(r, "\\\"abc\\\\");
+ free(r);
+ // null string
+ ck_assert_ptr_eq(quoteS(null, 0), null);
+
+}
+
+
+void bQuoteST(CuTest *tc UNUSED) {
+
+ char *r;
+ char s[40];
+
+ // no change
+ r = bQuoteS(s, "abc", '"');
+ ck_assert_str_eq(r, "abc");
+ // add backslashes
+ r = bQuoteS(s, "\"abc\\", '"');
+ ck_assert_str_eq(r, "\\\"abc\\\\");
+ // null string
+ ck_assert_ptr_eq(bQuoteS(s, null, 0), null);
+ // null dest
+ ck_assert_ptr_eq(bQuoteS(null, "asd", 0), null);
+
+}
+
+
+void bLQuoteST(CuTest *tc UNUSED) {
+
+ char *r;
+ char s[40];
+
+ // no change
+ r = bLQuoteS(s, sizeof(s), "abc", '"');
+ ck_assert_str_eq(r, "abc");
+ // add backslashes
+ r = bLQuoteS(s, sizeof(s), "\"abc\\", '"');
+ ck_assert_str_eq(r, "\\\"abc\\\\");
+ // too small dest buffer
+ r = bLQuoteS(s, 3, "abc", '"');
+ ck_assert_str_eq(r, "ab");
+ r = bLQuoteS(s, 3, "a\\\"", '"');
+ ck_assert_str_eq(r, "a");
+ r = bLQuoteS(s, 3, "ab\"", '"');
+ ck_assert_str_eq(r, "ab");
+ // null string
+ ck_assert_ptr_eq(bLQuoteS(s, 10, null, 0), null);
+ // null dest
+ ck_assert_ptr_eq(bLQuoteS(null, 10, "asd", 0), null);
+ // 0 dest size
+ ck_assert_ptr_eq(bLQuoteS(s, 0, "asd", 0), null);
+
+}
+
+
+void quoteLenST(CuTest *tc UNUSED) {
+
+ size_t r;
+
+ // no change
+ r = quoteLenS("abc", '"');
+ ck_assert_int_eq(r, 3);
+ // add backslashes
+ r = quoteLenS("\"abc\\", '"');
+ ck_assert_int_eq(r, 7);
+ // null string
+ ck_assert_int_eq(quoteLenS(null, 0), 0);
+
+}
+
+
+void escapeST(CuTest *tc UNUSED) {
+
+ char *r;
+
+ // no change
+ r = escapeS("abc", '"');
+ ck_assert_str_eq(r, "abc");
+ free(r);
+ // add backslashes
+ r = escapeS("\b\f\r\t\"abc\n\\", '"');
+ ck_assert_str_eq(r, "\\b\\f\\r\\t\\\"abc\\n\\\\");
+ free(r);
+ // null string
+ ck_assert_ptr_eq(escapeS(null, 0), null);
+
+}
+
+
+void bEscapeST(CuTest *tc UNUSED) {
+
+ char *r;
+ char s[40];
+
+ // no change
+ r = bEscapeS(s, "abc", '"');
+ ck_assert_str_eq(r, "abc");
+ // add backslashes
+ r = bEscapeS(s, "\b\f\r\t\"abc\n\\", '"');
+ ck_assert_str_eq(r, "\\b\\f\\r\\t\\\"abc\\n\\\\");
+ // null string
+ ck_assert_ptr_eq(bEscapeS(s, null, 0), null);
+ // null dest
+ ck_assert_ptr_eq(bEscapeS(null, "asd", 0), null);
+
+}
+
+
+void bLEscapeST(CuTest *tc UNUSED) {
+
+ char *r;
+ char s[40];
+
+ // no change
+ r = bLEscapeS(s, sizeof(s), "abc", '"');
+ ck_assert_str_eq(r, "abc");
+ // add backslashes
+ r = bLEscapeS(s, sizeof(s), "\b\f\r\t\"abc\n\\", '"');
+ ck_assert_str_eq(r, "\\b\\f\\r\\t\\\"abc\\n\\\\");
+ // too small dest buffer
+ r = bLEscapeS(s, 3, "abc", '"');
+ ck_assert_str_eq(r, "ab");
+ r = bLEscapeS(s, 3, "a\\\"", '"');
+ ck_assert_str_eq(r, "a");
+ r = bLEscapeS(s, 3, "ab\"", '"');
+ ck_assert_str_eq(r, "ab");
+ r = bLEscapeS(s, 3, "a\t", '"');
+ ck_assert_str_eq(r, "a");
+ // null string
+ ck_assert_ptr_eq(bLEscapeS(s, 10, null, 0), null);
+ // null dest
+ ck_assert_ptr_eq(bLEscapeS(null, 10, "asd", 0), null);
+ // 0 dest size
+ ck_assert_ptr_eq(bLEscapeS(s, 0, "asd", 0), null);
+
+}
+
+
+void escapeLenST(CuTest *tc UNUSED) {
+
+ size_t r;
+
+ // no change
+ r = escapeLenS("abc", '"');
+ ck_assert_int_eq(r, 3);
+ // add backslashes
+ r = escapeLenS("\"abc\b", '"');
+ ck_assert_int_eq(r, 7);
+ // null string
+ ck_assert_int_eq(escapeLenS(null, 0), 0);
+
+}
+
+
+void nibbleToHexT(CuTest *tc UNUSED) {
+
+ char r;
+
+ r = nibbleToHex(9);
+ ck_assert_int_eq(r, '9');
+ r = nibbleToHex(15);
+ ck_assert_int_eq(r, 'F');
+ // out of range
+ r = nibbleToHex(30);
+ ck_assert_int_eq(r, 'X');
+
+}
+
+
+void cEscapeST(CuTest *tc UNUSED) {
+
+ char *r;
+
+ // no change
+ r = cEscapeS("abc");
+ ck_assert_str_eq(r, "abc");
+ free(r);
+ // add backslashes
+ r = cEscapeS("\n\a\b\f\r\t\"ab\x03\v\\");
+ ck_assert_str_eq(r, "\\n\\a\\b\\f\\r\\t\\\"ab\"\"\\x03\"\"\\v\\\\");
+ free(r);
+ // null string
+ ck_assert_ptr_eq(cEscapeS(null), null);
+
+}
+
+
+void bCEscapeST(CuTest *tc UNUSED) {
+
+ char *r;
+ char s[40];
+
+ // no change
+ r = bCEscapeS(s, "abc");
+ ck_assert_str_eq(r, "abc");
+ // add backslashes
+ r = bCEscapeS(s, "\n\a\b\f\r\t\"ab\x03\v\\");
+ ck_assert_str_eq(r, "\\n\\a\\b\\f\\r\\t\\\"ab\"\"\\x03\"\"\\v\\\\");
+ // null string
+ ck_assert_ptr_eq(bCEscapeS(s, null), null);
+ // null dest
+ ck_assert_ptr_eq(bCEscapeS(null, "asd"), null);
+
+}
+
+
+void bLCEscapeST(CuTest *tc UNUSED) {
+
+ char *r;
+ char s[40];
+
+ // no change
+ r = bLCEscapeS(s, sizeof(s), "abc");
+ ck_assert_str_eq(r, "abc");
+ // add backslashes
+ r = bLCEscapeS(s, sizeof(s), "\n\a\b\f\r\t\"ab\x03\v\\");
+ ck_assert_str_eq(r, "\\n\\a\\b\\f\\r\\t\\\"ab\"\"\\x03\"\"\\v\\\\");
+ // too small dest buffer
+ r = bLCEscapeS(s, 3, "abc");
+ ck_assert_str_eq(r, "ab");
+ r = bLCEscapeS(s, 3, "a\\\"");
+ ck_assert_str_eq(r, "a");
+ r = bLCEscapeS(s, 3, "ab\"");
+ ck_assert_str_eq(r, "ab");
+ r = bLCEscapeS(s, 3, "a\a");
+ ck_assert_str_eq(r, "a");
+ r = bLCEscapeS(s, 3, "a\b");
+ ck_assert_str_eq(r, "a");
+ r = bLCEscapeS(s, 3, "a\t");
+ ck_assert_str_eq(r, "a");
+ r = bLCEscapeS(s, 3, "a\n");
+ ck_assert_str_eq(r, "a");
+ r = bLCEscapeS(s, 3, "a\v");
+ ck_assert_str_eq(r, "a");
+ r = bLCEscapeS(s, 3, "a\f");
+ ck_assert_str_eq(r, "a");
+ r = bLCEscapeS(s, 3, "a\r");
+ ck_assert_str_eq(r, "a");
+ r = bLCEscapeS(s, 3, "a\x01");
+ ck_assert_str_eq(r, "a");
+ // null string
+ ck_assert_ptr_eq(bLCEscapeS(s, 10, null), null);
+ // null dest
+ ck_assert_ptr_eq(bLCEscapeS(null, 10, "asd"), null);
+ // 0 dest size
+ ck_assert_ptr_eq(bLCEscapeS(s, 0, "asd"), null);
+
+}
+
+
+void cEscapeLenST(CuTest *tc UNUSED) {
+
+ size_t r;
+
+ // no change
+ r = cEscapeLenS("abc");
+ ck_assert_int_eq(r, 3);
+ // add backslashes
+ r = cEscapeLenS("\"abc\b\x01");
+ ck_assert_int_eq(r, 15);
+ // null string
+ ck_assert_int_eq(cEscapeLenS(null), 0);
+
+}
+
+
void isNumberT(CuTest *tc UNUSED) {
// number
@@ -5477,7 +6271,8 @@ void parseIntT(CuTest *tc UNUSED) {
ck_assert_int_eq(parseInt("lib123sheepy"), 123);
ck_assert_int_eq(parseInt("-123"), -123);
// out of range - TODO check stderr
- parseInt("999999999999999999999999999999999999999");
+ int r = parseInt("999999999999999999999999999999999999999");
+ ck_assert_int_eq(r, -1);
// string without number
ck_assert_int_eq(parseInt("sheepy"), 0);
// NULL string
@@ -5506,7 +6301,8 @@ void parseI64T(CuTest *tc UNUSED) {
ck_assert_int_eq(parseI64("lib123sheepy"), 123);
ck_assert_int_eq(parseI64("-123"), -123);
// out of range - TODO check stderr
- parseI64("999999999999999999999999999999999999999");
+ int r = parseI64("999999999999999999999999999999999999999");
+ ck_assert_int_eq(r, -1);
// string without number
ck_assert_int_eq(parseI64("sheepy"), 0);
// NULL string
@@ -5537,7 +6333,8 @@ void parseDoubleT(CuTest *tc UNUSED) {
ck_assert_int_eq(parseDouble("lib123sheepy"), 123);
ck_assert_int_eq(parseDouble("-123"), -123);
// out of range - TODO check stderr
- parseDouble("999999999999999999999999999999999999999");
+ int r = parseDouble("999999999999999999999999999999999999999");
+ ck_assert_int_eq(r, -2147483648);
// string without number
ck_assert_int_eq(parseDouble("sheepy"), 0);
// NULL string
@@ -5593,12 +6390,17 @@ void bIntToST(CuTest *tc UNUSED) {
// number
char s[50];
- bIntToS(s, 123);
+ char *r = null;
+
+ r = bIntToS(s, 123);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "123");
- bIntToS(s, -465464123);
+ r = bIntToS(s, -465464123);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "-465464123");
// NULL
- ck_assert_ptr_eq(bIntToS(NULL, 123), NULL);
+ r = bIntToS(NULL, 123);
+ ck_assert_ptr_eq(r, null);
}
@@ -5620,12 +6422,17 @@ void bDoubleToST(CuTest *tc UNUSED) {
// number
char s[256];
- bDoubleToS(s, 123.4);
+ char *r = null;
+
+ r = bDoubleToS(s, 123.4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "1.234000e+02");
- bDoubleToS(s, -4652445e5);
+ r = bDoubleToS(s, -4652445e5);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "-4.652445e+11");
// NULL
- ck_assert_ptr_eq(bDoubleToS(NULL, 123.4), NULL);
+ r = bDoubleToS(NULL, 123.4);
+ ck_assert_ptr_eq(r, null);
}
@@ -5665,17 +6472,22 @@ void upperST(CuTest *tc UNUSED) {
void iUpperST(CuTest *tc UNUSED) {
char *s;
+ char *r;
+
// string
s = strdup("sheepy");
- iUpperS(&s);
+ r = iUpperS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHEEPY");
free(s);
// NULL string
s = NULL;
- iUpperS(&s);
+ r = iUpperS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_ptr_eq(s, NULL);
// NULL var
- iUpperS(NULL);
+ r = iUpperS(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -5683,12 +6495,16 @@ void iUpperST(CuTest *tc UNUSED) {
void bUpperST(CuTest *tc UNUSED) {
char s[50];
+ char *r = null;
+
// string
strcpy(s, "sheepy");
- bUpperS(s);
+ r = bUpperS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHEEPY");
// NULL var
- ck_assert_ptr_eq(bUpperS(NULL), NULL);
+ r = bUpperS(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -5708,17 +6524,22 @@ void lowerST(CuTest *tc UNUSED) {
void iLowerST(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
+
// string
s = strdup("SHEEPY");
- iLowerS(&s);
+ r = iLowerS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepy");
free(s);
// NULL string
s = NULL;
- iLowerS(&s);
+ r = iLowerS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_ptr_eq(s, NULL);
// NULL var
- iLowerS(NULL);
+ r = iLowerS(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -5726,12 +6547,16 @@ void iLowerST(CuTest *tc UNUSED) {
void bLowerST(CuTest *tc UNUSED) {
char s[50];
+ char *r = null;
+
// string
strcpy(s, "SHEEPY");
- bLowerS(s);
+ r = bLowerS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepy");
// NULL var
- ck_assert_ptr_eq(bLowerS(NULL), NULL);
+ r = bLowerS(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -5767,37 +6592,46 @@ void trimST(CuTest *tc UNUSED) {
void iTrimST(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
+
// no spaces
s = strdup("SHeePY");
- iTrimS(&s);
+ r = iTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
free(s);
// heading spaces
s = strdup(" SHeePY");
- iTrimS(&s);
+ r = iTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
free(s);
// trailing spaces
s = strdup("SHeePY ");
- iTrimS(&s);
+ r = iTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
free(s);
// string with spaces in the middle
s = strdup(" SHe ePY ");
- iTrimS(&s);
+ r = iTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHe ePY");
free(s);
// all spaces
s = strdup(" ");
- iTrimS(&s);
+ r = iTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
free(s);
// NULL string
s = NULL;
- iTrimS(&s);
+ r = iTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_ptr_eq(s, NULL);
// NULL var
- iTrimS(NULL);
+ r = iTrimS(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -5805,28 +6639,36 @@ void iTrimST(CuTest *tc UNUSED) {
void bTrimST(CuTest *tc UNUSED) {
char s[50];
+ char *r = null;
+
// no spaces
strcpy(s, "SHeePY");
- bTrimS(s);
+ r = bTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
// heading spaces
strcpy(s, " SHeePY");
- bTrimS(s);
+ r = bTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
// trailing spaces
strcpy(s, "SHeePY ");
- bTrimS(s);
+ r = bTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
// string with spaces in the middle
strcpy(s, " SHe ePY ");
- bTrimS(s);
+ r = bTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHe ePY");
// all spaces
strcpy(s, " ");
- bTrimS(s);
+ r = bTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// NULL var
- ck_assert_ptr_eq(bTrimS(NULL), NULL);
+ r = bTrimS(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -5862,37 +6704,46 @@ void lTrimST(CuTest *tc UNUSED) {
void iLTrimST(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
+
// no spaces
s = strdup("SHeePY");
- iLTrimS(&s);
+ r = iLTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
free(s);
// heading spaces
s = strdup(" SHeePY");
- iLTrimS(&s);
+ r = iLTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
free(s);
// trailing spaces
s = strdup("SHeePY ");
- iLTrimS(&s);
+ r = iLTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY ");
free(s);
// string with spaces in the middle
s = strdup(" SHe ePY ");
- iLTrimS(&s);
+ r = iLTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHe ePY ");
free(s);
// all spaces
s = strdup(" ");
- iLTrimS(&s);
+ r = iLTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
free(s);
// NULL string
s = NULL;
- iLTrimS(&s);
+ r = iLTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_ptr_eq(s, NULL);
// NULL var
- iLTrimS(NULL);
+ r = iLTrimS(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -5900,28 +6751,36 @@ void iLTrimST(CuTest *tc UNUSED) {
void bLTrimST(CuTest *tc UNUSED) {
char s[50];
+ char *r = null;
+
// no spaces
strcpy(s, "SHeePY");
- bLTrimS(s);
+ r = bLTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
// heading spaces
strcpy(s, " SHeePY");
- bLTrimS(s);
+ r = bLTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
// trailing spaces
strcpy(s, "SHeePY ");
- bLTrimS(s);
+ r = bLTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY ");
// string with spaces in the middle
strcpy(s, " SHe ePY ");
- bLTrimS(s);
+ r = bLTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHe ePY ");
// all spaces
strcpy(s, " ");
- bLTrimS(s);
+ r = bLTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// NULL var
- ck_assert_ptr_eq(bLTrimS(NULL), NULL);
+ r = bLTrimS(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -5957,37 +6816,46 @@ void rTrimST(CuTest *tc UNUSED) {
void iRTrimST(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
+
// no spaces
s = strdup("SHeePY");
- iRTrimS(&s);
+ r = iRTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
free(s);
// heading spaces
s = strdup(" SHeePY");
- iRTrimS(&s);
+ r = iRTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, " SHeePY");
free(s);
// trailing spaces
s = strdup("SHeePY ");
- iRTrimS(&s);
+ r = iRTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
free(s);
// string with spaces in the middle
s = strdup(" SHe ePY ");
- iRTrimS(&s);
+ r = iRTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, " SHe ePY");
free(s);
// all spaces
s = strdup(" ");
- iRTrimS(&s);
+ r = iRTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
free(s);
// NULL string
s = NULL;
- iRTrimS(&s);
+ r = iRTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_ptr_eq(s, NULL);
// NULL var
- iRTrimS(NULL);
+ r = iRTrimS(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -5995,28 +6863,36 @@ void iRTrimST(CuTest *tc UNUSED) {
void bRTrimST(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
+
// no spaces
strcpy(s, "SHeePY");
- bRTrimS(s);
+ r = bRTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
// heading spaces
strcpy(s, " SHeePY");
- bRTrimS(s);
+ r = bRTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, " SHeePY");
// trailing spaces
strcpy(s, "SHeePY ");
- bRTrimS(s);
+ r = bRTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
// string with spaces in the middle
strcpy(s, " SHe ePY ");
- bRTrimS(s);
+ r = bRTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, " SHe ePY");
// all spaces
strcpy(s, " ");
- bRTrimS(s);
+ r = bRTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// NULL var
- ck_assert_ptr_eq(bRTrimS(NULL), NULL);
+ r = bRTrimS(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -7681,31 +8557,40 @@ void getST(CuTest *tc UNUSED) {
void setST(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
+
s = strdup("sheepy");
// set char
- setS(s, 0, 'S');
+ r = setS(s, 0, 'S');
+ ck_assert_ptr_eq(r, s);
ck_assert_uint_eq(s[0], 'S');
// negative index
- setS(s, -2, 'P');
+ r = setS(s, -2, 'P');
+ ck_assert_ptr_eq(r, s);
ck_assert_uint_eq(s[4], 'P');
// outside string
- setS(s, 20, 'Y');
- setS(s, -20, 'Y');
+ r = setS(s, 20, 'Y');
+ ck_assert_ptr_eq(r, null);
+ r = setS(s, -20, 'Y');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "SheePy");
free(s);
// negative index in a one char string
s = strdup("s");
- setS(s, -1, 'S');
+ r = setS(s, -1, 'S');
+ ck_assert_ptr_eq(r, s);
ck_assert_uint_eq(s[0], 'S');
free(s);
// empty string
emptyS(s);
- setS(s, -1, 'S');
+ r = setS(s, -1, 'S');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// NULL string
- setS(NULL, 0, 's');
+ r = setS(NULL, 0, 's');
+ ck_assert_ptr_eq(r, null);
}
@@ -7949,60 +8834,74 @@ void sliceST(CuTest *tc UNUSED) {
void iSliceST(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
+
// slice
s = strdup("sheepy");
- iSliceS(&s, 0,2);
+ r = iSliceS(&s, 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
free(s);
// negative index
s = strdup("sheepy");
- iSliceS(&s, -2,0);
+ r = iSliceS(&s, -2,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "py");
free(s);
// positive and negative indexes
s = strdup("sheepy");
- iSliceS(&s, 2,-2);
+ r = iSliceS(&s, 2,-2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ee");
free(s);
// start = end
s = strdup("sheepy");
- iSliceS(&s, 2,-4);
+ r = iSliceS(&s, 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
free(s);
// end of string
s = strdup("sheepy");
- iSliceS(&s, 2,6);
+ r = iSliceS(&s, 2,6);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
free(s);
// NULL string
s = NULL;
- iSliceS(&s, 2,-4);
+ r = iSliceS(&s, 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_ptr_eq(s, NULL);
// start outside string
s = strdup("sheepy");
- iSliceS(&s, 20,-4);
+ r = iSliceS(&s, 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// end outside string
s = strdup("sheepy");
- iSliceS(&s, 2,40);
+ r = iSliceS(&s, 2,40);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
free(s);
s = strdup("sheepy");
- iSliceS(&s, -22,3);
+ r = iSliceS(&s, -22,3);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "she");
free(s);
s = strdup("sheepy");
- iSliceS(&s, 2,-40);
+ r = iSliceS(&s, 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// end before start
s = strdup("sheepy");
- iSliceS(&s, 4,2);
+ r = iSliceS(&s, 4,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// NULL var
- iSliceS(NULL, 0, 0);
+ r = iSliceS(NULL, 0, 0);
+ ck_assert_ptr_eq(r, null);
}
@@ -8010,46 +8909,59 @@ void iSliceST(CuTest *tc UNUSED) {
void bSliceST(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
+
// slice
strcpy(s, "sheepy");
- bSliceS(s, 0,2);
+ r = bSliceS(s, 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
// negative index
strcpy(s, "sheepy");
- bSliceS(s, -2,0);
+ r = bSliceS(s, -2,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "py");
// positive and negative indexes
strcpy(s, "sheepy");
- bSliceS(s, 2,-2);
+ r = bSliceS(s, 2,-2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ee");
// start = end
strcpy(s, "sheepy");
- bSliceS(s, 2,-4);
+ r = bSliceS(s, 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// end of string
strcpy(s, "sheepy");
- bSliceS(s, 2,6);
+ r = bSliceS(s, 2,6);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
// start outside string
strcpy(s, "sheepy");
- bSliceS(s, 20,-4);
+ r = bSliceS(s, 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// end outside string
strcpy(s, "sheepy");
- bSliceS(s, 2,40);
+ r = bSliceS(s, 2,40);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
strcpy(s, "sheepy");
- bSliceS(s, -22,3);
+ r = bSliceS(s, -22,3);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "she");
strcpy(s, "sheepy");
- bSliceS(s, 2,-40);
+ r = bSliceS(s, 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// end before start
strcpy(s, "sheepy");
- bSliceS(s, 4,2);
+ r = bSliceS(s, 4,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// NULL var
- ck_assert_ptr_eq(bSliceS(NULL, 0, 0), NULL);
+ r = bSliceS(NULL, 0, 0);
+ ck_assert_ptr_eq(r, null);
}
@@ -8057,52 +8969,67 @@ void bSliceST(CuTest *tc UNUSED) {
void bLSliceST(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
+
// slice
strcpy(s, "sheepy");
- bLSliceS(s, sizeof(s), 0,2);
+ r = bLSliceS(s, sizeof(s), 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
// buffer shorter than string
strcpy(s, "sheepy");
- bLSliceS(s, 5, 0,2);
+ r = bLSliceS(s, 5, 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
// negative index
strcpy(s, "sheepy");
- bLSliceS(s, sizeof(s), -2,0);
+ r = bLSliceS(s, sizeof(s), -2,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "py");
// positive and negative indexes
strcpy(s, "sheepy");
- bLSliceS(s, sizeof(s), 2,-2);
+ r = bLSliceS(s, sizeof(s), 2,-2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ee");
// start = end
strcpy(s, "sheepy");
- bLSliceS(s, sizeof(s), 2,-4);
+ r = bLSliceS(s, sizeof(s), 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// end of string
strcpy(s, "sheepy");
- bLSliceS(s, sizeof(s), 2,6);
+ r = bLSliceS(s, sizeof(s), 2,6);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
// start outside string
strcpy(s, "sheepy");
- bLSliceS(s, sizeof(s), 20,-4);
+ r = bLSliceS(s, sizeof(s), 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// end outside string
strcpy(s, "sheepy");
- bLSliceS(s, sizeof(s), 2,40);
+ r = bLSliceS(s, sizeof(s), 2,40);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
strcpy(s, "sheepy");
- bLSliceS(s, sizeof(s), -22,3);
+ r = bLSliceS(s, sizeof(s), -22,3);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "she");
strcpy(s, "sheepy");
- bLSliceS(s, sizeof(s), 2,-40);
+ r = bLSliceS(s, sizeof(s), 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// end before start
strcpy(s, "sheepy");
- bLSliceS(s, sizeof(s), 4,2);
+ r = bLSliceS(s, sizeof(s), 4,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// size 0
- ck_assert_ptr_eq(bLSliceS(s, 0, 0, 0), NULL);
+ r = bLSliceS(s, 0, 0, 0);
+ ck_assert_ptr_eq(r, null);
// NULL var
- ck_assert_ptr_eq(bLSliceS(NULL, sizeof(s), 0, 0), NULL);
+ r = bLSliceS(NULL, sizeof(s), 0, 0);
+ ck_assert_ptr_eq(r, null);
}
@@ -8427,60 +9354,73 @@ void insertNFreeST(CuTest *tc UNUSED) {
void iInsertST(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
// insert
s = strdup("sheepy");
- iInsertS(&s, 0, "lib");
+ r = iInsertS(&s, 0, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
free(s);
// negative index
s = strdup("libsheepy");
- iInsertS(&s, -2, "P");
+ r = iInsertS(&s, -2, "P");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepPy");
free(s);
// edge
s = strdup("qwe");
- iInsertS(&s, 3, "C");
+ r = iInsertS(&s, 3, "C");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qweC");
free(s);
// outside string
s = strdup("qwe");
- iInsertS(&s, 4, "C");
+ r = iInsertS(&s, 4, "C");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
- iInsertS(&s, -5, "C");
+ r = iInsertS(&s, -5, "C");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
free(s);
// negative index in a one char string
s = strdup("s");
- iInsertS(&s, -1, "S");
+ r = iInsertS(&s, -1, "S");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sS");
free(s);
// empty string
emptyS(s);
- iInsertS(&s, 0, "s");
+ r = iInsertS(&s, 0, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
emptyS(s);
- iInsertS(&s, -1, "s");
+ r = iInsertS(&s, -1, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
// empty insert string
s = strdup("a");
- iInsertS(&s, 0, "");
+ r = iInsertS(&s, 0, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
free(s);
// NULL insert string
s = strdup("a");
- iInsertS(&s, 0, NULL);
+ r = iInsertS(&s, 0, NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
free(s);
// NULL string
s = NULL;
- iInsertS(&s, 0, "s");
+ r = iInsertS(&s, 0, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
// NULL var
- iInsertS(NULL, 0, "s");
+ r = iInsertS(NULL, 0, "s");
+ ck_assert_ptr_eq(r, null);
}
@@ -8491,17 +9431,20 @@ void iInsertNFreeST(CuTest *tc UNUSED) {
// insert
s = strdup("sheepy");
- iInsertNFreeS(&s, 0, strdup("lib"));
+ r = iInsertNFreeS(&s, 0, strdup("lib"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
free(s);
// negative index
s = strdup("libsheepy");
- iInsertNFreeS(&s, -2, strdup("P"));
+ r = iInsertNFreeS(&s, -2, strdup("P"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepPy");
free(s);
// edge
s = strdup("qwe");
- iInsertNFreeS(&s, 3, strdup("C"));
+ r = iInsertNFreeS(&s, 3, strdup("C"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qweC");
free(s);
// outside string
@@ -8517,31 +9460,37 @@ void iInsertNFreeST(CuTest *tc UNUSED) {
free(s);
// negative index in a one char string
s = strdup("s");
- iInsertNFreeS(&s, -1, strdup("S"));
+ r = iInsertNFreeS(&s, -1, strdup("S"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sS");
free(s);
// empty string
emptyS(s);
- iInsertNFreeS(&s, 0, strdup("s"));
+ r = iInsertNFreeS(&s, 0, strdup("s"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
emptyS(s);
- iInsertNFreeS(&s, -1, strdup("s"));
+ r = iInsertNFreeS(&s, -1, strdup("s"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
// empty insert string
s = strdup("a");
- iInsertNFreeS(&s, 0, strdup(""));
+ r = iInsertNFreeS(&s, 0, strdup(""));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
free(s);
// NULL insert string
s = strdup("a");
- iInsertNFreeS(&s, 0, NULL);
+ r = iInsertNFreeS(&s, 0, NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
free(s);
// NULL string
s = NULL;
- iInsertNFreeS(&s, 0, strdup("s"));
+ r = iInsertNFreeS(&s, 0, strdup("s"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
// NULL var
@@ -8556,46 +9505,58 @@ void iInsertNFreeST(CuTest *tc UNUSED) {
void bInsertST(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
// insert
strcpy(s, "sheepy");
- bInsertS(s, 0, "lib");
+ r = bInsertS(s, 0, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// negative index
strcpy(s, "libsheepy");
- bInsertS(s, -2, "P");
+ r = bInsertS(s, -2, "P");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepPy");
// edge
strcpy(s, "qwe");
- bInsertS(s, 3, "C");
+ r = bInsertS(s, 3, "C");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qweC");
// outside string
strcpy(s, "qwe");
- bInsertS(s, 4, "C");
+ r = bInsertS(s, 4, "C");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
- bInsertS(s, -5, "C");
+ r = bInsertS(s, -5, "C");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// negative index in a one char string
strcpy(s, "s");
- bInsertS(s, -1, "S");
+ r = bInsertS(s, -1, "S");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sS");
// empty string
bEmptyS(s);
- bInsertS(s, 0, "s");
+ r = bInsertS(s, 0, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
bEmptyS(s);
- bInsertS(s, -1, "s");
+ r = bInsertS(s, -1, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
// empty insert string
strcpy(s, "a");
- bInsertS(s, 0, "");
+ r = bInsertS(s, 0, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
// NULL insert string
strcpy(s, "a");
- bInsertS(s, 0, NULL);
+ r = bInsertS(s, 0, NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
// NULL var
- ck_assert_ptr_eq(bInsertS(NULL, 0, "s"), NULL);
+ r = bInsertS(NULL, 0, "s");
+ ck_assert_ptr_eq(r, null);
}
@@ -8603,53 +9564,67 @@ void bInsertST(CuTest *tc UNUSED) {
void bLInsertST(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
// insert
strcpy(s, "sheepy");
- bLInsertS(s, sizeof s, 0, "lib");
+ r = bLInsertS(s, sizeof s, 0, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// shorter buffer
strcpy(s, "sheepy");
- bLInsertS(s, 5, 0, "lib");
+ r = bLInsertS(s, 5, 0, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libs");
// negative index
strcpy(s, "libsheepy");
- bLInsertS(s, sizeof s, -2, "P");
+ r = bLInsertS(s, sizeof s, -2, "P");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepPy");
// edge
strcpy(s, "qwe");
- bLInsertS(s, sizeof s, 3, "C");
+ r = bLInsertS(s, sizeof s, 3, "C");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qweC");
// outside string
strcpy(s, "qwe");
- bLInsertS(s, sizeof s, 4, "C");
+ r = bLInsertS(s, sizeof s, 4, "C");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
- bLInsertS(s, sizeof s, -5, "C");
+ r = bLInsertS(s, sizeof s, -5, "C");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// negative index in a one char string
strcpy(s, "s");
- bLInsertS(s, sizeof s, -1, "S");
+ r = bLInsertS(s, sizeof s, -1, "S");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sS");
// empty string
bEmptyS(s);
- bLInsertS(s, sizeof s, 0, "s");
+ r = bLInsertS(s, sizeof s, 0, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
bEmptyS(s);
- bLInsertS(s, sizeof s, -1, "s");
+ r = bLInsertS(s, sizeof s, -1, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
// empty insert string
strcpy(s, "a");
- bLInsertS(s, sizeof s, 0, "");
+ r = bLInsertS(s, sizeof s, 0, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
// size 0 - no change
- bLInsertS(s, 0, 0, "qwe");
+ r = bLInsertS(s, 0, 0, "qwe");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
// NULL insert string
strcpy(s, "a");
- bLInsertS(s, sizeof s, 0, NULL);
+ r = bLInsertS(s, sizeof s, 0, NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
// NULL var
- ck_assert_ptr_eq(bLInsertS(NULL, sizeof s, 0, "s"), NULL);
+ r = bLInsertS(NULL, sizeof s, 0, "s");
+ ck_assert_ptr_eq(r, null);
}
@@ -8698,50 +9673,61 @@ void injectST(CuTest *tc UNUSED) {
void iInjectST(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
// insert
s = strdup("sheepy");
- iInjectS(&s, 0, 'L');
+ r = iInjectS(&s, 0, 'L');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "Lsheepy");
free(s);
// negative index
s = strdup("libsheepy");
- iInjectS(&s, -2, 'P');
+ r = iInjectS(&s, -2, 'P');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepPy");
free(s);
// edge
s = strdup("qwe");
- iInjectS(&s, 3, 'C');
+ r = iInjectS(&s, 3, 'C');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qweC");
free(s);
// outside string
s = strdup("qwe");
- iInjectS(&s, 4, 'C');
+ r = iInjectS(&s, 4, 'C');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
- iInjectS(&s, -5, 'C');
+ r = iInjectS(&s, -5, 'C');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
free(s);
// negative index in a one char string
s = strdup("s");
- iInjectS(&s, -1, 'S');
+ r = iInjectS(&s, -1, 'S');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sS");
free(s);
// empty string
emptyS(s);
- iInjectS(&s, 0, 's');
+ r = iInjectS(&s, 0, 's');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
emptyS(s);
- iInjectS(&s, -1, 's');
+ r = iInjectS(&s, -1, 's');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
// NULL string
s = NULL;
- iInjectS(&s, 0, 's');
+ r = iInjectS(&s, 0, 's');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
// NULL var
- iInjectS(NULL, 0, 's');
+ r = iInjectS(NULL, 0, 's');
+ ck_assert_ptr_eq(r, null);
}
@@ -8749,38 +9735,48 @@ void iInjectST(CuTest *tc UNUSED) {
void bInjectST(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
// insert
strcpy(s, "sheepy");
- bInjectS(s, 0, 'L');
+ r = bInjectS(s, 0, 'L');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "Lsheepy");
// negative index
strcpy(s, "libsheepy");
- bInjectS(s, -2, 'P');
+ r = bInjectS(s, -2, 'P');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepPy");
// edge
strcpy(s, "qwe");
- bInjectS(s, 3, 'C');
+ r = bInjectS(s, 3, 'C');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qweC");
// outside string
strcpy(s, "qwe");
- bInjectS(s, 4, 'C');
+ r = bInjectS(s, 4, 'C');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
- bInjectS(s, -5, 'C');
+ r = bInjectS(s, -5, 'C');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// negative index in a one char string
strcpy(s, "s");
- bInjectS(s, -1, 'S');
+ r = bInjectS(s, -1, 'S');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sS");
// empty string
bEmptyS(s);
- bInjectS(s, 0, 's');
+ r = bInjectS(s, 0, 's');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
bEmptyS(s);
- bInjectS(s, -1, 's');
+ r = bInjectS(s, -1, 's');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
// NULL var
- ck_assert_ptr_eq(bInjectS(NULL, 0, 's'), NULL);
+ r = bInjectS(NULL, 0, 's');
+ ck_assert_ptr_eq(r, null);
}
@@ -8788,45 +9784,57 @@ void bInjectST(CuTest *tc UNUSED) {
void bLInjectST(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
// insert
strcpy(s, "sheepy");
- bLInjectS(s, sizeof s, 0, 'L');
+ r = bLInjectS(s, sizeof s, 0, 'L');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "Lsheepy");
// shorter buffer
strcpy(s, "sheepy");
- bLInjectS(s, 5, 0, 'L');
+ r = bLInjectS(s, 5, 0, 'L');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "Lshe");
// negative index
strcpy(s, "libsheepy");
- bLInjectS(s, sizeof s, -2, 'P');
+ r = bLInjectS(s, sizeof s, -2, 'P');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepPy");
// edge
strcpy(s, "qwe");
- bLInjectS(s, sizeof s, 3, 'C');
+ r = bLInjectS(s, sizeof s, 3, 'C');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qweC");
// outside string
strcpy(s, "qwe");
- bLInjectS(s, sizeof s, 4, 'C');
+ r = bLInjectS(s, sizeof s, 4, 'C');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
- bLInjectS(s, sizeof s, -5, 'C');
+ r = bLInjectS(s, sizeof s, -5, 'C');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// negative index in a one char string
strcpy(s, "s");
- bLInjectS(s, sizeof s, -1, 'S');
+ r = bLInjectS(s, sizeof s, -1, 'S');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sS");
// empty string
bEmptyS(s);
- bLInjectS(s, sizeof s, 0, 's');
+ r = bLInjectS(s, sizeof s, 0, 's');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
bEmptyS(s);
- bLInjectS(s, sizeof s, -1, 's');
+ r = bLInjectS(s, sizeof s, -1, 's');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
// size 0 - no change
- bLInjectS(s, 0, -1, 's');
+ r = bLInjectS(s, 0, -1, 's');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
// NULL var
- ck_assert_ptr_eq(bLInjectS(NULL, sizeof s, 0, 's'), NULL);
+ r = bLInjectS(NULL, sizeof s, 0, 's');
+ ck_assert_ptr_eq(r, null);
}
@@ -8877,64 +9885,65 @@ void delST(CuTest *tc UNUSED) {
void iDelST(CuTest *tc UNUSED) {
- char *s;
+ char *s, *r;
// del
s = strdup("sheepy");
- iDelS(&s, 0,2);
+ r = iDelS(&s, 0,2);
ck_assert_str_eq(s, "eepy");
free(s);
// negative index
s = strdup("sheepy");
- iDelS(&s, -2,0);
+ r = iDelS(&s, -2,0);
ck_assert_str_eq(s, "shee");
free(s);
// positive and negative indexes
s = strdup("sheepy");
- iDelS(&s, 2,-2);
+ r = iDelS(&s, 2,-2);
ck_assert_str_eq(s, "shpy");
free(s);
// start = end
s = strdup("sheepy");
- iDelS(&s, 2,-4);
+ r = iDelS(&s, 2,-4);
ck_assert_str_eq(s, "sheepy");
free(s);
// delete entire string
s = strdup("sheepy");
- iDelS(&s, 0,0);
+ r = iDelS(&s, 0,0);
ck_assert_str_eq(s, "");
free(s);
// end of string
s = strdup("sheepy");
- iDelS(&s, 2,6);
+ r = iDelS(&s, 2,6);
ck_assert_str_eq(s, "sh");
free(s);
// NULL string
s = NULL;
- iDelS(&s, 2,-4);
+ r = iDelS(&s, 2,-4);
ck_assert_ptr_eq(s, NULL);
// start outside string
s = strdup("sheepy");
- iDelS(&s, 20,-4);
+ r = iDelS(&s, 20,-4);
ck_assert_str_eq(s, "sheepy");
- iDelS(&s, -20,-4);
+ r = iDelS(&s, -20,-4);
ck_assert_str_eq(s, "eepy");
free(s);
// end outside string
s = strdup("sheepy");
- iDelS(&s, 2,40);
+ r = iDelS(&s, 2,40);
ck_assert_str_eq(s, "sh");
free(s);
s = strdup("sheepy");
- iDelS(&s, 2,-40);
+ r = iDelS(&s, 2,-40);
ck_assert_str_eq(s, "sheepy");
free(s);
// end before start
s = strdup("sheepy");
- iDelS(&s, 4,2);
+ r = iDelS(&s, 4,2);
ck_assert_str_eq(s, "sheepy");
free(s);
// NULL var
- iDelS(NULL, 4,2);
+ r = iDelS(NULL, 4,2);
+ ck_assert_ptr_eq(r, null);
}
@@ -8942,49 +9951,63 @@ void iDelST(CuTest *tc UNUSED) {
void bDelST(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
+
// del
strcpy(s, "sheepy");
- bDelS(s, 0,2);
+ r = bDelS(s, 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
// negative index
strcpy(s, "sheepy");
- bDelS(s, -2,0);
+ r = bDelS(s, -2,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "shee");
// positive and negative indexes
strcpy(s, "sheepy");
- bDelS(s, 2,-2);
+ r = bDelS(s, 2,-2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "shpy");
// start = end
strcpy(s, "sheepy");
- bDelS(s, 2,-4);
+ r = bDelS(s, 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepy");
// delete entire string
strcpy(s, "sheepy");
- bDelS(s, 0,0);
+ r = bDelS(s, 0,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// end of string
strcpy(s, "sheepy");
- bDelS(s, 2,6);
+ r = bDelS(s, 2,6);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
// start outside string
strcpy(s, "sheepy");
- bDelS(s, 20,-4);
+ r = bDelS(s, 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
- bDelS(s, -20,-4);
+ r = bDelS(s, -20,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
// end outside string
strcpy(s, "sheepy");
- bDelS(s, 2,40);
+ r = bDelS(s, 2,40);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
strcpy(s, "sheepy");
- bDelS(s, 2,-40);
+ r = bDelS(s, 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
// end before start
strcpy(s, "sheepy");
- bDelS(s, 4,2);
+ r = bDelS(s, 4,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
// NULL var
- ck_assert_ptr_eq(bDelS(NULL, 4,2), NULL);
+ r = bDelS(NULL, 4,2);
+ ck_assert_ptr_eq(r, null);
}
@@ -8992,52 +10015,67 @@ void bDelST(CuTest *tc UNUSED) {
void bLDelST(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
+
// del
strcpy(s, "sheepy");
- bLDelS(s, sizeof(s), 0,2);
+ r = bLDelS(s, sizeof(s), 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
// buffer shorter than string
strcpy(s, "sheepy");
- bLDelS(s, 5, 0,2);
+ r = bLDelS(s, 5, 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ee");
// negative index
strcpy(s, "sheepy");
- bLDelS(s, sizeof(s), -2,0);
+ r = bLDelS(s, sizeof(s), -2,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "shee");
// positive and negative indexes
strcpy(s, "sheepy");
- bLDelS(s, sizeof(s), 2,-2);
+ r = bLDelS(s, sizeof(s), 2,-2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "shpy");
// start = end
strcpy(s, "sheepy");
- bLDelS(s, sizeof(s), 2,-4);
+ r = bLDelS(s, sizeof(s), 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepy");
// end of string
strcpy(s, "sheepy");
- bLDelS(s, sizeof(s), 2,6);
+ r = bLDelS(s, sizeof(s), 2,6);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
// start outside string
strcpy(s, "sheepy");
- bLDelS(s, sizeof(s), 20,-4);
+ r = bLDelS(s, sizeof(s), 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
// end outside string
strcpy(s, "sheepy");
- bLDelS(s, sizeof(s), 2,40);
+ r = bLDelS(s, sizeof(s), 2,40);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
strcpy(s, "sheepy");
- bLDelS(s, sizeof(s), -22,3);
+ r = bLDelS(s, sizeof(s), -22,3);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "epy");
strcpy(s, "sheepy");
- bLDelS(s, sizeof(s), 2,-40);
+ r = bLDelS(s, sizeof(s), 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
// end before start
strcpy(s, "sheepy");
- bLDelS(s, sizeof(s), 4,2);
+ r = bLDelS(s, sizeof(s), 4,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
// size 0
- ck_assert_ptr_eq(bLDelS(s, 0, 0, 0), NULL);
+ r = bLDelS(s, 0, 0, 0);
+ ck_assert_ptr_eq(r, null);
// NULL var
- ck_assert_ptr_eq(bLDelS(NULL, sizeof(s), 0, 0), NULL);
+ r = bLDelS(NULL, sizeof(s), 0, 0);
+ ck_assert_ptr_eq(r, null);
}
@@ -9472,13 +10510,15 @@ void bLLenUTF8T(CuTest *tc UNUSED) {
void isUTF8T(CuTest *tc UNUSED) {
char b[8];
+ char *r = null;
// string
ck_assert(isUTF8("sheepy"));
// UTF8
ck_assert(isUTF8("sheepy£"));
// invalid UTF8
- strLCpy(b, sizeof(b), "sheepy£");
+ r = strLCpy(b, sizeof(b), "sheepy£");
+ ck_assert_ptr_eq(r, b);
ck_assert(!isUTF8(b));
// null string
ck_assert(!isUTF8(null));
@@ -9524,7 +10564,7 @@ void isCodeUTF8T(CuTest *tc UNUSED) {
void nextUTF8T(CuTest *tc UNUSED) {
- char *r;
+ const char *r;
// next
r = nextUTF8("£sheepy");
@@ -9543,7 +10583,7 @@ void nextUTF8T(CuTest *tc UNUSED) {
void bLNextUTF8T(CuTest *tc UNUSED) {
char b[20] = init0Var;
- char *r;
+ const char *r;
strcpy(b, "£sheepy");
// next
@@ -9576,7 +10616,7 @@ void bLNextUTF8T(CuTest *tc UNUSED) {
void findNextUTF8T(CuTest *tc UNUSED) {
char b[20] = init0Var;
- char *r;
+ const char *r;
strcpy(b, "£sheepy");
// next
@@ -9613,7 +10653,7 @@ void findNextUTF8T(CuTest *tc UNUSED) {
void prevUTF8T(CuTest *tc UNUSED) {
char b[20] = init0Var;
- char *r;
+ const char *r;
strcpy(b, "£sheepy");
// prev
@@ -9630,7 +10670,7 @@ void prevUTF8T(CuTest *tc UNUSED) {
void bPrevUTF8T(CuTest *tc UNUSED) {
char b[20] = init0Var;
- char *r;
+ const char *r;
strcpy(b, "£sheepy");
// prev
@@ -9651,7 +10691,7 @@ void bPrevUTF8T(CuTest *tc UNUSED) {
void idx2PtrUTF8T(CuTest *tc UNUSED) {
char *emptys = "";
- char *r;
+ const char *r;
// index
r = idx2PtrUTF8("£sheepy", 1);
@@ -9686,7 +10726,7 @@ void idx2PtrUTF8T(CuTest *tc UNUSED) {
void bLIdx2PtrUTF8T(CuTest *tc UNUSED) {
char b[20] = init0Var;
- char *r;
+ const char *r;
strcpy(b, "£sheepy");
// index
@@ -10038,30 +11078,37 @@ void strNCpyUTF8T(CuTest *tc UNUSED) {
void strLCpyUTF8T(CuTest *tc UNUSED) {
char s[1024];
+ char *r = null;
// copy string
- strLCpyUTF8(s, 100, "lib");
+ r = strLCpyUTF8(s, 100, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "lib");
// truncate src
s[0] = 0;
s[1] = 0;
s[2] = 0;
- strLCpyUTF8(s, 3, "lib");
+ r = strLCpyUTF8(s, 3, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "li");
s[0] = 'a';
s[1] = 'a';
s[2] = 'a';
s[3] = 0;
- strLCpyUTF8(s, 3, "lib");
+ r = strLCpyUTF8(s, 3, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "li");
// size 0 - no change in s
- strLCpyUTF8(s, 0, "libsheepy");
+ r = strLCpyUTF8(s, 0, "libsheepy");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "li");
// NULL
s[0] = 0;
- strLCpyUTF8(s, 1, NULL);
+ r = strLCpyUTF8(s, 1, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
- ck_assert_ptr_eq(strLCpyUTF8(NULL,1, "lib"), NULL);
+ r = strLCpyUTF8(NULL,1, "lib");
+ ck_assert_ptr_eq(r, null);
}
@@ -10070,13 +11117,17 @@ void strLCpyUTF8T(CuTest *tc UNUSED) {
void strNCatUTF8T(CuTest *tc UNUSED) {
char s[1024];
+ char *r = null;
// append string
- strCpy(s, "lib");
- strNCatUTF8(s, "sheepy", 100);
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
+ r = strNCatUTF8(s, "sheepy", 100);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// empty string2
- strNCatUTF8(s, "", 10);
+ r = strNCatUTF8(s, "", 10);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// truncate src
s[0] = 'a';
@@ -10085,18 +11136,23 @@ void strNCatUTF8T(CuTest *tc UNUSED) {
s[3] = 'a';
s[4] = 'a';
s[5] = 'a';
- strCpy(s, "lib");
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "lib");
- strNCatUTF8(s, "sheepy", 2);
+ r = strNCatUTF8(s, "sheepy", 2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsh");
// length 0
- strNCatUTF8(s, "sheepy", 0);
+ r = strNCatUTF8(s, "sheepy", 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsh");
// NULL string2
- strNCatUTF8(s, NULL, 1);
+ r = strNCatUTF8(s, NULL, 1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "libsh");
// NULL parameter
- ck_assert_ptr_eq(strNCatUTF8(NULL, "ad", 1), NULL);
+ r = strNCatUTF8(NULL, "ad", 1);
+ ck_assert_ptr_eq(r, null);
}
@@ -10105,16 +11161,21 @@ void strNCatUTF8T(CuTest *tc UNUSED) {
void strLCatUTF8T(CuTest *tc UNUSED) {
char s[1024];
+ char *r = null;
// append string
- strCpy(s, "lib");
- strLCatUTF8(s, 100, "sheepy");
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
+ r = strLCatUTF8(s, 100, "sheepy");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// empty string2
- strLCatUTF8(s, 20, "");
+ r = strLCatUTF8(s, 20, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// s strlen bigger than s size - keep s as it is
- strLCatUTF8(s, 6, "qwqwe");
+ r = strLCatUTF8(s, 6, "qwqwe");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// truncate src
s[0] = 'a';
@@ -10123,9 +11184,11 @@ void strLCatUTF8T(CuTest *tc UNUSED) {
s[3] = 'a';
s[4] = 'a';
s[5] = 'a';
- strCpy(s, "lib");
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "lib");
- strLNCat(s,100, "sheepy", 2);
+ r = strLNCat(s,100, "sheepy", 2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsh");
// truncate dst
s[0] = 'a';
@@ -10134,15 +11197,19 @@ void strLCatUTF8T(CuTest *tc UNUSED) {
s[3] = 'a';
s[4] = 'a';
s[5] = 'a';
- strCpy(s, "lib");
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "lib");
- strLCatUTF8(s, 6, "sheepy");
+ r = strLCatUTF8(s, 6, "sheepy");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsh");
// NULL string2
- strLCatUTF8(s, 1, NULL);
+ r = strLCatUTF8(s, 1, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "libsh");
// NULL parameter
- ck_assert_ptr_eq(strLCatUTF8(NULL, 1, "ad"), NULL);
+ r = strLCatUTF8(NULL, 1, "ad");
+ ck_assert_ptr_eq(r, null);
}
@@ -10151,16 +11218,21 @@ void strLCatUTF8T(CuTest *tc UNUSED) {
void strLNCatUTF8T(CuTest *tc UNUSED) {
char s[1024];
+ char *r = null;
// append string
- strCpy(s, "lib");
- strLNCatUTF8(s, 100, "sheepy", 100);
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
+ r = strLNCatUTF8(s, 100, "sheepy", 100);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// empty string2
- strLNCatUTF8(s, 20, "", 10);
+ r = strLNCatUTF8(s, 20, "", 10);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// s strlen bigger than s size - keep s as it is
- strLNCatUTF8(s, 6, "qwqwe", 1);
+ r = strLNCatUTF8(s, 6, "qwqwe", 1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// truncate dst
s[0] = 'a';
@@ -10169,18 +11241,23 @@ void strLNCatUTF8T(CuTest *tc UNUSED) {
s[3] = 'a';
s[4] = 'a';
s[5] = 'a';
- strCpy(s, "lib");
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "lib");
- strLNCatUTF8(s, 6, "sheepy", 4);
+ r = strLNCatUTF8(s, 6, "sheepy", 4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsh");
// 0 source length
- strLNCatUTF8(s, 6, "sheepy", 0);
+ r = strLNCatUTF8(s, 6, "sheepy", 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsh");
// NULL string2
- strLNCatUTF8(s, 1, NULL, 1);
+ r = strLNCatUTF8(s, 1, NULL, 1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "libsh");
// NULL parameter
- ck_assert_ptr_eq(strLNCatUTF8(NULL, 1, "ad", 1), NULL);
+ r = strLNCatUTF8(NULL, 1, "ad", 1);
+ ck_assert_ptr_eq(r, null);
}
@@ -10415,8 +11492,9 @@ void toupperUTF8T(CuTest *tc UNUSED) {
r = code2RuneUTF8("Ã¥");
r = toupperUTF8(r);
- bRune2CodeUTF8(dst,r);
+ u8 r2 = bRune2CodeUTF8(dst,r);
ck_assert_str_eq(dst, "Ã…");
+ ck_assert_int_eq(r2, 2);
}
@@ -10437,17 +11515,22 @@ void upperUTF8T(CuTest *tc UNUSED) {
void iUpperUTF8T(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
+
// string
s = strdup("sheepy");
- iUpperUTF8(&s);
+ r = iUpperUTF8(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHEEPY");
free(s);
// NULL string
s = NULL;
- iUpperUTF8(&s);
+ r = iUpperUTF8(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_ptr_eq(s, NULL);
// NULL var
- iUpperUTF8(NULL);
+ r = iUpperUTF8(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -10463,8 +11546,9 @@ void tolowerUTF8T(CuTest *tc UNUSED) {
r = code2RuneUTF8("Ã…");
r = tolowerUTF8(r);
- bRune2CodeUTF8(dst,r);
+ u8 r2 = bRune2CodeUTF8(dst,r);
ck_assert_str_eq(dst, "Ã¥");
+ ck_assert_int_eq(r2, 2);
}
@@ -10486,17 +11570,22 @@ void lowerUTF8T(CuTest *tc UNUSED) {
void iLowerUTF8T(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
+
// string
s = strdup("SHEEPY");
- iLowerUTF8(&s);
+ r = iLowerUTF8(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepy");
free(s);
// NULL string
s = NULL;
- iLowerUTF8(&s);
+ r = iLowerUTF8(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_ptr_eq(s, NULL);
// NULL var
- iLowerUTF8(NULL);
+ r = iLowerUTF8(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -10587,30 +11676,38 @@ void setUTF8T(CuTest *tc UNUSED) {
char *s;
s = strdup("sheepy");
+ char *r = null;
// set char
- setUTF8(s, 0, 'S');
+ r = setUTF8(s, 0, 'S');
+ ck_assert_ptr_eq(r, s);
ck_assert_uint_eq(s[0], 'S');
// negative index
- setUTF8(s, -2, 'P');
+ r = setUTF8(s, -2, 'P');
+ ck_assert_ptr_eq(r, s);
ck_assert_uint_eq(s[4], 'P');
// outside string
- setUTF8(s, 20, 'Y');
- setUTF8(s, -20, 'Y');
+ r = setUTF8(s, 20, 'Y');
+ ck_assert_ptr_eq(r, null);
+ r = setUTF8(s, -20, 'Y');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "SheePy");
free(s);
// negative index in a one char string
s = strdup("s");
- setUTF8(s, -1, 'S');
+ r = setUTF8(s, -1, 'S');
+ ck_assert_ptr_eq(r, s);
ck_assert_uint_eq(s[0], 'S');
free(s);
// empty string
emptyS(s);
- setUTF8(s, -1, 'S');
+ r = setUTF8(s, -1, 'S');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// NULL string
- setUTF8(NULL, 0, 's');
+ r = setUTF8(NULL, 0, 's');
+ ck_assert_ptr_eq(r, null);
}
@@ -10660,60 +11757,74 @@ void sliceUTF8T(CuTest *tc UNUSED) {
void iSliceUTF8T(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
+
// slice
s = strdup("sheepy");
- iSliceUTF8(&s, 0,2);
+ r = iSliceUTF8(&s, 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
free(s);
// negative index
s = strdup("sheepy");
- iSliceUTF8(&s, -2,0);
+ r = iSliceUTF8(&s, -2,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "py");
free(s);
// positive and negative indexes
s = strdup("sheepy");
- iSliceUTF8(&s, 2,-2);
+ r = iSliceUTF8(&s, 2,-2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ee");
free(s);
// start = end
s = strdup("sheepy");
- iSliceUTF8(&s, 2,-4);
+ r = iSliceUTF8(&s, 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
free(s);
// end of string
s = strdup("sheepy");
- iSliceUTF8(&s, 2,6);
+ r = iSliceUTF8(&s, 2,6);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
free(s);
// NULL string
s = NULL;
- iSliceUTF8(&s, 2,-4);
+ r = iSliceUTF8(&s, 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_ptr_eq(s, NULL);
// start outside string
s = strdup("sheepy");
- iSliceUTF8(&s, 20,-4);
+ r = iSliceUTF8(&s, 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// end outside string
s = strdup("sheepy");
- iSliceUTF8(&s, 2,40);
+ r = iSliceUTF8(&s, 2,40);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
free(s);
s = strdup("sheepy");
- iSliceUTF8(&s, -22,3);
+ r = iSliceUTF8(&s, -22,3);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "she");
free(s);
s = strdup("sheepy");
- iSliceUTF8(&s, 2,-40);
+ r = iSliceUTF8(&s, 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// end before start
s = strdup("sheepy");
- iSliceUTF8(&s, 4,2);
+ r = iSliceUTF8(&s, 4,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// NULL var
- iSliceUTF8(NULL, 0, 0);
+ r = iSliceUTF8(NULL, 0, 0);
+ ck_assert_ptr_eq(r, null);
}
@@ -10722,46 +11833,59 @@ void iSliceUTF8T(CuTest *tc UNUSED) {
void bSliceUTF8T(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
+
// slice
strcpy(s, "sheepy");
- bSliceUTF8(s, 0,2);
+ r = bSliceUTF8(s, 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
// negative index
strcpy(s, "sheepy");
- bSliceUTF8(s, -2,0);
+ r = bSliceUTF8(s, -2,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "py");
// positive and negative indexes
strcpy(s, "sheepy");
- bSliceUTF8(s, 2,-2);
+ r = bSliceUTF8(s, 2,-2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ee");
// start = end
strcpy(s, "sheepy");
- bSliceUTF8(s, 2,-4);
+ r = bSliceUTF8(s, 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// end of string
strcpy(s, "sheepy");
- bSliceUTF8(s, 2,6);
+ r = bSliceUTF8(s, 2,6);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
// start outside string
strcpy(s, "sheepy");
- bSliceUTF8(s, 20,-4);
+ r = bSliceUTF8(s, 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// end outside string
strcpy(s, "sheepy");
- bSliceUTF8(s, 2,40);
+ r = bSliceUTF8(s, 2,40);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
strcpy(s, "sheepy");
- bSliceUTF8(s, -22,3);
+ r = bSliceUTF8(s, -22,3);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "she");
strcpy(s, "sheepy");
- bSliceUTF8(s, 2,-40);
+ r = bSliceUTF8(s, 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// end before start
strcpy(s, "sheepy");
- bSliceUTF8(s, 4,2);
+ r = bSliceUTF8(s, 4,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// NULL var
- ck_assert_ptr_eq(bSliceUTF8(NULL, 0, 0), NULL);
+ r = bSliceUTF8(NULL, 0, 0);
+ ck_assert_ptr_eq(r, null);
}
@@ -10770,52 +11894,67 @@ void bSliceUTF8T(CuTest *tc UNUSED) {
void bLSliceUTF8T(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
+
// slice
strcpy(s, "sheepy");
- bLSliceUTF8(s, sizeof(s), 0,2);
+ r = bLSliceUTF8(s, sizeof(s), 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
// buffer shorter than string
strcpy(s, "sheepy");
- bLSliceUTF8(s, 5, 0,2);
+ r = bLSliceUTF8(s, 5, 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
// negative index
strcpy(s, "sheepy");
- bLSliceUTF8(s, sizeof(s), -2,0);
+ r = bLSliceUTF8(s, sizeof(s), -2,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "py");
// positive and negative indexes
strcpy(s, "sheepy");
- bLSliceUTF8(s, sizeof(s), 2,-2);
+ r = bLSliceUTF8(s, sizeof(s), 2,-2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ee");
// start = end
strcpy(s, "sheepy");
- bLSliceUTF8(s, sizeof(s), 2,-4);
+ r = bLSliceUTF8(s, sizeof(s), 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// end of string
strcpy(s, "sheepy");
- bLSliceUTF8(s, sizeof(s), 2,6);
+ r = bLSliceUTF8(s, sizeof(s), 2,6);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
// start outside string
strcpy(s, "sheepy");
- bLSliceUTF8(s, sizeof(s), 20,-4);
+ r = bLSliceUTF8(s, sizeof(s), 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// end outside string
strcpy(s, "sheepy");
- bLSliceUTF8(s, sizeof(s), 2,40);
+ r = bLSliceUTF8(s, sizeof(s), 2,40);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
strcpy(s, "sheepy");
- bLSliceUTF8(s, sizeof(s), -22,3);
+ r = bLSliceUTF8(s, sizeof(s), -22,3);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "she");
strcpy(s, "sheepy");
- bLSliceUTF8(s, sizeof(s), 2,-40);
+ r = bLSliceUTF8(s, sizeof(s), 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// end before start
strcpy(s, "sheepy");
- bLSliceUTF8(s, sizeof(s), 4,2);
+ r = bLSliceUTF8(s, sizeof(s), 4,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// size 0
- ck_assert_ptr_eq(bLSliceUTF8(s, 0, 0, 0), NULL);
+ r = bLSliceUTF8(s, 0, 0, 0);
+ ck_assert_ptr_eq(r, null);
// NULL var
- ck_assert_ptr_eq(bLSliceUTF8(NULL, sizeof(s), 0, 0), NULL);
+ r = bLSliceUTF8(NULL, sizeof(s), 0, 0);
+ ck_assert_ptr_eq(r, null);
}
@@ -10924,60 +12063,73 @@ void insertNFreeUTF8T(CuTest *tc UNUSED) {
void iInsertUTF8T(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
// insert
s = strdup("sheepy");
- iInsertUTF8(&s, 0, "lib");
+ r = iInsertUTF8(&s, 0, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
free(s);
// negative index
s = strdup("libsheepy");
- iInsertUTF8(&s, -2, "P");
+ r = iInsertUTF8(&s, -2, "P");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepPy");
free(s);
// edge
s = strdup("qwe");
- iInsertUTF8(&s, 3, "C");
+ r = iInsertUTF8(&s, 3, "C");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qweC");
free(s);
// outside string
s = strdup("qwe");
- iInsertUTF8(&s, 4, "C");
+ r = iInsertUTF8(&s, 4, "C");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
- iInsertUTF8(&s, -5, "C");
+ r = iInsertUTF8(&s, -5, "C");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
free(s);
// negative index in a one char string
s = strdup("s");
- iInsertUTF8(&s, -1, "S");
+ r = iInsertUTF8(&s, -1, "S");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sS");
free(s);
// empty string
emptyS(s);
- iInsertUTF8(&s, 0, "s");
+ r = iInsertUTF8(&s, 0, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
emptyS(s);
- iInsertUTF8(&s, -1, "s");
+ r = iInsertUTF8(&s, -1, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
// empty insert string
s = strdup("a");
- iInsertUTF8(&s, 0, "");
+ r = iInsertUTF8(&s, 0, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
free(s);
// NULL insert string
s = strdup("a");
- iInsertUTF8(&s, 0, NULL);
+ r = iInsertUTF8(&s, 0, NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
free(s);
// NULL string
s = NULL;
- iInsertUTF8(&s, 0, "s");
+ r = iInsertUTF8(&s, 0, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
// NULL var
- iInsertUTF8(NULL, 0, "s");
+ r = iInsertUTF8(NULL, 0, "s");
+ ck_assert_ptr_eq(r, null);
}
@@ -10989,17 +12141,20 @@ void iInsertNFreeUTF8T(CuTest *tc UNUSED) {
// insert
s = strdup("sheepy");
- iInsertNFreeUTF8(&s, 0, strdup("lib"));
+ r = iInsertNFreeUTF8(&s, 0, strdup("lib"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
free(s);
// negative index
s = strdup("libsheepy");
- iInsertNFreeUTF8(&s, -2, strdup("P"));
+ r = iInsertNFreeUTF8(&s, -2, strdup("P"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepPy");
free(s);
// edge
s = strdup("qwe");
- iInsertNFreeUTF8(&s, 3, strdup("C"));
+ r = iInsertNFreeUTF8(&s, 3, strdup("C"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qweC");
free(s);
// outside string
@@ -11015,31 +12170,37 @@ void iInsertNFreeUTF8T(CuTest *tc UNUSED) {
free(s);
// negative index in a one char string
s = strdup("s");
- iInsertNFreeUTF8(&s, -1, strdup("S"));
+ r = iInsertNFreeUTF8(&s, -1, strdup("S"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sS");
free(s);
// empty string
emptyS(s);
- iInsertNFreeUTF8(&s, 0, strdup("s"));
+ r = iInsertNFreeUTF8(&s, 0, strdup("s"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
emptyS(s);
- iInsertNFreeUTF8(&s, -1, strdup("s"));
+ r = iInsertNFreeUTF8(&s, -1, strdup("s"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
// empty insert string
s = strdup("a");
- iInsertNFreeUTF8(&s, 0, strdup(""));
+ r = iInsertNFreeUTF8(&s, 0, strdup(""));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
free(s);
// NULL insert string
s = strdup("a");
- iInsertNFreeUTF8(&s, 0, NULL);
+ r = iInsertNFreeUTF8(&s, 0, NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
free(s);
// NULL string
s = NULL;
- iInsertNFreeUTF8(&s, 0, strdup("s"));
+ r = iInsertNFreeUTF8(&s, 0, strdup("s"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
// NULL var
@@ -11055,46 +12216,58 @@ void iInsertNFreeUTF8T(CuTest *tc UNUSED) {
void bInsertUTF8T(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
// insert
strcpy(s, "sheepy");
- bInsertUTF8(s, 0, "lib");
+ r = bInsertUTF8(s, 0, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// negative index
strcpy(s, "libsheepy");
- bInsertUTF8(s, -2, "P");
+ r = bInsertUTF8(s, -2, "P");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepPy");
// edge
strcpy(s, "qwe");
- bInsertUTF8(s, 3, "C");
+ r = bInsertUTF8(s, 3, "C");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qweC");
// outside string
strcpy(s, "qwe");
- bInsertUTF8(s, 4, "C");
+ r = bInsertUTF8(s, 4, "C");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
- bInsertUTF8(s, -5, "C");
+ r = bInsertUTF8(s, -5, "C");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// negative index in a one char string
strcpy(s, "s");
- bInsertUTF8(s, -1, "S");
+ r = bInsertUTF8(s, -1, "S");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sS");
// empty string
bEmptyS(s);
- bInsertUTF8(s, 0, "s");
+ r = bInsertUTF8(s, 0, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
bEmptyS(s);
- bInsertUTF8(s, -1, "s");
+ r = bInsertUTF8(s, -1, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
// empty insert string
strcpy(s, "a");
- bInsertUTF8(s, 0, "");
+ r = bInsertUTF8(s, 0, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
// NULL insert string
strcpy(s, "a");
- bInsertUTF8(s, 0, NULL);
+ r = bInsertUTF8(s, 0, NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
// NULL var
- ck_assert_ptr_eq(bInsertUTF8(NULL, 0, "s"), NULL);
+ r = bInsertUTF8(NULL, 0, "s");
+ ck_assert_ptr_eq(r, null);
}
@@ -11103,53 +12276,67 @@ void bInsertUTF8T(CuTest *tc UNUSED) {
void bLInsertUTF8T(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
// insert
strcpy(s, "sheepy");
- bLInsertUTF8(s, sizeof s, 0, "lib");
+ r = bLInsertUTF8(s, sizeof s, 0, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// shorter buffer
strcpy(s, "sheepy");
- bLInsertUTF8(s, 5, 0, "lib");
+ r = bLInsertUTF8(s, 5, 0, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libs");
// negative index
strcpy(s, "libsheepy");
- bLInsertUTF8(s, sizeof s, -2, "P");
+ r = bLInsertUTF8(s, sizeof s, -2, "P");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepPy");
// edge
strcpy(s, "qwe");
- bLInsertUTF8(s, sizeof s, 3, "C");
+ r = bLInsertUTF8(s, sizeof s, 3, "C");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qweC");
// outside string
strcpy(s, "qwe");
- bLInsertUTF8(s, sizeof s, 4, "C");
+ r = bLInsertUTF8(s, sizeof s, 4, "C");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
- bLInsertUTF8(s, sizeof s, -5, "C");
+ r = bLInsertUTF8(s, sizeof s, -5, "C");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// negative index in a one char string
strcpy(s, "s");
- bLInsertUTF8(s, sizeof s, -1, "S");
+ r = bLInsertUTF8(s, sizeof s, -1, "S");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sS");
// empty string
bEmptyS(s);
- bLInsertUTF8(s, sizeof s, 0, "s");
+ r = bLInsertUTF8(s, sizeof s, 0, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
bEmptyS(s);
- bLInsertUTF8(s, sizeof s, -1, "s");
+ r = bLInsertUTF8(s, sizeof s, -1, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
// empty insert string
strcpy(s, "a");
- bLInsertUTF8(s, sizeof s, 0, "");
+ r = bLInsertUTF8(s, sizeof s, 0, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
// size 0 - no change
- bLInsertUTF8(s, 0, 0, "qwe");
+ r = bLInsertUTF8(s, 0, 0, "qwe");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
// NULL insert string
strcpy(s, "a");
- bLInsertUTF8(s, sizeof s, 0, NULL);
+ r = bLInsertUTF8(s, sizeof s, 0, NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
// NULL var
- ck_assert_ptr_eq(bLInsertUTF8(NULL, sizeof s, 0, "s"), NULL);
+ r = bLInsertUTF8(NULL, sizeof s, 0, "s");
+ ck_assert_ptr_eq(r, null);
}
@@ -11203,63 +12390,78 @@ void delUTF8T(CuTest *tc UNUSED) {
void iDelUTF8T(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
+
// del
s = strdup("sheepy");
- iDelUTF8(&s, 0,2);
+ r = iDelUTF8(&s, 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
free(s);
// negative index
s = strdup("sheepy");
- iDelUTF8(&s, -2,0);
+ r = iDelUTF8(&s, -2,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "shee");
free(s);
// positive and negative indexes
s = strdup("sheepy");
- iDelUTF8(&s, 2,-2);
+ r = iDelUTF8(&s, 2,-2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "shpy");
free(s);
// start = end
s = strdup("sheepy");
- iDelUTF8(&s, 2,-4);
+ r = iDelUTF8(&s, 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepy");
free(s);
// delete entire string
s = strdup("sheepy");
- iDelUTF8(&s, 0,0);
+ r = iDelUTF8(&s, 0,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
free(s);
// end of string
s = strdup("sheepy");
- iDelUTF8(&s, 2,6);
+ r = iDelUTF8(&s, 2,6);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
free(s);
// NULL string
s = NULL;
- iDelUTF8(&s, 2,-4);
+ r = iDelUTF8(&s, 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_ptr_eq(s, NULL);
// start outside string
s = strdup("sheepy");
- iDelUTF8(&s, 20,-4);
+ r = iDelUTF8(&s, 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
- iDelUTF8(&s, -20,-4);
+ r = iDelUTF8(&s, -20,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
free(s);
// end outside string
s = strdup("sheepy");
- iDelUTF8(&s, 2,40);
+ r = iDelUTF8(&s, 2,40);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
free(s);
s = strdup("sheepy");
- iDelUTF8(&s, 2,-40);
+ r = iDelUTF8(&s, 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
free(s);
// end before start
s = strdup("sheepy");
- iDelUTF8(&s, 4,2);
+ r = iDelUTF8(&s, 4,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
free(s);
// NULL var
- iDelUTF8(NULL, 4,2);
+ r = iDelUTF8(NULL, 4,2);
+ ck_assert_ptr_eq(r, null);
}
@@ -11268,49 +12470,63 @@ void iDelUTF8T(CuTest *tc UNUSED) {
void bDelUTF8T(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
+
// del
strcpy(s, "sheepy");
- bDelUTF8(s, 0,2);
+ r = bDelUTF8(s, 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
// negative index
strcpy(s, "sheepy");
- bDelUTF8(s, -2,0);
+ r = bDelUTF8(s, -2,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "shee");
// positive and negative indexes
strcpy(s, "sheepy");
- bDelUTF8(s, 2,-2);
+ r = bDelUTF8(s, 2,-2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "shpy");
// start = end
strcpy(s, "sheepy");
- bDelUTF8(s, 2,-4);
+ r = bDelUTF8(s, 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepy");
// delete entire string
strcpy(s, "sheepy");
- bDelUTF8(s, 0,0);
+ r = bDelUTF8(s, 0,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// end of string
strcpy(s, "sheepy");
- bDelUTF8(s, 2,6);
+ r = bDelUTF8(s, 2,6);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
// start outside string
strcpy(s, "sheepy");
- bDelUTF8(s, 20,-4);
+ r = bDelUTF8(s, 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
- bDelUTF8(s, -20,-4);
+ r = bDelUTF8(s, -20,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
// end outside string
strcpy(s, "sheepy");
- bDelUTF8(s, 2,40);
+ r = bDelUTF8(s, 2,40);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
strcpy(s, "sheepy");
- bDelUTF8(s, 2,-40);
+ r = bDelUTF8(s, 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
// end before start
strcpy(s, "sheepy");
- bDelUTF8(s, 4,2);
+ r = bDelUTF8(s, 4,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
// NULL var
- ck_assert_ptr_eq(bDelUTF8(NULL, 4,2), NULL);
+ r = bDelUTF8(NULL, 4,2);
+ ck_assert_ptr_eq(r, null);
}
@@ -11319,52 +12535,67 @@ void bDelUTF8T(CuTest *tc UNUSED) {
void bLDelUTF8T(CuTest *tc UNUSED) {
char s[100];
+ char *r = null;
+
// del
strcpy(s, "sheepy");
- bLDelUTF8(s, sizeof(s), 0,2);
+ r = bLDelUTF8(s, sizeof(s), 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
// buffer shorter than string
strcpy(s, "sheepy");
- bLDelUTF8(s, 5, 0,2);
+ r = bLDelUTF8(s, 5, 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ee");
// negative index
strcpy(s, "sheepy");
- bLDelUTF8(s, sizeof(s), -2,0);
+ r = bLDelUTF8(s, sizeof(s), -2,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "shee");
// positive and negative indexes
strcpy(s, "sheepy");
- bLDelUTF8(s, sizeof(s), 2,-2);
+ r = bLDelUTF8(s, sizeof(s), 2,-2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "shpy");
// start = end
strcpy(s, "sheepy");
- bLDelUTF8(s, sizeof(s), 2,-4);
+ r = bLDelUTF8(s, sizeof(s), 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepy");
// end of string
strcpy(s, "sheepy");
- bLDelUTF8(s, sizeof(s), 2,6);
+ r = bLDelUTF8(s, sizeof(s), 2,6);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
// start outside string
strcpy(s, "sheepy");
- bLDelUTF8(s, sizeof(s), 20,-4);
+ r = bLDelUTF8(s, sizeof(s), 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
// end outside string
strcpy(s, "sheepy");
- bLDelUTF8(s, sizeof(s), 2,40);
+ r = bLDelUTF8(s, sizeof(s), 2,40);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
strcpy(s, "sheepy");
- bLDelUTF8(s, sizeof(s), -22,3);
+ r = bLDelUTF8(s, sizeof(s), -22,3);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "epy");
strcpy(s, "sheepy");
- bLDelUTF8(s, sizeof(s), 2,-40);
+ r = bLDelUTF8(s, sizeof(s), 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
// end before start
strcpy(s, "sheepy");
- bLDelUTF8(s, sizeof(s), 4,2);
+ r = bLDelUTF8(s, sizeof(s), 4,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
// size 0
- ck_assert_ptr_eq(bLDelUTF8(s, 0, 0, 0), NULL);
+ r = bLDelUTF8(s, 0, 0, 0);
+ ck_assert_ptr_eq(r, null);
// NULL var
- ck_assert_ptr_eq(bLDelUTF8(NULL, sizeof(s), 0, 0), NULL);
+ r = bLDelUTF8(NULL, sizeof(s), 0, 0);
+ ck_assert_ptr_eq(r, null);
}
@@ -11404,12 +12635,17 @@ void icListSortUTF8T(CuTest *tc UNUSED) {
char **l = NULL;
char **l2;
+ char **r = null;
// list
- listPushS(&l, "1sdfdsf");
- listPushS(&l, "4444");
- listPushS(&l, "3");
- listPushS(&l, "22sdf");
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "3");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22sdf");
+ ck_assert_ptr_eq(r, l);
l2 = icListSortUTF8(l);
ck_assert_str_eq(l2[0], "1sdfdsf");
ck_assert_str_eq(l2[3], "4444");
@@ -11417,7 +12653,8 @@ void icListSortUTF8T(CuTest *tc UNUSED) {
listFreeS(l2);
// one element list
l = NULL;
- listPushS(&l, "1sdfdsf");
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
l2 = icListSortUTF8(l);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "1sdfdsf");
@@ -11440,35 +12677,46 @@ void icListSortUTF8T(CuTest *tc UNUSED) {
void iicListSortUTF8T(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// list
- listPushS(&l, "1sdfdsf");
- listPushS(&l, "4444");
- listPushS(&l, "3");
- listPushS(&l, "22sdf");
- iicListSortUTF8(&l);
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "3");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22sdf");
+ ck_assert_ptr_eq(r, l);
+ r = iicListSortUTF8(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "1sdfdsf");
ck_assert_str_eq(l[3], "4444");
listFreeS(l);
// one element list
l = NULL;
- listPushS(&l, "1sdfdsf");
- iicListSortUTF8(&l);
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = iicListSortUTF8(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),1);
ck_assert_str_eq(l[0], "1sdfdsf");
listFreeS(l);
// empty list
listEmptyS(l)
- iicListSortUTF8(&l);
+ r = iicListSortUTF8(&l);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),0);
ck_assert_ptr_eq(l[0], NULL);
listFreeS(l);
// NULL list
l = NULL;
- iicListSortUTF8(&l);
+ r = iicListSortUTF8(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iicListSortUTF8(NULL);
+ r = iicListSortUTF8(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -11478,12 +12726,17 @@ void icListEqUTF8T(CuTest *tc UNUSED) {
char **l = NULL;
char **l2;
+ char **r = null;
// identical lists
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listDupS(l);
ck_assert(icListEqUTF8(l,l2));
// NULL lists
@@ -11507,12 +12760,17 @@ void icListEqUTF8T(CuTest *tc UNUSED) {
void icListHasUTF8T(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert(icListHasUTF8(l, "1"));
// NULL list
ck_assert(!icListHasUTF8(NULL, "1"));
@@ -11531,12 +12789,17 @@ void icListHasUTF8T(CuTest *tc UNUSED) {
void icListIndexOfUTF8T(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(icListIndexOfUTF8(l, "1"),0);
// NULL list
ck_assert_uint_eq(icListIndexOfUTF8(NULL, "1"),-1);
@@ -11555,14 +12818,21 @@ void icListIndexOfUTF8T(CuTest *tc UNUSED) {
void icListBinarySearchUTF8T(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l, "5");
- listPushS(&l, "6");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "5");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "6");
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(icListBinarySearchUTF8(l, "1"),0);
// NULL list
ck_assert_uint_eq(icListBinarySearchUTF8(NULL, "1"),-1);
@@ -11582,12 +12852,17 @@ void icListUniqUTF8T(CuTest *tc UNUSED) {
char **l = NULL;
char **l2;
+ char **r = null;
// list with unique elements
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = icListUniqUTF8(l);
ck_assert(listEqS(l,l2));
// list with identical elements
@@ -11602,7 +12877,8 @@ void icListUniqUTF8T(CuTest *tc UNUSED) {
listFreeS(l2);
// list with one element
l = NULL;
- listPushS(&l, "1");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
l2 = icListUniqUTF8(l);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "1");
@@ -11626,14 +12902,20 @@ void iicListUniqUTF8T(CuTest *tc UNUSED) {
char **l = NULL;
char **l2;
+ char **r = null;
// list with unique elements
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listDupS(l);
- iicListUniqUTF8(&l2);
+ r = iicListUniqUTF8(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert(listEqS(l,l2));
// list with identical elements
l[2][0] = '2';
@@ -11641,16 +12923,19 @@ void iicListUniqUTF8T(CuTest *tc UNUSED) {
l[2][2] = 0;
listFreeS(l2);
l2 = listDupS(l);
- iicListUniqUTF8(&l2);
+ r = iicListUniqUTF8(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),3);
ck_assert_str_eq(l2[2], "4444");
listFreeS(l);
listFreeS(l2);
// list with one element
l = NULL;
- listPushS(&l, "1");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
l2 = listDupS(l);
- iicListUniqUTF8(&l2);
+ r = iicListUniqUTF8(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "1");
listFreeS(l);
@@ -11658,17 +12943,20 @@ void iicListUniqUTF8T(CuTest *tc UNUSED) {
// empty list
listEmptyS(l)
l2 = listDupS(l);
- iicListUniqUTF8(&l2);
+ r = iicListUniqUTF8(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),0);
ck_assert_ptr_eq(l2[0], NULL);
listFreeS(l);
listFreeS(l2);
// NULL list
l = NULL;
- iicListUniqUTF8(&l);
+ r = iicListUniqUTF8(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iicListUniqUTF8(NULL);
+ r = iicListUniqUTF8(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -11689,19 +12977,23 @@ void emptySFT(CuTest *tc UNUSED) {
void iEmptySFT(CuTest *tc UNUSED) {
char *s;
+ char *r = null;
// empty string
s = strdup("qwe");
- iEmptySF(&s);
+ r = iEmptySF(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert(isEmptyS(s));
free(s);
// NULL string
s = NULL;
- iEmptySF(&s);
+ r = iEmptySF(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert(isEmptyS(s));
free(s);
// NULL var
- iEmptySF(NULL);
+ r = iEmptySF(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -11783,19 +13075,23 @@ void listEmptySFT(CuTest *tc UNUSED) {
void iListEmptySFT(CuTest *tc UNUSED) {
char **l;
+ char **r = null;
// empty list
l = listCreateS("lib", "sheepy");
- iListEmptySF(&l);
+ r = iListEmptySF(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmptyS(l));
listFreeS(l);
// NULL list
l = NULL;
- iListEmptySF(&l);
+ r = iListEmptySF(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmptyS(l));
listFreeS(l);
// NULL var
- iListEmptySF(NULL);
+ r = iListEmptySF(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -11866,14 +13162,18 @@ void listStrLengthST(CuTest *tc UNUSED) {
char **l = null;
ssize_t r;
+ char **r2 = null;
- listPushS(&l, "lib");
- listPushS(&l, "sheepy");
+ r2 = listPushS(&l, "lib");
+ ck_assert_ptr_eq(r2, l);
+ r2 = listPushS(&l, "sheepy");
+ ck_assert_ptr_eq(r2, l);
r = listStrLengthS(l);
ck_assert_int_eq(r, 9);
listFreeS(l);
// null list
- ck_assert_int_eq(listStrLengthS(null), -1);
+ r = listStrLengthS(null);
+ ck_assert_int_eq(r, -1);
}
@@ -11882,9 +13182,14 @@ void listIntIndexST(CuTest *tc UNUSED) {
char **l = null;
ssize_t r;
- listPushS(&l, "lib");
- listPushS(&l, "sheepy");
- listPushS(&l, "sheepy");
+ char **r2 = null;
+
+ r2 = listPushS(&l, "lib");
+ ck_assert_ptr_eq(r2, l);
+ r2 = listPushS(&l, "sheepy");
+ ck_assert_ptr_eq(r2, l);
+ r2 = listPushS(&l, "sheepy");
+ ck_assert_ptr_eq(r2, l);
// positive index
r = listIntIndexS(l, 2);
ck_assert_int_eq(r, 2);
@@ -11914,9 +13219,13 @@ void listAddrST(CuTest *tc UNUSED) {
char **l = null;
char **r;
- listPushS(&l, "lib");
- listPushS(&l, "sheepy");
- listPushS(&l, "sheepy");
+
+ r = listPushS(&l, "lib");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "sheepy");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "sheepy");
+ ck_assert_ptr_eq(r, l);
// positive index
r = listAddrS(l, 2);
ck_assert_ptr_eq(r, &l[2]);
@@ -11995,31 +13304,38 @@ void listFromArrayST(CuTest *tc UNUSED) {
void listPushST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// push strings and NULL list
- listPushS(&l, "sheepy");
+ r = listPushS(&l, "sheepy");
+ ck_assert_ptr_eq(r, l);
// check ck_assert_ptr_null not available in jessie
ck_assert_ptr_ne(l, NULL);
ck_assert_str_eq(l[0], "sheepy");
- listPushS(&l, "SHEEPY");
+ r = listPushS(&l, "SHEEPY");
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[1], "SHEEPY");
ck_assert_str_eq(l[0], "sheepy");
// push NULL
- listPushS(&l, NULL);
+ r = listPushS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l[2], NULL);
listFreeS(l);
// NULL list and NULL string
l = NULL;
- listPushS(&l, NULL);
+ r = listPushS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// empty list
listEmptyS(l)
- listPushS(&l, "sheepy");
+ r = listPushS(&l, "sheepy");
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "sheepy");
ck_assert_ptr_eq(l[1], NULL);
listFreeS(l);
// NULL pointer to list
- listPushS(NULL, NULL);
+ r = listPushS(NULL, NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -12027,24 +13343,29 @@ void listPushST(CuTest *tc UNUSED) {
void listPushCharST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// push strings and NULL list
- listPushCharS(&l, 's');
+ r = listPushCharS(&l, 's');
+ ck_assert_ptr_eq(r, l);
// check ck_assert_ptr_null not available in jessie
ck_assert_ptr_ne(l, NULL);
ck_assert_str_eq(l[0], "s");
- listPushCharS(&l, 'S');
+ r = listPushCharS(&l, 'S');
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[1], "S");
ck_assert_str_eq(l[0], "s");
listFreeS(l);
// empty list
listEmptyS(l)
- listPushCharS(&l, 's');
+ r = listPushCharS(&l, 's');
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "s");
ck_assert_ptr_eq(l[1], NULL);
listFreeS(l);
// NULL pointer to list
- listPushCharS(NULL, 's');
+ r = listPushCharS(NULL, 's');
+ ck_assert_ptr_eq(r, null);
}
@@ -12054,34 +13375,41 @@ void iListPushST(CuTest *tc UNUSED) {
char **l = NULL;
char *s;
+ char **r = null;
// push strings and NULL list
s = strdup("sheepy");
- iListPushS(&l, s);
+ r = iListPushS(&l, s);
+ ck_assert_ptr_eq(r, l);
// check ck_assert_ptr_null not available in jessie
ck_assert_ptr_ne(l, NULL);
ck_assert_str_eq(l[0], "sheepy");
s = strdup("SHEEPY");
- iListPushS(&l, s);
+ r = iListPushS(&l, s);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "sheepy");
ck_assert_str_eq(l[1], "SHEEPY");
// push NULL
- iListPushS(&l, NULL);
+ r = iListPushS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l[2], NULL);
listFreeS(l);
// NULL list and NULL string
l = NULL;
- iListPushS(&l, NULL);
+ r = iListPushS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// empty list
listEmptyS(l)
s = strdup("sheepy");
- iListPushS(&l, s);
+ r = iListPushS(&l, s);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "sheepy");
ck_assert_ptr_eq(l[1], NULL);
listFreeS(l);
// NULL pointer to list
- iListPushS(NULL, NULL);
+ r = iListPushS(NULL, NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -12090,10 +13418,13 @@ void listPopST(CuTest *tc UNUSED) {
char **l = NULL;
char *s;
+ char **r = null;
// pop string
- listPushS(&l, "sheepy");
- listPushS(&l, "SHEEPY");
+ r = listPushS(&l, "sheepy");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "SHEEPY");
+ ck_assert_ptr_eq(r, l);
s = listPopS(&l);
ck_assert_str_eq(s, "SHEEPY");
ck_assert_uint_eq(listLengthS(l),1);
@@ -12118,31 +13449,38 @@ void listPopST(CuTest *tc UNUSED) {
void listPrependST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// push strings and NULL list
- listPrependS(&l, "sheepy");
+ r = listPrependS(&l, "sheepy");
+ ck_assert_ptr_eq(r, l);
// check ck_assert_ptr_null not available in jessie
ck_assert_ptr_ne(l, NULL);
ck_assert_str_eq(l[0], "sheepy");
- listPrependS(&l, "SHEEPY");
+ r = listPrependS(&l, "SHEEPY");
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "SHEEPY");
ck_assert_str_eq(l[1], "sheepy");
// push NULL
- listPrependS(&l, NULL);
+ r = listPrependS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(l[0], "SHEEPY");
listFreeS(l);
// NULL list and NULL string`
l = NULL;
- listPrependS(&l, NULL);
+ r = listPrependS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// empty list
listEmptyS(l)
- listPrependS(&l, "sheepy");
+ r = listPrependS(&l, "sheepy");
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "sheepy");
ck_assert_ptr_eq(l[1], NULL);
listFreeS(l);
// NULL pointer to list
- listPrependS(NULL, NULL);
+ r = listPrependS(NULL, NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -12150,24 +13488,29 @@ void listPrependST(CuTest *tc UNUSED) {
void listPrependCharST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// push strings and NULL list
- listPrependCharS(&l, 's');
+ r = listPrependCharS(&l, 's');
+ ck_assert_ptr_eq(r, l);
// check ck_assert_ptr_null not available in jessie
ck_assert_ptr_ne(l, NULL);
ck_assert_str_eq(l[0], "s");
- listPrependCharS(&l, 'S');
+ r = listPrependCharS(&l, 'S');
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "S");
ck_assert_str_eq(l[1], "s");
listFreeS(l);
// empty list
listEmptyS(l)
- listPrependCharS(&l, 's');
+ r = listPrependCharS(&l, 's');
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "s");
ck_assert_ptr_eq(l[1], NULL);
listFreeS(l);
// NULL pointer to list
- listPrependCharS(NULL, 's');
+ r = listPrependCharS(NULL, 's');
+ ck_assert_ptr_eq(r, null);
}
@@ -12177,34 +13520,41 @@ void iListPrependST(CuTest *tc UNUSED) {
char **l = NULL;
char *s;
+ char **r = null;
// prepend strings and NULL list
s = strdup("sheepy");
- iListPrependS(&l, s);
+ r = iListPrependS(&l, s);
+ ck_assert_ptr_eq(r, l);
// check ck_assert_ptr_null not available in jessie
ck_assert_ptr_ne(l, NULL);
ck_assert_str_eq(l[0], "sheepy");
s = strdup("SHEEPY");
- iListPrependS(&l, s);
+ r = iListPrependS(&l, s);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "SHEEPY");
ck_assert_str_eq(l[1], "sheepy");
// prepend NULL
- iListPrependS(&l, NULL);
+ r = iListPrependS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(l[0], "SHEEPY");
listFreeS(l);
// NULL list and NULL string
l = NULL;
- iListPrependS(&l, NULL);
+ r = iListPrependS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// empty list
listEmptyS(l)
s = strdup("sheepy");
- iListPrependS(&l, s);
+ r = iListPrependS(&l, s);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "sheepy");
ck_assert_ptr_eq(l[1], NULL);
listFreeS(l);
// NULL pointer to list
- iListPrependS(NULL, NULL);
+ r = iListPrependS(NULL, NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -12213,10 +13563,13 @@ void listDequeueST(CuTest *tc UNUSED) {
char **l = NULL;
char *s;
+ char **r = null;
// dequeue string
- listPushS(&l, "sheepy");
- listPushS(&l, "SHEEPY");
+ r = listPushS(&l, "sheepy");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "SHEEPY");
+ ck_assert_ptr_eq(r, l);
s = listDequeueS(&l);
ck_assert_str_eq(s, "sheepy");
ck_assert_uint_eq(listLengthS(l),1);
@@ -12272,7 +13625,8 @@ void listPrintST(CuTest *tc UNUSED) {
//listPrintS(l);
listFreeS(l);
// NULL list
- listPrintS(NULL);
+ int r = listPrintS(NULL);
+ ck_assert_int_eq(r, 0);
}
@@ -12281,15 +13635,22 @@ void listForEachT(CuTest *tc UNUSED) {
char **l = NULL;
char **l2 = NULL;
+ char **r = null;
// for each element in list
- listPushS(&l, "1sdfdsf");
- listPushS(&l, "4444");
- listPushS(&l, "3");
- listPushS(&l, "22sdf");
- forEachCharP(l, i)
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "3");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22sdf");
+ ck_assert_ptr_eq(r, l);
+ forEachCharP(l, i) {
//printf(*i);
- listPushS(&l2, *i);
+ r = listPushS(&l2, *i);
+ ck_assert_ptr_eq(r, l2);
+ }
ck_assert_str_eq(l2[0], "1sdfdsf");
ck_assert_str_eq(l2[3], "22sdf");
listFreeS(l);
@@ -12302,14 +13663,20 @@ void listEnumerateT(CuTest *tc UNUSED) {
char **l = NULL;
char **l2 = NULL;
+ char **r = null;
// enumerateCharP elements
- listPushS(&l, "1sdfdsf");
- listPushS(&l, "4444");
- listPushS(&l, "3");
- listPushS(&l, "22sdf");
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "3");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22sdf");
+ ck_assert_ptr_eq(r, l);
enumerateCharP(l, i, j) {
- listPushS(&l2, *i);
+ r = listPushS(&l2, *i);
+ ck_assert_ptr_eq(r, l2);
}
ck_assert_uint_eq(j, 4);
ck_assert_str_eq(l2[0], "1sdfdsf");
@@ -12324,12 +13691,17 @@ void listSortST(CuTest *tc UNUSED) {
char **l = NULL;
char **l2;
+ char **r = null;
// list
- listPushS(&l, "1sdfdsf");
- listPushS(&l, "4444");
- listPushS(&l, "3");
- listPushS(&l, "22sdf");
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "3");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22sdf");
+ ck_assert_ptr_eq(r, l);
l2 = listSortS(l);
ck_assert_str_eq(l2[0], "1sdfdsf");
ck_assert_str_eq(l2[3], "4444");
@@ -12337,7 +13709,8 @@ void listSortST(CuTest *tc UNUSED) {
listFreeS(l2);
// one element list
l = NULL;
- listPushS(&l, "1sdfdsf");
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
l2 = listSortS(l);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "1sdfdsf");
@@ -12359,35 +13732,46 @@ void listSortST(CuTest *tc UNUSED) {
void iListSortST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// list
- listPushS(&l, "1sdfdsf");
- listPushS(&l, "4444");
- listPushS(&l, "3");
- listPushS(&l, "22sdf");
- iListSortS(&l);
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "3");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22sdf");
+ ck_assert_ptr_eq(r, l);
+ r = iListSortS(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "1sdfdsf");
ck_assert_str_eq(l[3], "4444");
listFreeS(l);
// one element list
l = NULL;
- listPushS(&l, "1sdfdsf");
- iListSortS(&l);
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = iListSortS(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),1);
ck_assert_str_eq(l[0], "1sdfdsf");
listFreeS(l);
// empty list
listEmptyS(l)
- iListSortS(&l);
+ r = iListSortS(&l);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),0);
ck_assert_ptr_eq(l[0], NULL);
listFreeS(l);
// NULL list
l = NULL;
- iListSortS(&l);
+ r = iListSortS(&l);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iListSortS(NULL);
+ r = iListSortS(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -12419,12 +13803,17 @@ void listSortFST(CuTest *tc UNUSED) {
char **l = NULL;
char **l2;
+ char **r = null;
// list
- listPushS(&l, "1sdfdsf");
- listPushS(&l, "4444");
- listPushS(&l, "3");
- listPushS(&l, "22sdf");
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "3");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22sdf");
+ ck_assert_ptr_eq(r, l);
l2 = listSortFS(l, listSortSCmp);
ck_assert_str_eq(l2[0], "1sdfdsf");
ck_assert_str_eq(l2[3], "4444");
@@ -12432,7 +13821,8 @@ void listSortFST(CuTest *tc UNUSED) {
listFreeS(l2);
// one element list
l = NULL;
- listPushS(&l, "1sdfdsf");
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
l2 = listSortFS(l, listSortSCmp);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "1sdfdsf");
@@ -12457,37 +13847,49 @@ void listSortFST(CuTest *tc UNUSED) {
void iListSortFST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// list
- listPushS(&l, "1sdfdsf");
- listPushS(&l, "4444");
- listPushS(&l, "3");
- listPushS(&l, "22sdf");
- iListSortFS(&l, listSortSCmp);
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "3");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22sdf");
+ ck_assert_ptr_eq(r, l);
+ r = iListSortFS(&l, listSortSCmp);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "1sdfdsf");
ck_assert_str_eq(l[3], "4444");
listFreeS(l);
// one element list
l = NULL;
- listPushS(&l, "1sdfdsf");
- iListSortFS(&l, listSortSCmp);
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = iListSortFS(&l, listSortSCmp);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),1);
ck_assert_str_eq(l[0], "1sdfdsf");
listFreeS(l);
// empty list
listEmptyS(l)
- iListSortFS(&l, listSortSCmp);
+ r = iListSortFS(&l, listSortSCmp);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),0);
ck_assert_ptr_eq(l[0], NULL);
// NULL compare function
- ck_assert_ptr_eq(iListSortFS(&l, null), null);
+ r = iListSortFS(&l, null);
+ ck_assert_ptr_eq(r, null);
listFreeS(l);
// NULL list
l = NULL;
- iListSortFS(&l, listSortSCmp);
+ r = iListSortFS(&l, listSortSCmp);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iListSortFS(NULL, listSortSCmp);
+ r = iListSortFS(NULL, listSortSCmp);
+ ck_assert_ptr_eq(r, null);
}
@@ -12497,12 +13899,17 @@ void icListSortST(CuTest *tc UNUSED) {
char **l = NULL;
char **l2;
+ char **r = null;
// list
- listPushS(&l, "A1sdfdsf");
- listPushS(&l, "d4444");
- listPushS(&l, "c3");
- listPushS(&l, "B22sdf");
+ r = listPushS(&l, "A1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "d4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "c3");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "B22sdf");
+ ck_assert_ptr_eq(r, l);
l2 = icListSortS(l);
ck_assert_str_eq(l2[0], "A1sdfdsf");
ck_assert_str_eq(l2[3], "d4444");
@@ -12510,7 +13917,8 @@ void icListSortST(CuTest *tc UNUSED) {
listFreeS(l2);
// one element list
l = NULL;
- listPushS(&l, "1sdfdsf");
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
l2 = icListSortS(l);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "1sdfdsf");
@@ -12533,35 +13941,46 @@ void icListSortST(CuTest *tc UNUSED) {
void iicListSortST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// list
- listPushS(&l, "a1sdfdsf");
- listPushS(&l, "D4444");
- listPushS(&l, "B3");
- listPushS(&l, "c22sdf");
- iicListSortS(&l);
+ r = listPushS(&l, "a1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "D4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "B3");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "c22sdf");
+ ck_assert_ptr_eq(r, l);
+ r = iicListSortS(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "a1sdfdsf");
ck_assert_str_eq(l[3], "D4444");
listFreeS(l);
// one element list
l = NULL;
- listPushS(&l, "1sdfdsf");
- iicListSortS(&l);
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = iicListSortS(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),1);
ck_assert_str_eq(l[0], "1sdfdsf");
listFreeS(l);
// empty list
listEmptyS(l)
- iicListSortS(&l);
+ r = iicListSortS(&l);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),0);
ck_assert_ptr_eq(l[0], NULL);
listFreeS(l);
// NULL list
l = NULL;
- iicListSortS(&l);
+ r = iicListSortS(&l);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iicListSortS(NULL);
+ r = iicListSortS(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -12585,8 +14004,10 @@ void readTextT(CuTest *tc UNUSED) {
// NULL path
ck_assert_ptr_eq(readText(NULL), NULL);
// non existing path
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
ck_assert_ptr_eq(readText("nonExistingFile"), NULL);
}
@@ -12636,11 +14057,15 @@ void writeTextT(CuTest *tc UNUSED) {
ck_assert_str_eq(l[1], "ANOTHER line");
// non existing file
// make sure the file doesnt exist
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
ck_assert(writeText("nonExistingFile",l));
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
// NULL path
ck_assert(!writeText(NULL,l));
listFreeS(l);
@@ -12704,11 +14129,15 @@ void appendTextT(CuTest *tc UNUSED) {
ck_assert_str_eq(l[3], "B");
// non existing file
// make sure the file doesnt exist
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
ck_assert(appendText("nonExistingFile",l));
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
// NULL path
ck_assert(!appendText(NULL,l));
listFreeS(l);
@@ -12721,12 +14150,17 @@ void appendTextT(CuTest *tc UNUSED) {
void listGetST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// get string
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
char *s = listGetS(l, 0);
ck_assert_str_eq(s, "1");
free(s);
@@ -12740,8 +14174,10 @@ void listGetST(CuTest *tc UNUSED) {
listFreeS(l);
// negative index in a one element list
l = NULL;
- listPushS(&l, "ASD");
- listPushS(&l, NULL);
+ r = listPushS(&l, "ASD");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
s = listGetS(l,-1);
ck_assert_ptr_ne(s, NULL);
free(s);
@@ -12759,12 +14195,17 @@ void listGetST(CuTest *tc UNUSED) {
void iListGetST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// get string
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(iListGetS(l, 0), "1");
// negative index
ck_assert_str_eq(iListGetS(l, -1), "4444");
@@ -12774,8 +14215,10 @@ void iListGetST(CuTest *tc UNUSED) {
listFreeS(l);
// negative index in a one element list
l = NULL;
- listPushS(&l, "ASD");
- listPushS(&l, NULL);
+ r = listPushS(&l, "ASD");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_ne(iListGetS(l,-1), NULL);
listFreeS(l);
// empty list
@@ -12791,27 +14234,37 @@ void iListGetST(CuTest *tc UNUSED) {
void listSetST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// get string
- listPushS(&l, "@@");
- listPushS(&l, "22");
- listPushS(&l, "|");
- listPushS(&l, "4444");
- listSetS(l, 0, "1");
+ r = listPushS(&l, "@@");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "|");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listSetS(l, 0, "1");
+ ck_assert_ptr_eq(r, l);
char *s = listGetS(l, 0);
ck_assert_str_eq(s, "1");
free(s);
// negative index
- listSetS(l, -2, "333");
+ r = listSetS(l, -2, "333");
+ ck_assert_ptr_eq(r, l);
s = listGetS(l, -2);
ck_assert_str_eq(s, "333");
free(s);
// outside list
// list is unchanged
- listSetS(l, 10, "QWE");
- listSetS(l, -10, "QWE");
+ r = listSetS(l, 10, "QWE");
+ ck_assert_ptr_eq(r, null);
+ r = listSetS(l, -10, "QWE");
+ ck_assert_ptr_eq(r, null);
// NULL s string
- listSetS(l, -2, NULL);
+ r = listSetS(l, -2, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
ck_assert_str_eq(l[2], "333");
@@ -12819,20 +14272,25 @@ void listSetST(CuTest *tc UNUSED) {
listFreeS(l);
// negative index in a one element list
l = NULL;
- listPushS(&l, "ASD");
- listPushS(&l, NULL);
- listSetS(l, -1, "QWE");
+ r = listPushS(&l, "ASD");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
+ r = listSetS(l, -1, "QWE");
+ ck_assert_ptr_eq(r, l);
s = listGetS(l,-1);
ck_assert_str_eq(s, "QWE");
free(s);
listFreeS(l);
// empty list - should not crash
listEmptyS(l)
- listSetS(l, 0, "QWE");
+ r = listSetS(l, 0, "QWE");
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(listGetS(l,0),NULL);
free(l);
// NULL list
- listSetS(NULL, 0, "QWE");
+ r = listSetS(NULL, 0, "QWE");
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(listGetS(NULL, 0), NULL);
}
@@ -12841,25 +14299,34 @@ void listSetST(CuTest *tc UNUSED) {
void listSetCharST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// get string
- listPushS(&l, "@@");
- listPushS(&l, "22");
- listPushS(&l, "|");
- listPushS(&l, "4444");
- listSetCharS(l, 0, '1');
+ r = listPushS(&l, "@@");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "|");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listSetCharS(l, 0, '1');
+ ck_assert_ptr_eq(r, l);
char *s = listGetS(l, 0);
ck_assert_str_eq(s, "1");
free(s);
// negative index
- listSetCharS(l, -2, '3');
+ r = listSetCharS(l, -2, '3');
+ ck_assert_ptr_eq(r, l);
s = listGetS(l, -2);
ck_assert_str_eq(s, "3");
free(s);
// outside list
// list is unchanged
- listSetCharS(l, 10, 'Q');
- listSetCharS(l, -10, 'Q');
+ r = listSetCharS(l, 10, 'Q');
+ ck_assert_ptr_eq(r, null);
+ r = listSetCharS(l, -10, 'Q');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
ck_assert_str_eq(l[2], "3");
@@ -12867,20 +14334,25 @@ void listSetCharST(CuTest *tc UNUSED) {
listFreeS(l);
// negative index in a one element list
l = NULL;
- listPushS(&l, "ASD");
- listPushS(&l, NULL);
- listSetCharS(l, -1, 'Q');
+ r = listPushS(&l, "ASD");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
+ r = listSetCharS(l, -1, 'Q');
+ ck_assert_ptr_eq(r, l);
s = listGetS(l,-1);
ck_assert_str_eq(s, "Q");
free(s);
listFreeS(l);
// empty list - should not crash
listEmptyS(l)
- listSetCharS(l, 0, 'Q');
+ r = listSetCharS(l, 0, 'Q');
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(listGetS(l,0),NULL);
free(l);
// NULL list
- listSetCharS(NULL, 0, 'Q');
+ r = listSetCharS(NULL, 0, 'Q');
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(listGetS(NULL, 0), NULL);
@@ -12891,30 +14363,41 @@ void iListSetST(CuTest *tc UNUSED) {
char **l = NULL;
char *s;
+ char **r = null;
// set string
- listPushS(&l, "@@");
- listPushS(&l, "22");
- listPushS(&l, "|");
- listPushS(&l, "4444");
+ r = listPushS(&l, "@@");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "|");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
s = strdup("1");
- iListSetS(l, 0, s);
+ r = iListSetS(l, 0, s);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(iListGetS(l, 0), "1");
// negative index
s = strdup("333");
- iListSetS(l, -2, s);
+ r = iListSetS(l, -2, s);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(iListGetS(l, -2), "333");
// outside list
// list is unchanged
s = strdup("QWE");
- iListSetS(l, 10, s);
- iListSetS(l, -10, s);
+ r = iListSetS(l, 10, s);
+ ck_assert_ptr_eq(r, null);
+ r = iListSetS(l, -10, s);
+ ck_assert_ptr_eq(r, null);
free(s);
// NULL s string
s = NULL;
- iListSetS(l, -2, s);
+ r = iListSetS(l, -2, s);
+ ck_assert_ptr_eq(r, null);
// NULL s var
- iListSetS(l, -2, NULL);
+ r = iListSetS(l, -2, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
ck_assert_str_eq(l[2], "333");
@@ -12922,22 +14405,27 @@ void iListSetST(CuTest *tc UNUSED) {
listFreeS(l);
// negative index in a one element list
l = NULL;
- listPushS(&l, "ASD");
- listPushS(&l, NULL);
+ r = listPushS(&l, "ASD");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
s = strdup("QWE");
- iListSetS(l, -1, s);
+ r = iListSetS(l, -1, s);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(iListGetS(l,-1), "QWE");
listFreeS(l);
// empty list - should not crash
listEmptyS(l)
s = strdup("QWE");
- iListSetS(l, 0, s);
+ r = iListSetS(l, 0, s);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(listGetS(l,0),NULL);
free(s);
free(l);
// NULL list
s = strdup("QWE");
- iListSetS(NULL, 0, s);
+ r = iListSetS(NULL, 0, s);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(listGetS(NULL, 0), NULL);
free(s);
@@ -12948,9 +14436,13 @@ void listSwapST(CuTest *tc UNUSED) {
char **l = null;
char **r;
- listPushS(&l, "lib");
- listPushS(&l, "sheepy");
- listPushS(&l, "spm");
+
+ r = listPushS(&l, "lib");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "sheepy");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "spm");
+ ck_assert_ptr_eq(r, l);
// positive index
r = listSwapS(l, 0, 2);
ck_assert_str_eq(r[0], "spm");
@@ -13004,9 +14496,13 @@ void iListSwapST(CuTest *tc UNUSED) {
char **l = null;
char **r;
- listPushS(&l, "lib");
- listPushS(&l, "sheepy");
- listPushS(&l, "spm");
+
+ r = listPushS(&l, "lib");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "sheepy");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "spm");
+ ck_assert_ptr_eq(r, l);
// positive index
r = iListSwapS(l, 0, 2);
ck_assert_str_eq(r[0], "spm");
@@ -13290,6 +14786,7 @@ void joinT(CuTest *tc UNUSED) {
char **l;
char *s;
+ char **r = null;
// list
l = split("one/two", "/");
@@ -13309,7 +14806,8 @@ void joinT(CuTest *tc UNUSED) {
ck_assert_ptr_eq(join(NULL, ";"), NULL);
// list with NULL first element
l = NULL;
- listPushS(&l, NULL);
+ r = listPushS(&l, NULL);
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(join(l, "/"), NULL);
listFreeS(l);
@@ -13344,25 +14842,33 @@ void bJoinT(CuTest *tc UNUSED) {
char **l;
char s[100];
+ char **r = null;
+ char *r2 = null;
// list
l = split("one/two", "/");
- bJoin(s, l, "/");
+ r2 = bJoin(s, l, "/");
+ ck_assert_ptr_eq(r2, s);
ck_assert_str_eq(s, "one/two");
// NULL delimiter
- ck_assert_ptr_eq(bJoin(s, l, NULL), NULL);
+ r2 = bJoin(s, l, NULL);
+ ck_assert_ptr_eq(r2, null);
listFreeS(l);
// empty list
listEmptyS(l)
- ck_assert_ptr_eq(bJoin(s, l, "/"), NULL);
+ r2 = bJoin(s, l, "/");
+ ck_assert_ptr_eq(r2, null);
ck_assert_str_eq(s, "one/two");
listFreeS(l);
// NULL list
- ck_assert_ptr_eq(bJoin(s, NULL, ";"), NULL);
+ r2 = bJoin(s, NULL, ";");
+ ck_assert_ptr_eq(r2, null);
// list with NULL first element
l = NULL;
- listPushS(&l, NULL);
- ck_assert_ptr_eq(bJoin(s, l, "/"), NULL);
+ r = listPushS(&l, NULL);
+ ck_assert_ptr_eq(r, l);
+ r2 = bJoin(s, l, "/");
+ ck_assert_ptr_eq(r2, null);
listFreeS(l);
}
@@ -13372,19 +14878,23 @@ void bJoinCharT(CuTest *tc UNUSED) {
char **l;
char s[100];
+ char *r = null;
// list
l = split("one/two", "/");
- bJoinChar(s, l, '/');
+ r = bJoinChar(s, l, '/');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "one/two");
listFreeS(l);
// empty list
listEmptyS(l)
- ck_assert_ptr_eq(bJoinChar(s, l, '/'), NULL);
+ r = bJoinChar(s, l, '/');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "one/two");
listFreeS(l);
// NULL list
- ck_assert_ptr_eq(bJoinChar(s, NULL, ';'), NULL);
+ r = bJoinChar(s, NULL, ';');
+ ck_assert_ptr_eq(r, null);
}
@@ -13394,32 +14904,41 @@ void bLJoinT(CuTest *tc UNUSED) {
char **l;
char s[100];
+ char **r = null;
+ char *r2 = null;
// list
l = split("one/two", "/");
- bLJoin(s, sizeof s, l, "/");
+ r2 = bLJoin(s, sizeof s, l, "/");
+ ck_assert_ptr_eq(r2, s);
ck_assert_str_eq(s, "one/two");
// shorter buffer
- bLJoin(s, 5, l, "/");
+ r2 = bLJoin(s, 5, l, "/");
+ ck_assert_ptr_eq(r2, s);
ck_assert_str_eq(s, "one/");
// size 0 - no change
- bLJoin(s, 0, l, "/");
+ r2 = bLJoin(s, 0, l, "/");
+ ck_assert_ptr_eq(r2, s);
ck_assert_str_eq(s, "one/");
// NULL delimiter
- ck_assert_ptr_eq(bLJoin(s, sizeof s, l, NULL), NULL);
+ r2 = bLJoin(s, sizeof s, l, NULL);
+ ck_assert_ptr_eq(r2, null);
listFreeS(l);
// empty list
listEmptyS(l)
- bLJoin(s, sizeof s, l, "/");
- ck_assert_ptr_eq(bLJoin(s, sizeof s, l, "/"), NULL);
+ r2 = bLJoin(s, sizeof s, l, "/");
+ ck_assert_ptr_eq(r2, null);
ck_assert_str_eq(s, "one/");
listFreeS(l);
// NULL list
- ck_assert_ptr_eq(bLJoin(s, sizeof s, NULL, ";"), NULL);
+ r2 = bLJoin(s, sizeof s, NULL, ";");
+ ck_assert_ptr_eq(r2, null);
// list with NULL first element
l = NULL;
- listPushS(&l, NULL);
- ck_assert_ptr_eq(bLJoin(s, sizeof s, l, "/"), NULL);
+ r = listPushS(&l, NULL);
+ ck_assert_ptr_eq(r, l);
+ r2 = bLJoin(s, sizeof s, l, "/");
+ ck_assert_ptr_eq(r2, null);
listFreeS(l);
}
@@ -13429,25 +14948,31 @@ void bLJoinCharT(CuTest *tc UNUSED) {
char **l;
char s[100];
+ char *r = null;
// list
l = split("one/two", "/");
- bLJoinChar(s, sizeof s, l, '/');
+ r = bLJoinChar(s, sizeof s, l, '/');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "one/two");
// shorter buffer
- bLJoinChar(s, 5, l, '/');
+ r = bLJoinChar(s, 5, l, '/');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "one/");
// size 0 - no change
- bLJoinChar(s, 0, l, '/');
+ r = bLJoinChar(s, 0, l, '/');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "one/");
listFreeS(l);
// empty list
listEmptyS(l)
- ck_assert_ptr_eq(bLJoinChar(s, sizeof s, l, '/'), NULL);
+ r = bLJoinChar(s, sizeof s, l, '/');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "one/");
listFreeS(l);
// NULL list
- ck_assert_ptr_eq(bLJoinChar(s, sizeof s, NULL, ';'), NULL);
+ r = bLJoinChar(s, sizeof s, NULL, ';');
+ ck_assert_ptr_eq(r, null);
}
@@ -13754,12 +15279,17 @@ void listDupST(CuTest *tc UNUSED) {
char **l = NULL;
char **l2;
+ char **r = null;
// list
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listDupS(l);
ck_assert_uint_eq(listLengthS(l2),4);
ck_assert_str_eq(l2[0], "1");
@@ -13782,12 +15312,17 @@ void iListDupST(CuTest *tc UNUSED) {
char **l = NULL;
char **l2;
+ char **r = null;
// list
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = iListDupS(l);
ck_assert_uint_eq(listLengthS(l2),4);
ck_assert_str_eq(l2[0], "1");
@@ -13810,12 +15345,17 @@ void listReverseST(CuTest *tc UNUSED) {
char **l = NULL;
char **l2;
+ char **r = null;
// list
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listReverseS(l);
ck_assert_uint_eq(listLengthS(l2),4);
ck_assert_str_eq(l2[0], "4444");
@@ -13837,28 +15377,37 @@ void listReverseST(CuTest *tc UNUSED) {
void iListReverseST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// list
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- iListReverseS(&l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = iListReverseS(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "4444");
ck_assert_str_eq(l[3], "1");
listFreeS(l);
// empty list
listEmptyS(l)
- iListReverseS(&l);
+ r = iListReverseS(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmptyS(l));
listFreeS(l);
// NULL list
l = NULL;
- iListReverseS(&l);
+ r = iListReverseS(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iListReverseS(NULL);
+ r = iListReverseS(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -13898,17 +15447,27 @@ void listAppendST(CuTest *tc UNUSED) {
char **l = NULL;
char **l2 = NULL;
+ char **r = null;
// lists
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- listAppendS(&l2,l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = listAppendS(&l2,l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
@@ -13916,11 +15475,16 @@ void listAppendST(CuTest *tc UNUSED) {
ck_assert_str_eq(l2[7],"4444");
listFreeS(l);
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listAppendS(&l,l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listAppendS(&l,l);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),8);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
@@ -13929,12 +15493,14 @@ void listAppendST(CuTest *tc UNUSED) {
listFreeS(l);
// empty list + list
listEmptyS(l)
- listAppendS(&l, l2);
+ r = listAppendS(&l, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listEqS(l,l2));
listFreeS(l);
// list + empty list
listEmptyS(l)
- listAppendS(&l2, l);
+ r = listAppendS(&l2, l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
@@ -13943,16 +15509,19 @@ void listAppendST(CuTest *tc UNUSED) {
listFreeS(l);
// empty list + empty list
listEmptyS(l)
- listAppendS(&l, l);
+ r = listAppendS(&l, l);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmptyS(l));
listFreeS(l);
// NULL list + list = duplicate
l = NULL;
- listAppendS(&l,l2);
+ r = listAppendS(&l,l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listEqS(l,l2));
listFreeS(l);
// list + NULL list
- listAppendS(&l2, NULL);
+ r = listAppendS(&l2, NULL);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
@@ -13960,7 +15529,8 @@ void listAppendST(CuTest *tc UNUSED) {
ck_assert_str_eq(l2[7],"4444");
listFreeS(l2);
// NULL list pointer
- listAppendS(NULL,l2);
+ r = listAppendS(NULL,l2);
+ ck_assert_ptr_eq(r, null);
// should not crash
}
@@ -13968,19 +15538,29 @@ void listAppendST(CuTest *tc UNUSED) {
void iListAppendST(CuTest *tc UNUSED) {
- char **l = NULL;
+ char **l = NULL;
char **l2 = NULL;
+ char **r = null;
// lists
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- iListAppendS(&l2,l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = iListAppendS(&l2,l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
@@ -13988,33 +15568,48 @@ void iListAppendST(CuTest *tc UNUSED) {
ck_assert_str_eq(l2[7],"4444");
free(l);
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- iListAppendS(&l,l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = iListAppendS(&l,l);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
listFreeS(l);
// empty list + list
listEmptyS(l)
- iListAppendS(&l, l2);
+ r = iListAppendS(&l, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listEqS(l,l2));
free(l2);
listFreeS(l);
// list + empty list
l2 = NULL;
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- listPushS(&l2, "1");
- listPushS(&l2, "22");
- listPushS(&l2, "333");
- listPushS(&l2, "4444");
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "1");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "22");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "333");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "4444");
+ ck_assert_ptr_eq(r, l2);
listEmptyS(l)
- iListAppendS(&l2, l);
+ r = iListAppendS(&l2, l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
@@ -14025,28 +15620,36 @@ void iListAppendST(CuTest *tc UNUSED) {
// empty list + empty list
listEmptyS(l);
listEmptyS(l2);
- iListAppendS(&l, l2);
+ r = iListAppendS(&l, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmptyS(l));
listFreeS(l);
listFreeS(l2);
// NULL list + list = duplicate
l = NULL;
l2 = NULL;
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- iListAppendS(&l,l2);
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = iListAppendS(&l,l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listEqS(l,l2));
free(l);
// list + NULL list
- iListAppendS(&l2, NULL);
+ r = iListAppendS(&l2, NULL);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),4);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
listFreeS(l2);
// NULL list pointer
- iListAppendS(NULL,l2);
+ r = iListAppendS(NULL,l2);
+ ck_assert_ptr_eq(r, null);
// should not crash
}
@@ -14054,37 +15657,53 @@ void iListAppendST(CuTest *tc UNUSED) {
void iListAppendNSmashST(CuTest *tc UNUSED) {
- char **l = NULL;
+ char **l = NULL;
char **l2 = NULL;
+ char **r = null;
// lists
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- iListAppendNSmashS(&l2,l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = iListAppendNSmashS(&l2,l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
ck_assert_str_eq(l2[4],"1");
ck_assert_str_eq(l2[7],"4444");
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- iListAppendNSmashS(&l,l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = iListAppendNSmashS(&l,l);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
listFreeS(l);
// empty list + list
listEmptyS(l)
- iListAppendNSmashS(&l, l2);
+ r = iListAppendNSmashS(&l, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "A");
ck_assert_str_eq(l[3], "DDDD");
ck_assert_str_eq(l[4],"1");
@@ -14092,16 +15711,25 @@ void iListAppendNSmashST(CuTest *tc UNUSED) {
listFreeS(l);
// list + empty list
l2 = NULL;
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- listPushS(&l2, "1");
- listPushS(&l2, "22");
- listPushS(&l2, "333");
- listPushS(&l2, "4444");
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "1");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "22");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "333");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "4444");
+ ck_assert_ptr_eq(r, l2);
listEmptyS(l)
- iListAppendNSmashS(&l2, l);
+ r = iListAppendNSmashS(&l2, l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
@@ -14111,29 +15739,37 @@ void iListAppendNSmashST(CuTest *tc UNUSED) {
// empty list + empty list
listEmptyS(l);
listEmptyS(l2);
- iListAppendNSmashS(&l, l2);
+ r = iListAppendNSmashS(&l, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmptyS(l));
listFreeS(l);
// NULL list + list = duplicate
l = NULL;
l2 = NULL;
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- iListAppendNSmashS(&l,l2);
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = iListAppendNSmashS(&l,l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "A");
ck_assert_str_eq(l[1], "BB");
ck_assert_str_eq(l[2], "CCC");
ck_assert_str_eq(l[3], "DDDD");
// list + NULL list
- iListAppendNSmashS(&l, NULL);
+ r = iListAppendNSmashS(&l, NULL);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "A");
ck_assert_str_eq(l[3], "DDDD");
listFreeS(l);
// NULL list pointer
- iListAppendNSmashS(NULL,l);
+ r = iListAppendNSmashS(NULL,l);
+ ck_assert_ptr_eq(r, null);
// should not crash
}
@@ -14143,17 +15779,27 @@ void listShiftST(CuTest *tc UNUSED) {
char **l = NULL;
char **l2 = NULL;
+ char **r = null;
// lists
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- listShiftS(&l2,l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = listShiftS(&l2,l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[4], "A");
ck_assert_str_eq(l2[7], "DDDD");
@@ -14161,11 +15807,16 @@ void listShiftST(CuTest *tc UNUSED) {
ck_assert_str_eq(l2[3],"4444");
listFreeS(l);
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listShiftS(&l,l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listShiftS(&l,l);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),8);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
@@ -14174,12 +15825,14 @@ void listShiftST(CuTest *tc UNUSED) {
listFreeS(l);
// empty list + list
listEmptyS(l)
- listShiftS(&l, l2);
+ r = listShiftS(&l, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listEqS(l,l2));
listFreeS(l);
// list + empty list
listEmptyS(l)
- listShiftS(&l2, l);
+ r = listShiftS(&l2, l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[4], "A");
ck_assert_str_eq(l2[7], "DDDD");
@@ -14188,16 +15841,19 @@ void listShiftST(CuTest *tc UNUSED) {
listFreeS(l);
// empty list + empty list
listEmptyS(l)
- listShiftS(&l, l);
+ r = listShiftS(&l, l);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmptyS(l));
listFreeS(l);
// NULL list + list = duplicate
l = NULL;
- listShiftS(&l,l2);
+ r = listShiftS(&l,l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listEqS(l,l2));
listFreeS(l);
// list + NULL list
- listShiftS(&l2, NULL);
+ r = listShiftS(&l2, NULL);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[4], "A");
ck_assert_str_eq(l2[7], "DDDD");
@@ -14205,7 +15861,8 @@ void listShiftST(CuTest *tc UNUSED) {
ck_assert_str_eq(l2[3],"4444");
listFreeS(l2);
// NULL list pointer
- listShiftS(NULL,l2);
+ r = listShiftS(NULL,l2);
+ ck_assert_ptr_eq(r, null);
// should not crash
@@ -14216,17 +15873,27 @@ void iListShiftST(CuTest *tc UNUSED) {
char **l = NULL;
char **l2 = NULL;
+ char **r = null;
// lists
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- iListShiftS(&l2,l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = iListShiftS(&l2,l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[4], "A");
ck_assert_str_eq(l2[7], "DDDD");
@@ -14234,33 +15901,48 @@ void iListShiftST(CuTest *tc UNUSED) {
ck_assert_str_eq(l2[3],"4444");
free(l);
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- iListShiftS(&l,l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = iListShiftS(&l,l);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
listFreeS(l);
// empty list + list
listEmptyS(l)
- iListShiftS(&l, l2);
+ r = iListShiftS(&l, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listEqS(l,l2));
free(l2);
listFreeS(l);
// list + empty list
l2 = NULL;
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- listPushS(&l2, "1");
- listPushS(&l2, "22");
- listPushS(&l2, "333");
- listPushS(&l2, "4444");
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "1");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "22");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "333");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "4444");
+ ck_assert_ptr_eq(r, l2);
listEmptyS(l)
- iListShiftS(&l2, l);
+ r = iListShiftS(&l2, l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
@@ -14271,28 +15953,36 @@ void iListShiftST(CuTest *tc UNUSED) {
// empty list + empty list
listEmptyS(l);
listEmptyS(l2);
- iListShiftS(&l, l2);
+ r = iListShiftS(&l, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmptyS(l));
listFreeS(l);
listFreeS(l2);
// NULL list + list = duplicate
l = NULL;
l2 = NULL;
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- iListShiftS(&l,l2);
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = iListShiftS(&l,l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listEqS(l,l2));
free(l);
// list + NULL list
- iListShiftS(&l2, NULL);
+ r = iListShiftS(&l2, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l2),4);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
listFreeS(l2);
// NULL list pointer
- iListShiftS(NULL,l2);
+ r = iListShiftS(NULL,l2);
+ ck_assert_ptr_eq(r, null);
// should not crash
@@ -14301,37 +15991,53 @@ void iListShiftST(CuTest *tc UNUSED) {
void iListShiftNSmashST(CuTest *tc UNUSED) {
- char **l = NULL;
+ char **l = NULL;
char **l2 = NULL;
+ char **r = null;
// lists
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- iListShiftNSmashS(&l2,l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = iListShiftNSmashS(&l2,l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[4], "A");
ck_assert_str_eq(l2[7], "DDDD");
ck_assert_str_eq(l2[0],"1");
ck_assert_str_eq(l2[3],"4444");
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- iListShiftNSmashS(&l,l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = iListShiftNSmashS(&l,l);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
listFreeS(l);
// empty list + list
listEmptyS(l)
- iListShiftNSmashS(&l, l2);
+ r = iListShiftNSmashS(&l, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[4], "A");
ck_assert_str_eq(l[7], "DDDD");
ck_assert_str_eq(l[0],"1");
@@ -14339,16 +16045,25 @@ void iListShiftNSmashST(CuTest *tc UNUSED) {
listFreeS(l);
// list + empty list
l2 = NULL;
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- listPushS(&l2, "1");
- listPushS(&l2, "22");
- listPushS(&l2, "333");
- listPushS(&l2, "4444");
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "1");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "22");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "333");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "4444");
+ ck_assert_ptr_eq(r, l2);
listEmptyS(l)
- iListShiftNSmashS(&l2, l);
+ r = iListShiftNSmashS(&l2, l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
@@ -14358,29 +16073,37 @@ void iListShiftNSmashST(CuTest *tc UNUSED) {
// empty list + empty list
listEmptyS(l);
listEmptyS(l2);
- iListShiftNSmashS(&l, l2);
+ r = iListShiftNSmashS(&l, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmptyS(l));
listFreeS(l);
// NULL list + list = duplicate
l = NULL;
l2 = NULL;
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- iListShiftNSmashS(&l,l2);
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = iListShiftNSmashS(&l,l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "A");
ck_assert_str_eq(l[1], "BB");
ck_assert_str_eq(l[2], "CCC");
ck_assert_str_eq(l[3], "DDDD");
// list + NULL list
- iListShiftNSmashS(&l, NULL);
+ r = iListShiftNSmashS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "A");
ck_assert_str_eq(l[3], "DDDD");
listFreeS(l);
// NULL list pointer
- iListShiftNSmashS(NULL,l);
+ r = iListShiftNSmashS(NULL,l);
+ ck_assert_ptr_eq(r, null);
// should not crash
@@ -14389,19 +16112,28 @@ void iListShiftNSmashST(CuTest *tc UNUSED) {
void listAddST(CuTest *tc UNUSED) {
- char **l = NULL;
+ char **l = NULL;
char **l2 = NULL;
char **l3;
+ char **r = null;
// lists
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
l3 = listAddS(l2,l);
ck_assert_uint_eq(listLengthS(l3),8);
ck_assert_str_eq(l3[0], "A");
@@ -14447,12 +16179,17 @@ void listSliceST(CuTest *tc UNUSED) {
char **l = NULL;
char **l2;
+ char **r = null;
// list negative index
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listSliceS(l, 1,-1);
ck_assert_uint_eq(listLengthS(l2),2);
ck_assert_str_eq(l2[0], "22");
@@ -14473,8 +16210,10 @@ void listSliceST(CuTest *tc UNUSED) {
listFreeS(l);
// negative start last element
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
l2 = listSliceS(l, -1,0);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "22");
@@ -14482,8 +16221,10 @@ void listSliceST(CuTest *tc UNUSED) {
listFreeS(l2);
// start = end
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
l2 = listSliceS(l, 1,1);
ck_assert_uint_eq(listLengthS(l2),0);
ck_assert_ptr_eq(l2[0], NULL);
@@ -14505,12 +16246,17 @@ void iListCopyST(CuTest *tc UNUSED) {
char **l = NULL;
char **l2;
+ char **r = null;
// list negative index
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = iListCopyS(l, 1,-1);
ck_assert_uint_eq(listLengthS(l2),2);
ck_assert_str_eq(l2[0], "22");
@@ -14519,10 +16265,14 @@ void iListCopyST(CuTest *tc UNUSED) {
listFreeS(l);
// start outside
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(iListCopyS(l, 20,-4), NULL);
// end outside
l2 = iListCopyS(l, 2,40);
@@ -14533,18 +16283,24 @@ void iListCopyST(CuTest *tc UNUSED) {
listFreeS(l);
// end negative and outside
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(iListCopyS(l, 2,-40), NULL);
// end before start
ck_assert_ptr_eq(iListCopyS(l, 3,2), NULL);
listFreeS(l);
// negative start last element
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
l2 = iListCopyS(l, -1,0);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "22");
@@ -14552,8 +16308,10 @@ void iListCopyST(CuTest *tc UNUSED) {
listFreeS(l);
// start = end
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
l2 = iListCopyS(l, 1,1);
ck_assert_uint_eq(listLengthS(l2),0);
ck_assert_ptr_eq(l2[0], NULL);
@@ -14574,62 +16332,87 @@ void iListCopyST(CuTest *tc UNUSED) {
void iListSliceST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// list negative index
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- iListSliceS(&l, 1,-1);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = iListSliceS(&l, 1,-1);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),2);
ck_assert_str_eq(l[0], "22");
ck_assert_str_eq(l[1], "333");
// start outside
- listPushS(&l, "1");
- listPushS(&l, "22");
- iListSliceS(&l, 20,-4);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = iListSliceS(&l, 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),0);
// end outside
- iListSliceS(&l, 2,40);
+ r = iListSliceS(&l, 2,40);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),0);
// end negative and outside
- iListSliceS(&l, 2,-40);
+ r = iListSliceS(&l, 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),0);
// end before start
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l, "55555");
- iListSliceS(&l, 3,2);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "55555");
+ ck_assert_ptr_eq(r, l);
+ r = iListSliceS(&l, 3,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),0);
listFreeS(l);
// negative start last element
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
- iListSliceS(&l, -1,0);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = iListSliceS(&l, -1,0);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),1);
ck_assert_str_eq(l[0], "22");
listFreeS(l);
// start = end
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
- iListSliceS(&l, 1,1);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = iListSliceS(&l, 1,1);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),0);
ck_assert_ptr_eq(l[0], NULL);
listFreeS(l);
// empty list
listEmptyS(l)
- iListSliceS(&l, 0,0);
+ r = iListSliceS(&l, 0,0);
+ ck_assert_ptr_eq(r, null);
ck_assert(listIsEmptyS(l));
- iListSliceS(&l, -1,0);
+ r = iListSliceS(&l, -1,0);
+ ck_assert_ptr_eq(r, null);
ck_assert(listIsEmptyS(l));
listFreeS(l);
// NULL list
l = NULL;
- iListSliceS(&l, 2,-4);
+ r = iListSliceS(&l, 2,-4);
+ ck_assert_ptr_eq(r, null);
// NULL var
- iListSliceS(NULL, 2,-4);
+ r = iListSliceS(NULL, 2,-4);
+ ck_assert_ptr_eq(r, null);
}
@@ -14639,12 +16422,17 @@ void listCropST(CuTest *tc UNUSED) {
char **l = NULL;
char **l2;
+ char **r = null;
// list negative index
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listCropS(l, 1,-1);
ck_assert_uint_eq(listLengthS(l2),2);
ck_assert_str_eq(l2[0], "22");
@@ -14665,10 +16453,14 @@ void listCropST(CuTest *tc UNUSED) {
listFreeS(l);
// end negative and outside
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(listCropS(l, 2,-40), NULL);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
@@ -14683,8 +16475,10 @@ void listCropST(CuTest *tc UNUSED) {
listFreeS(l);
// negative start last element
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
l2 = listCropS(l, -1,0);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "22");
@@ -14694,8 +16488,10 @@ void listCropST(CuTest *tc UNUSED) {
listFreeS(l2);
// start = end
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
l2 = listCropS(l, 1,1);
ck_assert_uint_eq(listLengthS(l2),0);
ck_assert_ptr_eq(l2[0], NULL);
@@ -14720,12 +16516,17 @@ void iListCropST(CuTest *tc UNUSED) {
char **l = NULL;
char **l2;
+ char **r = null;
// list negative index
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = iListCropS(&l, 1,-1);
ck_assert_uint_eq(listLengthS(l2),2);
ck_assert_str_eq(l2[0], "22");
@@ -14746,10 +16547,14 @@ void iListCropST(CuTest *tc UNUSED) {
listFreeS(l);
// end negative and outside
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(iListCropS(&l, 2,-40), NULL);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
@@ -14764,8 +16569,10 @@ void iListCropST(CuTest *tc UNUSED) {
listFreeS(l);
// negative start last element
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
l2 = iListCropS(&l, -1,0);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "22");
@@ -14775,8 +16582,10 @@ void iListCropST(CuTest *tc UNUSED) {
listFreeS(l2);
// start = end
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
l2 = iListCropS(&l, 1,1);
ck_assert_uint_eq(listLengthS(l2),0);
ck_assert_ptr_eq(l2[0], NULL);
@@ -14803,12 +16612,17 @@ void listCropElemST(CuTest *tc UNUSED) {
char **l = NULL;
char *r;
+ char **r2 = null;
// positive index
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r2 = listPushS(&l, "1");
+ ck_assert_ptr_eq(r2, l);
+ r2 = listPushS(&l, "22");
+ ck_assert_ptr_eq(r2, l);
+ r2 = listPushS(&l, "333");
+ ck_assert_ptr_eq(r2, l);
+ r2 = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r2, l);
r = listCropElemS(l, 1);
ck_assert_str_eq(r, "22");
ck_assert_str_eq(l[0], "1");
@@ -14843,12 +16657,17 @@ void iListCropElemST(CuTest *tc UNUSED) {
char **l = NULL;
char *r;
+ char **r2 = null;
// positive index
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r2 = listPushS(&l, "1");
+ ck_assert_ptr_eq(r2, l);
+ r2 = listPushS(&l, "22");
+ ck_assert_ptr_eq(r2, l);
+ r2 = listPushS(&l, "333");
+ ck_assert_ptr_eq(r2, l);
+ r2 = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r2, l);
r = iListCropElemS(&l, 1);
ck_assert_str_eq(r, "22");
ck_assert_str_eq(l[0], "1");
@@ -14953,11 +16772,13 @@ void iListInsertST(CuTest *tc UNUSED) {
char **l;
char **l2;
+ char **r = null;
// insert
l = listCreateS("1","22");
l2 = listCreateS("lib");
- iListInsertS(&l, 0, l2);
+ r = iListInsertS(&l, 0, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),3);
ck_assert_str_eq(l[0], "lib");
ck_assert_str_eq(l[1], "1");
@@ -14967,7 +16788,8 @@ void iListInsertST(CuTest *tc UNUSED) {
// negative index
l = listCreateS("1","22");
l2 = listCreateS("lib");
- iListInsertS(&l, -1, l2);
+ r = iListInsertS(&l, -1, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),3);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
@@ -14977,7 +16799,8 @@ void iListInsertST(CuTest *tc UNUSED) {
// edge
l = listCreateS("1","22");
l2 = listCreateS("lib");
- iListInsertS(&l, 2, l2);
+ r = iListInsertS(&l, 2, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),3);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
@@ -14987,18 +16810,21 @@ void iListInsertST(CuTest *tc UNUSED) {
// outside list
l = listCreateS("1","22");
l2 = listCreateS("lib");
- iListInsertS(&l, 4, l2);
+ r = iListInsertS(&l, 4, l2);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
- iListInsertS(&l, -4, l2);
+ r = iListInsertS(&l, -4, l2);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
listFreeS(l);
// negative index in a one element list
l = listCreateS("1");
- iListInsertS(&l, -1, l2);
+ r = iListInsertS(&l, -1, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "lib");
free(l2);
@@ -15006,45 +16832,53 @@ void iListInsertST(CuTest *tc UNUSED) {
// empty list
listEmptyS(l);
l2 = listCreateS("lib");
- iListInsertS(&l, 0, l2);
+ r = iListInsertS(&l, 0, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "lib");
free(l2);
listFreeS(l);
listEmptyS(l);
l2 = listCreateS("lib");
- iListInsertS(&l, -1, l2);
+ r = iListInsertS(&l, -1, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "lib");
free(l2);
listFreeS(l);
// empty insert list
l = listCreateS("1");
listEmptyS(l2);
- iListInsertS(&l, 0, l2);
+ r = iListInsertS(&l, 0, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "1");
listFreeS(l2);
// NULL insert string
- iListInsertS(&l, 0, NULL);
+ r = iListInsertS(&l, 0, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(l[0], "1");
listFreeS(l);
// NULL list and list to insert at index 0
l = NULL;
l2 = listCreateS("lib");
- iListInsertS(&l, 0, l2);
+ r = iListInsertS(&l, 0, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "lib");
free(l2);
listFreeS(l);
// NULL list and list to insert at non 0 index
l = NULL;
l2 = listCreateS("lib");
- iListInsertS(&l, -1, l2);
+ r = iListInsertS(&l, -1, l2);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
listFreeS(l2);
// NULL list
l = NULL;
- iListInsertS(&l, 0, NULL);
+ r = iListInsertS(&l, 0, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iListInsertS(NULL, 0, NULL);
+ r = iListInsertS(NULL, 0, NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -15058,7 +16892,8 @@ void iListInsertNFreeST(CuTest *tc UNUSED) {
// insert
l = listCreateS("1","22");
l2 = listCreateS("lib");
- iListInsertNFreeS(&l, 0, l2);
+ r = iListInsertNFreeS(&l, 0, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),3);
ck_assert_str_eq(l[0], "lib");
ck_assert_str_eq(l[1], "1");
@@ -15067,7 +16902,8 @@ void iListInsertNFreeST(CuTest *tc UNUSED) {
// negative index
l = listCreateS("1","22");
l2 = listCreateS("lib");
- iListInsertNFreeS(&l, -1, l2);
+ r = iListInsertNFreeS(&l, -1, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),3);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
@@ -15076,7 +16912,8 @@ void iListInsertNFreeST(CuTest *tc UNUSED) {
// edge
l = listCreateS("1","22");
l2 = listCreateS("lib");
- iListInsertNFreeS(&l, 2, l2);
+ r = iListInsertNFreeS(&l, 2, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),3);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
@@ -15104,34 +16941,40 @@ void iListInsertNFreeST(CuTest *tc UNUSED) {
// negative index in a one element list
l = listCreateS("1");
l2 = listCreateS("lib");
- iListInsertNFreeS(&l, -1, l2);
+ r = iListInsertNFreeS(&l, -1, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "lib");
listFreeS(l);
// empty list
listEmptyS(l);
l2 = listCreateS("lib");
- iListInsertNFreeS(&l, 0, l2);
+ r = iListInsertNFreeS(&l, 0, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "lib");
listFreeS(l);
listEmptyS(l);
l2 = listCreateS("lib");
- iListInsertNFreeS(&l, -1, l2);
+ r = iListInsertNFreeS(&l, -1, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "lib");
listFreeS(l);
// empty insert list
l = listCreateS("1");
listEmptyS(l2);
- iListInsertNFreeS(&l, 0, l2);
+ r = iListInsertNFreeS(&l, 0, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "1");
// NULL insert string
- iListInsertNFreeS(&l, 0, NULL);
+ r = iListInsertNFreeS(&l, 0, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(l[0], "1");
listFreeS(l);
// NULL list
l = NULL;
l2 = listCreateS("lib");
- iListInsertNFreeS(&l, 0, l2);
+ r = iListInsertNFreeS(&l, 0, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "lib");
listFreeS(l);
// NULL var
@@ -15266,10 +17109,12 @@ void listInjectCharST(CuTest *tc UNUSED) {
void iListInjectST(CuTest *tc UNUSED) {
char **l;
+ char **r = null;
// insert
l = listCreateS("1","22");
- iListInjectS(&l, 0, strdup("lib"));
+ r = iListInjectS(&l, 0, strdup("lib"));
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),3);
ck_assert_str_eq(l[0], "lib");
ck_assert_str_eq(l[1], "1");
@@ -15277,7 +17122,8 @@ void iListInjectST(CuTest *tc UNUSED) {
listFreeS(l);
// negative index
l = listCreateS("1","22");
- iListInjectS(&l, -1, strdup("lib"));
+ r = iListInjectS(&l, -1, strdup("lib"));
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),3);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
@@ -15285,7 +17131,8 @@ void iListInjectST(CuTest *tc UNUSED) {
listFreeS(l);
// edge
l = listCreateS("1","22");
- iListInjectS(&l, 2, strdup("lib"));
+ r = iListInjectS(&l, 2, strdup("lib"));
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),3);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
@@ -15293,46 +17140,55 @@ void iListInjectST(CuTest *tc UNUSED) {
listFreeS(l);
// outside list
l = listCreateS("1","22");
- iListInjectS(&l, 4, "lib");
+ r = iListInjectS(&l, 4, "lib");
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
- iListInjectS(&l, -4, "lib");
+ r = iListInjectS(&l, -4, "lib");
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
listFreeS(l);
// negative index in a one element list
l = listCreateS("1");
- iListInjectS(&l, -1, strdup("lib"));
+ r = iListInjectS(&l, -1, strdup("lib"));
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "lib");
listFreeS(l);
// empty list
listEmptyS(l);
- iListInjectS(&l, 0, strdup("lib"));
+ r = iListInjectS(&l, 0, strdup("lib"));
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "lib");
listFreeS(l);
listEmptyS(l);
- iListInjectS(&l, -1, strdup("lib"));
+ r = iListInjectS(&l, -1, strdup("lib"));
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "lib");
listFreeS(l);
// NULL insert string
l = listCreateS("1");
- iListInjectS(&l, 0, NULL);
+ r = iListInjectS(&l, 0, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(l[0], "1");
listFreeS(l);
// NULL list and non zero index
l = NULL;
- iListInjectS(&l, 1, "");
+ r = iListInjectS(&l, 1, "");
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// NULL list and zero index
l = NULL;
- iListInjectS(&l, 0, "aa");
+ r = iListInjectS(&l, 0, "aa");
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "aa");
free(l);
// NULL var
- ck_assert_ptr_eq(iListInjectS(NULL, 0, ""), NULL);
+ r = iListInjectS(NULL, 0, "");
+ ck_assert_ptr_eq(r, null);
}
@@ -15341,10 +17197,12 @@ void iListInjectST(CuTest *tc UNUSED) {
void iListInjectCharST(CuTest *tc UNUSED) {
char **l;
+ char **r = null;
// insert
l = listCreateS("1","22");
- iListInjectCharS(&l, 1, 'a');
+ r = iListInjectCharS(&l, 1, 'a');
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),3);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "a");
@@ -15352,15 +17210,18 @@ void iListInjectCharST(CuTest *tc UNUSED) {
listFreeS(l);
// NULL list and zero index
l = NULL;
- iListInjectCharS(&l, 0, 'a');
+ r = iListInjectCharS(&l, 0, 'a');
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "a");
listFreeS(l);
// NULL list and non zero index
l = NULL;
- iListInjectCharS(&l, 1, 'a');
+ r = iListInjectCharS(&l, 1, 'a');
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(l, NULL);
// NULL var
- ck_assert_ptr_eq(iListInjectCharS(NULL, 1, 'a'), NULL);
+ r = iListInjectCharS(NULL, 1, 'a');
+ ck_assert_ptr_eq(r, null);
}
@@ -15369,12 +17230,17 @@ void listDelST(CuTest *tc UNUSED) {
char **l = NULL;
char **l2;
+ char **r = null;
// list negative index
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listDelS(l, 1,-1);
ck_assert_uint_eq(listLengthS(l2),2);
ck_assert_str_eq(l2[0], "1");
@@ -15395,8 +17261,10 @@ void listDelST(CuTest *tc UNUSED) {
listFreeS(l);
// negative start last element
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
l2 = listDelS(l, -1,0);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "1");
@@ -15404,8 +17272,10 @@ void listDelST(CuTest *tc UNUSED) {
listFreeS(l2);
// start negative and outside (delete complete list because end is 0 (=len))
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
l2 = listDelS(l, -3,0);
ck_assert_uint_eq(listLengthS(l2),0);
ck_assert_ptr_eq(l2[0], NULL);
@@ -15413,8 +17283,10 @@ void listDelST(CuTest *tc UNUSED) {
listFreeS(l2);
// start = end
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
l2 = listDelS(l, 1,1);
ck_assert_uint_eq(listLengthS(l2),2);
ck_assert_str_eq(l2[0], "1");
@@ -15436,82 +17308,117 @@ void listDelST(CuTest *tc UNUSED) {
void iListDelST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// list negative index
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- iListDelS(&l, 1,-1);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = iListDelS(&l, 1,-1);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "4444");
- iListEmptySF(&l);
+ r = iListEmptySF(&l);
+ ck_assert_ptr_eq(r, l);
// start outside
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- iListDelS(&l, 20,-4);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = iListDelS(&l, 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
// end outside
- iListDelS(&l, 2,40);
+ r = iListDelS(&l, 2,40);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
- iListEmptySF(&l);
+ r = iListEmptySF(&l);
+ ck_assert_ptr_eq(r, l);
// end negative and outside
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- iListDelS(&l, 2,-40);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = iListDelS(&l, 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
// end before start
- iListDelS(&l, 3,2);
+ r = iListDelS(&l, 3,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
- iListEmptySF(&l);
+ r = iListEmptySF(&l);
+ ck_assert_ptr_eq(r, l);
// negative start last element
- listPushS(&l, "1");
- listPushS(&l, "22");
- iListDelS(&l, -1,0);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = iListDelS(&l, -1,0);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),1);
ck_assert_str_eq(l[0], "1");
- iListEmptySF(&l);
+ r = iListEmptySF(&l);
+ ck_assert_ptr_eq(r, l);
// start negative and outside (delete complete list because end is 0 (=len))
- listPushS(&l, "1");
- listPushS(&l, "22");
- iListDelS(&l, -3,0);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = iListDelS(&l, -3,0);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),0);
ck_assert_ptr_eq(l[0], NULL);
// start = end
// (l is empty from previous test)
- listPushS(&l, "1");
- listPushS(&l, "22");
- iListDelS(&l, 1,1);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = iListDelS(&l, 1,1);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
listFreeS(l);
// empty list
listEmptyS(l);
- iListDelS(&l, 0,0);
+ r = iListDelS(&l, 0,0);
+ ck_assert_ptr_eq(r, null);
ck_assert(listIsEmptyS(l));
- iListDelS(&l, -1,0);
+ r = iListDelS(&l, -1,0);
+ ck_assert_ptr_eq(r, null);
ck_assert(listIsEmptyS(l));
listFreeS(l);
// NULL list
l = NULL;
- iListDelS(&l, 2,-4);
+ r = iListDelS(&l, 2,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iListDelS(NULL, 2,-4);
+ r = iListDelS(NULL, 2,-4);
+ ck_assert_ptr_eq(r, null);
}
@@ -15520,22 +17427,32 @@ void iListDelST(CuTest *tc UNUSED) {
void iListRemoveST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// list negative index
- listPushS(&l, "1");
- iListPushS(&l, "22");
- iListPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = iListPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = iListPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
iListRemoveS(&l, 1,-1);
ck_assert_uint_eq(listLengthS(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "4444");
- iListEmptySF(&l);
+ r = iListEmptySF(&l);
+ ck_assert_ptr_eq(r, l);
// start outside
- listPushS(&l, "1");
- listPushS(&l, "22");
- iListPushS(&l, "333");
- iListPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = iListPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = iListPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
iListRemoveS(&l, 20,-4);
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "1");
@@ -15545,12 +17462,17 @@ void iListRemoveST(CuTest *tc UNUSED) {
ck_assert_uint_eq(listLengthS(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
- iListEmptySF(&l);
+ r = iListEmptySF(&l);
+ ck_assert_ptr_eq(r, l);
// end negative and outside
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
iListRemoveS(&l, 2,-40);
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "1");
@@ -15560,24 +17482,32 @@ void iListRemoveST(CuTest *tc UNUSED) {
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
- iListEmptySF(&l);
+ r = iListEmptySF(&l);
+ ck_assert_ptr_eq(r, l);
// negative start last element
- listPushS(&l, "1");
- iListPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = iListPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
iListRemoveS(&l, -1,0);
ck_assert_uint_eq(listLengthS(l),1);
ck_assert_str_eq(l[0], "1");
- iListEmptySF(&l);
+ r = iListEmptySF(&l);
+ ck_assert_ptr_eq(r, l);
// start negative and outside (delete complete list because end is 0 (=len))
- iListPushS(&l, "1");
- iListPushS(&l, "22");
+ r = iListPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = iListPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
iListRemoveS(&l, -3,0);
ck_assert_uint_eq(listLengthS(l),0);
ck_assert_ptr_eq(l[0], NULL);
// start = end
// (l is empty from previous test)
- listPushS(&l, "1");
- listPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
iListRemoveS(&l, 1,1);
ck_assert_uint_eq(listLengthS(l),2);
ck_assert_str_eq(l[0], "1");
@@ -15605,12 +17535,17 @@ void listDelElemST(CuTest *tc UNUSED) {
char **l = NULL;
char **l2;
+ char **r = null;
// positive index
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listDelElemS(l, 1);
ck_assert_str_eq(l2[0], "1");
ck_assert_str_eq(l2[1], "333");
@@ -15646,10 +17581,14 @@ void iListDelElemST(CuTest *tc UNUSED) {
char **r;
// positive index
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
r = iListDelElemS(&l, 1);
ck_assert_ptr_ne(r, null);
ck_assert_str_eq(l[0], "1");
@@ -15686,10 +17625,14 @@ void iListRemoveElemST(CuTest *tc UNUSED) {
char **r;
// positive index
- listPushS(&l, "1");
- iListPushS(&l, "22");
- listPushS(&l, "333");
- iListPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = iListPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = iListPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
r = iListRemoveElemS(&l, 1);
ck_assert_ptr_ne(r, null);
ck_assert_str_eq(l[0], "1");
@@ -15841,12 +17784,17 @@ void listEqST(CuTest *tc UNUSED) {
char **l = NULL;
char **l2;
+ char **r = null;
// identical lists
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listDupS(l);
ck_assert(listEqS(l,l2));
// NULL lists
@@ -15869,12 +17817,17 @@ void listEqST(CuTest *tc UNUSED) {
void listHasST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert(listHasS(l, "1"));
// NULL list
ck_assert(!listHasS(NULL, "1"));
@@ -15892,12 +17845,17 @@ void listHasST(CuTest *tc UNUSED) {
void listHasCharST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert(listHasCharS(l, '1'));
// NULL list
ck_assert(!listHasCharS(NULL, '1'));
@@ -15912,12 +17870,17 @@ void listHasCharST(CuTest *tc UNUSED) {
void listIndexOfST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listIndexOfS(l, "1"),0);
// NULL list
ck_assert_uint_eq(listIndexOfS(NULL, "1"),-1);
@@ -15935,12 +17898,17 @@ void listIndexOfST(CuTest *tc UNUSED) {
void listIndexOfCharST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listIndexOfCharS(l, '1'),0);
// NULL list
ck_assert_uint_eq(listIndexOfCharS(NULL, '1'),-1);
@@ -15955,14 +17923,21 @@ void listIndexOfCharST(CuTest *tc UNUSED) {
void listBinarySearchST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l, "5");
- listPushS(&l, "6");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "5");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "6");
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listBinarySearchS(l, "1"),0);
// NULL list
ck_assert_uint_eq(listBinarySearchS(NULL, "1"),-1);
@@ -15980,14 +17955,21 @@ void listBinarySearchST(CuTest *tc UNUSED) {
void listBinarySearchCharST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l, "5");
- listPushS(&l, "6");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "5");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "6");
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listBinarySearchCharS(l, '1'),0);
// NULL list
ck_assert_uint_eq(listBinarySearchCharS(NULL, '1'),-1);
@@ -16005,12 +17987,17 @@ void listUniqST(CuTest *tc UNUSED) {
char **l = NULL;
char **l2;
+ char **r = null;
// list with unique elements
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listUniqS(l);
ck_assert(listEqS(l,l2));
// list with identical elements
@@ -16025,7 +18012,8 @@ void listUniqST(CuTest *tc UNUSED) {
listFreeS(l2);
// list with one element
l = NULL;
- listPushS(&l, "1");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
l2 = listUniqS(l);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "1");
@@ -16048,14 +18036,20 @@ void iListUniqST(CuTest *tc UNUSED) {
char **l = NULL;
char **l2;
+ char **r = null;
// list with unique elements
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listDupS(l);
- iListUniqS(&l2);
+ r = iListUniqS(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert(listEqS(l,l2));
// list with identical elements
l[2][0] = '2';
@@ -16063,16 +18057,19 @@ void iListUniqST(CuTest *tc UNUSED) {
l[2][2] = 0;
listFreeS(l2);
l2 = listDupS(l);
- iListUniqS(&l2);
+ r = iListUniqS(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),3);
ck_assert_str_eq(l2[2], "4444");
listFreeS(l);
listFreeS(l2);
// list with one element
l = NULL;
- listPushS(&l, "1");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
l2 = listDupS(l);
- iListUniqS(&l2);
+ r = iListUniqS(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "1");
listFreeS(l);
@@ -16080,17 +18077,20 @@ void iListUniqST(CuTest *tc UNUSED) {
// empty list
listEmptyS(l)
l2 = listDupS(l);
- iListUniqS(&l2);
+ r = iListUniqS(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),0);
ck_assert_ptr_eq(l2[0], NULL);
listFreeS(l);
listFreeS(l2);
// NULL list
l = NULL;
- iListUniqS(&l);
+ r = iListUniqS(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iListUniqS(NULL);
+ r = iListUniqS(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -16099,14 +18099,21 @@ void icListEqST(CuTest *tc UNUSED) {
char **l = NULL;
char **l2;
+ char **r2 = null;
+ char *r = null;
// identical lists
- listPushS(&l, "1");
- listPushS(&l, "bb");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r2 = listPushS(&l, "1");
+ ck_assert_ptr_eq(r2, l);
+ r2 = listPushS(&l, "bb");
+ ck_assert_ptr_eq(r2, l);
+ r2 = listPushS(&l, "333");
+ ck_assert_ptr_eq(r2, l);
+ r2 = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r2, l);
l2 = listDupS(l);
- iUpperS(&l2[1]);
+ r = iUpperS(&l2[1]);
+ ck_assert_ptr_eq(r, l2[1]);
ck_assert(icListEqS(l,l2));
// NULL lists
ck_assert(!icListEqS(NULL,l));
@@ -16129,12 +18136,17 @@ void icListEqST(CuTest *tc UNUSED) {
void icListHasST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "a");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "a");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert(icListHasS(l, "A"));
// NULL list
ck_assert(!icListHasS(NULL, "1"));
@@ -16153,12 +18165,17 @@ void icListHasST(CuTest *tc UNUSED) {
void icListHasCharST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "A");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "A");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert(icListHasCharS(l, 'a'));
// NULL list
ck_assert(!icListHasCharS(NULL, '1'));
@@ -16173,12 +18190,17 @@ void icListHasCharST(CuTest *tc UNUSED) {
void icListIndexOfST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "a");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "a");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(icListIndexOfS(l, "A"),0);
// NULL list
ck_assert_uint_eq(icListIndexOfS(NULL, "1"),-1);
@@ -16197,12 +18219,17 @@ void icListIndexOfST(CuTest *tc UNUSED) {
void icListIndexOfCharST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "A");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "A");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(icListIndexOfCharS(l, 'a'),0);
// NULL list
ck_assert_uint_eq(icListIndexOfCharS(NULL, '1'),-1);
@@ -16217,15 +18244,23 @@ void icListIndexOfCharST(CuTest *tc UNUSED) {
void icListBinarySearchST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "a");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l, "ccc");
- listPushS(&l, "6");
- iListSortS(&l);
+ r = listPushS(&l, "a");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "ccc");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "6");
+ ck_assert_ptr_eq(r, l);
+ r = iListSortS(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(icListBinarySearchS(l, "A"),4);
// NULL list
ck_assert_uint_eq(icListBinarySearchS(NULL, "1"),-1);
@@ -16244,15 +18279,23 @@ void icListBinarySearchST(CuTest *tc UNUSED) {
void icListBinarySearchCharST(CuTest *tc UNUSED) {
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "A");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l, "C");
- listPushS(&l, "6");
- iListSortS(&l);
+ r = listPushS(&l, "A");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "C");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "6");
+ ck_assert_ptr_eq(r, l);
+ r = iListSortS(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(icListBinarySearchCharS(l, 'a'),4);
// NULL list
ck_assert_uint_eq(icListBinarySearchCharS(NULL, '1'),-1);
@@ -16270,12 +18313,17 @@ void icListUniqST(CuTest *tc UNUSED) {
char **l = NULL;
char **l2;
+ char **r = null;
// list with unique elements
- listPushS(&l, "1");
- listPushS(&l, "bb");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "bb");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = icListUniqS(l);
ck_assert(listEqS(l,l2));
// list with identical elements
@@ -16290,7 +18338,8 @@ void icListUniqST(CuTest *tc UNUSED) {
listFreeS(l2);
// list with one element
l = NULL;
- listPushS(&l, "1");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
l2 = icListUniqS(l);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "1");
@@ -16314,14 +18363,20 @@ void iicListUniqST(CuTest *tc UNUSED) {
char **l = NULL;
char **l2;
+ char **r = null;
// list with unique elements
- listPushS(&l, "1");
- listPushS(&l, "BB");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "BB");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listDupS(l);
- iicListUniqS(&l2);
+ r = iicListUniqS(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert(listEqS(l,l2));
// list with identical elements
l[2][0] = 'b';
@@ -16329,16 +18384,19 @@ void iicListUniqST(CuTest *tc UNUSED) {
l[2][2] = 0;
listFreeS(l2);
l2 = listDupS(l);
- iicListUniqS(&l2);
+ r = iicListUniqS(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),3);
ck_assert_str_eq(l2[2], "4444");
listFreeS(l);
listFreeS(l2);
// list with one element
l = NULL;
- listPushS(&l, "1");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
l2 = listDupS(l);
- iicListUniqS(&l2);
+ r = iicListUniqS(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "1");
listFreeS(l);
@@ -16346,17 +18404,20 @@ void iicListUniqST(CuTest *tc UNUSED) {
// empty list
listEmptyS(l)
l2 = listDupS(l);
- iicListUniqS(&l2);
+ r = iicListUniqS(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),0);
ck_assert_ptr_eq(l2[0], NULL);
listFreeS(l);
listFreeS(l2);
// NULL list
l = NULL;
- iicListUniqS(&l);
+ r = iicListUniqS(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iicListUniqS(NULL);
+ r = iicListUniqS(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -16366,12 +18427,17 @@ void listCompactST(CuTest *tc UNUSED) {
char **l = NULL;
char **l2;
+ char **r = null;
// list with empty elements
- listPushS(&l, "1");
- listPushS(&l, "");
- listPushS(&l, "");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listCompactS(l);
ck_assert_uint_eq(listLengthS(l2),2);
ck_assert_str_eq(l2[1], "4444");
@@ -16394,39 +18460,50 @@ void iListCompactST(CuTest *tc UNUSED) {
char **l = NULL;
char **l2;
+ char **r = null;
// list with empty elements
- listPushS(&l, "1");
- listPushS(&l, "");
- listPushS(&l, "");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listDupS(l);
- iListCompactS(&l2);
+ r = iListCompactS(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),2);
ck_assert_str_eq(l2[1], "4444");
listFreeS(l);
listFreeS(l2);
// list with an empty string
l = NULL;
- listPushS(&l, "");
- iListCompactS(&l);
+ r = listPushS(&l, "");
+ ck_assert_ptr_eq(r, l);
+ r = iListCompactS(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),0);
ck_assert_ptr_eq(l[0], NULL);
listFreeS(l);
// empty list
listEmptyS(l)
l2 = listDupS(l);
- iListCompactS(&l2);
+ r = iListCompactS(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),0);
ck_assert_ptr_eq(l2[0], NULL);
listFreeS(l);
listFreeS(l2);
// NULL list
l = NULL;
- iListCompactS(&l);
+ r = iListCompactS(&l);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iListCompactS(NULL);
+ r = iListCompactS(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -16471,20 +18548,26 @@ void iListEmptyFT(CuTest *tc UNUSED) {
void **l = NULL;
char *s1 = "lib";
char *s2 = "sheepy";
+ void **r = null;
// empty list
- listPush(&l, s1);
- listPush(&l, s2);
- iListEmptyF(&l);
+ r = listPush(&l, s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, s2);
+ ck_assert_ptr_eq(r, l);
+ r = iListEmptyF(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmpty(l));
free(l);
// NULL list
l = NULL;
- iListEmptyF(&l);
+ r = iListEmptyF(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmpty(l));
free(l);
// NULL var
- iListEmptyF(NULL);
+ r = iListEmptyF(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -16494,10 +18577,13 @@ void listIsEmptyT(CuTest *tc UNUSED) {
void **l = NULL;
char *s1 = "lib";
char *s2 = "sheepy";
+ void **r = null;
// non empty list
- listPush(&l, s1);
- listPush(&l, s2);
+ r = listPush(&l, s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, s2);
+ ck_assert_ptr_eq(r, l);
// check ck_assert_ptr_null not available in jessie
ck_assert_ptr_ne(l, NULL);
ck_assert(!listIsEmpty(l));
@@ -16567,31 +18653,38 @@ void listPushT(CuTest *tc UNUSED) {
void **l = NULL;
char *s = "sheepy";
char *s2 = "SHEEPY";
+ void **r = null;
// push strings and NULL list
- listPush(&l, (void *)s);
+ r = listPush(&l, (void *)s);
+ ck_assert_ptr_eq(r, l);
// check ck_assert_ptr_null not available in jessie
ck_assert_ptr_ne(l, NULL);
ck_assert_str_eq(l[0], "sheepy");
- listPush(&l, (void *)s2);
+ r = listPush(&l, (void *)s2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[1], "SHEEPY");
ck_assert_str_eq(l[0], "sheepy");
// push NULL
- listPush(&l, NULL);
+ r = listPush(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l[2], NULL);
free(l);
// NULL list and NULL string
l = NULL;
- listPush(&l, NULL);
+ r = listPush(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// empty list
listEmpty(l);
- listPush(&l, (void *)s);
+ r = listPush(&l, (void *)s);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "sheepy");
ck_assert_ptr_eq(l[1], NULL);
free(l);
// NULL pointer to list
- listPush(NULL, NULL);
+ r = listPush(NULL, NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -16599,13 +18692,16 @@ void listPushT(CuTest *tc UNUSED) {
void listPopT(CuTest *tc UNUSED) {
void **l = NULL;
- char *s1 = "sheepy";
+ char *s1 = "sheepy";
char *s2 = "SHEEPY";
char *s;
+ void **r = null;
// pop string
- listPush(&l, (void *)s1);
- listPush(&l, (void *)s2);
+ r = listPush(&l, (void *)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void *)s2);
+ ck_assert_ptr_eq(r, l);
s = (char *)listPop(&l);
ck_assert_str_eq(s, "SHEEPY");
ck_assert_uint_eq(listLength(l),1);
@@ -16630,31 +18726,38 @@ void listPrependT(CuTest *tc UNUSED) {
void **l = NULL;
char *s1 = "sheepy";
char *s2 = "SHEEPY";
+ void **r = null;
// push strings and NULL list
- listPrepend(&l, (void *)s1);
+ r = listPrepend(&l, (void *)s1);
+ ck_assert_ptr_eq(r, l);
// check ck_assert_ptr_null not available in jessie
ck_assert_ptr_ne(l, NULL);
ck_assert_str_eq(l[0], "sheepy");
- listPrepend(&l, (void *)s2);
+ r = listPrepend(&l, (void *)s2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "SHEEPY");
ck_assert_str_eq(l[1], "sheepy");
// push NULL
- listPrepend(&l, NULL);
+ r = listPrepend(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(l[0], "SHEEPY");
free(l);
// NULL list and NULL string`
l = NULL;
- listPrepend(&l, NULL);
+ r = listPrepend(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// empty list
listEmpty(l)
- listPrepend(&l, (void *)s1);
+ r = listPrepend(&l, (void *)s1);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "sheepy");
ck_assert_ptr_eq(l[1], NULL);
free(l);
// NULL pointer to list
- listPrepend(NULL, NULL);
+ r = listPrepend(NULL, NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -16665,10 +18768,13 @@ void listDequeueT(CuTest *tc UNUSED) {
char *s1 = "sheepy";
char *s2 = "SHEEPY";
char *s;
+ void **r = null;
// pop string
- listPush(&l, (void *)s1);
- listPush(&l, (void *)s2);
+ r = listPush(&l, (void *)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void *)s2);
+ ck_assert_ptr_eq(r, l);
s = listDequeue(&l);
ck_assert_str_eq(s, "sheepy");
ck_assert_uint_eq(listLength(l),1);
@@ -16693,9 +18799,13 @@ void listFreeT(CuTest *tc UNUSED) {
void **l = NULL;
char *s1 = strdup("sheepy");
char *s2 = strdup("SHEEPY");
+ void **r = null;
+
// not possible to know if a pointer is already freed
- listPush(&l, (void *)s1);
- listPush(&l, (void *)s2);
+ r = listPush(&l, (void *)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void *)s2);
+ ck_assert_ptr_eq(r, l);
listFree(l);
// empty list
listEmpty(l);
@@ -16711,9 +18821,13 @@ void listFreeManyT(CuTest *tc UNUSED) {
void **l1 = NULL;
char *s1 = strdup("sheepy");
char *s2 = strdup("SHEEPY");
+ void **r = null;
+
// not possible to know if a pointer is already freed
- listPush(&l1, (void *)s1);
- listPush(&l1, (void *)s2);
+ r = listPush(&l1, (void *)s1);
+ ck_assert_ptr_eq(r, l1);
+ r = listPush(&l1, (void *)s2);
+ ck_assert_ptr_eq(r, l1);
void **l2 = listEmptyF();
listFreeMany(l1, l2);
@@ -16748,12 +18862,17 @@ void listGetT(CuTest *tc UNUSED) {
char *s2 = "22";
char *s3 = "333";
char *s4 = "4444";
+ void **r = null;
// get string
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(listGet(l, 0), "1");
// negative index
ck_assert_str_eq(listGet(l, -1), "4444");
@@ -16763,8 +18882,10 @@ void listGetT(CuTest *tc UNUSED) {
free(l);
// negative index in a one element list
l = NULL;
- listPush(&l, (void*)s1);
- listPush(&l, NULL);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_ne(listGet(l,-1), NULL);
free(l);
// empty list
@@ -16786,23 +18907,33 @@ void listSetT(CuTest *tc UNUSED) {
char *s4 = "4444";
char *sA = "@@";
char *sB = "|";
+ void **r = null;
// get string
- listPush(&l, (void*)sA);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)sB);
- listPush(&l, (void*)s4);
- listSet(l, 0, (void*)s1);
+ r = listPush(&l, (void*)sA);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)sB);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
+ r = listSet(l, 0, (void*)s1);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(listGet(l, 0), "1");
// negative index
- listSet(l, -2, (void*)s3);
+ r = listSet(l, -2, (void*)s3);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(listGet(l, -2), "333");
// outside list
// list is unchanged
- listSet(l, 10, (void*)s1);
- listSet(l, -10, (void*)s1);
+ r = listSet(l, 10, (void*)s1);
+ ck_assert_ptr_eq(r, null);
+ r = listSet(l, -10, (void*)s1);
+ ck_assert_ptr_eq(r, null);
// NULL s var
- listSet(l, -2, NULL);
+ r = listSet(l, -2, NULL);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
ck_assert_str_eq(l[2], "333");
@@ -16810,18 +18941,23 @@ void listSetT(CuTest *tc UNUSED) {
free(l);
// negative index in a one element list
l = NULL;
- listPush(&l, (void*)s1);
- listPush(&l, NULL);
- listSet(l, -1, (void*)s1);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, NULL);
+ ck_assert_ptr_eq(r, null);
+ r = listSet(l, -1, (void*)s1);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(listGet(l,-1), "1");
free(l);
// empty list - should not crash
listEmpty(l);
- listSet(l, 0, (void*)s1);
+ r = listSet(l, 0, (void*)s1);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(listGet(l,0),NULL);
free(l);
// NULL list
- listSet(NULL, 0, (void*)s1);
+ r = listSet(NULL, 0, (void*)s1);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(listGet(NULL, 0), NULL);
}
@@ -16835,12 +18971,17 @@ void listDupT(CuTest *tc UNUSED) {
char *s2 = "22";
char *s3 = "333";
char *s4 = "4444";
+ void **r = null;
// list
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
l2 = listDup(l);
ck_assert_uint_eq(listLength(l2),4);
ck_assert_str_eq(l2[0], "1");
@@ -16867,12 +19008,17 @@ void listReverseT(CuTest *tc UNUSED) {
char *s2 = "22";
char *s3 = "333";
char *s4 = "4444";
+ void **r = null;
// list
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
l2 = listReverse(l);
ck_assert_uint_eq(listLength(l2),4);
ck_assert_str_eq(l2[0], "4444");
@@ -16898,28 +19044,37 @@ void iListReverseT(CuTest *tc UNUSED) {
char *s2 = "22";
char *s3 = "333";
char *s4 = "4444";
+ void **r = null;
// list
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
- iListReverse(&l);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
+ r = iListReverse(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLength(l),4);
ck_assert_str_eq(l[0], "4444");
ck_assert_str_eq(l[3], "1");
free(l);
/* // empty list */
listEmpty(l);
- iListReverse(&l);
+ r = iListReverse(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmpty(l));
free(l);
// NULL list
l = NULL;
- iListReverse(&l);
+ r = iListReverse(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iListReverse(NULL);
+ r = iListReverse(NULL);
+ ck_assert_ptr_eq(r, null);
}
@@ -16935,10 +19090,14 @@ void listCatT(CuTest *tc UNUSED) {
char *s4 = "sheepy";
// cat lists
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s1);
- listPush(&l2, (void*)s3);
- listPush(&l2, (void*)s4);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l2, (void*)s3);
+ ck_assert_ptr_eq(r, l2);
+ r = listPush(&l2, (void*)s4);
+ ck_assert_ptr_eq(r, l2);
r = listCat(l,l2);
ck_assert_str_eq(r[0], "#@#");
ck_assert_str_eq(r[1], "1");
@@ -16953,8 +19112,10 @@ void listCatT(CuTest *tc UNUSED) {
// cat empty list with list
listEmpty(l);
l2 = NULL;
- listPush(&l2, (void*)s3);
- listPush(&l2, (void*)s4);
+ r = listPush(&l2, (void*)s3);
+ ck_assert_ptr_eq(r, l2);
+ r = listPush(&l2, (void*)s4);
+ ck_assert_ptr_eq(r, l2);
r = listCat(l, l2);
ck_assert_str_eq(r[0], "lib");
ck_assert_str_eq(r[1], "sheepy");
@@ -16975,17 +19136,27 @@ void listAppendT(CuTest *tc UNUSED) {
char *sB = "BB";
char *sC = "CCC";
char *sD = "DDDD";
+ void **r = null;
// lists
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
- listPush(&l2, (void*)sA);
- listPush(&l2, (void*)sB);
- listPush(&l2, (void*)sC);
- listPush(&l2, (void*)sD);
- listAppend(&l2,l);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l2, (void*)sA);
+ ck_assert_ptr_eq(r, l2);
+ r = listPush(&l2, (void*)sB);
+ ck_assert_ptr_eq(r, l2);
+ r = listPush(&l2, (void*)sC);
+ ck_assert_ptr_eq(r, l2);
+ r = listPush(&l2, (void*)sD);
+ ck_assert_ptr_eq(r, l2);
+ r = listAppend(&l2,l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLength(l2),8);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
@@ -16994,18 +19165,24 @@ void listAppendT(CuTest *tc UNUSED) {
free(l);
// append list to itself - no change
l = NULL;
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
- listAppend(&l,l);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
+ r = listAppend(&l,l);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLength(l),4);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
free(l);
// empty list + list
listEmpty(l);
- listAppend(&l, l2);
+ r = listAppend(&l, l2);
+ ck_assert_ptr_eq(r, l);
//ck_assert(listEqS(l,l2));
ck_assert_uint_eq(listLength(l),listLength(l2));
ck_assert_str_eq(l2[0], l[0]);
@@ -17015,7 +19192,8 @@ void listAppendT(CuTest *tc UNUSED) {
free(l);
// list + empty list
listEmptyS(l);
- listAppend(&l2, l);
+ r = listAppend(&l2, l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLength(l2),8);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
@@ -17026,31 +19204,39 @@ void listAppendT(CuTest *tc UNUSED) {
// empty list + empty list
listEmpty(l);
listEmpty(l2);
- listAppend(&l, l2);
+ r = listAppend(&l, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmpty(l));
free(l);
free(l2);
// NULL list + list = duplicate
l = NULL;
l2 = NULL;
- listPush(&l2, (void*)sA);
- listPush(&l2, (void*)sB);
- listPush(&l2, (void*)sC);
- listPush(&l2, (void*)sD);
- listAppend(&l,l2);
+ r = listPush(&l2, (void*)sA);
+ ck_assert_ptr_eq(r, l2);
+ r = listPush(&l2, (void*)sB);
+ ck_assert_ptr_eq(r, l2);
+ r = listPush(&l2, (void*)sC);
+ ck_assert_ptr_eq(r, l2);
+ r = listPush(&l2, (void*)sD);
+ ck_assert_ptr_eq(r, l2);
+ r = listAppend(&l,l2);
+ ck_assert_ptr_eq(r, l);
//ck_assert(listEqS(l,l2));
ck_assert_uint_eq(listLength(l),listLength(l2));
ck_assert_str_eq(l2[0], l[0]);
ck_assert_str_eq(l2[3], l[3]);
free(l);
// list + NULL list
- listAppend(&l2, NULL);
+ r = listAppend(&l2, NULL);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLength(l2),4);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
free(l2);
// NULL list pointer
- listAppend(NULL,l2);
+ r = listAppend(NULL,l2);
+ ck_assert_ptr_eq(r, null);
// should not crash
}
@@ -17069,16 +19255,25 @@ void listAddT(CuTest *tc UNUSED) {
char *sB = "BB";
char *sC = "CCC";
char *sD = "DDDD";
+ void **r = null;
// lists
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
- listPush(&l2, (void*)sA);
- listPush(&l2, (void*)sB);
- listPush(&l2, (void*)sC);
- listPush(&l2, (void*)sD);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l2, (void*)sA);
+ ck_assert_ptr_eq(r, l2);
+ r = listPush(&l2, (void*)sB);
+ ck_assert_ptr_eq(r, l2);
+ r = listPush(&l2, (void*)sC);
+ ck_assert_ptr_eq(r, l2);
+ r = listPush(&l2, (void*)sD);
+ ck_assert_ptr_eq(r, l2);
l3 = listAdd(l2,l);
ck_assert_uint_eq(listLength(l3),8);
ck_assert_str_eq(l3[0], "A");
@@ -17140,12 +19335,17 @@ void listSliceT(CuTest *tc UNUSED) {
char *s2 = "22";
char *s3 = "333";
char *s4 = "4444";
+ void **r = null;
// list negative index
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
l2 = listSlice(l, 1,-1);
ck_assert_uint_eq(listLength(l2),2);
ck_assert_str_eq(l2[0], "22");
@@ -17154,10 +19354,14 @@ void listSliceT(CuTest *tc UNUSED) {
free(l2);
// start outside
l = NULL;
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(listSlice(l, 20,-4), NULL);
// end outside
l2 = listSlice(l, 2,40);
@@ -17168,18 +19372,24 @@ void listSliceT(CuTest *tc UNUSED) {
free(l2);
// end negative and outside
l = NULL;
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(listSlice(l, 2,-40), NULL);
// end before start
ck_assert_ptr_eq(listSlice(l, 3,2), NULL);
free(l);
// negative start last element
l = NULL;
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
l2 = listSlice(l, -1,0);
ck_assert_uint_eq(listLength(l2),1);
ck_assert_str_eq(l2[0], "22");
@@ -17187,8 +19397,10 @@ void listSliceT(CuTest *tc UNUSED) {
free(l2);
// start = end
l = NULL;
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
l2 = listSlice(l, 1,1);
ck_assert_uint_eq(listLength(l2),0);
ck_assert_ptr_eq(l2[0], NULL);
@@ -17213,61 +19425,85 @@ void iListSliceT(CuTest *tc UNUSED) {
char *s2 = "22";
char *s3 = "333";
char *s4 = "4444";
+ void **r = null;
// list negative index
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
- iListSlice(&l, 1,-1);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
+ r = iListSlice(&l, 1,-1);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLength(l),2);
ck_assert_str_eq(l[0], "22");
ck_assert_str_eq(l[1], "333");
// start outside
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- iListSlice(&l, 20,-4);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = iListSlice(&l, 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLength(l),0);
// end outside
- iListSlice(&l, 2,40);
+ r = iListSlice(&l, 2,40);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLength(l),0);
// end negative and outside
- iListSlice(&l, 2,-40);
+ r = iListSlice(&l, 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLength(l),0);
// end before start
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
- iListSlice(&l, 3,2);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
+ r = iListSlice(&l, 3,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLength(l),0);
free(l);
// negative start last element
l = NULL;
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- iListSlice(&l, -1,0);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = iListSlice(&l, -1,0);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLength(l),1);
ck_assert_str_eq(l[0], "22");
free(l);
// start = end
l = NULL;
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- iListSlice(&l, 1,1);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = iListSlice(&l, 1,1);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLength(l),0);
ck_assert_ptr_eq(l[0], NULL);
free(l);
// empty list
listEmpty(l)
- iListSlice(&l, 0,0);
+ r = iListSlice(&l, 0,0);
+ ck_assert_ptr_eq(r, null);
ck_assert(listIsEmpty(l));
- iListSlice(&l, -1,0);
+ r = iListSlice(&l, -1,0);
+ ck_assert_ptr_eq(r, null);
ck_assert(listIsEmpty(l));
free(l);
// NULL list
l = NULL;
- iListSlice(&l, 2,-4);
+ r = iListSlice(&l, 2,-4);
+ ck_assert_ptr_eq(r, null);
// NULL var
- iListSlice(NULL, 2,-4);
+ r = iListSlice(NULL, 2,-4);
+ ck_assert_ptr_eq(r, null);
}
@@ -17347,11 +19583,13 @@ void iListInsertT(CuTest *tc UNUSED) {
char *s1 = "1";
char *s2 = "22";
char *s3 = "lib";
+ void **r = null;
// insert
l = listCreate((void*)s1, (void*)s2);
l2 = listCreate((void*)s3);
- iListInsert(&l, 0, l2);
+ r = iListInsert(&l, 0, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLength(l),3);
ck_assert_str_eq(l[0], "lib");
ck_assert_str_eq(l[1], "1");
@@ -17361,7 +19599,8 @@ void iListInsertT(CuTest *tc UNUSED) {
// negative index
l = listCreate((void*)s1, (void*)s2);
l2 = listCreate((void*)s3);
- iListInsert(&l, -1, l2);
+ r = iListInsert(&l, -1, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLength(l),3);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
@@ -17371,7 +19610,8 @@ void iListInsertT(CuTest *tc UNUSED) {
// edge
l = listCreate((void*)s1, (void*)s2);
l2 = listCreate((void*)s3);
- iListInsert(&l, 2, l2);
+ r = iListInsert(&l, 2, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLength(l),3);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
@@ -17381,18 +19621,21 @@ void iListInsertT(CuTest *tc UNUSED) {
// outside list
l = listCreate((void*)s1, (void*)s2);
l2 = listCreate((void*)s3);
- iListInsert(&l, 4, l2);
+ r = iListInsert(&l, 4, l2);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLength(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
- iListInsert(&l, -4, l2);
+ r = iListInsert(&l, -4, l2);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLength(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
free(l);
// negative index in a one element list
l = listCreate((void*)s1);
- iListInsert(&l, -1, l2);
+ r = iListInsert(&l, -1, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "lib");
free(l2);
@@ -17400,26 +19643,31 @@ void iListInsertT(CuTest *tc UNUSED) {
// empty list
listEmpty(l);
l2 = listCreate((void*)s3);
- iListInsert(&l, 0, l2);
+ r = iListInsert(&l, 0, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "lib");
free(l2);
free(l);
// empty insert list
l = listCreate((void*)s1);
listEmpty(l2);
- iListInsert(&l, 0, l2);
+ r = iListInsert(&l, 0, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "1");
free(l2);
// NULL insert string
- iListInsert(&l, 0, NULL);
+ r = iListInsert(&l, 0, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(l[0], "1");
free(l);
// NULL list
l = NULL;
- iListInsert(&l, 0, NULL);
+ r = iListInsert(&l, 0, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iListInsert(NULL, 0, NULL);
+ r = iListInsert(NULL, 0, NULL);
+ ck_assert_ptr_eq(r, NULL);
}
@@ -17433,12 +19681,17 @@ void listDelT(CuTest *tc UNUSED) {
char *s2 = "22";
char *s3 = "333";
char *s4 = "4444";
+ void **r = null;
// list negative index
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
l2 = listDel(l, 1,-1);
ck_assert_uint_eq(listLength(l2),2);
ck_assert_str_eq(l2[0], "1");
@@ -17459,8 +19712,10 @@ void listDelT(CuTest *tc UNUSED) {
free(l);
// negative start last element
l = NULL;
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
l2 = listDel(l, -1,0);
ck_assert_uint_eq(listLength(l2),1);
ck_assert_str_eq(l2[0], "1");
@@ -17468,8 +19723,10 @@ void listDelT(CuTest *tc UNUSED) {
free(l2);
// start negative and outside (delete complete list because end is 0 (=len))
l = NULL;
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
l2 = listDel(l, -3,0);
ck_assert_uint_eq(listLength(l2),0);
ck_assert_ptr_eq(l2[0], NULL);
@@ -17477,8 +19734,10 @@ void listDelT(CuTest *tc UNUSED) {
free(l2);
// start = end
l = NULL;
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
l2 = listDel(l, 1,1);
ck_assert_uint_eq(listLength(l2),2);
ck_assert_str_eq(l2[0], "1");
@@ -17504,82 +19763,117 @@ void iListDelT(CuTest *tc UNUSED) {
char *s2 = "22";
char *s3 = "333";
char *s4 = "4444";
+ void **r = null;
// list negative index
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
- iListDel(&l, 1,-1);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
+ r = iListDel(&l, 1,-1);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLength(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "4444");
- iListEmptyF(&l);
+ r = iListEmptyF(&l);
+ ck_assert_ptr_eq(r, l);
// start outside
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
- iListDel(&l, 20,-4);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
+ r = iListDel(&l, 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLength(l),4);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
// end outside
- iListDel(&l, 2,40);
+ r = iListDel(&l, 2,40);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLength(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
- iListEmptyF(&l);
+ r = iListEmptyF(&l);
+ ck_assert_ptr_eq(r, l);
// end negative and outside
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
- iListDel(&l, 2,-40);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
+ r = iListDel(&l, 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLength(l),4);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
// end before start
- iListDel(&l, 3,2);
+ r = iListDel(&l, 3,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLength(l),4);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
- iListEmptyF(&l);
+ r = iListEmptyF(&l);
+ ck_assert_ptr_eq(r, l);
// negative start last element
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- iListDel(&l, -1,0);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = iListDel(&l, -1,0);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLength(l),1);
ck_assert_str_eq(l[0], "1");
- iListEmptyF(&l);
+ r = iListEmptyF(&l);
+ ck_assert_ptr_eq(r, l);
// start negative and outside (delete complete list because end is 0 (=len))
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- iListDel(&l, -3,0);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = iListDel(&l, -3,0);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLength(l),0);
ck_assert_ptr_eq(l[0], NULL);
// start = end
// (l is empty from previous test)
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- iListDel(&l, 1,1);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = iListDel(&l, 1,1);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLength(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
free(l);
// empty list
listEmpty(l);
- iListDel(&l, 0,0);
+ r = iListDel(&l, 0,0);
+ ck_assert_ptr_eq(r, null);
ck_assert(listIsEmpty(l));
- iListDel(&l, -1,0);
+ r = iListDel(&l, -1,0);
+ ck_assert_ptr_eq(r, null);
ck_assert(listIsEmpty(l));
free(l);
// NULL list
l = NULL;
- iListDel(&l, 2,-4);
+ r = iListDel(&l, 2,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iListDel(NULL, 2,-4);
+ r = iListDel(NULL, 2,-4);
+ ck_assert_ptr_eq(r, null);
}
@@ -17834,7 +20128,8 @@ void schedulerT(CuTest *tc UNUSED) {
void getMonotonicTimeT(CuTest *tc UNUSED) {
- getMonotonicTime();
+ uint64_t r = getMonotonicTime();
+ ck_assert_uint_ne(r, 0);
}
@@ -18049,6 +20344,19 @@ int main(int n UNUSED, char**v UNUSED) {
SUITE_ADD_TEST(suite, stripCtrlST);
SUITE_ADD_TEST(suite, iStripCtrlST);
SUITE_ADD_TEST(suite, bStripCtrlST);
+ SUITE_ADD_TEST(suite, quoteST);
+ SUITE_ADD_TEST(suite, bQuoteST);
+ SUITE_ADD_TEST(suite, bLQuoteST);
+ SUITE_ADD_TEST(suite, quoteLenST);
+ SUITE_ADD_TEST(suite, escapeST);
+ SUITE_ADD_TEST(suite, bEscapeST);
+ SUITE_ADD_TEST(suite, bLEscapeST);
+ SUITE_ADD_TEST(suite, escapeLenST);
+ SUITE_ADD_TEST(suite, nibbleToHexT);
+ SUITE_ADD_TEST(suite, cEscapeST);
+ SUITE_ADD_TEST(suite, bCEscapeST);
+ SUITE_ADD_TEST(suite, bLCEscapeST);
+ SUITE_ADD_TEST(suite, cEscapeLenST);
SUITE_ADD_TEST(suite, isNumberT);
SUITE_ADD_TEST(suite, isIntT);
SUITE_ADD_TEST(suite, parseIntT);
diff --git a/src/libsheepyObject.h b/src/libsheepyObject.h
@@ -7491,6 +7491,9 @@ void finishManyOF(void *paramType, ...);
// generated with utils/oGMacros
+#define escapeO(self) (self)->f->escape(self)
+#define escapeG escapeO
+
#define disposeO(self) (self)->f->dispose(self)
#define disposeG disposeO
diff --git a/src/libsheepySmall.c b/src/libsheepySmall.c
@@ -64,6 +64,11 @@ char* sStringToStringTiny(sStringt* obj);
char* sArrayToStringTiny(sArrayt* obj);
char* sUndefinedToStringTiny(sUndefinedt* obj UNUSED);
char* sBytesToStringTiny(sBytest* obj);
+char* sEscapeTiny(smallt *obj);
+char* sEscape(smallt *obj);
+char* sDictEscapeTiny(sDictt* obj);
+char* sStringEscapeTiny(sStringt* obj);
+char* sArrayEscapeTiny(sArrayt* obj);
char* sTypesTiny(smallt* obj);
sBytest* sTypesToBytesTiny(smallt *obj);
const char** sDictTypeStrings(sDictt* obj);
@@ -882,6 +887,211 @@ char* sBytesToStringTiny(sBytest* obj) {
}
/**
+ * stringify a small object
+ *
+ * Escape characters to produce a parsable json
+ *
+ * the returned string has to be freed
+ *
+ * \param
+ * obj object
+ * \return
+ * string representing the object
+ */
+char* sEscapeTiny(smallt *obj) {
+ char *r = NULL;
+
+ switch(obj->type) {
+ case UNDEFINED:
+ r = sUndefinedToStringTiny((sUndefinedt *)obj);
+ break;
+ case BOOL:
+ r = sBoolToStringTiny((sBoolt *)obj);
+ break;
+ case CONTAINER:
+ r = sContainerToStringTiny((sContainert *)obj);
+ break;
+ case DICT:
+ r = sDictEscapeTiny((sDictt *)obj);
+ break;
+ case DOUBLE:
+ r = sDoubleToStringTiny((sDoublet *)obj);
+ break;
+ case INT:
+ r = sIntToStringTiny((sIntt *)obj);
+ break;
+ case STRING:
+ r = sStringEscapeTiny((sStringt *)obj);
+ break;
+ case ARRAY:
+ r = sArrayEscapeTiny((sArrayt* )obj);
+ break;
+ case BYTES:
+ r = sBytesToStringTiny((sBytest* )obj);
+ break;
+ default:
+ logME(libsheepyErrorMask, "Unsupported object type.");
+ }
+ return(r);
+}
+
+/**
+ * stringify object
+ *
+ * the returned string has to be freed
+ *
+ * \param
+ * obj object
+ * \return
+ * string representing the object
+ * NULL when obj is NULL
+ */
+char* sEscape(smallt *obj) {
+
+ if (obj) {
+ return(sEscapeTiny(obj));
+ }
+ return(NULL);
+}
+
+/**
+ * stringify dictionary
+ *
+ * the returned string has to be freed
+ *
+ * \param
+ * obj object
+ * \return
+ * string representing the object
+ */
+char* sDictEscapeTiny(sDictt* obj) {
+ char *s = NULL;
+
+ if (!obj->count) {
+ return(strdup("{}"));
+ }
+
+ char *r = strdup("{");
+
+ bool hasAtLeastOneElement = no;
+
+ forEachSDict(obj, e) {
+ if (e->key) {
+ hasAtLeastOneElement = yes;
+ pErrorNULL(iAppendS(&r, "\""));
+ pErrorNULL(iAppendNFreeS(&r, escapeS(e->key, '\"')));
+ pErrorNULL(iAppendS(&r, "\""));
+ if (isSType(e->data, STRING)) {
+ // add quotes for strings
+ pErrorNULL(iAppendS(&r, ":\""));
+ s = sEscapeTiny(e->data);
+ pErrorNULL(iAppendS(&r, s));
+ free(s);
+ pErrorNULL(iAppendS(&r, "\","));
+ }
+ else if (isSType(e->data, CONTAINER)) {
+ // add quotes for strings
+ pErrorNULL(iAppendS(&r, ":\""));
+ s = sToStringTiny(e->data);
+ pErrorNULL(iAppendS(&r, s));
+ free(s);
+ pErrorNULL(iAppendS(&r, "\","));
+ }
+ else {
+ pErrorNULL(iAppendS(&r, ":"));
+ s = sToStringTiny(e->data);
+ pErrorNULL(iAppendS(&r, s));
+ free(s);
+ pErrorNULL(iAppendS(&r, ","));
+ }
+ }
+ }
+
+ if (hasAtLeastOneElement) {
+ pErrorNULL(setS(r, -1, '}'));
+ }
+ else {
+ pErrorNULL(iAppendS(&r, "}"));
+ }
+ return(r);
+}
+
+/**
+ * stringify string
+ *
+ * the returned string has to be freed
+ *
+ * \param
+ * obj object
+ * \return
+ * string representing the object
+ */
+char* sStringEscapeTiny(sStringt* obj) {
+
+ return(escapeS(sStringGetTiny(obj), '\"'));
+}
+
+/**
+ * stringify array
+ *
+ * the returned string has to be freed
+ *
+ * \param
+ * obj object
+ * \return
+ * string representing the object
+ */
+char* sArrayEscapeTiny(sArrayt* obj) {
+ char *s = NULL;
+
+ if (!obj->count) {
+ return(strdup("[]"));
+ }
+
+ char *r = strdup("[");
+ uint32_t cnt = 0;;
+ bool emptySlot = false;;
+ forEachSArray(obj, o) {
+ if (!o) {
+ // empty slot
+ emptySlot = true;;
+ continue;
+ }
+ emptySlot = false;;
+ cnt++;
+ if (isSType(o, STRING)) {
+ // add quotes for strings
+ pErrorNULL(iAppendS(&r, "\""));
+ s = sEscapeTiny(o);
+ pErrorNULL(iAppendS(&r, s));
+ free(s);
+ pErrorNULL(iAppendS(&r, "\""));
+ }
+ else if (isSType(o, CONTAINER)) {
+ // add quotes for strings
+ pErrorNULL(iAppendS(&r, "\""));
+ s = sToStringTiny(o);
+ pErrorNULL(iAppendS(&r, s));
+ free(s);
+ pErrorNULL(iAppendS(&r, "\""));
+ }
+ else {
+ s = sToStringTiny(o);
+ pErrorNULL(iAppendS(&r, s));
+ free(s);
+ }
+ pErrorNULL(iAppendS(&r, ","));
+ }
+ if (!cnt && emptySlot) {
+ pErrorNULL(iAppendS(&r, "]"));
+ }
+ else {
+ pErrorNULL(setS(r, -1, ']'));
+ }
+ return(r);
+}
+
+/**
* get list of object types string
*
* only the types in the first level are listed
diff --git a/src/libsheepySmall.h b/src/libsheepySmall.h
@@ -241,6 +241,12 @@ char* sArrayToStringTiny(sArrayt* obj) MUST_CHECK;
char* sUndefinedToStringTiny(sUndefinedt* obj) MUST_CHECK;
char* sBytesToStringTiny(sBytest* obj) MUST_CHECK;
+char* sEscapeTiny(smallt *obj) MUST_CHECK;
+char* sEscape(smallt *obj) MUST_CHECK;
+char* sDictEscapeTiny(sDictt* obj) MUST_CHECK;
+char* sStringEscapeTiny(sStringt* obj) MUST_CHECK;
+char* sArrayEscapeTiny(sArrayt* obj) MUST_CHECK;
+
char* sTypesTiny(smallt* obj) MUST_CHECK;
sBytest* sTypesToBytesTiny(smallt *obj) MUST_CHECK;
const char** sDictTypeStrings(sDictt* obj) MUST_CHECK;
diff --git a/src/libsheepySmallCuTest.c b/src/libsheepySmallCuTest.c
@@ -567,7 +567,7 @@ void sDictTypeStringsT(CuTest *tc UNUSED) {
sDictPushTiny(&o, "c", (smallt *) c);
sStringt *s = allocSStringTiny("");
sDictPushTiny(&o, "s", (smallt *) s);
- char **t = sDictTypeStrings(o);
+ char **t = (char**)sDictTypeStrings(o);
char *S = join(t, ",");
ck_assert_str_eq(S, "bool,container,string");
free(S);
@@ -614,7 +614,7 @@ void sArrayTypeStringsT(CuTest *tc UNUSED) {
sUndefinedt *u = allocSUndefined();
sArrayPushTiny(&o, (smallt *) u);
sArraySetTiny(o, 3, NULL);
- char **t = sArrayTypeStrings(o);
+ char **t = (char**)sArrayTypeStrings(o);
char *S = join(t, ",");
ck_assert_str_eq(S, "bool,container,string");
free(S);
@@ -1220,7 +1220,8 @@ void sArrayReverseT(CuTest *tc UNUSED) {
sArrayPushTiny(&a, (smallt *) s);
sArrayPushTiny(&a, NULL);
sArrayPushTiny(&a, NULL);
- sArrayReverseTiny(a);
+ int r = sArrayReverseTiny(a);
+ ck_assert_int_ne(r,0);
b = (sBoolt *) sArrayGetTiny(a, 4);
ck_assert(!b->value);
ck_assert_uint_eq(a->count, 5);
diff --git a/src/libsheepySmallTest.c b/src/libsheepySmallTest.c
@@ -556,7 +556,7 @@ START_TEST(sDictTypeStringsT)
sDictPushTiny(&o, "c", (smallt *) c);
sStringt *s = allocSStringTiny("");
sDictPushTiny(&o, "s", (smallt *) s);
- char **t = sDictTypeStrings(o);
+ char **t = (char**)sDictTypeStrings(o);
char *S = join(t, ",");
ck_assert_str_eq(S, "bool,container,string");
free(S);
@@ -603,7 +603,7 @@ START_TEST(sArrayTypeStringsT)
sUndefinedt *u = allocSUndefined();
sArrayPushTiny(&o, (smallt *) u);
sArraySetTiny(o, 3, NULL);
- char **t = sArrayTypeStrings(o);
+ char **t = (char**)sArrayTypeStrings(o);
char *S = join(t, ",");
ck_assert_str_eq(S, "bool,container,string");
free(S);
@@ -1209,7 +1209,8 @@ START_TEST(sArrayReverseT)
sArrayPushTiny(&a, (smallt *) s);
sArrayPushTiny(&a, NULL);
sArrayPushTiny(&a, NULL);
- sArrayReverseTiny(a);
+ int r = sArrayReverseTiny(a);
+ ck_assert_int_ne(r,0);
b = (sBoolt *) sArrayGetTiny(a, 4);
ck_assert(!b->value);
ck_assert_uint_eq(a->count, 5);
diff --git a/src/libsheepyTest.c b/src/libsheepyTest.c
@@ -144,13 +144,15 @@ START_TEST(openProgLogFileT)
ck_assert(!r);
// set progname and open file
- setProgName("openProgLogFileT");
+ r = setProgName("openProgLogFileT");
+ ck_assert(r);
r = openProgLogFile();
ck_assert(r);
freeProgName();
closeLogFiles();
- rmAll("openProgLogFileT.log");
+ int R = rmAll("openProgLogFileT.log");
+ ck_assert_int_ne(R, 0);
END_TEST
@@ -214,20 +216,35 @@ START_TEST(setLogFileT)
ck_assert_ptr_eq(f, NULL);
closeLogFiles();
- rmAll("test1.log");
- rmAll("test2.log");
- rmAll("test3.log");
- rmAll("test4.log");
- rmAll("test5.log");
- rmAll("test6.log");
- rmAll("test7.log");
- rmAll("test8.log");
- rmAll("test9.log");
- rmAll("test10.log");
- rmAll("test11.log");
- rmAll("test12.log");
- rmAll("test13.log");
- rmAll("test14.log");
+ int R;
+ R = rmAll("test1.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test2.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test3.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test4.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test5.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test6.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test7.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test8.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test9.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test10.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test11.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test12.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test13.log");
+ ck_assert_int_ne(R, 0);
+ R = rmAll("test14.log");
+ ck_assert_int_ne(R, 0);
// NULL
ck_assert_ptr_eq(setLogFile(NULL), NULL);
@@ -428,7 +445,8 @@ START_TEST(_pLogT)
pLog(LOG_INFO+20, "pLog test");
closeLogFiles();
- rmAll("test.log");
+ int R = rmAll("test.log");
+ ck_assert_int_ne(R, 0);
END_TEST
@@ -838,23 +856,30 @@ END_TEST
START_TEST(bDirnameT)
char s[100] = "release/libsheepy.a";
+ char *r = null;
// path
- bDirname(s);
+ r = bDirname(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "release");
// one item path
- strCpy(s, "sheepy.lib");
- bDirname(s);
+ r = strCpy(s, "sheepy.lib");
+ ck_assert_ptr_eq(r, s);
+ r = bDirname(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "./");
// empty
- strCpy(s, " ");
- bDirname(s);
+ r = strCpy(s, " ");
+ ck_assert_ptr_eq(r, s);
+ r = bDirname(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "./");
// NULL
- ck_assert_ptr_eq(bDirname(NULL), NULL);
+ r = bDirname(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -862,35 +887,45 @@ END_TEST
START_TEST(bLDirnameT)
char s[100] = "release/libsheepy.a";
+ char *r = null;
// path
- bLDirname(s, sizeof s);
+ r = bLDirname(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "release");
// buffer shorter than path
strcpy(s, "release/anotherdir/libsheepy.a");
- bLDirname(s, 10);
+ r = bLDirname(s, 10);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "release");
strcpy(s, "release/anotherdir/libsheepy.a");
- bLDirname(s, 9);
+ r = bLDirname(s, 9);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "release/");
// one item path
- strCpy(s, "sheepy.lib");
- bLDirname(s, sizeof s);
+ r = strCpy(s, "sheepy.lib");
+ ck_assert_ptr_eq(r, s);
+ r = bLDirname(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "./");
// empty
- strCpy(s, " ");
- bLDirname(s, sizeof s);
+ r = strCpy(s, " ");
+ ck_assert_ptr_eq(r, s);
+ r = bLDirname(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "./");
// size 0 - no change in s
- bLDirname(s, 0);
+ r = bLDirname(s, 0);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "./");
// NULL
- ck_assert_ptr_eq(bLDirname(NULL, 0), NULL);
+ r = bLDirname(NULL, 0);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -912,15 +947,20 @@ START_TEST(iExpandHomeT)
// no ~/
char *s = strdup("sheepy");
- iExpandHome(&s);
+ char *r = null;
+
+ r = iExpandHome(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepy");
free(s);
// NULL path
s = NULL;
- iExpandHome(&s);
+ r = iExpandHome(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_ptr_eq(s, NULL);
// NULL var
- iExpandHome(NULL);
+ r = iExpandHome(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -929,10 +969,14 @@ START_TEST(bExpandHomeT)
// no ~/
char s[100] = "sheepy";
- bExpandHome(s);
+ char *r = null;
+
+ r = bExpandHome(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepy");
// NULL
- ck_assert_ptr_eq(bExpandHome(NULL), NULL);
+ r = bExpandHome(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -941,16 +985,22 @@ START_TEST(bLExpandHomeT)
// no ~/
char s[100] = "sheepy";
- bLExpandHome(s, sizeof s);
+ char *r = null;
+
+ r = bLExpandHome(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepy");
// shorter buffer size
- bLExpandHome(s, 3);
+ r = bLExpandHome(s, 3);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
// size 0
- bLExpandHome(s, 0);
+ r = bLExpandHome(s, 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
// NULL
- ck_assert_ptr_eq(bLExpandHome(NULL, sizeof s), NULL);
+ r = bLExpandHome(NULL, sizeof s);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -1042,102 +1092,125 @@ START_TEST(iNormalizePathT)
// test
char *s = strdup("test/.././file.txt");
- iNormalizePath(&s);
+ char *r = null;
+
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "file.txt");
free(s);
// remove end /
s = strdup("/home/");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/home");
free(s);
// cancel path and keep leading /
s = strdup("/home/..");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
free(s);
// cancel path
s = strdup("home/..");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
free(s);
// multiple /
s = strdup("/home///stuff");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/home/stuff");
free(s);
// remove . and .. and keep leading /
s = strdup("/a/./b/../../c/");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/c");
free(s);
// keep leading /
s = strdup("/../");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
free(s);
// keep leading ..
s = strdup(".././/");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "..");
free(s);
// remove .
s = strdup("./");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
free(s);
// keep / before .
s = strdup("/.");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
free(s);
// remove .
s = strdup(".");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
free(s);
// / not changed
s = strdup("/");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
free(s);
// // becomes /
s = strdup("//");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
free(s);
// remove leading .
s = strdup("/./werwer");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/werwer");
free(s);
// keep leading .. and remove .. in path
s = strdup(".././test/../test/file");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "../test/file");
free(s);
s = strdup("../d1/./d2/../f1");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "../d1/f1");
free(s);
s = strdup("a/b/c/../d/../e");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a/b/e");
free(s);
// dont remove .. when there are only .. in front
s = strdup("../../test/test/file");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "../../test/test/file");
free(s);
// empty path
s = strdup("");
- iNormalizePath(&s);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
free(s);
// empty NULL path
s = NULL;
- ck_assert_ptr_eq(iNormalizePath(&s), NULL);
+ r = iNormalizePath(&s);
+ ck_assert_ptr_eq(r, null);
// NULL path
- ck_assert_ptr_eq(iNormalizePath(NULL), NULL);
+ r = iNormalizePath(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -1146,80 +1219,102 @@ START_TEST(bNormalizePathT)
// test
char s[100] = "test/.././file.txt";
- bNormalizePath(s);
+ char *r = null;
+
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "file.txt");
// remove end /
strcpy(s, "/home/");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/home");
// cancel path and keep leading /
strcpy(s, "/home/..");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
// cancel path
strcpy(s, "home/..");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// multiple /
strcpy(s, "/home///stuff");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/home/stuff");
// remove . and .. and keep leading /
strcpy(s, "/a/./b/../../c/");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/c");
// keep leading /
strcpy(s, "/../");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
// keep leading ..
strcpy(s, ".././/");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "..");
// remove .
strcpy(s, "./");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// keep / before .
strcpy(s, "/.");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
// remove .
strcpy(s, ".");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// / not changed
strcpy(s, "/");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
// // becomes /
strcpy(s, "//");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
// remove leading .
strcpy(s, "/./werwer");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/werwer");
// keep leading .. and remove .. in path
strcpy(s, ".././test/../test/file");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "../test/file");
strcpy(s, "../d1/./d2/../f1");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "../d1/f1");
strcpy(s, "a/b/c/../d/../e");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a/b/e");
// dont remove .. when there are only .. in front
strcpy(s, "../../test/test/file");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "../../test/test/file");
// empty path
strcpy(s, "");
- bNormalizePath(s);
+ r = bNormalizePath(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// NULL path
- ck_assert_ptr_eq(bNormalizePath(NULL), NULL);
+ r = bNormalizePath(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -1228,88 +1323,112 @@ START_TEST(bLNormalizePathT)
// test
char s[100] = "test/.././file.txt";
- bLNormalizePath(s, sizeof s);
+ char *r = null;
+
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "file.txt");
// remove end /
strcpy(s, "/home/");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/home");
// cancel path and keep leading /
strcpy(s, "/home/..");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
// cancel path
strcpy(s, "home/..");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// multiple /
strcpy(s, "/home///stuff");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/home/stuff");
// remove . and .. and keep leading /
strcpy(s, "/a/./b/../../c/");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/c");
// keep leading /
strcpy(s, "/../");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
// keep leading ..
strcpy(s, ".././/");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "..");
// remove .
strcpy(s, "./");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// keep / before .
strcpy(s, "/.");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
// remove .
strcpy(s, ".");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// / not changed
strcpy(s, "/");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
// // becomes /
strcpy(s, "//");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/");
// remove leading .
strcpy(s, "/./werwer");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "/werwer");
// keep leading .. and remove .. in path
strcpy(s, ".././test/../test/file");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "../test/file");
strcpy(s, "../d1/./d2/../f1");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "../d1/f1");
strcpy(s, "a/b/c/../d/../e");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a/b/e");
// dont remove .. when there are only .. in front
strcpy(s, "../../test/test/file");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "../../test/test/file");
// empty path
strcpy(s, "");
- bLNormalizePath(s, sizeof s);
+ r = bLNormalizePath(s, sizeof s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// shorter buffer than path
strcpy(s, "a/b/c/../d/../e");
- bLNormalizePath(s, 4);
+ r = bLNormalizePath(s, 4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a/b");
strcpy(s, "a/b/c/../d/../e");
// size 0 - no change in path
- bLNormalizePath(s, 0);
+ r = bLNormalizePath(s, 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a/b/c/../d/../e");
// NULL path
- ck_assert_ptr_eq(bLNormalizePath(NULL, sizeof s), NULL);
+ r = bLNormalizePath(NULL, sizeof s);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -1321,7 +1440,8 @@ START_TEST(relPathT)
// relative to cwd
cwd = getCwd();
- iAppendS(&cwd, "/../sheepy");
+ r = iAppendS(&cwd, "/../sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = relPath(cwd, null);
ck_assert_str_eq(r, "../sheepy");
free(r);
@@ -1330,7 +1450,8 @@ START_TEST(relPathT)
// relative to cwd and path starts with cwd but is a different path
// (no slash between cwd and "../sheepy")
cwd = getCwd();
- iAppendS(&cwd, "../sheepy");
+ r = iAppendS(&cwd, "../sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = relPath(cwd, null);
ck_assert_str_eq(r, "../src../sheepy");
free(r);
@@ -1338,7 +1459,8 @@ START_TEST(relPathT)
// subdirectory to cwd
cwd = getCwd();
- iAppendS(&cwd, "/sheepy");
+ r = iAppendS(&cwd, "/sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = relPath(cwd, null);
ck_assert_str_eq(r, "sheepy");
free(r);
@@ -1353,7 +1475,8 @@ START_TEST(relPathT)
// start = root
cwd = getCwd();
- iAppendS(&cwd, "/sheepy");
+ r = iAppendS(&cwd, "/sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = relPath(cwd, "/../");
ck_assert_str_eq(r, cwd+1);
free(r);
@@ -1376,7 +1499,8 @@ START_TEST(relPathT)
// start is relative to cwd
cwd = getCwd();
- iAppendS(&cwd, "/../sheepy");
+ r = iAppendS(&cwd, "/../sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = relPath(cwd, "test/");
ck_assert_str_eq(r, "../../sheepy");
free(r);
@@ -1406,7 +1530,8 @@ START_TEST(iRelPathT)
// relative to cwd
cwd = getCwd();
- iAppendS(&cwd, "/../sheepy");
+ r = iAppendS(&cwd, "/../sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = iRelPath(&cwd, null);
ck_assert_str_eq(r, "../sheepy");
free(r);
@@ -1414,14 +1539,16 @@ START_TEST(iRelPathT)
// relative to cwd and path starts with cwd but is a different path
// (no slash between cwd and "../sheepy")
cwd = getCwd();
- iAppendS(&cwd, "../sheepy");
+ r = iAppendS(&cwd, "../sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = iRelPath(&cwd, null);
ck_assert_str_eq(r, "../src../sheepy");
free(r);
// subdirectory to cwd
cwd = getCwd();
- iAppendS(&cwd, "/sheepy");
+ r = iAppendS(&cwd, "/sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = iRelPath(&cwd, null);
ck_assert_str_eq(r, "sheepy");
free(r);
@@ -1434,7 +1561,8 @@ START_TEST(iRelPathT)
// start = root
cwd = getCwd();
- iAppendS(&cwd, "/sheepy");
+ r = iAppendS(&cwd, "/sheepy");
+ ck_assert_ptr_eq(r, cwd);
char *expected = strdup(cwd+1);
r = iRelPath(&cwd, "/../");
ck_assert_str_eq(r, expected);
@@ -1461,7 +1589,8 @@ START_TEST(iRelPathT)
// start is relative to cwd
cwd = getCwd();
- iAppendS(&cwd, "/../sheepy");
+ r = iAppendS(&cwd, "/../sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = iRelPath(&cwd, "test/");
ck_assert_str_eq(r, "../../sheepy");
free(r);
@@ -1498,7 +1627,8 @@ START_TEST(bRelPathT)
// relative to cwd
cwd = getCwd();
- iAppendS(&cwd, "/../sheepy");
+ r = iAppendS(&cwd, "/../sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = bRelPath(b, cwd, null);
ck_assert_str_eq(r, "../sheepy");
free(cwd);
@@ -1506,14 +1636,16 @@ START_TEST(bRelPathT)
// relative to cwd and path starts with cwd but is a different path
// (no slash between cwd and "../sheepy")
cwd = getCwd();
- iAppendS(&cwd, "../sheepy");
+ r = iAppendS(&cwd, "../sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = bRelPath(b, cwd, null);
ck_assert_str_eq(r, "../src../sheepy");
free(cwd);
// subdirectory to cwd
cwd = getCwd();
- iAppendS(&cwd, "/sheepy");
+ r = iAppendS(&cwd, "/sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = bRelPath(b, cwd, null);
ck_assert_str_eq(r, "sheepy");
free(cwd);
@@ -1526,7 +1658,8 @@ START_TEST(bRelPathT)
// start = root
cwd = getCwd();
- iAppendS(&cwd, "/sheepy");
+ r = iAppendS(&cwd, "/sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = bRelPath(b, cwd, "/../");
ck_assert_str_eq(r, cwd+1);
free(cwd);
@@ -1545,7 +1678,8 @@ START_TEST(bRelPathT)
// start is relative to cwd
cwd = getCwd();
- iAppendS(&cwd, "/../sheepy");
+ r = iAppendS(&cwd, "/../sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = bRelPath(b, cwd, "test/");
ck_assert_str_eq(r, "../../sheepy");
free(cwd);
@@ -1578,7 +1712,8 @@ START_TEST(bLRelPathT)
// relative to cwd
cwd = getCwd();
- iAppendS(&cwd, "/../sheepy");
+ r = iAppendS(&cwd, "/../sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = bLRelPath(b, sizeof(b), cwd, null);
ck_assert_str_eq(r, "../sheepy");
free(cwd);
@@ -1586,14 +1721,16 @@ START_TEST(bLRelPathT)
// relative to cwd and path starts with cwd but is a different path
// (no slash between cwd and "../sheepy")
cwd = getCwd();
- iAppendS(&cwd, "../sheepy");
+ r = iAppendS(&cwd, "../sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = bLRelPath(b, sizeof(b), cwd, null);
ck_assert_str_eq(r, "../src../sheepy");
free(cwd);
// subdirectory to cwd
cwd = getCwd();
- iAppendS(&cwd, "/sheepy");
+ r = iAppendS(&cwd, "/sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = bLRelPath(b, sizeof(b), cwd, null);
ck_assert_str_eq(r, "sheepy");
free(cwd);
@@ -1606,7 +1743,8 @@ START_TEST(bLRelPathT)
// start = root
cwd = getCwd();
- iAppendS(&cwd, "/sheepy");
+ r = iAppendS(&cwd, "/sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = bLRelPath(b, sizeof(b), cwd, "/../");
ck_assert_str_eq(r, cwd+1);
free(cwd);
@@ -1625,7 +1763,8 @@ START_TEST(bLRelPathT)
// start is relative to cwd
cwd = getCwd();
- iAppendS(&cwd, "/../sheepy");
+ r = iAppendS(&cwd, "/../sheepy");
+ ck_assert_ptr_eq(r, cwd);
r = bLRelPath(b, sizeof(b), cwd, "test/");
ck_assert_str_eq(r, "../../sheepy");
free(cwd);
@@ -1705,7 +1844,8 @@ START_TEST(chDirT)
ck_assert(chDir("dirTest.null"));
char *s = getCwd();
ck_assert((size_t)findS(s, "dirTest.null"));
- chDir(c);
+ bool r = chDir(c);
+ ck_assert(r);
freeManyS(c,s);
// non existing dir
ck_assert(!chDir("RandomNonExistingDir"));
@@ -1898,7 +2038,8 @@ START_TEST(readFileToST)
free(l);
// write only file
- fileChmod("writeOnlyText.null", S_IWUSR | S_IWGRP | S_IWOTH);
+ bool r = fileChmod("writeOnlyText.null", S_IWUSR | S_IWGRP | S_IWOTH);
+ ck_assert(r);
ck_assert_ptr_eq(readFileToS("writeOnlyText.null"), NULL);
// blank path
@@ -1908,8 +2049,10 @@ START_TEST(readFileToST)
ck_assert_ptr_eq(readFileToS(NULL), NULL);
// non existing path
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
ck_assert_ptr_eq(readFileToS("nonExistingFile"), NULL);
END_TEST
@@ -1943,31 +2086,41 @@ END_TEST
START_TEST(bReadFileToST)
char l[100];
+ void *r = null;
// text
- bReadFileToS("textTest.null", l);
+ r = bReadFileToS("textTest.null", l);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l, "LINE 1\nANOTHER line\n");
// empty text
- bReadFileToS("chmodTest.null", l);
+ r = bReadFileToS("chmodTest.null", l);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l, "");
// write only file
- ck_assert_ptr_eq(bReadFileToS("writeOnlyText.null", l), NULL);
+ r = bReadFileToS("writeOnlyText.null", l);
+ ck_assert_ptr_eq(r, null);
// blank path
- ck_assert_ptr_eq(bReadFileToS("", l), NULL);
+ r = bReadFileToS("", l);
+ ck_assert_ptr_eq(r, null);
// NULL path
- ck_assert_ptr_eq(bReadFileToS(NULL, l), NULL);
+ r = bReadFileToS(NULL, l);
+ ck_assert_ptr_eq(r, null);
// NULL buffer
- ck_assert_ptr_eq(bReadFileToS("wqe", NULL), NULL);
+ r = bReadFileToS("wqe", NULL);
+ ck_assert_ptr_eq(r, null);
// non existing path
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
- ck_assert_ptr_eq(bReadFileToS("nonExistingFile", l), NULL);
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
+ r = bReadFileToS("nonExistingFile", l);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -2003,40 +2156,52 @@ END_TEST
START_TEST(bLReadFileToST)
char l[100];
+ void *r = null;
// text
- bLReadFileToS("textTest.null", l, sizeof l);
+ r = bLReadFileToS("textTest.null", l, sizeof l);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l, "LINE 1\nANOTHER line\n");
// shorter buffer
- bLReadFileToS("textTest.null", l, 3);
+ r = bLReadFileToS("textTest.null", l, 3);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l, "LI");
// empty text
- bLReadFileToS("chmodTest.null", l, sizeof l);
+ r = bLReadFileToS("chmodTest.null", l, sizeof l);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l, "");
// size 0 buffer - no change
strcpy(l, "libsheepy");
- bLReadFileToS("textTest.null", l, 0);
+ r = bLReadFileToS("textTest.null", l, 0);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l, "libsheepy");
// write only file
- ck_assert_ptr_eq(bLReadFileToS("writeOnlyText.null", l, sizeof l), NULL);
+ r = bLReadFileToS("writeOnlyText.null", l, sizeof l);
+ ck_assert_ptr_eq(r, null);
// blank path
- ck_assert_ptr_eq(bLReadFileToS("", l, sizeof l), NULL);
+ r = bLReadFileToS("", l, sizeof l);
+ ck_assert_ptr_eq(r, null);
// NULL path
- ck_assert_ptr_eq(bLReadFileToS(NULL, l, sizeof l), NULL);
+ r = bLReadFileToS(NULL, l, sizeof l);
+ ck_assert_ptr_eq(r, null);
// NULL buffer
- ck_assert_ptr_eq(bLReadFileToS("wqe", NULL, sizeof l), NULL);
+ r = bLReadFileToS("wqe", NULL, sizeof l);
+ ck_assert_ptr_eq(r, null);
// non existing path
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
- ck_assert_ptr_eq(bLReadFileToS("nonExistingFile", l, sizeof l), NULL);
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
+ r = bLReadFileToS("nonExistingFile", l, sizeof l);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -2100,7 +2265,8 @@ START_TEST(readFileT)
free(l);
// write only file
- fileChmod("writeOnlyText.null", S_IWUSR | S_IWGRP | S_IWOTH);
+ bool r = fileChmod("writeOnlyText.null", S_IWUSR | S_IWGRP | S_IWOTH);
+ ck_assert(r);
ck_assert_int_eq(readFile("writeOnlyText.null", (void **) &l), -1);
// blank path
@@ -2113,8 +2279,10 @@ START_TEST(readFileT)
ck_assert_int_eq(readFile(NULL, (void **) &l), -1);
// non existing path
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
ck_assert_int_eq(readFile("nonExistingFile", (void **) &l), -1);
END_TEST
@@ -2149,8 +2317,10 @@ START_TEST(bReadFileT)
ck_assert_int_eq(bReadFile(NULL, l), -1);
// non existing path
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
ck_assert_int_eq(bReadFile("nonExistingFile", l), -1);
END_TEST
@@ -2197,8 +2367,10 @@ START_TEST(bLReadFileT)
ck_assert_int_eq(bLReadFile(NULL, l, sizeof l), -1);
// non existing path
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
ck_assert_int_eq(bLReadFile("nonExistingFile", l, sizeof l), -1);
END_TEST
@@ -2221,11 +2393,15 @@ START_TEST(writeFileST)
ck_assert_str_eq(l, "LINE 1\nANOTHER line\n");
// non existing file
// make sure the file doesnt exist
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
ck_assert(writeFileS("nonExistingFile",l));
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
// blank file name
ck_assert(!writeFileS(" ",l));
// read only path
@@ -2256,13 +2432,17 @@ START_TEST(writeFileT)
ck_assert_str_eq(l, "LINE 1\nANOTHER line\n");
// non existing file
// make sure the file doesnt exist
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
ck_assert(writeFile("nonExistingFile",l, strlen(l)+1));
// 0 length
ck_assert(writeFile("nonExistingFile", l, 0));
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
// blank file name
ck_assert(!writeFile(" ",l, 1));
// read only path
@@ -2351,8 +2531,10 @@ START_TEST(appendFileST)
l = readFileToS("appendTextOutTest.null");
ck_assert_uint_eq(strlen(l),30);
ck_assert_str_eq(l, "appended line\nappended line 2\n");
- if (fileExists("appendTextOutTest.null"))
- rmAll("appendTextOutTest.null");
+ if (fileExists("appendTextOutTest.null")) {
+ int R = rmAll("appendTextOutTest.null");
+ ck_assert_int_ne(R, 0);
+ }
// blank file name
ck_assert(!appendFileS(" ",l));
// read only path
@@ -2384,8 +2566,10 @@ START_TEST(appendFileT)
l = readFileToS("appendTextOutTest.null");
ck_assert_uint_eq(strlen(l),30);
ck_assert_str_eq(l, "appended line\nappended line 2\n");
- if (fileExists("appendTextOutTest.null"))
- rmAll("appendTextOutTest.null");
+ if (fileExists("appendTextOutTest.null")) {
+ int R = rmAll("appendTextOutTest.null");
+ ck_assert_int_ne(R, 0);
+ }
// blank file name
ck_assert(!appendFile(" ",l, strlen(l)));
// read only path
@@ -2539,7 +2723,8 @@ END_TEST
START_TEST(mkdirParentsT)
// directory
- rmAll("mkdirTest.null/null");
+ int R = rmAll("mkdirTest.null/null");
+ ck_assert_int_ne(R, 0);
ck_assert_int_eq(mkdirParents("mkdirTest.null/null"),1);
ck_assert_int_eq(mkdirParents("mkdirTest.null/null/"),1);
// not allowed
@@ -2556,7 +2741,8 @@ END_TEST
START_TEST(rmAllT)
// directory
- mkdirParents("rmAllTest.null/null");
+ int r = mkdirParents("rmAllTest.null/null");
+ ck_assert_int_ne(r, 0);
ck_assert_int_eq(rmAll("rmAllTest.null"),1);
// empty path
ck_assert_int_eq(rmAll(""),0);
@@ -2571,15 +2757,20 @@ END_TEST
START_TEST(copyT)
// file
- rmAll("copyTest.null");
- rmAll("copy2Test.null");
+ int R = rmAll("copyTest.null");
+ printf("%d\n",R);
+ R = rmAll("copy2Test.null");
+ printf("%d\n",R);
ck_assert_int_eq(copy("chmodTest.null", "copyTest.null"),1);
ck_assert(fileExists("copyTest.null"));
// too little permissions
- fileChmod("copyTest.null", 0);
+ bool r = fileChmod("copyTest.null", 0);
+ ck_assert(r);
ck_assert_int_eq(copy("copyTest.null", "copy2Test.null"),0);
- fileChmod("copyTest.null", S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
- rmAll("copyTest.null");
+ r = fileChmod("copyTest.null", S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IXGRP | S_IROTH | S_IXOTH);
+ ck_assert(r);
+ R = rmAll("copyTest.null");
+ ck_assert_int_ne(R, 0);
// give dir another name
ck_assert_int_eq(copy("dirTest.null", "copyTest.null"),1);
// copy dir to non existing dir
@@ -2611,7 +2802,8 @@ START_TEST(copyT)
ck_assert_str_eq(l[15], "copyTest.null/we/dirTest.null/two/four");
ck_assert_str_eq(l[16], "copyTest.null/we/dirTest.null/two/three");
listFreeS(l);
- rmAll("copyTest.null");
+ R = rmAll("copyTest.null");
+ ck_assert_int_ne(R, 0);
// copy dir to read only destination, no mkdir
ck_assert_int_eq(copy("mkdirTest.null/", "/newdir"),0);
// copy dir to read only destination, new dir
@@ -2661,7 +2853,8 @@ START_TEST(shMoveT)
// dir
ck_assert_int_eq(shMove("mkdirTest.null", "rename2Test.null"), 1);
ck_assert_int_eq(shMove("rename2Test.null/mkdirTest.null", "."), 1);
- rmAll("rename2Test.null");
+ int R = rmAll("rename2Test.null");
+ ck_assert_int_ne(R, 0);
// non existing source
ck_assert_int_eq(shMove("rename2Test.null", "renameTest.null"), 0);
// already existing destination
@@ -2697,8 +2890,11 @@ END_TEST
START_TEST(randomOpenCloseT)
+ int r;
+
// open /dev/urandom
- ck_assert_int_eq(randomUrandomOpen(),1);
+ r = randomUrandomOpen();
+ ck_assert_int_eq(r,1);
randomUrandomClose();
END_TEST
@@ -2707,7 +2903,8 @@ END_TEST
START_TEST(randomWordT)
// get random value
- randomUrandomOpen();
+ int r = randomUrandomOpen();
+ ck_assert_int_eq(r,1);
ck_assert_int_ne(randomWord(),0);
randomUrandomClose();
// error when /dev/urandom is closed
@@ -2720,7 +2917,8 @@ START_TEST(randomWordFromHWT)
// get random value
setHardwareRandom();
- randomWordFromHW();
+ uint64_t r = randomWordFromHW();
+ printf("%"PRIu64"\n", r);
// string
char *s = randomS(10);
@@ -2735,7 +2933,8 @@ END_TEST
START_TEST(randomChoiceT)
// get random value
- randomUrandomOpen();
+ int r = randomUrandomOpen();
+ ck_assert_int_eq(r,1);
ck_assert_int_ne(randomChoice(10),10);
// invalid range (0)
ck_assert_int_eq(randomChoice(0),0);
@@ -2812,12 +3011,17 @@ END_TEST
START_TEST(bLReadST)
char s[21];
- bLReadS(s, 21);
+ char *r = null;
+
+ r = bLReadS(s, 21);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "aaaaaaaaaaaaaaaaaaaa");
// size 1
- ck_assert_ptr_eq(bLReadS(s, 1), NULL);
+ r = bLReadS(s, 1);
+ ck_assert_ptr_eq(r, null);
// NULL
- ck_assert_ptr_eq(bLReadS(NULL, 2), NULL);
+ r = bLReadS(NULL, 2);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -3068,14 +3272,15 @@ START_TEST(strCpyT)
// copy string
r = strCpy(s, "lib");
- ck_assert_ptr_ne(r, null);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "lib");
// NULL
s[0] = 0;
r = strCpy(s, NULL);
ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
- ck_assert_ptr_eq(strCpy(NULL, "lib"), NULL);
+ r = strCpy(NULL, "lib");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -3108,30 +3313,37 @@ END_TEST
START_TEST(strLCpyT)
char s[1024];
+ char *r = null;
// copy string
- strLCpy(s, 100, "lib");
+ r = strLCpy(s, 100, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "lib");
// truncate src
s[0] = 0;
s[1] = 0;
s[2] = 0;
- strLCpy(s, 3, "lib");
+ r = strLCpy(s, 3, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "li");
s[0] = 'a';
s[1] = 'a';
s[2] = 'a';
s[3] = 0;
- strLCpy(s, 3, "lib");
+ r = strLCpy(s, 3, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "li");
// size 0 - no change in s
- strLCpy(s, 0, "libsheepy");
+ r = strLCpy(s, 0, "libsheepy");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "li");
// NULL
s[0] = 0;
- strLCpy(s, 1, NULL);
+ r = strLCpy(s, 1, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
- ck_assert_ptr_eq(strLCpy(NULL,1, "lib"), NULL);
+ r = strLCpy(NULL,1, "lib");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -3139,19 +3351,25 @@ END_TEST
START_TEST(strCatT)
char s[1024];
+ char *r = null;
// append string
- strCpy(s, "lib");
- strCat(s, "sheepy");
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
+ r = strCat(s, "sheepy");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// empty string2
- strCat(s, "");
+ r = strCat(s, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// NULL string2
- strCat(s, NULL);
+ r = strCat(s, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "libsheepy");
// NULL parameter
- ck_assert_ptr_eq(strCat(NULL, "ad"), NULL);
+ r = strCat(NULL, "ad");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -3159,13 +3377,17 @@ END_TEST
START_TEST(strNCatT)
char s[1024];
+ char *r = null;
// append string
- strCpy(s, "lib");
- strNCat(s, "sheepy", 100);
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
+ r = strNCat(s, "sheepy", 100);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// empty string2
- strNCat(s, "", 10);
+ r = strNCat(s, "", 10);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// truncate src
s[0] = 'a';
@@ -3174,15 +3396,19 @@ START_TEST(strNCatT)
s[3] = 'a';
s[4] = 'a';
s[5] = 'a';
- strCpy(s, "lib");
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "lib");
- strNCat(s, "sheepy", 2);
+ r = strNCat(s, "sheepy", 2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsh");
// NULL string2
- strNCat(s, NULL, 1);
+ r = strNCat(s, NULL, 1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "libsh");
// NULL parameter
- ck_assert_ptr_eq(strNCat(NULL, "ad", 1), NULL);
+ r = strNCat(NULL, "ad", 1);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -3190,16 +3416,21 @@ END_TEST
START_TEST(strLCatT)
char s[1024];
+ char *r = null;
// append string
- strCpy(s, "lib");
- strLCat(s, 100, "sheepy");
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
+ r = strLCat(s, 100, "sheepy");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// empty string2
- strLCat(s, 20, "");
+ r = strLCat(s, 20, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// s strlen bigger than s size - keep s as it is
- strLCat(s, 6, "qwqwe");
+ r = strLCat(s, 6, "qwqwe");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// truncate src
s[0] = 'a';
@@ -3208,9 +3439,11 @@ START_TEST(strLCatT)
s[3] = 'a';
s[4] = 'a';
s[5] = 'a';
- strCpy(s, "lib");
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "lib");
- strLNCat(s,100, "sheepy", 2);
+ r = strLNCat(s,100, "sheepy", 2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsh");
// truncate dst
s[0] = 'a';
@@ -3219,15 +3452,19 @@ START_TEST(strLCatT)
s[3] = 'a';
s[4] = 'a';
s[5] = 'a';
- strCpy(s, "lib");
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "lib");
- strLCat(s, 6, "sheepy");
+ r = strLCat(s, 6, "sheepy");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsh");
// NULL string2
- strLCat(s, 1, NULL);
+ r = strLCat(s, 1, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "libsh");
// NULL parameter
- ck_assert_ptr_eq(strLCat(NULL, 1, "ad"), NULL);
+ r = strLCat(NULL, 1, "ad");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -3235,16 +3472,21 @@ END_TEST
START_TEST(strLNCatT)
char s[1024];
+ char *r = null;
// append string
- strCpy(s, "lib");
- strLNCat(s, 100, "sheepy", 100);
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
+ r = strLNCat(s, 100, "sheepy", 100);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// empty string2
- strLNCat(s, 20, "", 10);
+ r = strLNCat(s, 20, "", 10);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// s strlen bigger than s size - keep s as it is
- strLNCat(s, 6, "qwqwe", 1);
+ r = strLNCat(s, 6, "qwqwe", 1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// truncate dst
s[0] = 'a';
@@ -3253,15 +3495,19 @@ START_TEST(strLNCatT)
s[3] = 'a';
s[4] = 'a';
s[5] = 'a';
- strCpy(s, "lib");
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "lib");
- strLNCat(s, 6, "sheepy", 4);
+ r = strLNCat(s, 6, "sheepy", 4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsh");
// NULL string2
- strLNCat(s, 1, NULL, 1);
+ r = strLNCat(s, 1, NULL, 1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "libsh");
// NULL parameter
- ck_assert_ptr_eq(strLNCat(NULL, 1, "ad", 1), NULL);
+ r = strLNCat(NULL, 1, "ad", 1);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -3293,20 +3539,25 @@ START_TEST(iCatST)
char *s;
char r[100];
+ char *r2 = null;
// cat strings
s = strdup("#@#");
- iCatS(r, s,"asd");
+ r2 = iCatS(r, s,"asd");
+ ck_assert_ptr_eq(r2, r);
ck_assert_str_eq(r, "#@#asd");
free(s);
// empty string
- iCatS(r, "");
+ r2 = iCatS(r, "");
+ ck_assert_ptr_eq(r2, r);
ck_assert(isEmptyS(r));
// cat empty string with string
- iCatS(r, "", "asd");
+ r2 = iCatS(r, "", "asd");
+ ck_assert_ptr_eq(r2, r);
ck_assert_str_eq(r, "asd");
// NULL
- ck_assert_ptr_eq(iCatS(NULL, "wef","wef"), NULL);
+ r2 = iCatS(NULL, "wef","wef");
+ ck_assert_ptr_eq(r2, null);
END_TEST
@@ -3315,26 +3566,33 @@ START_TEST(bLCatST)
char *s;
char r[100];
+ char *r2 = null;
// cat strings
s = strdup("#@#");
- bLCatS(r, sizeof r, s,"asd");
+ r2 = bLCatS(r, sizeof r, s,"asd");
+ ck_assert_ptr_eq(r2, r);
ck_assert_str_eq(r, "#@#asd");
// shorter buffer
- bLCatS(r, 3, s,"asd");
+ r2 = bLCatS(r, 3, s,"asd");
+ ck_assert_ptr_eq(r2, r);
ck_assert_str_eq(r, "#@");
free(s);
// empty string
- bLCatS(r, sizeof r, "");
+ r2 = bLCatS(r, sizeof r, "");
+ ck_assert_ptr_eq(r2, r);
ck_assert(isEmptyS(r));
// cat empty string with string
- bLCatS(r, sizeof r, "", "asd");
+ r2 = bLCatS(r, sizeof r, "", "asd");
+ ck_assert_ptr_eq(r2, r);
ck_assert_str_eq(r, "asd");
// size 0 - no change in r
- bLCatS(r, 0, "", "asd");
+ r2 = bLCatS(r, 0, "", "asd");
+ ck_assert_ptr_eq(r2, r);
ck_assert_str_eq(r, "asd");
// NULL
- ck_assert_ptr_eq(bLCatS(NULL, sizeof r, "wef","wef"), NULL);
+ r2 = bLCatS(NULL, sizeof r, "wef","wef");
+ ck_assert_ptr_eq(r2, null);
END_TEST
@@ -3439,25 +3697,31 @@ END_TEST
START_TEST(iAppendST)
char *s;
+ char *r = null;
// append string
s = strdup("lib");
- iAppendS(&s, "sheepy");
+ r = iAppendS(&s, "sheepy");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// empty string2
- iAppendS(&s, "");
+ r = iAppendS(&s, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// NULL string2
- iAppendS(&s, NULL);
+ r = iAppendS(&s, NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
free(s);
// NULL string
s = NULL;
- iAppendS(&s, "ad");
+ r = iAppendS(&s, "ad");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ad");
free(s);
// NULL parameter
- iAppendS(NULL, "ad");
+ r = iAppendS(NULL, "ad");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -3465,22 +3729,27 @@ END_TEST
START_TEST(iAppendCharST)
char *s;
+ char *r = null;
// append string
s = strdup("lib");
- iAppendCharS(&s, 'C');
+ r = iAppendCharS(&s, 'C');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libC");
// empty string2
- iAppendCharS(&s, 0);
+ r = iAppendCharS(&s, 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libC");
free(s);
// NULL string
s = NULL;
- iAppendCharS(&s, 'C');
+ r = iAppendCharS(&s, 'C');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "C");
free(s);
// NULL parameter
- ck_assert_ptr_eq(iAppendCharS(NULL, 'C'), NULL);
+ r = iAppendCharS(NULL, 'C');
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -3488,26 +3757,32 @@ END_TEST
START_TEST(iAppendNFreeST)
char *s;
+ char *r = null;
// append string
s = strdup("lib");
- iAppendNFreeS(&s, strdup("sheepy"));
+ r = iAppendNFreeS(&s, strdup("sheepy"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// empty string2
- iAppendNFreeS(&s, strdup(""));
+ r = iAppendNFreeS(&s, strdup(""));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// NULL string2
- iAppendNFreeS(&s, NULL);
+ r = iAppendNFreeS(&s, NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
free(s);
// NULL string
s = NULL;
- iAppendNFreeS(&s, strdup("ad"));
+ r = iAppendNFreeS(&s, strdup("ad"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ad");
free(s);
// NULL parameter
s = strdup("ad");
- iAppendNFreeS(NULL, s);
+ r = iAppendNFreeS(NULL, s);
+ ck_assert_ptr_eq(r, null);
free(s);
END_TEST
@@ -3516,26 +3791,32 @@ END_TEST
START_TEST(iAppendManyST)
char *s;
+ char *r = null;
// append string
s = strdup("lib");
- iAppendManyS(&s, "sheepy","2");
+ r = iAppendManyS(&s, "sheepy","2");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy2");
// empty string2
- iAppendManyS(&s, "", "");
+ r = iAppendManyS(&s, "", "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy2");
// NULL string2
- iAppendManyS(&s, "a", NULL);
+ r = iAppendManyS(&s, "a", NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy2a");
//not allowed - iAppendManyS(&s, NULL);
free(s);
// NULL string (allocate)
s = NULL;
- iAppendManyS(&s, "ad", "");
+ r = iAppendManyS(&s, "ad", "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ad");
free(s);
// NULL parameter
- iAppendManyS(NULL, "ad", "");
+ r = iAppendManyS(NULL, "ad", "");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -3543,20 +3824,25 @@ END_TEST
START_TEST(bAppendManyST)
char s[100];
+ char *r = null;
// append string
strcpy(s, "lib");
- bAppendManyS(s, "sheepy","2");
+ r = bAppendManyS(s, "sheepy","2");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy2");
// empty string2
- bAppendManyS(s, "", "");
+ r = bAppendManyS(s, "", "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy2");
// NULL string2
- bAppendManyS(s, "a", NULL);
+ r = bAppendManyS(s, "a", NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy2a");
//not allowed - bAppendManyS(s, NULL);
// NULL parameter
- ck_assert_ptr_eq(bAppendManyS(NULL, "ad", ""), NULL);
+ r = bAppendManyS(NULL, "ad", "");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -3564,27 +3850,34 @@ END_TEST
START_TEST(bLAppendManyST)
char s[100];
+ char *r = null;
// append string
strcpy(s, "lib");
- bLAppendManyS(s, sizeof s, "sheepy","2");
+ r = bLAppendManyS(s, sizeof s, "sheepy","2");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy2");
// shorter buffer
strcpy(s, "lib");
- bLAppendManyS(s, 5, "sheepy","2");
+ r = bLAppendManyS(s, 5, "sheepy","2");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libs");
// empty string2
- bLAppendManyS(s, sizeof s, "", "");
+ r = bLAppendManyS(s, sizeof s, "", "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libs");
// NULL string2
- bLAppendManyS(s, sizeof s, "a", NULL);
+ r = bLAppendManyS(s, sizeof s, "a", NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsa");
// size 0 - no change
- bLAppendManyS(s, 0, "a", NULL);
+ r = bLAppendManyS(s, 0, "a", NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsa");
//not allowed - bLAppendManyS(s, sizeof s, NULL);
// NULL parameter
- ck_assert_ptr_eq(bLAppendManyS(NULL, sizeof s, "ad", ""), NULL);
+ r = bLAppendManyS(NULL, sizeof s, "ad", "");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -3625,25 +3918,31 @@ END_TEST
START_TEST(iPrependST)
char *s;
+ char *r = null;
// append string
s = strdup("lib");
- iPrependS(&s, "sheepy");
+ r = iPrependS(&s, "sheepy");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepylib");
// empty string2
- iPrependS(&s, "");
+ r = iPrependS(&s, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepylib");
// NULL string2
- iPrependS(&s, NULL);
+ r = iPrependS(&s, NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepylib");
free(s);
// NULL string
s = NULL;
- iPrependS(&s, "ad");
+ r = iPrependS(&s, "ad");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ad");
free(s);
// NULL parameter
- ck_assert_ptr_eq(iPrependS(NULL, "ad"), NULL);
+ r = iPrependS(NULL, "ad");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -3651,22 +3950,27 @@ END_TEST
START_TEST(iPrependCharST)
char *s;
+ char *r = null;
// append string
s = strdup("lib");
- iPrependCharS(&s, 'C');
+ r = iPrependCharS(&s, 'C');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "Clib");
// empty string2
- iPrependCharS(&s, 0);
+ r = iPrependCharS(&s, 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "Clib");
free(s);
// NULL string
s = NULL;
- iPrependCharS(&s, 'C');
+ r = iPrependCharS(&s, 'C');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "C");
free(s);
// NULL parameter
- ck_assert_ptr_eq(iPrependCharS(NULL, 'a'), NULL);
+ r = iPrependCharS(NULL, 'a');
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -3674,26 +3978,32 @@ END_TEST
START_TEST(iPrependNFreeST)
char *s;
+ char *r = null;
// append string
s = strdup("lib");
- iPrependNFreeS(&s, strdup("sheepy"));
+ r = iPrependNFreeS(&s, strdup("sheepy"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepylib");
// empty string2
- iPrependNFreeS(&s, strdup(""));
+ r = iPrependNFreeS(&s, strdup(""));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepylib");
// NULL string2
- iPrependNFreeS(&s, NULL);
+ r = iPrependNFreeS(&s, NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepylib");
free(s);
// NULL string
s = NULL;
- iPrependNFreeS(&s, strdup("ad"));
+ r = iPrependNFreeS(&s, strdup("ad"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ad");
free(s);
// NULL parameter
s = strdup("ad");
- ck_assert_ptr_eq(iPrependNFreeS(NULL, s), NULL);
+ r = iPrependNFreeS(NULL, s);
+ ck_assert_ptr_eq(r, null);
free(s);
END_TEST
@@ -3702,23 +4012,29 @@ END_TEST
START_TEST(bPrependST)
char s[100];
+ char *r = null;
// append string
strcpy(s, "lib");
- bPrependS(s, "sheepy");
+ r = bPrependS(s, "sheepy");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepylib");
// empty string2
- bPrependS(s, "");
+ r = bPrependS(s, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepylib");
// NULL string2
- bPrependS(s, NULL);
+ r = bPrependS(s, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepylib");
// empty string
bEmptyS(s);
- bPrependS(s, "ad");
+ r = bPrependS(s, "ad");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ad");
// NULL parameter
- ck_assert_ptr_eq(bPrependS(NULL, "ad"), NULL);
+ r = bPrependS(NULL, "ad");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -3726,30 +4042,38 @@ END_TEST
START_TEST(bLPrependST)
char s[100];
+ char *r = null;
// append string
strcpy(s, "lib");
- bLPrependS(s, sizeof s, "sheepy");
+ r = bLPrependS(s, sizeof s, "sheepy");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepylib");
// shorter buffer
strcpy(s, "lib");
- bLPrependS(s, 5, "sheepy");
+ r = bLPrependS(s, 5, "sheepy");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "shee");
// empty string2
- bLPrependS(s, sizeof s, "");
+ r = bLPrependS(s, sizeof s, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "shee");
// NULL string2
- bLPrependS(s, sizeof s, NULL);
+ r = bLPrependS(s, sizeof s, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "shee");
// empty string
bEmptyS(s);
- bLPrependS(s, sizeof s, "ad");
+ r = bLPrependS(s, sizeof s, "ad");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ad");
// size 0 - no change
- bLPrependS(s, 0, "ad");
+ r = bLPrependS(s, 0, "ad");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ad");
// NULL parameter
- ck_assert_ptr_eq(bLPrependS(NULL, sizeof s, "ad"), NULL);
+ r = bLPrependS(NULL, sizeof s, "ad");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -3893,51 +4217,63 @@ END_TEST
START_TEST(iReplaceST)
char *s;
+ char *r = null;
+
// replace string, multiple character new delimeter
s = strdup("#ee#ee#ad");
- iReplaceS_max(&s, "#","^^");
+ r = iReplaceS_max(&s, "#","^^");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee^^ee^^ad");
free(s);
// replace string, multiple character old delimeter
s = strdup("AA##ee##ee#");
- iReplaceS_max(&s, "##","|");
+ r = iReplaceS_max(&s, "##","|");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee|ee#");
free(s);
// replace one time at the start of string
s = strdup("#ee#ee#ad");
- iReplaceS(&s, "#","^^",1);
+ r = iReplaceS(&s, "#","^^",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee#ee#ad");
free(s);
// replace one time
s = strdup("AA##ee##ee#");
- iReplaceS(&s, "##","|",1);
+ r = iReplaceS(&s, "##","|",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee##ee#");
free(s);
// NULL new delimiter, one time: same as empty delimiter
s = strdup("AA##ee##ee#");
- iReplaceS(&s, "##",NULL,1);
+ r = iReplaceS(&s, "##",NULL,1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AAee##ee#");
free(s);
// empty string
emptyS(s);
- iReplaceS(&s, "##",NULL,1);
+ r = iReplaceS(&s, "##",NULL,1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// empty old delimiter
s = strdup("qwe");
- iReplaceS(&s, "","|",1);
+ r = iReplaceS(&s, "","|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
free(s);
// NULL old delimiter
s = strdup("qwe");
- iReplaceS(&s, NULL,"|",1);
+ r = iReplaceS(&s, NULL,"|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
free(s);
// NULL string
s = NULL;
- iReplaceS(&s, "##","|",1);
+ r = iReplaceS(&s, "##","|",1);
+ ck_assert_ptr_eq(r, null);
// NULL var
- iReplaceS(NULL, "##","|",1);
+ r = iReplaceS(NULL, "##","|",1);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -3945,41 +4281,51 @@ END_TEST
START_TEST(iReplaceCharSST)
char *s;
+ char *r = null;
+
// replace string, multiple character new delimeter
s = strdup("#ee#ee#ad");
- iReplaceCharSS(&s, '#',"^^", 0);
+ r = iReplaceCharSS(&s, '#',"^^", 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee^^ee^^ad");
free(s);
// replace one time at the start of string
s = strdup("#ee#ee#ad");
- iReplaceCharSS(&s, '#',"^^",1);
+ r = iReplaceCharSS(&s, '#',"^^",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee#ee#ad");
free(s);
// replace one time
s = strdup("AA#ee##ee#");
- iReplaceCharSS(&s, '#',"|",1);
+ r = iReplaceCharSS(&s, '#',"|",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee##ee#");
free(s);
// NULL new delimiter, one time: same as empty delimiter
s = strdup("AA#ee##ee#");
- iReplaceCharSS(&s, '#',NULL,1);
+ r = iReplaceCharSS(&s, '#',NULL,1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AAee##ee#");
free(s);
// empty string
emptyS(s);
- iReplaceCharSS(&s, '#',NULL,1);
+ r = iReplaceCharSS(&s, '#',NULL,1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// empty old delimiter
s = strdup("qwe");
- iReplaceCharSS(&s, 0,"|",1);
+ r = iReplaceCharSS(&s, 0,"|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
free(s);
// NULL string
s = NULL;
- iReplaceCharSS(&s, '#',"|",1);
+ r = iReplaceCharSS(&s, '#',"|",1);
+ ck_assert_ptr_eq(r, s);
// NULL var
- iReplaceCharSS(NULL, '#',"|",1);
+ r = iReplaceCharSS(NULL, '#',"|",1);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -3987,46 +4333,57 @@ END_TEST
START_TEST(iReplaceSCharST)
char *s;
+ char *r = null;
+
// replace string, multiple character new delimeter
s = strdup("#ee#ee#ad");
- iReplaceSCharS(&s, "#",'^', 0);
+ r = iReplaceSCharS(&s, "#",'^', 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^ee^ee^ad");
free(s);
// replace string, multiple character old delimeter
s = strdup("AA##ee##ee#");
- iReplaceSCharS(&s, "##",'|', 0);
+ r = iReplaceSCharS(&s, "##",'|', 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee|ee#");
free(s);
// replace one time at the start of string
s = strdup("#ee#ee#ad");
- iReplaceSCharS(&s, "#",'^',1);
+ r = iReplaceSCharS(&s, "#",'^',1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^ee#ee#ad");
free(s);
// replace one time
s = strdup("AA##ee##ee#");
- iReplaceSCharS(&s, "##",'|',1);
+ r = iReplaceSCharS(&s, "##",'|',1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee##ee#");
free(s);
// empty string
emptyS(s);
- iReplaceSCharS(&s, "##", 0,1);
+ r = iReplaceSCharS(&s, "##", 0,1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// empty old delimiter
s = strdup("qwe");
- iReplaceSCharS(&s, "",'|',1);
+ r = iReplaceSCharS(&s, "",'|',1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
free(s);
// NULL old delimiter
s = strdup("qwe");
- iReplaceSCharS(&s, NULL,'|',1);
+ r = iReplaceSCharS(&s, NULL,'|',1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
free(s);
// NULL string
s = NULL;
- iReplaceSCharS(&s, "##",'|',1);
+ r = iReplaceSCharS(&s, "##",'|',1);
+ ck_assert_ptr_eq(r, null);
// NULL var
- iReplaceSCharS(NULL, "##",'|',1);
+ r = iReplaceSCharS(NULL, "##",'|',1);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -4034,36 +4391,45 @@ END_TEST
START_TEST(iReplaceCharCharST)
char *s;
+ char *r = null;
+
// replace string, multiple character new delimeter
s = strdup("#ee#ee#ad");
- iReplaceCharCharS(&s, '#','^', 0);
+ r = iReplaceCharCharS(&s, '#','^', 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^ee^ee^ad");
free(s);
// replace one time at the start of string
s = strdup("#ee#ee#ad");
- iReplaceCharCharS(&s, '#','^',1);
+ r = iReplaceCharCharS(&s, '#','^',1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^ee#ee#ad");
free(s);
// replace one time
s = strdup("AA#ee##ee#");
- iReplaceCharCharS(&s, '#','|',1);
+ r = iReplaceCharCharS(&s, '#','|',1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee##ee#");
free(s);
// empty string
emptyS(s);
- iReplaceCharCharS(&s, '#', 0,1);
+ r = iReplaceCharCharS(&s, '#', 0,1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// empty old delimiter
s = strdup("qwe");
- iReplaceCharCharS(&s, 0,'|',1);
+ r = iReplaceCharCharS(&s, 0,'|',1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
free(s);
// NULL string
s = NULL;
- iReplaceCharCharS(&s, '#','|',1);
+ r = iReplaceCharCharS(&s, '#','|',1);
+ ck_assert_ptr_eq(r, s);
// NULL var
- iReplaceCharCharS(NULL, '#','|',1);
+ r = iReplaceCharCharS(NULL, '#','|',1);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -4071,40 +4437,51 @@ END_TEST
START_TEST(bReplaceST)
char s[100];
+ char *r = null;
+
// replace string, multiple character new delimeter
strcpy(s, "#ee#ee#ad");
- bReplaceS_max(s, "#","^^");
+ r = bReplaceS_max(s, "#","^^");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee^^ee^^ad");
// replace string, multiple character old delimeter
strcpy(s, "AA##ee##ee#");
- bReplaceS_max(s, "##","|");
+ r = bReplaceS_max(s, "##","|");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee|ee#");
// replace one time at the start of string
strcpy(s, "#ee#ee#ad");
- bReplaceS(s, "#","^^",1);
+ r = bReplaceS(s, "#","^^",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee#ee#ad");
// replace one time
strcpy(s, "AA##ee##ee#");
- bReplaceS(s, "##","|",1);
+ r = bReplaceS(s, "##","|",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee##ee#");
// NULL new delimiter, one time: same as empty delimiter
strcpy(s, "AA##ee##ee#");
- bReplaceS(s, "##",NULL,1);
+ r = bReplaceS(s, "##",NULL,1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AAee##ee#");
// empty string
bEmptyS(s);
- bReplaceS(s, "##",NULL,1);
+ r = bReplaceS(s, "##",NULL,1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// empty old delimiter
strcpy(s, "qwe");
- bReplaceS(s, "","|",1);
+ r = bReplaceS(s, "","|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// NULL old delimiter
strcpy(s, "qwe");
- bReplaceS(s, NULL,"|",1);
+ r = bReplaceS(s, NULL,"|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// NULL var
- ck_assert_ptr_eq(bReplaceS(NULL, "##","|",1), NULL);
+ r = bReplaceS(NULL, "##","|",1);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -4112,48 +4489,61 @@ END_TEST
START_TEST(bLReplaceST)
char s[100];
+ char *r = null;
+
// replace string, multiple character new delimeter
strcpy(s, "#ee#ee#ad");
- bLReplaceS_max(s, sizeof s, "#","^^");
+ r = bLReplaceS_max(s, sizeof s, "#","^^");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee^^ee^^ad");
// shorter buffer
strcpy(s, "#ee#ee#ad");
- bLReplaceS_max(s, 5, "#","^^");
+ r = bLReplaceS_max(s, 5, "#","^^");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee");
// replace string, multiple character old delimeter
strcpy(s, "AA##ee##ee#");
- bLReplaceS_max(s, sizeof s, "##","|");
+ r = bLReplaceS_max(s, sizeof s, "##","|");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee|ee#");
// replace one time at the start of string
strcpy(s, "#ee#ee#ad");
- bLReplaceS(s, sizeof s, "#","^^",1);
+ r = bLReplaceS(s, sizeof s, "#","^^",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee#ee#ad");
// replace one time
strcpy(s, "AA##ee##ee#");
- bLReplaceS(s, sizeof s, "##","|",1);
+ r = bLReplaceS(s, sizeof s, "##","|",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee##ee#");
// NULL new delimiter, one time: same as empty delimiter
strcpy(s, "AA##ee##ee#");
- bLReplaceS(s, sizeof s, "##",NULL,1);
+ r = bLReplaceS(s, sizeof s, "##",NULL,1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AAee##ee#");
// empty string
bEmptyS(s);
- bLReplaceS(s, sizeof s, "##",NULL,1);
+ r = bLReplaceS(s, sizeof s, "##",NULL,1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// empty old delimiter
strcpy(s, "qwe");
- bLReplaceS(s, sizeof s, "","|",1);
+ r = bLReplaceS(s, sizeof s, "","|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// NULL old delimiter
strcpy(s, "qwe");
- bLReplaceS(s, sizeof s, NULL,"|",1);
+ r = bLReplaceS(s, sizeof s, NULL,"|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// size 0 - no change
strcpy(s, "qwe");
- bLReplaceS(s, 0, "q","|",1);
+ r = bLReplaceS(s, 0, "q","|",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qwe");
// NULL var
- ck_assert_ptr_eq(bLReplaceS(NULL, sizeof s, "##","|",1), NULL);
+ r = bLReplaceS(NULL, sizeof s, "##","|",1);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -4215,9 +4605,12 @@ END_TEST
START_TEST(iicReplaceST)
char *s;
+ char *r = null;
+
// replace string, multiple character new delimeter
s = strdup("#EE#ee#ad");
- iicReplaceS(&s, "EE","VV", 0);
+ r = iicReplaceS(&s, "EE","VV", 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "#VV#VV#ad");
free(s);
// iicReplaceCharSS
@@ -4237,44 +4630,53 @@ START_TEST(iicReplaceST)
free(s);
// replace string, multiple character old delimeter
s = strdup("AA##ee##ee#");
- iicReplaceS(&s, "##","|", 0);
+ r = iicReplaceS(&s, "##","|", 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee|ee#");
free(s);
// replace one time at the start of string
s = strdup("#ee#ee#ad");
- iicReplaceS(&s, "#","^^",1);
+ r = iicReplaceS(&s, "#","^^",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee#ee#ad");
free(s);
// replace one time
s = strdup("AA##ee##ee#");
- iicReplaceS(&s, "##","|",1);
+ r = iicReplaceS(&s, "##","|",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee##ee#");
free(s);
// NULL new delimiter, one time: same as empty delimiter
s = strdup("AA##ee##ee#");
- iicReplaceS(&s, "##",NULL,1);
+ r = iicReplaceS(&s, "##",NULL,1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AAee##ee#");
free(s);
// empty string
emptyS(s);
- iicReplaceS(&s, "##",NULL,1);
+ r = iicReplaceS(&s, "##",NULL,1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// empty old delimiter
s = strdup("qwe");
- iicReplaceS(&s, "","|",1);
+ r = iicReplaceS(&s, "","|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
free(s);
// NULL old delimiter
s = strdup("qwe");
- iicReplaceS(&s, NULL,"|",1);
+ r = iicReplaceS(&s, NULL,"|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
free(s);
// NULL string
s = NULL;
- iicReplaceS(&s, "##","|",1);
+ r = iicReplaceS(&s, "##","|",1);
+ ck_assert_ptr_eq(r, null);
// NULL var
- iicReplaceS(NULL, "##","|",1);
+ r = iicReplaceS(NULL, "##","|",1);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -4283,40 +4685,51 @@ END_TEST
START_TEST(bicReplaceST)
char s[100];
+ char *r = null;
+
// replace string, multiple character new delimeter
strcpy(s, "#EE#ee#ad");
- bicReplaceS(s, "ee","VV", 0);
+ r = bicReplaceS(s, "ee","VV", 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "#VV#VV#ad");
// replace string, multiple character old delimeter
strcpy(s, "AA##ee##ee#");
- bicReplaceS(s, "##","|", 0);
+ r = bicReplaceS(s, "##","|", 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee|ee#");
// replace one time at the start of string
strcpy(s, "#ee#ee#ad");
- bicReplaceS(s, "#","^^",1);
+ r = bicReplaceS(s, "#","^^",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee#ee#ad");
// replace one time
strcpy(s, "AA##ee##ee#");
- bicReplaceS(s, "##","|",1);
+ r = bicReplaceS(s, "##","|",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee##ee#");
// NULL new delimiter, one time: same as empty delimiter
strcpy(s, "AA##ee##ee#");
- bicReplaceS(s, "##",NULL,1);
+ r = bicReplaceS(s, "##",NULL,1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AAee##ee#");
// empty string
bEmptyS(s);
- bicReplaceS(s, "##",NULL,1);
+ r = bicReplaceS(s, "##",NULL,1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// empty old delimiter
strcpy(s, "qwe");
- bicReplaceS(s, "","|",1);
+ r = bicReplaceS(s, "","|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// NULL old delimiter
strcpy(s, "qwe");
- bicReplaceS(s, NULL,"|",1);
+ r = bicReplaceS(s, NULL,"|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// NULL var
- ck_assert_ptr_eq(bicReplaceS(NULL, "##","|",1), NULL);
+ r = bicReplaceS(NULL, "##","|",1);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -4325,48 +4738,61 @@ END_TEST
START_TEST(bLicReplaceST)
char s[100];
+ char *r = null;
+
// replace string, multiple character new delimeter
strcpy(s, "#ee#EE#ad");
- bLicReplaceS(s, sizeof s, "ee","vv", 0);
+ r = bLicReplaceS(s, sizeof s, "ee","vv", 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "#vv#vv#ad");
// shorter buffer
strcpy(s, "#ee#ee#ad");
- bLicReplaceS(s, 5, "#","^^", 0);
+ r = bLicReplaceS(s, 5, "#","^^", 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee");
// replace string, multiple character old delimeter
strcpy(s, "AA##ee##ee#");
- bLicReplaceS(s, sizeof s, "##","|", 0);
+ r = bLicReplaceS(s, sizeof s, "##","|", 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee|ee#");
// replace one time at the start of string
strcpy(s, "#ee#ee#ad");
- bLicReplaceS(s, sizeof s, "#","^^",1);
+ r = bLicReplaceS(s, sizeof s, "#","^^",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee#ee#ad");
// replace one time
strcpy(s, "AA##ee##ee#");
- bLicReplaceS(s, sizeof s, "##","|",1);
+ r = bLicReplaceS(s, sizeof s, "##","|",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AA|ee##ee#");
// NULL new delimiter, one time: same as empty delimiter
strcpy(s, "AA##ee##ee#");
- bLicReplaceS(s, sizeof s, "##",NULL,1);
+ r = bLicReplaceS(s, sizeof s, "##",NULL,1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "AAee##ee#");
// empty string
bEmptyS(s);
- bLicReplaceS(s, sizeof s, "##",NULL,1);
+ r = bLicReplaceS(s, sizeof s, "##",NULL,1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// empty old delimiter
strcpy(s, "qwe");
- bLicReplaceS(s, sizeof s, "","|",1);
+ r = bLicReplaceS(s, sizeof s, "","|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// NULL old delimiter
strcpy(s, "qwe");
- bLicReplaceS(s, sizeof s, NULL,"|",1);
+ r = bLicReplaceS(s, sizeof s, NULL,"|",1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// size 0 - no change
strcpy(s, "qwe");
- bLicReplaceS(s, 0, "q","|",1);
+ r = bLicReplaceS(s, 0, "q","|",1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qwe");
// NULL var
- ck_assert_ptr_eq(bLicReplaceS(NULL, sizeof s, "##","|",1), NULL);
+ r = bLicReplaceS(NULL, sizeof s, "##","|",1);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -4429,19 +4855,24 @@ END_TEST
START_TEST(iReplaceManyST)
char *s;
+ char *r = null;
+
// replace string, multiple character new delimeter
s = strdup("#ee#ee#ad");
- iReplaceManyS(&s, "#","^^","ad","AD");
+ r = iReplaceManyS(&s, "#","^^","ad","AD");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee^^ee^^AD");
free(s);
// replace string, empty new delimeter
s = strdup("#ee#ee#ad");
- iReplaceManyS(&s, "#","","ad","AD");
+ r = iReplaceManyS(&s, "#","","ad","AD");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eeeeAD");
free(s);
// not enough olds:news pairs
s = strdup("#ee#ee#ad");
- iReplaceManyS(&s, "#","","ad");
+ r = iReplaceManyS(&s, "#","","ad");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eeeead");
free(s);
// only 2 parameters
@@ -4452,51 +4883,61 @@ START_TEST(iReplaceManyST)
/* free(s); */
// NULL new delimiter: same as only 2 parameters or not enough olds:news pairs
s = strdup("#ee#ee#ad");
- iReplaceManyS(&s, "#", NULL);
+ r = iReplaceManyS(&s, "#", NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "#ee#ee#ad");
free(s);
// empty string
emptyS(s);
- iReplaceManyS(&s, "#", "");
+ r = iReplaceManyS(&s, "#", "");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// empty string many pairs
emptyS(s);
- iReplaceManyS(&s, "#", "", "%", "");
+ r = iReplaceManyS(&s, "#", "", "%", "");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// many pairs empty olds
s = strdup("qw#e");
- iReplaceManyS(&s, "#", "", "", "");
+ r = iReplaceManyS(&s, "#", "", "", "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qwe");
free(s);
// NULL old delimiter
s = strdup("qw#e");
- iReplaceManyS(&s, NULL, "");
+ r = iReplaceManyS(&s, NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw#e");
free(s);
// NULL old delimiter not first - same as replace empty string
s = strdup("qw#e");
- iReplaceManyS(&s, "#","|", NULL, "");
+ r = iReplaceManyS(&s, "#","|", NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
free(s);
// empty old delimiter
s = strdup("qw#e");
- iReplaceManyS(&s, "","|", NULL, "");
+ r = iReplaceManyS(&s, "","|", NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw#e");
free(s);
// empty old delimiter not first
s = strdup("qw#e");
- iReplaceManyS(&s, "#","|", "", "*");
+ r = iReplaceManyS(&s, "#","|", "", "*");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
free(s);
// NULL string
s = NULL;
- iReplaceManyS(&s, "#","|", "$", "*");
+ r = iReplaceManyS(&s, "#","|", "$", "*");
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(s, NULL);
free(s);
// NULL var
- iReplaceManyS(NULL, "#","|", "$", "*");
+ r = iReplaceManyS(NULL, "#","|", "$", "*");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -4504,17 +4945,22 @@ END_TEST
START_TEST(bReplaceManyST)
char s[100];
+ char *r = null;
+
// replace string, multiple character new delimeter
strcpy(s, "#ee#ee#ad");
- bReplaceManyS(s, "#","^^","ad","AD");
+ r = bReplaceManyS(s, "#","^^","ad","AD");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee^^ee^^AD");
// replace string, empty new delimeter
strcpy(s, "#ee#ee#ad");
- bReplaceManyS(s, "#","","ad","AD");
+ r = bReplaceManyS(s, "#","","ad","AD");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eeeeAD");
// not enough olds:news pairs
strcpy(s, "#ee#ee#ad");
- bReplaceManyS(s, "#","","ad");
+ r = bReplaceManyS(s, "#","","ad");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eeeead");
// only 2 parameters
// doesn't compile
@@ -4524,38 +4970,47 @@ START_TEST(bReplaceManyST)
/* free(s); */
// NULL new delimiter: same as only 2 parameters or not enough olds:news pairs
strcpy(s, "#ee#ee#ad");
- bReplaceManyS(s, "#", NULL);
+ r = bReplaceManyS(s, "#", NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "#ee#ee#ad");
// empty string
bEmptyS(s);
- bReplaceManyS(s, "#", "");
+ r = bReplaceManyS(s, "#", "");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// empty string many pairs
bEmptyS(s);
- bReplaceManyS(s, "#", "", "%", "");
+ r = bReplaceManyS(s, "#", "", "%", "");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// many pairs empty olds
strcpy(s, "qw#e");
- bReplaceManyS(s, "#", "", "", "");
+ r = bReplaceManyS(s, "#", "", "", "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qwe");
// NULL old delimiter
strcpy(s, "qw#e");
- bReplaceManyS(s, NULL, "");
+ r = bReplaceManyS(s, NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw#e");
// NULL old delimiter not first - same as replace empty string
strcpy(s, "qw#e");
- bReplaceManyS(s, "#","|", NULL, "");
+ r = bReplaceManyS(s, "#","|", NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
// empty old delimiter
strcpy(s, "qw#e");
- bReplaceManyS(s, "","|", NULL, "");
+ r = bReplaceManyS(s, "","|", NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw#e");
// empty old delimiter not first
strcpy(s, "qw#e");
- bReplaceManyS(s, "#","|", "", "*");
+ r = bReplaceManyS(s, "#","|", "", "*");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
// NULL var
- ck_assert_ptr_eq(bReplaceManyS(NULL, "#","|", "$", "*"), NULL);
+ r = bReplaceManyS(NULL, "#","|", "$", "*");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -4563,21 +5018,27 @@ END_TEST
START_TEST(bLReplaceManyST)
char s[100];
+ char *r = null;
+
// replace string, multiple character new delimeter
strcpy(s, "#ee#ee#ad");
- bLReplaceManyS(s, sizeof s, "#","^^","ad","AD");
+ r = bLReplaceManyS(s, sizeof s, "#","^^","ad","AD");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee^^ee^^AD");
// shorter buffer
strcpy(s, "#ee#ee#ad");
- bLReplaceManyS(s, 5, "#","^^","ad","AD");
+ r = bLReplaceManyS(s, 5, "#","^^","ad","AD");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee");
// replace string, empty new delimeter
strcpy(s, "#ee#ee#ad");
- bLReplaceManyS(s, sizeof s, "#","","ad","AD");
+ r = bLReplaceManyS(s, sizeof s, "#","","ad","AD");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eeeeAD");
// not enough olds:news pairs
strcpy(s, "#ee#ee#ad");
- bLReplaceManyS(s, sizeof s, "#","","ad");
+ r = bLReplaceManyS(s, sizeof s, "#","","ad");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eeeead");
// only 2 parameters
// doesn't compile
@@ -4587,41 +5048,51 @@ START_TEST(bLReplaceManyST)
/* free(s); */
// NULL new delimiter: same as only 2 parameters or not enough olds:news pairs
strcpy(s, "#ee#ee#ad");
- bLReplaceManyS(s, sizeof s, "#", NULL);
+ r = bLReplaceManyS(s, sizeof s, "#", NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "#ee#ee#ad");
// empty string
bEmptyS(s);
- bLReplaceManyS(s, sizeof s, "#", "");
+ r = bLReplaceManyS(s, sizeof s, "#", "");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// empty string many pairs
bEmptyS(s);
- bLReplaceManyS(s, sizeof s, "#", "", "%", "");
+ r = bLReplaceManyS(s, sizeof s, "#", "", "%", "");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// many pairs empty olds
strcpy(s, "qw#e");
- bLReplaceManyS(s, sizeof s, "#", "", "", "");
+ r = bLReplaceManyS(s, sizeof s, "#", "", "", "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qwe");
// NULL old delimiter
strcpy(s, "qw#e");
- bLReplaceManyS(s, sizeof s, NULL, "");
+ r = bLReplaceManyS(s, sizeof s, NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw#e");
// NULL old delimiter not first - same as replace empty string
strcpy(s, "qw#e");
- bLReplaceManyS(s, sizeof s, "#","|", NULL, "");
+ r = bLReplaceManyS(s, sizeof s, "#","|", NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
// empty old delimiter
strcpy(s, "qw#e");
- bLReplaceManyS(s, sizeof s, "","|", NULL, "");
+ r = bLReplaceManyS(s, sizeof s, "","|", NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw#e");
// empty old delimiter not first
strcpy(s, "qw#e");
- bLReplaceManyS(s, sizeof s, "#","|", "", "*");
+ r = bLReplaceManyS(s, sizeof s, "#","|", "", "*");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
// size 0 - no change
- bLReplaceManyS(s, 0, "#","|", "", "*");
+ r = bLReplaceManyS(s, 0, "#","|", "", "*");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
// NULL var
- ck_assert_ptr_eq(bLReplaceManyS(NULL, sizeof s, "#","|", "$", "*"), NULL);
+ r = bLReplaceManyS(NULL, sizeof s, "#","|", "$", "*");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -4684,19 +5155,24 @@ END_TEST
START_TEST(iicReplaceManyST)
char *s;
+ char *r = null;
+
// replace string, multiple character new delimeter
s = strdup("#ee#ee#ad");
- iicReplaceManyS(&s, "#","^^","ad","vv");
+ r = iicReplaceManyS(&s, "#","^^","ad","vv");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee^^ee^^vv");
free(s);
// replace string, empty new delimeter
s = strdup("#ee#ee#ad");
- iicReplaceManyS(&s, "#","","ad","AD");
+ r = iicReplaceManyS(&s, "#","","ad","AD");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eeeeAD");
free(s);
// not enough olds:news pairs
s = strdup("#ee#ee#ad");
- iicReplaceManyS(&s, "#","","ad");
+ r = iicReplaceManyS(&s, "#","","ad");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eeeead");
free(s);
// only 2 parameters
@@ -4707,51 +5183,61 @@ START_TEST(iicReplaceManyST)
/* free(s); */
// NULL new delimiter: same as only 2 parameters or not enough olds:news pairs
s = strdup("#ee#ee#ad");
- iicReplaceManyS(&s, "#", NULL);
+ r = iicReplaceManyS(&s, "#", NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "#ee#ee#ad");
free(s);
// empty string
emptyS(s);
- iicReplaceManyS(&s, "#", "");
+ r = iicReplaceManyS(&s, "#", "");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// empty string many pairs
emptyS(s);
- iicReplaceManyS(&s, "#", "", "%", "");
+ r = iicReplaceManyS(&s, "#", "", "%", "");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// many pairs empty olds
s = strdup("qw#e");
- iicReplaceManyS(&s, "#", "", "", "");
+ r = iicReplaceManyS(&s, "#", "", "", "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qwe");
free(s);
// NULL old delimiter
s = strdup("qw#e");
- iicReplaceManyS(&s, NULL, "");
+ r = iicReplaceManyS(&s, NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw#e");
free(s);
// NULL old delimiter not first - same as replace empty string
s = strdup("qw#e");
- iicReplaceManyS(&s, "#","|", NULL, "");
+ r = iicReplaceManyS(&s, "#","|", NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
free(s);
// empty old delimiter
s = strdup("qw#e");
- iicReplaceManyS(&s, "","|", NULL, "");
+ r = iicReplaceManyS(&s, "","|", NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw#e");
free(s);
// empty old delimiter not first
s = strdup("qw#e");
- iicReplaceManyS(&s, "#","|", "", "*");
+ r = iicReplaceManyS(&s, "#","|", "", "*");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
free(s);
// NULL string
s = NULL;
- iicReplaceManyS(&s, "#","|", "$", "*");
+ r = iicReplaceManyS(&s, "#","|", "$", "*");
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(s, NULL);
free(s);
// NULL var
- iicReplaceManyS(NULL, "#","|", "$", "*");
+ r = iicReplaceManyS(NULL, "#","|", "$", "*");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -4760,17 +5246,22 @@ END_TEST
START_TEST(bicReplaceManyST)
char s[100];
+ char *r = null;
+
// replace string, multiple character new delimeter
strcpy(s, "#ee#ee#ad");
- bicReplaceManyS(s, "#","^^","AD","vv");
+ r = bicReplaceManyS(s, "#","^^","AD","vv");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee^^ee^^vv");
// replace string, empty new delimeter
strcpy(s, "#ee#ee#ad");
- bicReplaceManyS(s, "#","","ad","AD");
+ r = bicReplaceManyS(s, "#","","ad","AD");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eeeeAD");
// not enough olds:news pairs
strcpy(s, "#ee#ee#ad");
- bicReplaceManyS(s, "#","","ad");
+ r = bicReplaceManyS(s, "#","","ad");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eeeead");
// only 2 parameters
// doesn't compile
@@ -4780,38 +5271,47 @@ START_TEST(bicReplaceManyST)
/* free(s); */
// NULL new delimiter: same as only 2 parameters or not enough olds:news pairs
strcpy(s, "#ee#ee#ad");
- bicReplaceManyS(s, "#", NULL);
+ r = bicReplaceManyS(s, "#", NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "#ee#ee#ad");
// empty string
bEmptyS(s);
- bicReplaceManyS(s, "#", "");
+ r = bicReplaceManyS(s, "#", "");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// empty string many pairs
bEmptyS(s);
- bicReplaceManyS(s, "#", "", "%", "");
+ r = bicReplaceManyS(s, "#", "", "%", "");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// many pairs empty olds
strcpy(s, "qw#e");
- bicReplaceManyS(s, "#", "", "", "");
+ r = bicReplaceManyS(s, "#", "", "", "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qwe");
// NULL old delimiter
strcpy(s, "qw#e");
- bicReplaceManyS(s, NULL, "");
+ r = bicReplaceManyS(s, NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw#e");
// NULL old delimiter not first - same as replace empty string
strcpy(s, "qw#e");
- bicReplaceManyS(s, "#","|", NULL, "");
+ r = bicReplaceManyS(s, "#","|", NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
// empty old delimiter
strcpy(s, "qw#e");
- bicReplaceManyS(s, "","|", NULL, "");
+ r = bicReplaceManyS(s, "","|", NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw#e");
// empty old delimiter not first
strcpy(s, "qw#e");
- bicReplaceManyS(s, "#","|", "", "*");
+ r = bicReplaceManyS(s, "#","|", "", "*");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
// NULL var
- ck_assert_ptr_eq(bicReplaceManyS(NULL, "#","|", "$", "*"), NULL);
+ r = bicReplaceManyS(NULL, "#","|", "$", "*");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -4820,21 +5320,27 @@ END_TEST
START_TEST(bLicReplaceManyST)
char s[100];
+ char *r = null;
+
// replace string, multiple character new delimeter
strcpy(s, "#ee#ee#ad");
- bLicReplaceManyS(s, sizeof s, "#","^^","AD","vv");
+ r = bLicReplaceManyS(s, sizeof s, "#","^^","AD","vv");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee^^ee^^vv");
// shorter buffer
strcpy(s, "#ee#ee#ad");
- bLicReplaceManyS(s, 5, "#","^^","ad","AD");
+ r = bLicReplaceManyS(s, 5, "#","^^","ad","AD");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "^^ee");
// replace string, empty new delimeter
strcpy(s, "#ee#ee#ad");
- bLicReplaceManyS(s, sizeof s, "#","","ad","AD");
+ r = bLicReplaceManyS(s, sizeof s, "#","","ad","AD");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eeeeAD");
// not enough olds:news pairs
strcpy(s, "#ee#ee#ad");
- bLicReplaceManyS(s, sizeof s, "#","","ad");
+ r = bLicReplaceManyS(s, sizeof s, "#","","ad");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eeeead");
// only 2 parameters
// doesn't compile
@@ -4844,41 +5350,51 @@ START_TEST(bLicReplaceManyST)
/* free(s); */
// NULL new delimiter: same as only 2 parameters or not enough olds:news pairs
strcpy(s, "#ee#ee#ad");
- bLicReplaceManyS(s, sizeof s, "#", NULL);
+ r = bLicReplaceManyS(s, sizeof s, "#", NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "#ee#ee#ad");
// empty string
bEmptyS(s);
- bLicReplaceManyS(s, sizeof s, "#", "");
+ r = bLicReplaceManyS(s, sizeof s, "#", "");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// empty string many pairs
bEmptyS(s);
- bLicReplaceManyS(s, sizeof s, "#", "", "%", "");
+ r = bLicReplaceManyS(s, sizeof s, "#", "", "%", "");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// many pairs empty olds
strcpy(s, "qw#e");
- bLicReplaceManyS(s, sizeof s, "#", "", "", "");
+ r = bLicReplaceManyS(s, sizeof s, "#", "", "", "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qwe");
// NULL old delimiter
strcpy(s, "qw#e");
- bLicReplaceManyS(s, sizeof s, NULL, "");
+ r = bLicReplaceManyS(s, sizeof s, NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw#e");
// NULL old delimiter not first - same as replace empty string
strcpy(s, "qw#e");
- bLicReplaceManyS(s, sizeof s, "#","|", NULL, "");
+ r = bLicReplaceManyS(s, sizeof s, "#","|", NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
// empty old delimiter
strcpy(s, "qw#e");
- bLicReplaceManyS(s, sizeof s, "","|", NULL, "");
+ r = bLicReplaceManyS(s, sizeof s, "","|", NULL, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw#e");
// empty old delimiter not first
strcpy(s, "qw#e");
- bLicReplaceManyS(s, sizeof s, "#","|", "", "*");
+ r = bLicReplaceManyS(s, sizeof s, "#","|", "", "*");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
// size 0 - no change
- bLicReplaceManyS(s, 0, "#","|", "", "*");
+ r = bLicReplaceManyS(s, 0, "#","|", "", "*");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qw|e");
// NULL var
- ck_assert_ptr_eq(bLicReplaceManyS(NULL, sizeof s, "#","|", "$", "*"), NULL);
+ r = bLicReplaceManyS(NULL, sizeof s, "#","|", "$", "*");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -5371,11 +5887,13 @@ START_TEST(bStripCtrlST)
char s[40];
// string with control char
- strLCpy(s, sizeof(s), "\tsheepy\n");
+ r = strLCpy(s, sizeof(s), "\tsheepy\n");
+ ck_assert_ptr_eq(r, s);
r = bStripCtrlS(s);
ck_assert_str_eq(r, "sheepy");
// no control char
- strLCpy(s, sizeof(s), "sheepy");
+ r = strLCpy(s, sizeof(s), "sheepy");
+ ck_assert_ptr_eq(r, s);
r = bStripCtrlS(s);
ck_assert_str_eq(r, "sheepy");
// null string
@@ -5386,6 +5904,282 @@ START_TEST(bStripCtrlST)
END_TEST
+START_TEST(quoteST)
+
+ char *r;
+
+ // no change
+ r = quoteS("abc", '"');
+ ck_assert_str_eq(r, "abc");
+ free(r);
+ // add backslashes
+ r = quoteS("\"abc\\", '"');
+ ck_assert_str_eq(r, "\\\"abc\\\\");
+ free(r);
+ // null string
+ ck_assert_ptr_eq(quoteS(null, 0), null);
+
+END_TEST
+
+
+START_TEST(bQuoteST)
+
+ char *r;
+ char s[40];
+
+ // no change
+ r = bQuoteS(s, "abc", '"');
+ ck_assert_str_eq(r, "abc");
+ // add backslashes
+ r = bQuoteS(s, "\"abc\\", '"');
+ ck_assert_str_eq(r, "\\\"abc\\\\");
+ // null string
+ ck_assert_ptr_eq(bQuoteS(s, null, 0), null);
+ // null dest
+ ck_assert_ptr_eq(bQuoteS(null, "asd", 0), null);
+
+END_TEST
+
+
+START_TEST(bLQuoteST)
+
+ char *r;
+ char s[40];
+
+ // no change
+ r = bLQuoteS(s, sizeof(s), "abc", '"');
+ ck_assert_str_eq(r, "abc");
+ // add backslashes
+ r = bLQuoteS(s, sizeof(s), "\"abc\\", '"');
+ ck_assert_str_eq(r, "\\\"abc\\\\");
+ // too small dest buffer
+ r = bLQuoteS(s, 3, "abc", '"');
+ ck_assert_str_eq(r, "ab");
+ r = bLQuoteS(s, 3, "a\\\"", '"');
+ ck_assert_str_eq(r, "a");
+ r = bLQuoteS(s, 3, "ab\"", '"');
+ ck_assert_str_eq(r, "ab");
+ // null string
+ ck_assert_ptr_eq(bLQuoteS(s, 10, null, 0), null);
+ // null dest
+ ck_assert_ptr_eq(bLQuoteS(null, 10, "asd", 0), null);
+ // 0 dest size
+ ck_assert_ptr_eq(bLQuoteS(s, 0, "asd", 0), null);
+
+END_TEST
+
+
+START_TEST(quoteLenST)
+
+ size_t r;
+
+ // no change
+ r = quoteLenS("abc", '"');
+ ck_assert_int_eq(r, 3);
+ // add backslashes
+ r = quoteLenS("\"abc\\", '"');
+ ck_assert_int_eq(r, 7);
+ // null string
+ ck_assert_int_eq(quoteLenS(null, 0), 0);
+
+END_TEST
+
+
+START_TEST(escapeST)
+
+ char *r;
+
+ // no change
+ r = escapeS("abc", '"');
+ ck_assert_str_eq(r, "abc");
+ free(r);
+ // add backslashes
+ r = escapeS("\b\f\r\t\"abc\n\\", '"');
+ ck_assert_str_eq(r, "\\b\\f\\r\\t\\\"abc\\n\\\\");
+ free(r);
+ // null string
+ ck_assert_ptr_eq(escapeS(null, 0), null);
+
+END_TEST
+
+
+START_TEST(bEscapeST)
+
+ char *r;
+ char s[40];
+
+ // no change
+ r = bEscapeS(s, "abc", '"');
+ ck_assert_str_eq(r, "abc");
+ // add backslashes
+ r = bEscapeS(s, "\b\f\r\t\"abc\n\\", '"');
+ ck_assert_str_eq(r, "\\b\\f\\r\\t\\\"abc\\n\\\\");
+ // null string
+ ck_assert_ptr_eq(bEscapeS(s, null, 0), null);
+ // null dest
+ ck_assert_ptr_eq(bEscapeS(null, "asd", 0), null);
+
+END_TEST
+
+
+START_TEST(bLEscapeST)
+
+ char *r;
+ char s[40];
+
+ // no change
+ r = bLEscapeS(s, sizeof(s), "abc", '"');
+ ck_assert_str_eq(r, "abc");
+ // add backslashes
+ r = bLEscapeS(s, sizeof(s), "\b\f\r\t\"abc\n\\", '"');
+ ck_assert_str_eq(r, "\\b\\f\\r\\t\\\"abc\\n\\\\");
+ // too small dest buffer
+ r = bLEscapeS(s, 3, "abc", '"');
+ ck_assert_str_eq(r, "ab");
+ r = bLEscapeS(s, 3, "a\\\"", '"');
+ ck_assert_str_eq(r, "a");
+ r = bLEscapeS(s, 3, "ab\"", '"');
+ ck_assert_str_eq(r, "ab");
+ r = bLEscapeS(s, 3, "a\t", '"');
+ ck_assert_str_eq(r, "a");
+ // null string
+ ck_assert_ptr_eq(bLEscapeS(s, 10, null, 0), null);
+ // null dest
+ ck_assert_ptr_eq(bLEscapeS(null, 10, "asd", 0), null);
+ // 0 dest size
+ ck_assert_ptr_eq(bLEscapeS(s, 0, "asd", 0), null);
+
+END_TEST
+
+
+START_TEST(escapeLenST)
+
+ size_t r;
+
+ // no change
+ r = escapeLenS("abc", '"');
+ ck_assert_int_eq(r, 3);
+ // add backslashes
+ r = escapeLenS("\"abc\b", '"');
+ ck_assert_int_eq(r, 7);
+ // null string
+ ck_assert_int_eq(escapeLenS(null, 0), 0);
+
+END_TEST
+
+
+START_TEST(nibbleToHexT)
+
+ char r;
+
+ r = nibbleToHex(9);
+ ck_assert_int_eq(r, '9');
+ r = nibbleToHex(15);
+ ck_assert_int_eq(r, 'F');
+ // out of range
+ r = nibbleToHex(30);
+ ck_assert_int_eq(r, 'X');
+
+END_TEST
+
+
+START_TEST(cEscapeST)
+
+ char *r;
+
+ // no change
+ r = cEscapeS("abc");
+ ck_assert_str_eq(r, "abc");
+ free(r);
+ // add backslashes
+ r = cEscapeS("\n\a\b\f\r\t\"ab\x03\v\\");
+ ck_assert_str_eq(r, "\\n\\a\\b\\f\\r\\t\\\"ab\"\"\\x03\"\"\\v\\\\");
+ free(r);
+ // null string
+ ck_assert_ptr_eq(cEscapeS(null), null);
+
+END_TEST
+
+
+START_TEST(bCEscapeST)
+
+ char *r;
+ char s[40];
+
+ // no change
+ r = bCEscapeS(s, "abc");
+ ck_assert_str_eq(r, "abc");
+ // add backslashes
+ r = bCEscapeS(s, "\n\a\b\f\r\t\"ab\x03\v\\");
+ ck_assert_str_eq(r, "\\n\\a\\b\\f\\r\\t\\\"ab\"\"\\x03\"\"\\v\\\\");
+ // null string
+ ck_assert_ptr_eq(bCEscapeS(s, null), null);
+ // null dest
+ ck_assert_ptr_eq(bCEscapeS(null, "asd"), null);
+
+END_TEST
+
+
+START_TEST(bLCEscapeST)
+
+ char *r;
+ char s[40];
+
+ // no change
+ r = bLCEscapeS(s, sizeof(s), "abc");
+ ck_assert_str_eq(r, "abc");
+ // add backslashes
+ r = bLCEscapeS(s, sizeof(s), "\n\a\b\f\r\t\"ab\x03\v\\");
+ ck_assert_str_eq(r, "\\n\\a\\b\\f\\r\\t\\\"ab\"\"\\x03\"\"\\v\\\\");
+ // too small dest buffer
+ r = bLCEscapeS(s, 3, "abc");
+ ck_assert_str_eq(r, "ab");
+ r = bLCEscapeS(s, 3, "a\\\"");
+ ck_assert_str_eq(r, "a");
+ r = bLCEscapeS(s, 3, "ab\"");
+ ck_assert_str_eq(r, "ab");
+ r = bLCEscapeS(s, 3, "a\a");
+ ck_assert_str_eq(r, "a");
+ r = bLCEscapeS(s, 3, "a\b");
+ ck_assert_str_eq(r, "a");
+ r = bLCEscapeS(s, 3, "a\t");
+ ck_assert_str_eq(r, "a");
+ r = bLCEscapeS(s, 3, "a\n");
+ ck_assert_str_eq(r, "a");
+ r = bLCEscapeS(s, 3, "a\v");
+ ck_assert_str_eq(r, "a");
+ r = bLCEscapeS(s, 3, "a\f");
+ ck_assert_str_eq(r, "a");
+ r = bLCEscapeS(s, 3, "a\r");
+ ck_assert_str_eq(r, "a");
+ r = bLCEscapeS(s, 3, "a\x01");
+ ck_assert_str_eq(r, "a");
+ // null string
+ ck_assert_ptr_eq(bLCEscapeS(s, 10, null), null);
+ // null dest
+ ck_assert_ptr_eq(bLCEscapeS(null, 10, "asd"), null);
+ // 0 dest size
+ ck_assert_ptr_eq(bLCEscapeS(s, 0, "asd"), null);
+
+END_TEST
+
+
+START_TEST(cEscapeLenST)
+
+ size_t r;
+
+ // no change
+ r = cEscapeLenS("abc");
+ ck_assert_int_eq(r, 3);
+ // add backslashes
+ r = cEscapeLenS("\"abc\b\x01");
+ ck_assert_int_eq(r, 15);
+ // null string
+ ck_assert_int_eq(cEscapeLenS(null), 0);
+
+END_TEST
+
+
START_TEST(isNumberT)
// number
@@ -5466,7 +6260,8 @@ START_TEST(parseIntT)
ck_assert_int_eq(parseInt("lib123sheepy"), 123);
ck_assert_int_eq(parseInt("-123"), -123);
// out of range - TODO check stderr
- parseInt("999999999999999999999999999999999999999");
+ int r = parseInt("999999999999999999999999999999999999999");
+ ck_assert_int_eq(r, -1);
// string without number
ck_assert_int_eq(parseInt("sheepy"), 0);
// NULL string
@@ -5495,7 +6290,8 @@ START_TEST(parseI64T)
ck_assert_int_eq(parseI64("lib123sheepy"), 123);
ck_assert_int_eq(parseI64("-123"), -123);
// out of range - TODO check stderr
- parseI64("999999999999999999999999999999999999999");
+ int r = parseI64("999999999999999999999999999999999999999");
+ ck_assert_int_eq(r, -1);
// string without number
ck_assert_int_eq(parseI64("sheepy"), 0);
// NULL string
@@ -5526,7 +6322,8 @@ START_TEST(parseDoubleT)
ck_assert_int_eq(parseDouble("lib123sheepy"), 123);
ck_assert_int_eq(parseDouble("-123"), -123);
// out of range - TODO check stderr
- parseDouble("999999999999999999999999999999999999999");
+ int r = parseDouble("999999999999999999999999999999999999999");
+ ck_assert_int_eq(r, -2147483648);
// string without number
ck_assert_int_eq(parseDouble("sheepy"), 0);
// NULL string
@@ -5582,12 +6379,17 @@ START_TEST(bIntToST)
// number
char s[50];
- bIntToS(s, 123);
+ char *r = null;
+
+ r = bIntToS(s, 123);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "123");
- bIntToS(s, -465464123);
+ r = bIntToS(s, -465464123);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "-465464123");
// NULL
- ck_assert_ptr_eq(bIntToS(NULL, 123), NULL);
+ r = bIntToS(NULL, 123);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -5609,12 +6411,17 @@ START_TEST(bDoubleToST)
// number
char s[256];
- bDoubleToS(s, 123.4);
+ char *r = null;
+
+ r = bDoubleToS(s, 123.4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "1.234000e+02");
- bDoubleToS(s, -4652445e5);
+ r = bDoubleToS(s, -4652445e5);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "-4.652445e+11");
// NULL
- ck_assert_ptr_eq(bDoubleToS(NULL, 123.4), NULL);
+ r = bDoubleToS(NULL, 123.4);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -5654,17 +6461,22 @@ END_TEST
START_TEST(iUpperST)
char *s;
+ char *r;
+
// string
s = strdup("sheepy");
- iUpperS(&s);
+ r = iUpperS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHEEPY");
free(s);
// NULL string
s = NULL;
- iUpperS(&s);
+ r = iUpperS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_ptr_eq(s, NULL);
// NULL var
- iUpperS(NULL);
+ r = iUpperS(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -5672,12 +6484,16 @@ END_TEST
START_TEST(bUpperST)
char s[50];
+ char *r = null;
+
// string
strcpy(s, "sheepy");
- bUpperS(s);
+ r = bUpperS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHEEPY");
// NULL var
- ck_assert_ptr_eq(bUpperS(NULL), NULL);
+ r = bUpperS(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -5697,17 +6513,22 @@ END_TEST
START_TEST(iLowerST)
char *s;
+ char *r = null;
+
// string
s = strdup("SHEEPY");
- iLowerS(&s);
+ r = iLowerS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepy");
free(s);
// NULL string
s = NULL;
- iLowerS(&s);
+ r = iLowerS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_ptr_eq(s, NULL);
// NULL var
- iLowerS(NULL);
+ r = iLowerS(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -5715,12 +6536,16 @@ END_TEST
START_TEST(bLowerST)
char s[50];
+ char *r = null;
+
// string
strcpy(s, "SHEEPY");
- bLowerS(s);
+ r = bLowerS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepy");
// NULL var
- ck_assert_ptr_eq(bLowerS(NULL), NULL);
+ r = bLowerS(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -5756,37 +6581,46 @@ END_TEST
START_TEST(iTrimST)
char *s;
+ char *r = null;
+
// no spaces
s = strdup("SHeePY");
- iTrimS(&s);
+ r = iTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
free(s);
// heading spaces
s = strdup(" SHeePY");
- iTrimS(&s);
+ r = iTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
free(s);
// trailing spaces
s = strdup("SHeePY ");
- iTrimS(&s);
+ r = iTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
free(s);
// string with spaces in the middle
s = strdup(" SHe ePY ");
- iTrimS(&s);
+ r = iTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHe ePY");
free(s);
// all spaces
s = strdup(" ");
- iTrimS(&s);
+ r = iTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
free(s);
// NULL string
s = NULL;
- iTrimS(&s);
+ r = iTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_ptr_eq(s, NULL);
// NULL var
- iTrimS(NULL);
+ r = iTrimS(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -5794,28 +6628,36 @@ END_TEST
START_TEST(bTrimST)
char s[50];
+ char *r = null;
+
// no spaces
strcpy(s, "SHeePY");
- bTrimS(s);
+ r = bTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
// heading spaces
strcpy(s, " SHeePY");
- bTrimS(s);
+ r = bTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
// trailing spaces
strcpy(s, "SHeePY ");
- bTrimS(s);
+ r = bTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
// string with spaces in the middle
strcpy(s, " SHe ePY ");
- bTrimS(s);
+ r = bTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHe ePY");
// all spaces
strcpy(s, " ");
- bTrimS(s);
+ r = bTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// NULL var
- ck_assert_ptr_eq(bTrimS(NULL), NULL);
+ r = bTrimS(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -5851,37 +6693,46 @@ END_TEST
START_TEST(iLTrimST)
char *s;
+ char *r = null;
+
// no spaces
s = strdup("SHeePY");
- iLTrimS(&s);
+ r = iLTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
free(s);
// heading spaces
s = strdup(" SHeePY");
- iLTrimS(&s);
+ r = iLTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
free(s);
// trailing spaces
s = strdup("SHeePY ");
- iLTrimS(&s);
+ r = iLTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY ");
free(s);
// string with spaces in the middle
s = strdup(" SHe ePY ");
- iLTrimS(&s);
+ r = iLTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHe ePY ");
free(s);
// all spaces
s = strdup(" ");
- iLTrimS(&s);
+ r = iLTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
free(s);
// NULL string
s = NULL;
- iLTrimS(&s);
+ r = iLTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_ptr_eq(s, NULL);
// NULL var
- iLTrimS(NULL);
+ r = iLTrimS(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -5889,28 +6740,36 @@ END_TEST
START_TEST(bLTrimST)
char s[50];
+ char *r = null;
+
// no spaces
strcpy(s, "SHeePY");
- bLTrimS(s);
+ r = bLTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
// heading spaces
strcpy(s, " SHeePY");
- bLTrimS(s);
+ r = bLTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
// trailing spaces
strcpy(s, "SHeePY ");
- bLTrimS(s);
+ r = bLTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY ");
// string with spaces in the middle
strcpy(s, " SHe ePY ");
- bLTrimS(s);
+ r = bLTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHe ePY ");
// all spaces
strcpy(s, " ");
- bLTrimS(s);
+ r = bLTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// NULL var
- ck_assert_ptr_eq(bLTrimS(NULL), NULL);
+ r = bLTrimS(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -5946,37 +6805,46 @@ END_TEST
START_TEST(iRTrimST)
char *s;
+ char *r = null;
+
// no spaces
s = strdup("SHeePY");
- iRTrimS(&s);
+ r = iRTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
free(s);
// heading spaces
s = strdup(" SHeePY");
- iRTrimS(&s);
+ r = iRTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, " SHeePY");
free(s);
// trailing spaces
s = strdup("SHeePY ");
- iRTrimS(&s);
+ r = iRTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
free(s);
// string with spaces in the middle
s = strdup(" SHe ePY ");
- iRTrimS(&s);
+ r = iRTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, " SHe ePY");
free(s);
// all spaces
s = strdup(" ");
- iRTrimS(&s);
+ r = iRTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
free(s);
// NULL string
s = NULL;
- iRTrimS(&s);
+ r = iRTrimS(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_ptr_eq(s, NULL);
// NULL var
- iRTrimS(NULL);
+ r = iRTrimS(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -5984,28 +6852,36 @@ END_TEST
START_TEST(bRTrimST)
char s[100];
+ char *r = null;
+
// no spaces
strcpy(s, "SHeePY");
- bRTrimS(s);
+ r = bRTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
// heading spaces
strcpy(s, " SHeePY");
- bRTrimS(s);
+ r = bRTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, " SHeePY");
// trailing spaces
strcpy(s, "SHeePY ");
- bRTrimS(s);
+ r = bRTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHeePY");
// string with spaces in the middle
strcpy(s, " SHe ePY ");
- bRTrimS(s);
+ r = bRTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, " SHe ePY");
// all spaces
strcpy(s, " ");
- bRTrimS(s);
+ r = bRTrimS(s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// NULL var
- ck_assert_ptr_eq(bRTrimS(NULL), NULL);
+ r = bRTrimS(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -7670,31 +8546,40 @@ END_TEST
START_TEST(setST)
char *s;
+ char *r = null;
+
s = strdup("sheepy");
// set char
- setS(s, 0, 'S');
+ r = setS(s, 0, 'S');
+ ck_assert_ptr_eq(r, s);
ck_assert_uint_eq(s[0], 'S');
// negative index
- setS(s, -2, 'P');
+ r = setS(s, -2, 'P');
+ ck_assert_ptr_eq(r, s);
ck_assert_uint_eq(s[4], 'P');
// outside string
- setS(s, 20, 'Y');
- setS(s, -20, 'Y');
+ r = setS(s, 20, 'Y');
+ ck_assert_ptr_eq(r, null);
+ r = setS(s, -20, 'Y');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "SheePy");
free(s);
// negative index in a one char string
s = strdup("s");
- setS(s, -1, 'S');
+ r = setS(s, -1, 'S');
+ ck_assert_ptr_eq(r, s);
ck_assert_uint_eq(s[0], 'S');
free(s);
// empty string
emptyS(s);
- setS(s, -1, 'S');
+ r = setS(s, -1, 'S');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// NULL string
- setS(NULL, 0, 's');
+ r = setS(NULL, 0, 's');
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -7938,60 +8823,74 @@ END_TEST
START_TEST(iSliceST)
char *s;
+ char *r = null;
+
// slice
s = strdup("sheepy");
- iSliceS(&s, 0,2);
+ r = iSliceS(&s, 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
free(s);
// negative index
s = strdup("sheepy");
- iSliceS(&s, -2,0);
+ r = iSliceS(&s, -2,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "py");
free(s);
// positive and negative indexes
s = strdup("sheepy");
- iSliceS(&s, 2,-2);
+ r = iSliceS(&s, 2,-2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ee");
free(s);
// start = end
s = strdup("sheepy");
- iSliceS(&s, 2,-4);
+ r = iSliceS(&s, 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
free(s);
// end of string
s = strdup("sheepy");
- iSliceS(&s, 2,6);
+ r = iSliceS(&s, 2,6);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
free(s);
// NULL string
s = NULL;
- iSliceS(&s, 2,-4);
+ r = iSliceS(&s, 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_ptr_eq(s, NULL);
// start outside string
s = strdup("sheepy");
- iSliceS(&s, 20,-4);
+ r = iSliceS(&s, 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// end outside string
s = strdup("sheepy");
- iSliceS(&s, 2,40);
+ r = iSliceS(&s, 2,40);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
free(s);
s = strdup("sheepy");
- iSliceS(&s, -22,3);
+ r = iSliceS(&s, -22,3);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "she");
free(s);
s = strdup("sheepy");
- iSliceS(&s, 2,-40);
+ r = iSliceS(&s, 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// end before start
s = strdup("sheepy");
- iSliceS(&s, 4,2);
+ r = iSliceS(&s, 4,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// NULL var
- iSliceS(NULL, 0, 0);
+ r = iSliceS(NULL, 0, 0);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -7999,46 +8898,59 @@ END_TEST
START_TEST(bSliceST)
char s[100];
+ char *r = null;
+
// slice
strcpy(s, "sheepy");
- bSliceS(s, 0,2);
+ r = bSliceS(s, 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
// negative index
strcpy(s, "sheepy");
- bSliceS(s, -2,0);
+ r = bSliceS(s, -2,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "py");
// positive and negative indexes
strcpy(s, "sheepy");
- bSliceS(s, 2,-2);
+ r = bSliceS(s, 2,-2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ee");
// start = end
strcpy(s, "sheepy");
- bSliceS(s, 2,-4);
+ r = bSliceS(s, 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// end of string
strcpy(s, "sheepy");
- bSliceS(s, 2,6);
+ r = bSliceS(s, 2,6);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
// start outside string
strcpy(s, "sheepy");
- bSliceS(s, 20,-4);
+ r = bSliceS(s, 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// end outside string
strcpy(s, "sheepy");
- bSliceS(s, 2,40);
+ r = bSliceS(s, 2,40);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
strcpy(s, "sheepy");
- bSliceS(s, -22,3);
+ r = bSliceS(s, -22,3);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "she");
strcpy(s, "sheepy");
- bSliceS(s, 2,-40);
+ r = bSliceS(s, 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// end before start
strcpy(s, "sheepy");
- bSliceS(s, 4,2);
+ r = bSliceS(s, 4,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// NULL var
- ck_assert_ptr_eq(bSliceS(NULL, 0, 0), NULL);
+ r = bSliceS(NULL, 0, 0);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -8046,52 +8958,67 @@ END_TEST
START_TEST(bLSliceST)
char s[100];
+ char *r = null;
+
// slice
strcpy(s, "sheepy");
- bLSliceS(s, sizeof(s), 0,2);
+ r = bLSliceS(s, sizeof(s), 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
// buffer shorter than string
strcpy(s, "sheepy");
- bLSliceS(s, 5, 0,2);
+ r = bLSliceS(s, 5, 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
// negative index
strcpy(s, "sheepy");
- bLSliceS(s, sizeof(s), -2,0);
+ r = bLSliceS(s, sizeof(s), -2,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "py");
// positive and negative indexes
strcpy(s, "sheepy");
- bLSliceS(s, sizeof(s), 2,-2);
+ r = bLSliceS(s, sizeof(s), 2,-2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ee");
// start = end
strcpy(s, "sheepy");
- bLSliceS(s, sizeof(s), 2,-4);
+ r = bLSliceS(s, sizeof(s), 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// end of string
strcpy(s, "sheepy");
- bLSliceS(s, sizeof(s), 2,6);
+ r = bLSliceS(s, sizeof(s), 2,6);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
// start outside string
strcpy(s, "sheepy");
- bLSliceS(s, sizeof(s), 20,-4);
+ r = bLSliceS(s, sizeof(s), 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// end outside string
strcpy(s, "sheepy");
- bLSliceS(s, sizeof(s), 2,40);
+ r = bLSliceS(s, sizeof(s), 2,40);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
strcpy(s, "sheepy");
- bLSliceS(s, sizeof(s), -22,3);
+ r = bLSliceS(s, sizeof(s), -22,3);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "she");
strcpy(s, "sheepy");
- bLSliceS(s, sizeof(s), 2,-40);
+ r = bLSliceS(s, sizeof(s), 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// end before start
strcpy(s, "sheepy");
- bLSliceS(s, sizeof(s), 4,2);
+ r = bLSliceS(s, sizeof(s), 4,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// size 0
- ck_assert_ptr_eq(bLSliceS(s, 0, 0, 0), NULL);
+ r = bLSliceS(s, 0, 0, 0);
+ ck_assert_ptr_eq(r, null);
// NULL var
- ck_assert_ptr_eq(bLSliceS(NULL, sizeof(s), 0, 0), NULL);
+ r = bLSliceS(NULL, sizeof(s), 0, 0);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -8416,60 +9343,73 @@ END_TEST
START_TEST(iInsertST)
char *s;
+ char *r = null;
// insert
s = strdup("sheepy");
- iInsertS(&s, 0, "lib");
+ r = iInsertS(&s, 0, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
free(s);
// negative index
s = strdup("libsheepy");
- iInsertS(&s, -2, "P");
+ r = iInsertS(&s, -2, "P");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepPy");
free(s);
// edge
s = strdup("qwe");
- iInsertS(&s, 3, "C");
+ r = iInsertS(&s, 3, "C");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qweC");
free(s);
// outside string
s = strdup("qwe");
- iInsertS(&s, 4, "C");
+ r = iInsertS(&s, 4, "C");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
- iInsertS(&s, -5, "C");
+ r = iInsertS(&s, -5, "C");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
free(s);
// negative index in a one char string
s = strdup("s");
- iInsertS(&s, -1, "S");
+ r = iInsertS(&s, -1, "S");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sS");
free(s);
// empty string
emptyS(s);
- iInsertS(&s, 0, "s");
+ r = iInsertS(&s, 0, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
emptyS(s);
- iInsertS(&s, -1, "s");
+ r = iInsertS(&s, -1, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
// empty insert string
s = strdup("a");
- iInsertS(&s, 0, "");
+ r = iInsertS(&s, 0, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
free(s);
// NULL insert string
s = strdup("a");
- iInsertS(&s, 0, NULL);
+ r = iInsertS(&s, 0, NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
free(s);
// NULL string
s = NULL;
- iInsertS(&s, 0, "s");
+ r = iInsertS(&s, 0, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
// NULL var
- iInsertS(NULL, 0, "s");
+ r = iInsertS(NULL, 0, "s");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -8480,17 +9420,20 @@ START_TEST(iInsertNFreeST)
// insert
s = strdup("sheepy");
- iInsertNFreeS(&s, 0, strdup("lib"));
+ r = iInsertNFreeS(&s, 0, strdup("lib"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
free(s);
// negative index
s = strdup("libsheepy");
- iInsertNFreeS(&s, -2, strdup("P"));
+ r = iInsertNFreeS(&s, -2, strdup("P"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepPy");
free(s);
// edge
s = strdup("qwe");
- iInsertNFreeS(&s, 3, strdup("C"));
+ r = iInsertNFreeS(&s, 3, strdup("C"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qweC");
free(s);
// outside string
@@ -8506,31 +9449,37 @@ START_TEST(iInsertNFreeST)
free(s);
// negative index in a one char string
s = strdup("s");
- iInsertNFreeS(&s, -1, strdup("S"));
+ r = iInsertNFreeS(&s, -1, strdup("S"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sS");
free(s);
// empty string
emptyS(s);
- iInsertNFreeS(&s, 0, strdup("s"));
+ r = iInsertNFreeS(&s, 0, strdup("s"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
emptyS(s);
- iInsertNFreeS(&s, -1, strdup("s"));
+ r = iInsertNFreeS(&s, -1, strdup("s"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
// empty insert string
s = strdup("a");
- iInsertNFreeS(&s, 0, strdup(""));
+ r = iInsertNFreeS(&s, 0, strdup(""));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
free(s);
// NULL insert string
s = strdup("a");
- iInsertNFreeS(&s, 0, NULL);
+ r = iInsertNFreeS(&s, 0, NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
free(s);
// NULL string
s = NULL;
- iInsertNFreeS(&s, 0, strdup("s"));
+ r = iInsertNFreeS(&s, 0, strdup("s"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
// NULL var
@@ -8545,46 +9494,58 @@ END_TEST
START_TEST(bInsertST)
char s[100];
+ char *r = null;
// insert
strcpy(s, "sheepy");
- bInsertS(s, 0, "lib");
+ r = bInsertS(s, 0, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// negative index
strcpy(s, "libsheepy");
- bInsertS(s, -2, "P");
+ r = bInsertS(s, -2, "P");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepPy");
// edge
strcpy(s, "qwe");
- bInsertS(s, 3, "C");
+ r = bInsertS(s, 3, "C");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qweC");
// outside string
strcpy(s, "qwe");
- bInsertS(s, 4, "C");
+ r = bInsertS(s, 4, "C");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
- bInsertS(s, -5, "C");
+ r = bInsertS(s, -5, "C");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// negative index in a one char string
strcpy(s, "s");
- bInsertS(s, -1, "S");
+ r = bInsertS(s, -1, "S");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sS");
// empty string
bEmptyS(s);
- bInsertS(s, 0, "s");
+ r = bInsertS(s, 0, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
bEmptyS(s);
- bInsertS(s, -1, "s");
+ r = bInsertS(s, -1, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
// empty insert string
strcpy(s, "a");
- bInsertS(s, 0, "");
+ r = bInsertS(s, 0, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
// NULL insert string
strcpy(s, "a");
- bInsertS(s, 0, NULL);
+ r = bInsertS(s, 0, NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
// NULL var
- ck_assert_ptr_eq(bInsertS(NULL, 0, "s"), NULL);
+ r = bInsertS(NULL, 0, "s");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -8592,53 +9553,67 @@ END_TEST
START_TEST(bLInsertST)
char s[100];
+ char *r = null;
// insert
strcpy(s, "sheepy");
- bLInsertS(s, sizeof s, 0, "lib");
+ r = bLInsertS(s, sizeof s, 0, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// shorter buffer
strcpy(s, "sheepy");
- bLInsertS(s, 5, 0, "lib");
+ r = bLInsertS(s, 5, 0, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libs");
// negative index
strcpy(s, "libsheepy");
- bLInsertS(s, sizeof s, -2, "P");
+ r = bLInsertS(s, sizeof s, -2, "P");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepPy");
// edge
strcpy(s, "qwe");
- bLInsertS(s, sizeof s, 3, "C");
+ r = bLInsertS(s, sizeof s, 3, "C");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qweC");
// outside string
strcpy(s, "qwe");
- bLInsertS(s, sizeof s, 4, "C");
+ r = bLInsertS(s, sizeof s, 4, "C");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
- bLInsertS(s, sizeof s, -5, "C");
+ r = bLInsertS(s, sizeof s, -5, "C");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// negative index in a one char string
strcpy(s, "s");
- bLInsertS(s, sizeof s, -1, "S");
+ r = bLInsertS(s, sizeof s, -1, "S");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sS");
// empty string
bEmptyS(s);
- bLInsertS(s, sizeof s, 0, "s");
+ r = bLInsertS(s, sizeof s, 0, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
bEmptyS(s);
- bLInsertS(s, sizeof s, -1, "s");
+ r = bLInsertS(s, sizeof s, -1, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
// empty insert string
strcpy(s, "a");
- bLInsertS(s, sizeof s, 0, "");
+ r = bLInsertS(s, sizeof s, 0, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
// size 0 - no change
- bLInsertS(s, 0, 0, "qwe");
+ r = bLInsertS(s, 0, 0, "qwe");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
// NULL insert string
strcpy(s, "a");
- bLInsertS(s, sizeof s, 0, NULL);
+ r = bLInsertS(s, sizeof s, 0, NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
// NULL var
- ck_assert_ptr_eq(bLInsertS(NULL, sizeof s, 0, "s"), NULL);
+ r = bLInsertS(NULL, sizeof s, 0, "s");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -8687,50 +9662,61 @@ END_TEST
START_TEST(iInjectST)
char *s;
+ char *r = null;
// insert
s = strdup("sheepy");
- iInjectS(&s, 0, 'L');
+ r = iInjectS(&s, 0, 'L');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "Lsheepy");
free(s);
// negative index
s = strdup("libsheepy");
- iInjectS(&s, -2, 'P');
+ r = iInjectS(&s, -2, 'P');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepPy");
free(s);
// edge
s = strdup("qwe");
- iInjectS(&s, 3, 'C');
+ r = iInjectS(&s, 3, 'C');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qweC");
free(s);
// outside string
s = strdup("qwe");
- iInjectS(&s, 4, 'C');
+ r = iInjectS(&s, 4, 'C');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
- iInjectS(&s, -5, 'C');
+ r = iInjectS(&s, -5, 'C');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
free(s);
// negative index in a one char string
s = strdup("s");
- iInjectS(&s, -1, 'S');
+ r = iInjectS(&s, -1, 'S');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sS");
free(s);
// empty string
emptyS(s);
- iInjectS(&s, 0, 's');
+ r = iInjectS(&s, 0, 's');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
emptyS(s);
- iInjectS(&s, -1, 's');
+ r = iInjectS(&s, -1, 's');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
// NULL string
s = NULL;
- iInjectS(&s, 0, 's');
+ r = iInjectS(&s, 0, 's');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
// NULL var
- iInjectS(NULL, 0, 's');
+ r = iInjectS(NULL, 0, 's');
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -8738,38 +9724,48 @@ END_TEST
START_TEST(bInjectST)
char s[100];
+ char *r = null;
// insert
strcpy(s, "sheepy");
- bInjectS(s, 0, 'L');
+ r = bInjectS(s, 0, 'L');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "Lsheepy");
// negative index
strcpy(s, "libsheepy");
- bInjectS(s, -2, 'P');
+ r = bInjectS(s, -2, 'P');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepPy");
// edge
strcpy(s, "qwe");
- bInjectS(s, 3, 'C');
+ r = bInjectS(s, 3, 'C');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qweC");
// outside string
strcpy(s, "qwe");
- bInjectS(s, 4, 'C');
+ r = bInjectS(s, 4, 'C');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
- bInjectS(s, -5, 'C');
+ r = bInjectS(s, -5, 'C');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// negative index in a one char string
strcpy(s, "s");
- bInjectS(s, -1, 'S');
+ r = bInjectS(s, -1, 'S');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sS");
// empty string
bEmptyS(s);
- bInjectS(s, 0, 's');
+ r = bInjectS(s, 0, 's');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
bEmptyS(s);
- bInjectS(s, -1, 's');
+ r = bInjectS(s, -1, 's');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
// NULL var
- ck_assert_ptr_eq(bInjectS(NULL, 0, 's'), NULL);
+ r = bInjectS(NULL, 0, 's');
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -8777,45 +9773,57 @@ END_TEST
START_TEST(bLInjectST)
char s[100];
+ char *r = null;
// insert
strcpy(s, "sheepy");
- bLInjectS(s, sizeof s, 0, 'L');
+ r = bLInjectS(s, sizeof s, 0, 'L');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "Lsheepy");
// shorter buffer
strcpy(s, "sheepy");
- bLInjectS(s, 5, 0, 'L');
+ r = bLInjectS(s, 5, 0, 'L');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "Lshe");
// negative index
strcpy(s, "libsheepy");
- bLInjectS(s, sizeof s, -2, 'P');
+ r = bLInjectS(s, sizeof s, -2, 'P');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepPy");
// edge
strcpy(s, "qwe");
- bLInjectS(s, sizeof s, 3, 'C');
+ r = bLInjectS(s, sizeof s, 3, 'C');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qweC");
// outside string
strcpy(s, "qwe");
- bLInjectS(s, sizeof s, 4, 'C');
+ r = bLInjectS(s, sizeof s, 4, 'C');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
- bLInjectS(s, sizeof s, -5, 'C');
+ r = bLInjectS(s, sizeof s, -5, 'C');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// negative index in a one char string
strcpy(s, "s");
- bLInjectS(s, sizeof s, -1, 'S');
+ r = bLInjectS(s, sizeof s, -1, 'S');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sS");
// empty string
bEmptyS(s);
- bLInjectS(s, sizeof s, 0, 's');
+ r = bLInjectS(s, sizeof s, 0, 's');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
bEmptyS(s);
- bLInjectS(s, sizeof s, -1, 's');
+ r = bLInjectS(s, sizeof s, -1, 's');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
// size 0 - no change
- bLInjectS(s, 0, -1, 's');
+ r = bLInjectS(s, 0, -1, 's');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
// NULL var
- ck_assert_ptr_eq(bLInjectS(NULL, sizeof s, 0, 's'), NULL);
+ r = bLInjectS(NULL, sizeof s, 0, 's');
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -8866,64 +9874,65 @@ END_TEST
START_TEST(iDelST)
- char *s;
+ char *s, *r;
// del
s = strdup("sheepy");
- iDelS(&s, 0,2);
+ r = iDelS(&s, 0,2);
ck_assert_str_eq(s, "eepy");
free(s);
// negative index
s = strdup("sheepy");
- iDelS(&s, -2,0);
+ r = iDelS(&s, -2,0);
ck_assert_str_eq(s, "shee");
free(s);
// positive and negative indexes
s = strdup("sheepy");
- iDelS(&s, 2,-2);
+ r = iDelS(&s, 2,-2);
ck_assert_str_eq(s, "shpy");
free(s);
// start = end
s = strdup("sheepy");
- iDelS(&s, 2,-4);
+ r = iDelS(&s, 2,-4);
ck_assert_str_eq(s, "sheepy");
free(s);
// delete entire string
s = strdup("sheepy");
- iDelS(&s, 0,0);
+ r = iDelS(&s, 0,0);
ck_assert_str_eq(s, "");
free(s);
// end of string
s = strdup("sheepy");
- iDelS(&s, 2,6);
+ r = iDelS(&s, 2,6);
ck_assert_str_eq(s, "sh");
free(s);
// NULL string
s = NULL;
- iDelS(&s, 2,-4);
+ r = iDelS(&s, 2,-4);
ck_assert_ptr_eq(s, NULL);
// start outside string
s = strdup("sheepy");
- iDelS(&s, 20,-4);
+ r = iDelS(&s, 20,-4);
ck_assert_str_eq(s, "sheepy");
- iDelS(&s, -20,-4);
+ r = iDelS(&s, -20,-4);
ck_assert_str_eq(s, "eepy");
free(s);
// end outside string
s = strdup("sheepy");
- iDelS(&s, 2,40);
+ r = iDelS(&s, 2,40);
ck_assert_str_eq(s, "sh");
free(s);
s = strdup("sheepy");
- iDelS(&s, 2,-40);
+ r = iDelS(&s, 2,-40);
ck_assert_str_eq(s, "sheepy");
free(s);
// end before start
s = strdup("sheepy");
- iDelS(&s, 4,2);
+ r = iDelS(&s, 4,2);
ck_assert_str_eq(s, "sheepy");
free(s);
// NULL var
- iDelS(NULL, 4,2);
+ r = iDelS(NULL, 4,2);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -8931,49 +9940,63 @@ END_TEST
START_TEST(bDelST)
char s[100];
+ char *r = null;
+
// del
strcpy(s, "sheepy");
- bDelS(s, 0,2);
+ r = bDelS(s, 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
// negative index
strcpy(s, "sheepy");
- bDelS(s, -2,0);
+ r = bDelS(s, -2,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "shee");
// positive and negative indexes
strcpy(s, "sheepy");
- bDelS(s, 2,-2);
+ r = bDelS(s, 2,-2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "shpy");
// start = end
strcpy(s, "sheepy");
- bDelS(s, 2,-4);
+ r = bDelS(s, 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepy");
// delete entire string
strcpy(s, "sheepy");
- bDelS(s, 0,0);
+ r = bDelS(s, 0,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// end of string
strcpy(s, "sheepy");
- bDelS(s, 2,6);
+ r = bDelS(s, 2,6);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
// start outside string
strcpy(s, "sheepy");
- bDelS(s, 20,-4);
+ r = bDelS(s, 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
- bDelS(s, -20,-4);
+ r = bDelS(s, -20,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
// end outside string
strcpy(s, "sheepy");
- bDelS(s, 2,40);
+ r = bDelS(s, 2,40);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
strcpy(s, "sheepy");
- bDelS(s, 2,-40);
+ r = bDelS(s, 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
// end before start
strcpy(s, "sheepy");
- bDelS(s, 4,2);
+ r = bDelS(s, 4,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
// NULL var
- ck_assert_ptr_eq(bDelS(NULL, 4,2), NULL);
+ r = bDelS(NULL, 4,2);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -8981,52 +10004,67 @@ END_TEST
START_TEST(bLDelST)
char s[100];
+ char *r = null;
+
// del
strcpy(s, "sheepy");
- bLDelS(s, sizeof(s), 0,2);
+ r = bLDelS(s, sizeof(s), 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
// buffer shorter than string
strcpy(s, "sheepy");
- bLDelS(s, 5, 0,2);
+ r = bLDelS(s, 5, 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ee");
// negative index
strcpy(s, "sheepy");
- bLDelS(s, sizeof(s), -2,0);
+ r = bLDelS(s, sizeof(s), -2,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "shee");
// positive and negative indexes
strcpy(s, "sheepy");
- bLDelS(s, sizeof(s), 2,-2);
+ r = bLDelS(s, sizeof(s), 2,-2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "shpy");
// start = end
strcpy(s, "sheepy");
- bLDelS(s, sizeof(s), 2,-4);
+ r = bLDelS(s, sizeof(s), 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepy");
// end of string
strcpy(s, "sheepy");
- bLDelS(s, sizeof(s), 2,6);
+ r = bLDelS(s, sizeof(s), 2,6);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
// start outside string
strcpy(s, "sheepy");
- bLDelS(s, sizeof(s), 20,-4);
+ r = bLDelS(s, sizeof(s), 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
// end outside string
strcpy(s, "sheepy");
- bLDelS(s, sizeof(s), 2,40);
+ r = bLDelS(s, sizeof(s), 2,40);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
strcpy(s, "sheepy");
- bLDelS(s, sizeof(s), -22,3);
+ r = bLDelS(s, sizeof(s), -22,3);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "epy");
strcpy(s, "sheepy");
- bLDelS(s, sizeof(s), 2,-40);
+ r = bLDelS(s, sizeof(s), 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
// end before start
strcpy(s, "sheepy");
- bLDelS(s, sizeof(s), 4,2);
+ r = bLDelS(s, sizeof(s), 4,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
// size 0
- ck_assert_ptr_eq(bLDelS(s, 0, 0, 0), NULL);
+ r = bLDelS(s, 0, 0, 0);
+ ck_assert_ptr_eq(r, null);
// NULL var
- ck_assert_ptr_eq(bLDelS(NULL, sizeof(s), 0, 0), NULL);
+ r = bLDelS(NULL, sizeof(s), 0, 0);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -9461,13 +10499,15 @@ END_TEST
START_TEST(isUTF8T)
char b[8];
+ char *r = null;
// string
ck_assert(isUTF8("sheepy"));
// UTF8
ck_assert(isUTF8("sheepy£"));
// invalid UTF8
- strLCpy(b, sizeof(b), "sheepy£");
+ r = strLCpy(b, sizeof(b), "sheepy£");
+ ck_assert_ptr_eq(r, b);
ck_assert(!isUTF8(b));
// null string
ck_assert(!isUTF8(null));
@@ -9513,7 +10553,7 @@ END_TEST
START_TEST(nextUTF8T)
- char *r;
+ const char *r;
// next
r = nextUTF8("£sheepy");
@@ -9532,7 +10572,7 @@ END_TEST
START_TEST(bLNextUTF8T)
char b[20] = init0Var;
- char *r;
+ const char *r;
strcpy(b, "£sheepy");
// next
@@ -9565,7 +10605,7 @@ END_TEST
START_TEST(findNextUTF8T)
char b[20] = init0Var;
- char *r;
+ const char *r;
strcpy(b, "£sheepy");
// next
@@ -9602,7 +10642,7 @@ END_TEST
START_TEST(prevUTF8T)
char b[20] = init0Var;
- char *r;
+ const char *r;
strcpy(b, "£sheepy");
// prev
@@ -9619,7 +10659,7 @@ END_TEST
START_TEST(bPrevUTF8T)
char b[20] = init0Var;
- char *r;
+ const char *r;
strcpy(b, "£sheepy");
// prev
@@ -9640,7 +10680,7 @@ END_TEST
START_TEST(idx2PtrUTF8T)
char *emptys = "";
- char *r;
+ const char *r;
// index
r = idx2PtrUTF8("£sheepy", 1);
@@ -9675,7 +10715,7 @@ END_TEST
START_TEST(bLIdx2PtrUTF8T)
char b[20] = init0Var;
- char *r;
+ const char *r;
strcpy(b, "£sheepy");
// index
@@ -10027,30 +11067,37 @@ END_TEST
START_TEST(strLCpyUTF8T)
char s[1024];
+ char *r = null;
// copy string
- strLCpyUTF8(s, 100, "lib");
+ r = strLCpyUTF8(s, 100, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "lib");
// truncate src
s[0] = 0;
s[1] = 0;
s[2] = 0;
- strLCpyUTF8(s, 3, "lib");
+ r = strLCpyUTF8(s, 3, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "li");
s[0] = 'a';
s[1] = 'a';
s[2] = 'a';
s[3] = 0;
- strLCpyUTF8(s, 3, "lib");
+ r = strLCpyUTF8(s, 3, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "li");
// size 0 - no change in s
- strLCpyUTF8(s, 0, "libsheepy");
+ r = strLCpyUTF8(s, 0, "libsheepy");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "li");
// NULL
s[0] = 0;
- strLCpyUTF8(s, 1, NULL);
+ r = strLCpyUTF8(s, 1, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
- ck_assert_ptr_eq(strLCpyUTF8(NULL,1, "lib"), NULL);
+ r = strLCpyUTF8(NULL,1, "lib");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -10059,13 +11106,17 @@ END_TEST
START_TEST(strNCatUTF8T)
char s[1024];
+ char *r = null;
// append string
- strCpy(s, "lib");
- strNCatUTF8(s, "sheepy", 100);
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
+ r = strNCatUTF8(s, "sheepy", 100);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// empty string2
- strNCatUTF8(s, "", 10);
+ r = strNCatUTF8(s, "", 10);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// truncate src
s[0] = 'a';
@@ -10074,18 +11125,23 @@ START_TEST(strNCatUTF8T)
s[3] = 'a';
s[4] = 'a';
s[5] = 'a';
- strCpy(s, "lib");
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "lib");
- strNCatUTF8(s, "sheepy", 2);
+ r = strNCatUTF8(s, "sheepy", 2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsh");
// length 0
- strNCatUTF8(s, "sheepy", 0);
+ r = strNCatUTF8(s, "sheepy", 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsh");
// NULL string2
- strNCatUTF8(s, NULL, 1);
+ r = strNCatUTF8(s, NULL, 1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "libsh");
// NULL parameter
- ck_assert_ptr_eq(strNCatUTF8(NULL, "ad", 1), NULL);
+ r = strNCatUTF8(NULL, "ad", 1);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -10094,16 +11150,21 @@ END_TEST
START_TEST(strLCatUTF8T)
char s[1024];
+ char *r = null;
// append string
- strCpy(s, "lib");
- strLCatUTF8(s, 100, "sheepy");
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
+ r = strLCatUTF8(s, 100, "sheepy");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// empty string2
- strLCatUTF8(s, 20, "");
+ r = strLCatUTF8(s, 20, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// s strlen bigger than s size - keep s as it is
- strLCatUTF8(s, 6, "qwqwe");
+ r = strLCatUTF8(s, 6, "qwqwe");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// truncate src
s[0] = 'a';
@@ -10112,9 +11173,11 @@ START_TEST(strLCatUTF8T)
s[3] = 'a';
s[4] = 'a';
s[5] = 'a';
- strCpy(s, "lib");
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "lib");
- strLNCat(s,100, "sheepy", 2);
+ r = strLNCat(s,100, "sheepy", 2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsh");
// truncate dst
s[0] = 'a';
@@ -10123,15 +11186,19 @@ START_TEST(strLCatUTF8T)
s[3] = 'a';
s[4] = 'a';
s[5] = 'a';
- strCpy(s, "lib");
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "lib");
- strLCatUTF8(s, 6, "sheepy");
+ r = strLCatUTF8(s, 6, "sheepy");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsh");
// NULL string2
- strLCatUTF8(s, 1, NULL);
+ r = strLCatUTF8(s, 1, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "libsh");
// NULL parameter
- ck_assert_ptr_eq(strLCatUTF8(NULL, 1, "ad"), NULL);
+ r = strLCatUTF8(NULL, 1, "ad");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -10140,16 +11207,21 @@ END_TEST
START_TEST(strLNCatUTF8T)
char s[1024];
+ char *r = null;
// append string
- strCpy(s, "lib");
- strLNCatUTF8(s, 100, "sheepy", 100);
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
+ r = strLNCatUTF8(s, 100, "sheepy", 100);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// empty string2
- strLNCatUTF8(s, 20, "", 10);
+ r = strLNCatUTF8(s, 20, "", 10);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// s strlen bigger than s size - keep s as it is
- strLNCatUTF8(s, 6, "qwqwe", 1);
+ r = strLNCatUTF8(s, 6, "qwqwe", 1);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// truncate dst
s[0] = 'a';
@@ -10158,18 +11230,23 @@ START_TEST(strLNCatUTF8T)
s[3] = 'a';
s[4] = 'a';
s[5] = 'a';
- strCpy(s, "lib");
+ r = strCpy(s, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "lib");
- strLNCatUTF8(s, 6, "sheepy", 4);
+ r = strLNCatUTF8(s, 6, "sheepy", 4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsh");
// 0 source length
- strLNCatUTF8(s, 6, "sheepy", 0);
+ r = strLNCatUTF8(s, 6, "sheepy", 0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsh");
// NULL string2
- strLNCatUTF8(s, 1, NULL, 1);
+ r = strLNCatUTF8(s, 1, NULL, 1);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "libsh");
// NULL parameter
- ck_assert_ptr_eq(strLNCatUTF8(NULL, 1, "ad", 1), NULL);
+ r = strLNCatUTF8(NULL, 1, "ad", 1);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -10404,8 +11481,9 @@ START_TEST(toupperUTF8T)
r = code2RuneUTF8("Ã¥");
r = toupperUTF8(r);
- bRune2CodeUTF8(dst,r);
+ u8 r2 = bRune2CodeUTF8(dst,r);
ck_assert_str_eq(dst, "Ã…");
+ ck_assert_int_eq(r2, 2);
END_TEST
@@ -10426,17 +11504,22 @@ END_TEST
START_TEST(iUpperUTF8T)
char *s;
+ char *r = null;
+
// string
s = strdup("sheepy");
- iUpperUTF8(&s);
+ r = iUpperUTF8(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "SHEEPY");
free(s);
// NULL string
s = NULL;
- iUpperUTF8(&s);
+ r = iUpperUTF8(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_ptr_eq(s, NULL);
// NULL var
- iUpperUTF8(NULL);
+ r = iUpperUTF8(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -10452,8 +11535,9 @@ START_TEST(tolowerUTF8T)
r = code2RuneUTF8("Ã…");
r = tolowerUTF8(r);
- bRune2CodeUTF8(dst,r);
+ u8 r2 = bRune2CodeUTF8(dst,r);
ck_assert_str_eq(dst, "Ã¥");
+ ck_assert_int_eq(r2, 2);
END_TEST
@@ -10475,17 +11559,22 @@ END_TEST
START_TEST(iLowerUTF8T)
char *s;
+ char *r = null;
+
// string
s = strdup("SHEEPY");
- iLowerUTF8(&s);
+ r = iLowerUTF8(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepy");
free(s);
// NULL string
s = NULL;
- iLowerUTF8(&s);
+ r = iLowerUTF8(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert_ptr_eq(s, NULL);
// NULL var
- iLowerUTF8(NULL);
+ r = iLowerUTF8(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -10576,30 +11665,38 @@ START_TEST(setUTF8T)
char *s;
s = strdup("sheepy");
+ char *r = null;
// set char
- setUTF8(s, 0, 'S');
+ r = setUTF8(s, 0, 'S');
+ ck_assert_ptr_eq(r, s);
ck_assert_uint_eq(s[0], 'S');
// negative index
- setUTF8(s, -2, 'P');
+ r = setUTF8(s, -2, 'P');
+ ck_assert_ptr_eq(r, s);
ck_assert_uint_eq(s[4], 'P');
// outside string
- setUTF8(s, 20, 'Y');
- setUTF8(s, -20, 'Y');
+ r = setUTF8(s, 20, 'Y');
+ ck_assert_ptr_eq(r, null);
+ r = setUTF8(s, -20, 'Y');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "SheePy");
free(s);
// negative index in a one char string
s = strdup("s");
- setUTF8(s, -1, 'S');
+ r = setUTF8(s, -1, 'S');
+ ck_assert_ptr_eq(r, s);
ck_assert_uint_eq(s[0], 'S');
free(s);
// empty string
emptyS(s);
- setUTF8(s, -1, 'S');
+ r = setUTF8(s, -1, 'S');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// NULL string
- setUTF8(NULL, 0, 's');
+ r = setUTF8(NULL, 0, 's');
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -10649,60 +11746,74 @@ END_TEST
START_TEST(iSliceUTF8T)
char *s;
+ char *r = null;
+
// slice
s = strdup("sheepy");
- iSliceUTF8(&s, 0,2);
+ r = iSliceUTF8(&s, 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
free(s);
// negative index
s = strdup("sheepy");
- iSliceUTF8(&s, -2,0);
+ r = iSliceUTF8(&s, -2,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "py");
free(s);
// positive and negative indexes
s = strdup("sheepy");
- iSliceUTF8(&s, 2,-2);
+ r = iSliceUTF8(&s, 2,-2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ee");
free(s);
// start = end
s = strdup("sheepy");
- iSliceUTF8(&s, 2,-4);
+ r = iSliceUTF8(&s, 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
free(s);
// end of string
s = strdup("sheepy");
- iSliceUTF8(&s, 2,6);
+ r = iSliceUTF8(&s, 2,6);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
free(s);
// NULL string
s = NULL;
- iSliceUTF8(&s, 2,-4);
+ r = iSliceUTF8(&s, 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_ptr_eq(s, NULL);
// start outside string
s = strdup("sheepy");
- iSliceUTF8(&s, 20,-4);
+ r = iSliceUTF8(&s, 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// end outside string
s = strdup("sheepy");
- iSliceUTF8(&s, 2,40);
+ r = iSliceUTF8(&s, 2,40);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
free(s);
s = strdup("sheepy");
- iSliceUTF8(&s, -22,3);
+ r = iSliceUTF8(&s, -22,3);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "she");
free(s);
s = strdup("sheepy");
- iSliceUTF8(&s, 2,-40);
+ r = iSliceUTF8(&s, 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// end before start
s = strdup("sheepy");
- iSliceUTF8(&s, 4,2);
+ r = iSliceUTF8(&s, 4,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
free(s);
// NULL var
- iSliceUTF8(NULL, 0, 0);
+ r = iSliceUTF8(NULL, 0, 0);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -10711,46 +11822,59 @@ END_TEST
START_TEST(bSliceUTF8T)
char s[100];
+ char *r = null;
+
// slice
strcpy(s, "sheepy");
- bSliceUTF8(s, 0,2);
+ r = bSliceUTF8(s, 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
// negative index
strcpy(s, "sheepy");
- bSliceUTF8(s, -2,0);
+ r = bSliceUTF8(s, -2,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "py");
// positive and negative indexes
strcpy(s, "sheepy");
- bSliceUTF8(s, 2,-2);
+ r = bSliceUTF8(s, 2,-2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ee");
// start = end
strcpy(s, "sheepy");
- bSliceUTF8(s, 2,-4);
+ r = bSliceUTF8(s, 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// end of string
strcpy(s, "sheepy");
- bSliceUTF8(s, 2,6);
+ r = bSliceUTF8(s, 2,6);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
// start outside string
strcpy(s, "sheepy");
- bSliceUTF8(s, 20,-4);
+ r = bSliceUTF8(s, 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// end outside string
strcpy(s, "sheepy");
- bSliceUTF8(s, 2,40);
+ r = bSliceUTF8(s, 2,40);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
strcpy(s, "sheepy");
- bSliceUTF8(s, -22,3);
+ r = bSliceUTF8(s, -22,3);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "she");
strcpy(s, "sheepy");
- bSliceUTF8(s, 2,-40);
+ r = bSliceUTF8(s, 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// end before start
strcpy(s, "sheepy");
- bSliceUTF8(s, 4,2);
+ r = bSliceUTF8(s, 4,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// NULL var
- ck_assert_ptr_eq(bSliceUTF8(NULL, 0, 0), NULL);
+ r = bSliceUTF8(NULL, 0, 0);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -10759,52 +11883,67 @@ END_TEST
START_TEST(bLSliceUTF8T)
char s[100];
+ char *r = null;
+
// slice
strcpy(s, "sheepy");
- bLSliceUTF8(s, sizeof(s), 0,2);
+ r = bLSliceUTF8(s, sizeof(s), 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
// buffer shorter than string
strcpy(s, "sheepy");
- bLSliceUTF8(s, 5, 0,2);
+ r = bLSliceUTF8(s, 5, 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
// negative index
strcpy(s, "sheepy");
- bLSliceUTF8(s, sizeof(s), -2,0);
+ r = bLSliceUTF8(s, sizeof(s), -2,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "py");
// positive and negative indexes
strcpy(s, "sheepy");
- bLSliceUTF8(s, sizeof(s), 2,-2);
+ r = bLSliceUTF8(s, sizeof(s), 2,-2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ee");
// start = end
strcpy(s, "sheepy");
- bLSliceUTF8(s, sizeof(s), 2,-4);
+ r = bLSliceUTF8(s, sizeof(s), 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// end of string
strcpy(s, "sheepy");
- bLSliceUTF8(s, sizeof(s), 2,6);
+ r = bLSliceUTF8(s, sizeof(s), 2,6);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
// start outside string
strcpy(s, "sheepy");
- bLSliceUTF8(s, sizeof(s), 20,-4);
+ r = bLSliceUTF8(s, sizeof(s), 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// end outside string
strcpy(s, "sheepy");
- bLSliceUTF8(s, sizeof(s), 2,40);
+ r = bLSliceUTF8(s, sizeof(s), 2,40);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
strcpy(s, "sheepy");
- bLSliceUTF8(s, sizeof(s), -22,3);
+ r = bLSliceUTF8(s, sizeof(s), -22,3);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "she");
strcpy(s, "sheepy");
- bLSliceUTF8(s, sizeof(s), 2,-40);
+ r = bLSliceUTF8(s, sizeof(s), 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// end before start
strcpy(s, "sheepy");
- bLSliceUTF8(s, sizeof(s), 4,2);
+ r = bLSliceUTF8(s, sizeof(s), 4,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "");
// size 0
- ck_assert_ptr_eq(bLSliceUTF8(s, 0, 0, 0), NULL);
+ r = bLSliceUTF8(s, 0, 0, 0);
+ ck_assert_ptr_eq(r, null);
// NULL var
- ck_assert_ptr_eq(bLSliceUTF8(NULL, sizeof(s), 0, 0), NULL);
+ r = bLSliceUTF8(NULL, sizeof(s), 0, 0);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -10913,60 +12052,73 @@ END_TEST
START_TEST(iInsertUTF8T)
char *s;
+ char *r = null;
// insert
s = strdup("sheepy");
- iInsertUTF8(&s, 0, "lib");
+ r = iInsertUTF8(&s, 0, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
free(s);
// negative index
s = strdup("libsheepy");
- iInsertUTF8(&s, -2, "P");
+ r = iInsertUTF8(&s, -2, "P");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepPy");
free(s);
// edge
s = strdup("qwe");
- iInsertUTF8(&s, 3, "C");
+ r = iInsertUTF8(&s, 3, "C");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qweC");
free(s);
// outside string
s = strdup("qwe");
- iInsertUTF8(&s, 4, "C");
+ r = iInsertUTF8(&s, 4, "C");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
- iInsertUTF8(&s, -5, "C");
+ r = iInsertUTF8(&s, -5, "C");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
free(s);
// negative index in a one char string
s = strdup("s");
- iInsertUTF8(&s, -1, "S");
+ r = iInsertUTF8(&s, -1, "S");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sS");
free(s);
// empty string
emptyS(s);
- iInsertUTF8(&s, 0, "s");
+ r = iInsertUTF8(&s, 0, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
emptyS(s);
- iInsertUTF8(&s, -1, "s");
+ r = iInsertUTF8(&s, -1, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
// empty insert string
s = strdup("a");
- iInsertUTF8(&s, 0, "");
+ r = iInsertUTF8(&s, 0, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
free(s);
// NULL insert string
s = strdup("a");
- iInsertUTF8(&s, 0, NULL);
+ r = iInsertUTF8(&s, 0, NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
free(s);
// NULL string
s = NULL;
- iInsertUTF8(&s, 0, "s");
+ r = iInsertUTF8(&s, 0, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
// NULL var
- iInsertUTF8(NULL, 0, "s");
+ r = iInsertUTF8(NULL, 0, "s");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -10978,17 +12130,20 @@ START_TEST(iInsertNFreeUTF8T)
// insert
s = strdup("sheepy");
- iInsertNFreeUTF8(&s, 0, strdup("lib"));
+ r = iInsertNFreeUTF8(&s, 0, strdup("lib"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
free(s);
// negative index
s = strdup("libsheepy");
- iInsertNFreeUTF8(&s, -2, strdup("P"));
+ r = iInsertNFreeUTF8(&s, -2, strdup("P"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepPy");
free(s);
// edge
s = strdup("qwe");
- iInsertNFreeUTF8(&s, 3, strdup("C"));
+ r = iInsertNFreeUTF8(&s, 3, strdup("C"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qweC");
free(s);
// outside string
@@ -11004,31 +12159,37 @@ START_TEST(iInsertNFreeUTF8T)
free(s);
// negative index in a one char string
s = strdup("s");
- iInsertNFreeUTF8(&s, -1, strdup("S"));
+ r = iInsertNFreeUTF8(&s, -1, strdup("S"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sS");
free(s);
// empty string
emptyS(s);
- iInsertNFreeUTF8(&s, 0, strdup("s"));
+ r = iInsertNFreeUTF8(&s, 0, strdup("s"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
emptyS(s);
- iInsertNFreeUTF8(&s, -1, strdup("s"));
+ r = iInsertNFreeUTF8(&s, -1, strdup("s"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
// empty insert string
s = strdup("a");
- iInsertNFreeUTF8(&s, 0, strdup(""));
+ r = iInsertNFreeUTF8(&s, 0, strdup(""));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
free(s);
// NULL insert string
s = strdup("a");
- iInsertNFreeUTF8(&s, 0, NULL);
+ r = iInsertNFreeUTF8(&s, 0, NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
free(s);
// NULL string
s = NULL;
- iInsertNFreeUTF8(&s, 0, strdup("s"));
+ r = iInsertNFreeUTF8(&s, 0, strdup("s"));
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
free(s);
// NULL var
@@ -11044,46 +12205,58 @@ END_TEST
START_TEST(bInsertUTF8T)
char s[100];
+ char *r = null;
// insert
strcpy(s, "sheepy");
- bInsertUTF8(s, 0, "lib");
+ r = bInsertUTF8(s, 0, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// negative index
strcpy(s, "libsheepy");
- bInsertUTF8(s, -2, "P");
+ r = bInsertUTF8(s, -2, "P");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepPy");
// edge
strcpy(s, "qwe");
- bInsertUTF8(s, 3, "C");
+ r = bInsertUTF8(s, 3, "C");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qweC");
// outside string
strcpy(s, "qwe");
- bInsertUTF8(s, 4, "C");
+ r = bInsertUTF8(s, 4, "C");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
- bInsertUTF8(s, -5, "C");
+ r = bInsertUTF8(s, -5, "C");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// negative index in a one char string
strcpy(s, "s");
- bInsertUTF8(s, -1, "S");
+ r = bInsertUTF8(s, -1, "S");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sS");
// empty string
bEmptyS(s);
- bInsertUTF8(s, 0, "s");
+ r = bInsertUTF8(s, 0, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
bEmptyS(s);
- bInsertUTF8(s, -1, "s");
+ r = bInsertUTF8(s, -1, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
// empty insert string
strcpy(s, "a");
- bInsertUTF8(s, 0, "");
+ r = bInsertUTF8(s, 0, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
// NULL insert string
strcpy(s, "a");
- bInsertUTF8(s, 0, NULL);
+ r = bInsertUTF8(s, 0, NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
// NULL var
- ck_assert_ptr_eq(bInsertUTF8(NULL, 0, "s"), NULL);
+ r = bInsertUTF8(NULL, 0, "s");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -11092,53 +12265,67 @@ END_TEST
START_TEST(bLInsertUTF8T)
char s[100];
+ char *r = null;
// insert
strcpy(s, "sheepy");
- bLInsertUTF8(s, sizeof s, 0, "lib");
+ r = bLInsertUTF8(s, sizeof s, 0, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepy");
// shorter buffer
strcpy(s, "sheepy");
- bLInsertUTF8(s, 5, 0, "lib");
+ r = bLInsertUTF8(s, 5, 0, "lib");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libs");
// negative index
strcpy(s, "libsheepy");
- bLInsertUTF8(s, sizeof s, -2, "P");
+ r = bLInsertUTF8(s, sizeof s, -2, "P");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "libsheepPy");
// edge
strcpy(s, "qwe");
- bLInsertUTF8(s, sizeof s, 3, "C");
+ r = bLInsertUTF8(s, sizeof s, 3, "C");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "qweC");
// outside string
strcpy(s, "qwe");
- bLInsertUTF8(s, sizeof s, 4, "C");
+ r = bLInsertUTF8(s, sizeof s, 4, "C");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
- bLInsertUTF8(s, sizeof s, -5, "C");
+ r = bLInsertUTF8(s, sizeof s, -5, "C");
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "qwe");
// negative index in a one char string
strcpy(s, "s");
- bLInsertUTF8(s, sizeof s, -1, "S");
+ r = bLInsertUTF8(s, sizeof s, -1, "S");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sS");
// empty string
bEmptyS(s);
- bLInsertUTF8(s, sizeof s, 0, "s");
+ r = bLInsertUTF8(s, sizeof s, 0, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
bEmptyS(s);
- bLInsertUTF8(s, sizeof s, -1, "s");
+ r = bLInsertUTF8(s, sizeof s, -1, "s");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "s");
// empty insert string
strcpy(s, "a");
- bLInsertUTF8(s, sizeof s, 0, "");
+ r = bLInsertUTF8(s, sizeof s, 0, "");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
// size 0 - no change
- bLInsertUTF8(s, 0, 0, "qwe");
+ r = bLInsertUTF8(s, 0, 0, "qwe");
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
// NULL insert string
strcpy(s, "a");
- bLInsertUTF8(s, sizeof s, 0, NULL);
+ r = bLInsertUTF8(s, sizeof s, 0, NULL);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "a");
// NULL var
- ck_assert_ptr_eq(bLInsertUTF8(NULL, sizeof s, 0, "s"), NULL);
+ r = bLInsertUTF8(NULL, sizeof s, 0, "s");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -11192,63 +12379,78 @@ END_TEST
START_TEST(iDelUTF8T)
char *s;
+ char *r = null;
+
// del
s = strdup("sheepy");
- iDelUTF8(&s, 0,2);
+ r = iDelUTF8(&s, 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
free(s);
// negative index
s = strdup("sheepy");
- iDelUTF8(&s, -2,0);
+ r = iDelUTF8(&s, -2,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "shee");
free(s);
// positive and negative indexes
s = strdup("sheepy");
- iDelUTF8(&s, 2,-2);
+ r = iDelUTF8(&s, 2,-2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "shpy");
free(s);
// start = end
s = strdup("sheepy");
- iDelUTF8(&s, 2,-4);
+ r = iDelUTF8(&s, 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepy");
free(s);
// delete entire string
s = strdup("sheepy");
- iDelUTF8(&s, 0,0);
+ r = iDelUTF8(&s, 0,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
free(s);
// end of string
s = strdup("sheepy");
- iDelUTF8(&s, 2,6);
+ r = iDelUTF8(&s, 2,6);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
free(s);
// NULL string
s = NULL;
- iDelUTF8(&s, 2,-4);
+ r = iDelUTF8(&s, 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_ptr_eq(s, NULL);
// start outside string
s = strdup("sheepy");
- iDelUTF8(&s, 20,-4);
+ r = iDelUTF8(&s, 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
- iDelUTF8(&s, -20,-4);
+ r = iDelUTF8(&s, -20,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
free(s);
// end outside string
s = strdup("sheepy");
- iDelUTF8(&s, 2,40);
+ r = iDelUTF8(&s, 2,40);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
free(s);
s = strdup("sheepy");
- iDelUTF8(&s, 2,-40);
+ r = iDelUTF8(&s, 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
free(s);
// end before start
s = strdup("sheepy");
- iDelUTF8(&s, 4,2);
+ r = iDelUTF8(&s, 4,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
free(s);
// NULL var
- iDelUTF8(NULL, 4,2);
+ r = iDelUTF8(NULL, 4,2);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -11257,49 +12459,63 @@ END_TEST
START_TEST(bDelUTF8T)
char s[100];
+ char *r = null;
+
// del
strcpy(s, "sheepy");
- bDelUTF8(s, 0,2);
+ r = bDelUTF8(s, 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
// negative index
strcpy(s, "sheepy");
- bDelUTF8(s, -2,0);
+ r = bDelUTF8(s, -2,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "shee");
// positive and negative indexes
strcpy(s, "sheepy");
- bDelUTF8(s, 2,-2);
+ r = bDelUTF8(s, 2,-2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "shpy");
// start = end
strcpy(s, "sheepy");
- bDelUTF8(s, 2,-4);
+ r = bDelUTF8(s, 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepy");
// delete entire string
strcpy(s, "sheepy");
- bDelUTF8(s, 0,0);
+ r = bDelUTF8(s, 0,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "");
// end of string
strcpy(s, "sheepy");
- bDelUTF8(s, 2,6);
+ r = bDelUTF8(s, 2,6);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
// start outside string
strcpy(s, "sheepy");
- bDelUTF8(s, 20,-4);
+ r = bDelUTF8(s, 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
- bDelUTF8(s, -20,-4);
+ r = bDelUTF8(s, -20,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
// end outside string
strcpy(s, "sheepy");
- bDelUTF8(s, 2,40);
+ r = bDelUTF8(s, 2,40);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
strcpy(s, "sheepy");
- bDelUTF8(s, 2,-40);
+ r = bDelUTF8(s, 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
// end before start
strcpy(s, "sheepy");
- bDelUTF8(s, 4,2);
+ r = bDelUTF8(s, 4,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
// NULL var
- ck_assert_ptr_eq(bDelUTF8(NULL, 4,2), NULL);
+ r = bDelUTF8(NULL, 4,2);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -11308,52 +12524,67 @@ END_TEST
START_TEST(bLDelUTF8T)
char s[100];
+ char *r = null;
+
// del
strcpy(s, "sheepy");
- bLDelUTF8(s, sizeof(s), 0,2);
+ r = bLDelUTF8(s, sizeof(s), 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "eepy");
// buffer shorter than string
strcpy(s, "sheepy");
- bLDelUTF8(s, 5, 0,2);
+ r = bLDelUTF8(s, 5, 0,2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "ee");
// negative index
strcpy(s, "sheepy");
- bLDelUTF8(s, sizeof(s), -2,0);
+ r = bLDelUTF8(s, sizeof(s), -2,0);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "shee");
// positive and negative indexes
strcpy(s, "sheepy");
- bLDelUTF8(s, sizeof(s), 2,-2);
+ r = bLDelUTF8(s, sizeof(s), 2,-2);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "shpy");
// start = end
strcpy(s, "sheepy");
- bLDelUTF8(s, sizeof(s), 2,-4);
+ r = bLDelUTF8(s, sizeof(s), 2,-4);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sheepy");
// end of string
strcpy(s, "sheepy");
- bLDelUTF8(s, sizeof(s), 2,6);
+ r = bLDelUTF8(s, sizeof(s), 2,6);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
// start outside string
strcpy(s, "sheepy");
- bLDelUTF8(s, sizeof(s), 20,-4);
+ r = bLDelUTF8(s, sizeof(s), 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
// end outside string
strcpy(s, "sheepy");
- bLDelUTF8(s, sizeof(s), 2,40);
+ r = bLDelUTF8(s, sizeof(s), 2,40);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "sh");
strcpy(s, "sheepy");
- bLDelUTF8(s, sizeof(s), -22,3);
+ r = bLDelUTF8(s, sizeof(s), -22,3);
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "epy");
strcpy(s, "sheepy");
- bLDelUTF8(s, sizeof(s), 2,-40);
+ r = bLDelUTF8(s, sizeof(s), 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
// end before start
strcpy(s, "sheepy");
- bLDelUTF8(s, sizeof(s), 4,2);
+ r = bLDelUTF8(s, sizeof(s), 4,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "sheepy");
// size 0
- ck_assert_ptr_eq(bLDelUTF8(s, 0, 0, 0), NULL);
+ r = bLDelUTF8(s, 0, 0, 0);
+ ck_assert_ptr_eq(r, null);
// NULL var
- ck_assert_ptr_eq(bLDelUTF8(NULL, sizeof(s), 0, 0), NULL);
+ r = bLDelUTF8(NULL, sizeof(s), 0, 0);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -11393,12 +12624,17 @@ START_TEST(icListSortUTF8T)
char **l = NULL;
char **l2;
+ char **r = null;
// list
- listPushS(&l, "1sdfdsf");
- listPushS(&l, "4444");
- listPushS(&l, "3");
- listPushS(&l, "22sdf");
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "3");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22sdf");
+ ck_assert_ptr_eq(r, l);
l2 = icListSortUTF8(l);
ck_assert_str_eq(l2[0], "1sdfdsf");
ck_assert_str_eq(l2[3], "4444");
@@ -11406,7 +12642,8 @@ START_TEST(icListSortUTF8T)
listFreeS(l2);
// one element list
l = NULL;
- listPushS(&l, "1sdfdsf");
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
l2 = icListSortUTF8(l);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "1sdfdsf");
@@ -11429,35 +12666,46 @@ END_TEST
START_TEST(iicListSortUTF8T)
char **l = NULL;
+ char **r = null;
// list
- listPushS(&l, "1sdfdsf");
- listPushS(&l, "4444");
- listPushS(&l, "3");
- listPushS(&l, "22sdf");
- iicListSortUTF8(&l);
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "3");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22sdf");
+ ck_assert_ptr_eq(r, l);
+ r = iicListSortUTF8(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "1sdfdsf");
ck_assert_str_eq(l[3], "4444");
listFreeS(l);
// one element list
l = NULL;
- listPushS(&l, "1sdfdsf");
- iicListSortUTF8(&l);
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = iicListSortUTF8(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),1);
ck_assert_str_eq(l[0], "1sdfdsf");
listFreeS(l);
// empty list
listEmptyS(l)
- iicListSortUTF8(&l);
+ r = iicListSortUTF8(&l);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),0);
ck_assert_ptr_eq(l[0], NULL);
listFreeS(l);
// NULL list
l = NULL;
- iicListSortUTF8(&l);
+ r = iicListSortUTF8(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iicListSortUTF8(NULL);
+ r = iicListSortUTF8(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -11467,12 +12715,17 @@ START_TEST(icListEqUTF8T)
char **l = NULL;
char **l2;
+ char **r = null;
// identical lists
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listDupS(l);
ck_assert(icListEqUTF8(l,l2));
// NULL lists
@@ -11496,12 +12749,17 @@ END_TEST
START_TEST(icListHasUTF8T)
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert(icListHasUTF8(l, "1"));
// NULL list
ck_assert(!icListHasUTF8(NULL, "1"));
@@ -11520,12 +12778,17 @@ END_TEST
START_TEST(icListIndexOfUTF8T)
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(icListIndexOfUTF8(l, "1"),0);
// NULL list
ck_assert_uint_eq(icListIndexOfUTF8(NULL, "1"),-1);
@@ -11544,14 +12807,21 @@ END_TEST
START_TEST(icListBinarySearchUTF8T)
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l, "5");
- listPushS(&l, "6");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "5");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "6");
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(icListBinarySearchUTF8(l, "1"),0);
// NULL list
ck_assert_uint_eq(icListBinarySearchUTF8(NULL, "1"),-1);
@@ -11571,12 +12841,17 @@ START_TEST(icListUniqUTF8T)
char **l = NULL;
char **l2;
+ char **r = null;
// list with unique elements
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = icListUniqUTF8(l);
ck_assert(listEqS(l,l2));
// list with identical elements
@@ -11591,7 +12866,8 @@ START_TEST(icListUniqUTF8T)
listFreeS(l2);
// list with one element
l = NULL;
- listPushS(&l, "1");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
l2 = icListUniqUTF8(l);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "1");
@@ -11615,14 +12891,20 @@ START_TEST(iicListUniqUTF8T)
char **l = NULL;
char **l2;
+ char **r = null;
// list with unique elements
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listDupS(l);
- iicListUniqUTF8(&l2);
+ r = iicListUniqUTF8(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert(listEqS(l,l2));
// list with identical elements
l[2][0] = '2';
@@ -11630,16 +12912,19 @@ START_TEST(iicListUniqUTF8T)
l[2][2] = 0;
listFreeS(l2);
l2 = listDupS(l);
- iicListUniqUTF8(&l2);
+ r = iicListUniqUTF8(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),3);
ck_assert_str_eq(l2[2], "4444");
listFreeS(l);
listFreeS(l2);
// list with one element
l = NULL;
- listPushS(&l, "1");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
l2 = listDupS(l);
- iicListUniqUTF8(&l2);
+ r = iicListUniqUTF8(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "1");
listFreeS(l);
@@ -11647,17 +12932,20 @@ START_TEST(iicListUniqUTF8T)
// empty list
listEmptyS(l)
l2 = listDupS(l);
- iicListUniqUTF8(&l2);
+ r = iicListUniqUTF8(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),0);
ck_assert_ptr_eq(l2[0], NULL);
listFreeS(l);
listFreeS(l2);
// NULL list
l = NULL;
- iicListUniqUTF8(&l);
+ r = iicListUniqUTF8(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iicListUniqUTF8(NULL);
+ r = iicListUniqUTF8(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -11678,19 +12966,23 @@ END_TEST
START_TEST(iEmptySFT)
char *s;
+ char *r = null;
// empty string
s = strdup("qwe");
- iEmptySF(&s);
+ r = iEmptySF(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert(isEmptyS(s));
free(s);
// NULL string
s = NULL;
- iEmptySF(&s);
+ r = iEmptySF(&s);
+ ck_assert_ptr_eq(r, s);
ck_assert(isEmptyS(s));
free(s);
// NULL var
- iEmptySF(NULL);
+ r = iEmptySF(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -11772,19 +13064,23 @@ END_TEST
START_TEST(iListEmptySFT)
char **l;
+ char **r = null;
// empty list
l = listCreateS("lib", "sheepy");
- iListEmptySF(&l);
+ r = iListEmptySF(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmptyS(l));
listFreeS(l);
// NULL list
l = NULL;
- iListEmptySF(&l);
+ r = iListEmptySF(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmptyS(l));
listFreeS(l);
// NULL var
- iListEmptySF(NULL);
+ r = iListEmptySF(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -11855,14 +13151,18 @@ START_TEST(listStrLengthST)
char **l = null;
ssize_t r;
+ char **r2 = null;
- listPushS(&l, "lib");
- listPushS(&l, "sheepy");
+ r2 = listPushS(&l, "lib");
+ ck_assert_ptr_eq(r2, l);
+ r2 = listPushS(&l, "sheepy");
+ ck_assert_ptr_eq(r2, l);
r = listStrLengthS(l);
ck_assert_int_eq(r, 9);
listFreeS(l);
// null list
- ck_assert_int_eq(listStrLengthS(null), -1);
+ r = listStrLengthS(null);
+ ck_assert_int_eq(r, -1);
END_TEST
@@ -11871,9 +13171,14 @@ START_TEST(listIntIndexST)
char **l = null;
ssize_t r;
- listPushS(&l, "lib");
- listPushS(&l, "sheepy");
- listPushS(&l, "sheepy");
+ char **r2 = null;
+
+ r2 = listPushS(&l, "lib");
+ ck_assert_ptr_eq(r2, l);
+ r2 = listPushS(&l, "sheepy");
+ ck_assert_ptr_eq(r2, l);
+ r2 = listPushS(&l, "sheepy");
+ ck_assert_ptr_eq(r2, l);
// positive index
r = listIntIndexS(l, 2);
ck_assert_int_eq(r, 2);
@@ -11903,9 +13208,13 @@ START_TEST(listAddrST)
char **l = null;
char **r;
- listPushS(&l, "lib");
- listPushS(&l, "sheepy");
- listPushS(&l, "sheepy");
+
+ r = listPushS(&l, "lib");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "sheepy");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "sheepy");
+ ck_assert_ptr_eq(r, l);
// positive index
r = listAddrS(l, 2);
ck_assert_ptr_eq(r, &l[2]);
@@ -11984,31 +13293,38 @@ END_TEST
START_TEST(listPushST)
char **l = NULL;
+ char **r = null;
// push strings and NULL list
- listPushS(&l, "sheepy");
+ r = listPushS(&l, "sheepy");
+ ck_assert_ptr_eq(r, l);
// check ck_assert_ptr_null not available in jessie
ck_assert_ptr_ne(l, NULL);
ck_assert_str_eq(l[0], "sheepy");
- listPushS(&l, "SHEEPY");
+ r = listPushS(&l, "SHEEPY");
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[1], "SHEEPY");
ck_assert_str_eq(l[0], "sheepy");
// push NULL
- listPushS(&l, NULL);
+ r = listPushS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l[2], NULL);
listFreeS(l);
// NULL list and NULL string
l = NULL;
- listPushS(&l, NULL);
+ r = listPushS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// empty list
listEmptyS(l)
- listPushS(&l, "sheepy");
+ r = listPushS(&l, "sheepy");
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "sheepy");
ck_assert_ptr_eq(l[1], NULL);
listFreeS(l);
// NULL pointer to list
- listPushS(NULL, NULL);
+ r = listPushS(NULL, NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -12016,24 +13332,29 @@ END_TEST
START_TEST(listPushCharST)
char **l = NULL;
+ char **r = null;
// push strings and NULL list
- listPushCharS(&l, 's');
+ r = listPushCharS(&l, 's');
+ ck_assert_ptr_eq(r, l);
// check ck_assert_ptr_null not available in jessie
ck_assert_ptr_ne(l, NULL);
ck_assert_str_eq(l[0], "s");
- listPushCharS(&l, 'S');
+ r = listPushCharS(&l, 'S');
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[1], "S");
ck_assert_str_eq(l[0], "s");
listFreeS(l);
// empty list
listEmptyS(l)
- listPushCharS(&l, 's');
+ r = listPushCharS(&l, 's');
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "s");
ck_assert_ptr_eq(l[1], NULL);
listFreeS(l);
// NULL pointer to list
- listPushCharS(NULL, 's');
+ r = listPushCharS(NULL, 's');
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -12043,34 +13364,41 @@ START_TEST(iListPushST)
char **l = NULL;
char *s;
+ char **r = null;
// push strings and NULL list
s = strdup("sheepy");
- iListPushS(&l, s);
+ r = iListPushS(&l, s);
+ ck_assert_ptr_eq(r, l);
// check ck_assert_ptr_null not available in jessie
ck_assert_ptr_ne(l, NULL);
ck_assert_str_eq(l[0], "sheepy");
s = strdup("SHEEPY");
- iListPushS(&l, s);
+ r = iListPushS(&l, s);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "sheepy");
ck_assert_str_eq(l[1], "SHEEPY");
// push NULL
- iListPushS(&l, NULL);
+ r = iListPushS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l[2], NULL);
listFreeS(l);
// NULL list and NULL string
l = NULL;
- iListPushS(&l, NULL);
+ r = iListPushS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// empty list
listEmptyS(l)
s = strdup("sheepy");
- iListPushS(&l, s);
+ r = iListPushS(&l, s);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "sheepy");
ck_assert_ptr_eq(l[1], NULL);
listFreeS(l);
// NULL pointer to list
- iListPushS(NULL, NULL);
+ r = iListPushS(NULL, NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -12079,10 +13407,13 @@ START_TEST(listPopST)
char **l = NULL;
char *s;
+ char **r = null;
// pop string
- listPushS(&l, "sheepy");
- listPushS(&l, "SHEEPY");
+ r = listPushS(&l, "sheepy");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "SHEEPY");
+ ck_assert_ptr_eq(r, l);
s = listPopS(&l);
ck_assert_str_eq(s, "SHEEPY");
ck_assert_uint_eq(listLengthS(l),1);
@@ -12107,31 +13438,38 @@ END_TEST
START_TEST(listPrependST)
char **l = NULL;
+ char **r = null;
// push strings and NULL list
- listPrependS(&l, "sheepy");
+ r = listPrependS(&l, "sheepy");
+ ck_assert_ptr_eq(r, l);
// check ck_assert_ptr_null not available in jessie
ck_assert_ptr_ne(l, NULL);
ck_assert_str_eq(l[0], "sheepy");
- listPrependS(&l, "SHEEPY");
+ r = listPrependS(&l, "SHEEPY");
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "SHEEPY");
ck_assert_str_eq(l[1], "sheepy");
// push NULL
- listPrependS(&l, NULL);
+ r = listPrependS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(l[0], "SHEEPY");
listFreeS(l);
// NULL list and NULL string`
l = NULL;
- listPrependS(&l, NULL);
+ r = listPrependS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// empty list
listEmptyS(l)
- listPrependS(&l, "sheepy");
+ r = listPrependS(&l, "sheepy");
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "sheepy");
ck_assert_ptr_eq(l[1], NULL);
listFreeS(l);
// NULL pointer to list
- listPrependS(NULL, NULL);
+ r = listPrependS(NULL, NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -12139,24 +13477,29 @@ END_TEST
START_TEST(listPrependCharST)
char **l = NULL;
+ char **r = null;
// push strings and NULL list
- listPrependCharS(&l, 's');
+ r = listPrependCharS(&l, 's');
+ ck_assert_ptr_eq(r, l);
// check ck_assert_ptr_null not available in jessie
ck_assert_ptr_ne(l, NULL);
ck_assert_str_eq(l[0], "s");
- listPrependCharS(&l, 'S');
+ r = listPrependCharS(&l, 'S');
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "S");
ck_assert_str_eq(l[1], "s");
listFreeS(l);
// empty list
listEmptyS(l)
- listPrependCharS(&l, 's');
+ r = listPrependCharS(&l, 's');
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "s");
ck_assert_ptr_eq(l[1], NULL);
listFreeS(l);
// NULL pointer to list
- listPrependCharS(NULL, 's');
+ r = listPrependCharS(NULL, 's');
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -12166,34 +13509,41 @@ START_TEST(iListPrependST)
char **l = NULL;
char *s;
+ char **r = null;
// prepend strings and NULL list
s = strdup("sheepy");
- iListPrependS(&l, s);
+ r = iListPrependS(&l, s);
+ ck_assert_ptr_eq(r, l);
// check ck_assert_ptr_null not available in jessie
ck_assert_ptr_ne(l, NULL);
ck_assert_str_eq(l[0], "sheepy");
s = strdup("SHEEPY");
- iListPrependS(&l, s);
+ r = iListPrependS(&l, s);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "SHEEPY");
ck_assert_str_eq(l[1], "sheepy");
// prepend NULL
- iListPrependS(&l, NULL);
+ r = iListPrependS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(l[0], "SHEEPY");
listFreeS(l);
// NULL list and NULL string
l = NULL;
- iListPrependS(&l, NULL);
+ r = iListPrependS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// empty list
listEmptyS(l)
s = strdup("sheepy");
- iListPrependS(&l, s);
+ r = iListPrependS(&l, s);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "sheepy");
ck_assert_ptr_eq(l[1], NULL);
listFreeS(l);
// NULL pointer to list
- iListPrependS(NULL, NULL);
+ r = iListPrependS(NULL, NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -12202,10 +13552,13 @@ START_TEST(listDequeueST)
char **l = NULL;
char *s;
+ char **r = null;
// dequeue string
- listPushS(&l, "sheepy");
- listPushS(&l, "SHEEPY");
+ r = listPushS(&l, "sheepy");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "SHEEPY");
+ ck_assert_ptr_eq(r, l);
s = listDequeueS(&l);
ck_assert_str_eq(s, "sheepy");
ck_assert_uint_eq(listLengthS(l),1);
@@ -12261,7 +13614,8 @@ START_TEST(listPrintST)
//listPrintS(l);
listFreeS(l);
// NULL list
- listPrintS(NULL);
+ int r = listPrintS(NULL);
+ ck_assert_int_eq(r, 0);
END_TEST
@@ -12270,15 +13624,22 @@ START_TEST(listForEachT)
char **l = NULL;
char **l2 = NULL;
+ char **r = null;
// for each element in list
- listPushS(&l, "1sdfdsf");
- listPushS(&l, "4444");
- listPushS(&l, "3");
- listPushS(&l, "22sdf");
- forEachCharP(l, i)
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "3");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22sdf");
+ ck_assert_ptr_eq(r, l);
+ forEachCharP(l, i) {
//printf(*i);
- listPushS(&l2, *i);
+ r = listPushS(&l2, *i);
+ ck_assert_ptr_eq(r, l2);
+ }
ck_assert_str_eq(l2[0], "1sdfdsf");
ck_assert_str_eq(l2[3], "22sdf");
listFreeS(l);
@@ -12291,14 +13652,20 @@ START_TEST(listEnumerateT)
char **l = NULL;
char **l2 = NULL;
+ char **r = null;
// enumerateCharP elements
- listPushS(&l, "1sdfdsf");
- listPushS(&l, "4444");
- listPushS(&l, "3");
- listPushS(&l, "22sdf");
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "3");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22sdf");
+ ck_assert_ptr_eq(r, l);
enumerateCharP(l, i, j) {
- listPushS(&l2, *i);
+ r = listPushS(&l2, *i);
+ ck_assert_ptr_eq(r, l2);
}
ck_assert_uint_eq(j, 4);
ck_assert_str_eq(l2[0], "1sdfdsf");
@@ -12313,12 +13680,17 @@ START_TEST(listSortST)
char **l = NULL;
char **l2;
+ char **r = null;
// list
- listPushS(&l, "1sdfdsf");
- listPushS(&l, "4444");
- listPushS(&l, "3");
- listPushS(&l, "22sdf");
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "3");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22sdf");
+ ck_assert_ptr_eq(r, l);
l2 = listSortS(l);
ck_assert_str_eq(l2[0], "1sdfdsf");
ck_assert_str_eq(l2[3], "4444");
@@ -12326,7 +13698,8 @@ START_TEST(listSortST)
listFreeS(l2);
// one element list
l = NULL;
- listPushS(&l, "1sdfdsf");
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
l2 = listSortS(l);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "1sdfdsf");
@@ -12348,35 +13721,46 @@ END_TEST
START_TEST(iListSortST)
char **l = NULL;
+ char **r = null;
// list
- listPushS(&l, "1sdfdsf");
- listPushS(&l, "4444");
- listPushS(&l, "3");
- listPushS(&l, "22sdf");
- iListSortS(&l);
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "3");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22sdf");
+ ck_assert_ptr_eq(r, l);
+ r = iListSortS(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "1sdfdsf");
ck_assert_str_eq(l[3], "4444");
listFreeS(l);
// one element list
l = NULL;
- listPushS(&l, "1sdfdsf");
- iListSortS(&l);
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = iListSortS(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),1);
ck_assert_str_eq(l[0], "1sdfdsf");
listFreeS(l);
// empty list
listEmptyS(l)
- iListSortS(&l);
+ r = iListSortS(&l);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),0);
ck_assert_ptr_eq(l[0], NULL);
listFreeS(l);
// NULL list
l = NULL;
- iListSortS(&l);
+ r = iListSortS(&l);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iListSortS(NULL);
+ r = iListSortS(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -12408,12 +13792,17 @@ START_TEST(listSortFST)
char **l = NULL;
char **l2;
+ char **r = null;
// list
- listPushS(&l, "1sdfdsf");
- listPushS(&l, "4444");
- listPushS(&l, "3");
- listPushS(&l, "22sdf");
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "3");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22sdf");
+ ck_assert_ptr_eq(r, l);
l2 = listSortFS(l, listSortSCmp);
ck_assert_str_eq(l2[0], "1sdfdsf");
ck_assert_str_eq(l2[3], "4444");
@@ -12421,7 +13810,8 @@ START_TEST(listSortFST)
listFreeS(l2);
// one element list
l = NULL;
- listPushS(&l, "1sdfdsf");
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
l2 = listSortFS(l, listSortSCmp);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "1sdfdsf");
@@ -12446,37 +13836,49 @@ END_TEST
START_TEST(iListSortFST)
char **l = NULL;
+ char **r = null;
// list
- listPushS(&l, "1sdfdsf");
- listPushS(&l, "4444");
- listPushS(&l, "3");
- listPushS(&l, "22sdf");
- iListSortFS(&l, listSortSCmp);
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "3");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22sdf");
+ ck_assert_ptr_eq(r, l);
+ r = iListSortFS(&l, listSortSCmp);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "1sdfdsf");
ck_assert_str_eq(l[3], "4444");
listFreeS(l);
// one element list
l = NULL;
- listPushS(&l, "1sdfdsf");
- iListSortFS(&l, listSortSCmp);
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = iListSortFS(&l, listSortSCmp);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),1);
ck_assert_str_eq(l[0], "1sdfdsf");
listFreeS(l);
// empty list
listEmptyS(l)
- iListSortFS(&l, listSortSCmp);
+ r = iListSortFS(&l, listSortSCmp);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),0);
ck_assert_ptr_eq(l[0], NULL);
// NULL compare function
- ck_assert_ptr_eq(iListSortFS(&l, null), null);
+ r = iListSortFS(&l, null);
+ ck_assert_ptr_eq(r, null);
listFreeS(l);
// NULL list
l = NULL;
- iListSortFS(&l, listSortSCmp);
+ r = iListSortFS(&l, listSortSCmp);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iListSortFS(NULL, listSortSCmp);
+ r = iListSortFS(NULL, listSortSCmp);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -12486,12 +13888,17 @@ START_TEST(icListSortST)
char **l = NULL;
char **l2;
+ char **r = null;
// list
- listPushS(&l, "A1sdfdsf");
- listPushS(&l, "d4444");
- listPushS(&l, "c3");
- listPushS(&l, "B22sdf");
+ r = listPushS(&l, "A1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "d4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "c3");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "B22sdf");
+ ck_assert_ptr_eq(r, l);
l2 = icListSortS(l);
ck_assert_str_eq(l2[0], "A1sdfdsf");
ck_assert_str_eq(l2[3], "d4444");
@@ -12499,7 +13906,8 @@ START_TEST(icListSortST)
listFreeS(l2);
// one element list
l = NULL;
- listPushS(&l, "1sdfdsf");
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
l2 = icListSortS(l);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "1sdfdsf");
@@ -12522,35 +13930,46 @@ END_TEST
START_TEST(iicListSortST)
char **l = NULL;
+ char **r = null;
// list
- listPushS(&l, "a1sdfdsf");
- listPushS(&l, "D4444");
- listPushS(&l, "B3");
- listPushS(&l, "c22sdf");
- iicListSortS(&l);
+ r = listPushS(&l, "a1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "D4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "B3");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "c22sdf");
+ ck_assert_ptr_eq(r, l);
+ r = iicListSortS(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "a1sdfdsf");
ck_assert_str_eq(l[3], "D4444");
listFreeS(l);
// one element list
l = NULL;
- listPushS(&l, "1sdfdsf");
- iicListSortS(&l);
+ r = listPushS(&l, "1sdfdsf");
+ ck_assert_ptr_eq(r, l);
+ r = iicListSortS(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),1);
ck_assert_str_eq(l[0], "1sdfdsf");
listFreeS(l);
// empty list
listEmptyS(l)
- iicListSortS(&l);
+ r = iicListSortS(&l);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),0);
ck_assert_ptr_eq(l[0], NULL);
listFreeS(l);
// NULL list
l = NULL;
- iicListSortS(&l);
+ r = iicListSortS(&l);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iicListSortS(NULL);
+ r = iicListSortS(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -12574,8 +13993,10 @@ START_TEST(readTextT)
// NULL path
ck_assert_ptr_eq(readText(NULL), NULL);
// non existing path
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
ck_assert_ptr_eq(readText("nonExistingFile"), NULL);
END_TEST
@@ -12625,11 +14046,15 @@ START_TEST(writeTextT)
ck_assert_str_eq(l[1], "ANOTHER line");
// non existing file
// make sure the file doesnt exist
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
ck_assert(writeText("nonExistingFile",l));
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
// NULL path
ck_assert(!writeText(NULL,l));
listFreeS(l);
@@ -12693,11 +14118,15 @@ START_TEST(appendTextT)
ck_assert_str_eq(l[3], "B");
// non existing file
// make sure the file doesnt exist
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
ck_assert(appendText("nonExistingFile",l));
- if (fileExists("nonExistingFile"))
- rmAll("nonExistingFile");
+ if (fileExists("nonExistingFile")) {
+ int R = rmAll("nonExistingFile");
+ ck_assert_int_ne(R, 0);
+ }
// NULL path
ck_assert(!appendText(NULL,l));
listFreeS(l);
@@ -12710,12 +14139,17 @@ END_TEST
START_TEST(listGetST)
char **l = NULL;
+ char **r = null;
// get string
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
char *s = listGetS(l, 0);
ck_assert_str_eq(s, "1");
free(s);
@@ -12729,8 +14163,10 @@ START_TEST(listGetST)
listFreeS(l);
// negative index in a one element list
l = NULL;
- listPushS(&l, "ASD");
- listPushS(&l, NULL);
+ r = listPushS(&l, "ASD");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
s = listGetS(l,-1);
ck_assert_ptr_ne(s, NULL);
free(s);
@@ -12748,12 +14184,17 @@ END_TEST
START_TEST(iListGetST)
char **l = NULL;
+ char **r = null;
// get string
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(iListGetS(l, 0), "1");
// negative index
ck_assert_str_eq(iListGetS(l, -1), "4444");
@@ -12763,8 +14204,10 @@ START_TEST(iListGetST)
listFreeS(l);
// negative index in a one element list
l = NULL;
- listPushS(&l, "ASD");
- listPushS(&l, NULL);
+ r = listPushS(&l, "ASD");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_ne(iListGetS(l,-1), NULL);
listFreeS(l);
// empty list
@@ -12780,27 +14223,37 @@ END_TEST
START_TEST(listSetST)
char **l = NULL;
+ char **r = null;
// get string
- listPushS(&l, "@@");
- listPushS(&l, "22");
- listPushS(&l, "|");
- listPushS(&l, "4444");
- listSetS(l, 0, "1");
+ r = listPushS(&l, "@@");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "|");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listSetS(l, 0, "1");
+ ck_assert_ptr_eq(r, l);
char *s = listGetS(l, 0);
ck_assert_str_eq(s, "1");
free(s);
// negative index
- listSetS(l, -2, "333");
+ r = listSetS(l, -2, "333");
+ ck_assert_ptr_eq(r, l);
s = listGetS(l, -2);
ck_assert_str_eq(s, "333");
free(s);
// outside list
// list is unchanged
- listSetS(l, 10, "QWE");
- listSetS(l, -10, "QWE");
+ r = listSetS(l, 10, "QWE");
+ ck_assert_ptr_eq(r, null);
+ r = listSetS(l, -10, "QWE");
+ ck_assert_ptr_eq(r, null);
// NULL s string
- listSetS(l, -2, NULL);
+ r = listSetS(l, -2, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
ck_assert_str_eq(l[2], "333");
@@ -12808,20 +14261,25 @@ START_TEST(listSetST)
listFreeS(l);
// negative index in a one element list
l = NULL;
- listPushS(&l, "ASD");
- listPushS(&l, NULL);
- listSetS(l, -1, "QWE");
+ r = listPushS(&l, "ASD");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
+ r = listSetS(l, -1, "QWE");
+ ck_assert_ptr_eq(r, l);
s = listGetS(l,-1);
ck_assert_str_eq(s, "QWE");
free(s);
listFreeS(l);
// empty list - should not crash
listEmptyS(l)
- listSetS(l, 0, "QWE");
+ r = listSetS(l, 0, "QWE");
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(listGetS(l,0),NULL);
free(l);
// NULL list
- listSetS(NULL, 0, "QWE");
+ r = listSetS(NULL, 0, "QWE");
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(listGetS(NULL, 0), NULL);
END_TEST
@@ -12830,25 +14288,34 @@ END_TEST
START_TEST(listSetCharST)
char **l = NULL;
+ char **r = null;
// get string
- listPushS(&l, "@@");
- listPushS(&l, "22");
- listPushS(&l, "|");
- listPushS(&l, "4444");
- listSetCharS(l, 0, '1');
+ r = listPushS(&l, "@@");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "|");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listSetCharS(l, 0, '1');
+ ck_assert_ptr_eq(r, l);
char *s = listGetS(l, 0);
ck_assert_str_eq(s, "1");
free(s);
// negative index
- listSetCharS(l, -2, '3');
+ r = listSetCharS(l, -2, '3');
+ ck_assert_ptr_eq(r, l);
s = listGetS(l, -2);
ck_assert_str_eq(s, "3");
free(s);
// outside list
// list is unchanged
- listSetCharS(l, 10, 'Q');
- listSetCharS(l, -10, 'Q');
+ r = listSetCharS(l, 10, 'Q');
+ ck_assert_ptr_eq(r, null);
+ r = listSetCharS(l, -10, 'Q');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
ck_assert_str_eq(l[2], "3");
@@ -12856,20 +14323,25 @@ START_TEST(listSetCharST)
listFreeS(l);
// negative index in a one element list
l = NULL;
- listPushS(&l, "ASD");
- listPushS(&l, NULL);
- listSetCharS(l, -1, 'Q');
+ r = listPushS(&l, "ASD");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
+ r = listSetCharS(l, -1, 'Q');
+ ck_assert_ptr_eq(r, l);
s = listGetS(l,-1);
ck_assert_str_eq(s, "Q");
free(s);
listFreeS(l);
// empty list - should not crash
listEmptyS(l)
- listSetCharS(l, 0, 'Q');
+ r = listSetCharS(l, 0, 'Q');
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(listGetS(l,0),NULL);
free(l);
// NULL list
- listSetCharS(NULL, 0, 'Q');
+ r = listSetCharS(NULL, 0, 'Q');
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(listGetS(NULL, 0), NULL);
@@ -12880,30 +14352,41 @@ START_TEST(iListSetST)
char **l = NULL;
char *s;
+ char **r = null;
// set string
- listPushS(&l, "@@");
- listPushS(&l, "22");
- listPushS(&l, "|");
- listPushS(&l, "4444");
+ r = listPushS(&l, "@@");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "|");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
s = strdup("1");
- iListSetS(l, 0, s);
+ r = iListSetS(l, 0, s);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(iListGetS(l, 0), "1");
// negative index
s = strdup("333");
- iListSetS(l, -2, s);
+ r = iListSetS(l, -2, s);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(iListGetS(l, -2), "333");
// outside list
// list is unchanged
s = strdup("QWE");
- iListSetS(l, 10, s);
- iListSetS(l, -10, s);
+ r = iListSetS(l, 10, s);
+ ck_assert_ptr_eq(r, null);
+ r = iListSetS(l, -10, s);
+ ck_assert_ptr_eq(r, null);
free(s);
// NULL s string
s = NULL;
- iListSetS(l, -2, s);
+ r = iListSetS(l, -2, s);
+ ck_assert_ptr_eq(r, null);
// NULL s var
- iListSetS(l, -2, NULL);
+ r = iListSetS(l, -2, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
ck_assert_str_eq(l[2], "333");
@@ -12911,22 +14394,27 @@ START_TEST(iListSetST)
listFreeS(l);
// negative index in a one element list
l = NULL;
- listPushS(&l, "ASD");
- listPushS(&l, NULL);
+ r = listPushS(&l, "ASD");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
s = strdup("QWE");
- iListSetS(l, -1, s);
+ r = iListSetS(l, -1, s);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(iListGetS(l,-1), "QWE");
listFreeS(l);
// empty list - should not crash
listEmptyS(l)
s = strdup("QWE");
- iListSetS(l, 0, s);
+ r = iListSetS(l, 0, s);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(listGetS(l,0),NULL);
free(s);
free(l);
// NULL list
s = strdup("QWE");
- iListSetS(NULL, 0, s);
+ r = iListSetS(NULL, 0, s);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(listGetS(NULL, 0), NULL);
free(s);
@@ -12937,9 +14425,13 @@ START_TEST(listSwapST)
char **l = null;
char **r;
- listPushS(&l, "lib");
- listPushS(&l, "sheepy");
- listPushS(&l, "spm");
+
+ r = listPushS(&l, "lib");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "sheepy");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "spm");
+ ck_assert_ptr_eq(r, l);
// positive index
r = listSwapS(l, 0, 2);
ck_assert_str_eq(r[0], "spm");
@@ -12993,9 +14485,13 @@ START_TEST(iListSwapST)
char **l = null;
char **r;
- listPushS(&l, "lib");
- listPushS(&l, "sheepy");
- listPushS(&l, "spm");
+
+ r = listPushS(&l, "lib");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "sheepy");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "spm");
+ ck_assert_ptr_eq(r, l);
// positive index
r = iListSwapS(l, 0, 2);
ck_assert_str_eq(r[0], "spm");
@@ -13279,6 +14775,7 @@ START_TEST(joinT)
char **l;
char *s;
+ char **r = null;
// list
l = split("one/two", "/");
@@ -13298,7 +14795,8 @@ START_TEST(joinT)
ck_assert_ptr_eq(join(NULL, ";"), NULL);
// list with NULL first element
l = NULL;
- listPushS(&l, NULL);
+ r = listPushS(&l, NULL);
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(join(l, "/"), NULL);
listFreeS(l);
@@ -13333,25 +14831,33 @@ START_TEST(bJoinT)
char **l;
char s[100];
+ char **r = null;
+ char *r2 = null;
// list
l = split("one/two", "/");
- bJoin(s, l, "/");
+ r2 = bJoin(s, l, "/");
+ ck_assert_ptr_eq(r2, s);
ck_assert_str_eq(s, "one/two");
// NULL delimiter
- ck_assert_ptr_eq(bJoin(s, l, NULL), NULL);
+ r2 = bJoin(s, l, NULL);
+ ck_assert_ptr_eq(r2, null);
listFreeS(l);
// empty list
listEmptyS(l)
- ck_assert_ptr_eq(bJoin(s, l, "/"), NULL);
+ r2 = bJoin(s, l, "/");
+ ck_assert_ptr_eq(r2, null);
ck_assert_str_eq(s, "one/two");
listFreeS(l);
// NULL list
- ck_assert_ptr_eq(bJoin(s, NULL, ";"), NULL);
+ r2 = bJoin(s, NULL, ";");
+ ck_assert_ptr_eq(r2, null);
// list with NULL first element
l = NULL;
- listPushS(&l, NULL);
- ck_assert_ptr_eq(bJoin(s, l, "/"), NULL);
+ r = listPushS(&l, NULL);
+ ck_assert_ptr_eq(r, l);
+ r2 = bJoin(s, l, "/");
+ ck_assert_ptr_eq(r2, null);
listFreeS(l);
END_TEST
@@ -13361,19 +14867,23 @@ START_TEST(bJoinCharT)
char **l;
char s[100];
+ char *r = null;
// list
l = split("one/two", "/");
- bJoinChar(s, l, '/');
+ r = bJoinChar(s, l, '/');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "one/two");
listFreeS(l);
// empty list
listEmptyS(l)
- ck_assert_ptr_eq(bJoinChar(s, l, '/'), NULL);
+ r = bJoinChar(s, l, '/');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "one/two");
listFreeS(l);
// NULL list
- ck_assert_ptr_eq(bJoinChar(s, NULL, ';'), NULL);
+ r = bJoinChar(s, NULL, ';');
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -13383,32 +14893,41 @@ START_TEST(bLJoinT)
char **l;
char s[100];
+ char **r = null;
+ char *r2 = null;
// list
l = split("one/two", "/");
- bLJoin(s, sizeof s, l, "/");
+ r2 = bLJoin(s, sizeof s, l, "/");
+ ck_assert_ptr_eq(r2, s);
ck_assert_str_eq(s, "one/two");
// shorter buffer
- bLJoin(s, 5, l, "/");
+ r2 = bLJoin(s, 5, l, "/");
+ ck_assert_ptr_eq(r2, s);
ck_assert_str_eq(s, "one/");
// size 0 - no change
- bLJoin(s, 0, l, "/");
+ r2 = bLJoin(s, 0, l, "/");
+ ck_assert_ptr_eq(r2, s);
ck_assert_str_eq(s, "one/");
// NULL delimiter
- ck_assert_ptr_eq(bLJoin(s, sizeof s, l, NULL), NULL);
+ r2 = bLJoin(s, sizeof s, l, NULL);
+ ck_assert_ptr_eq(r2, null);
listFreeS(l);
// empty list
listEmptyS(l)
- bLJoin(s, sizeof s, l, "/");
- ck_assert_ptr_eq(bLJoin(s, sizeof s, l, "/"), NULL);
+ r2 = bLJoin(s, sizeof s, l, "/");
+ ck_assert_ptr_eq(r2, null);
ck_assert_str_eq(s, "one/");
listFreeS(l);
// NULL list
- ck_assert_ptr_eq(bLJoin(s, sizeof s, NULL, ";"), NULL);
+ r2 = bLJoin(s, sizeof s, NULL, ";");
+ ck_assert_ptr_eq(r2, null);
// list with NULL first element
l = NULL;
- listPushS(&l, NULL);
- ck_assert_ptr_eq(bLJoin(s, sizeof s, l, "/"), NULL);
+ r = listPushS(&l, NULL);
+ ck_assert_ptr_eq(r, l);
+ r2 = bLJoin(s, sizeof s, l, "/");
+ ck_assert_ptr_eq(r2, null);
listFreeS(l);
END_TEST
@@ -13418,25 +14937,31 @@ START_TEST(bLJoinCharT)
char **l;
char s[100];
+ char *r = null;
// list
l = split("one/two", "/");
- bLJoinChar(s, sizeof s, l, '/');
+ r = bLJoinChar(s, sizeof s, l, '/');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "one/two");
// shorter buffer
- bLJoinChar(s, 5, l, '/');
+ r = bLJoinChar(s, 5, l, '/');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "one/");
// size 0 - no change
- bLJoinChar(s, 0, l, '/');
+ r = bLJoinChar(s, 0, l, '/');
+ ck_assert_ptr_eq(r, s);
ck_assert_str_eq(s, "one/");
listFreeS(l);
// empty list
listEmptyS(l)
- ck_assert_ptr_eq(bLJoinChar(s, sizeof s, l, '/'), NULL);
+ r = bLJoinChar(s, sizeof s, l, '/');
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(s, "one/");
listFreeS(l);
// NULL list
- ck_assert_ptr_eq(bLJoinChar(s, sizeof s, NULL, ';'), NULL);
+ r = bLJoinChar(s, sizeof s, NULL, ';');
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -13743,12 +15268,17 @@ START_TEST(listDupST)
char **l = NULL;
char **l2;
+ char **r = null;
// list
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listDupS(l);
ck_assert_uint_eq(listLengthS(l2),4);
ck_assert_str_eq(l2[0], "1");
@@ -13771,12 +15301,17 @@ START_TEST(iListDupST)
char **l = NULL;
char **l2;
+ char **r = null;
// list
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = iListDupS(l);
ck_assert_uint_eq(listLengthS(l2),4);
ck_assert_str_eq(l2[0], "1");
@@ -13799,12 +15334,17 @@ START_TEST(listReverseST)
char **l = NULL;
char **l2;
+ char **r = null;
// list
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listReverseS(l);
ck_assert_uint_eq(listLengthS(l2),4);
ck_assert_str_eq(l2[0], "4444");
@@ -13826,28 +15366,37 @@ END_TEST
START_TEST(iListReverseST)
char **l = NULL;
+ char **r = null;
// list
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- iListReverseS(&l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = iListReverseS(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "4444");
ck_assert_str_eq(l[3], "1");
listFreeS(l);
// empty list
listEmptyS(l)
- iListReverseS(&l);
+ r = iListReverseS(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmptyS(l));
listFreeS(l);
// NULL list
l = NULL;
- iListReverseS(&l);
+ r = iListReverseS(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iListReverseS(NULL);
+ r = iListReverseS(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -13887,17 +15436,27 @@ START_TEST(listAppendST)
char **l = NULL;
char **l2 = NULL;
+ char **r = null;
// lists
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- listAppendS(&l2,l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = listAppendS(&l2,l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
@@ -13905,11 +15464,16 @@ START_TEST(listAppendST)
ck_assert_str_eq(l2[7],"4444");
listFreeS(l);
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listAppendS(&l,l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listAppendS(&l,l);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),8);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
@@ -13918,12 +15482,14 @@ START_TEST(listAppendST)
listFreeS(l);
// empty list + list
listEmptyS(l)
- listAppendS(&l, l2);
+ r = listAppendS(&l, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listEqS(l,l2));
listFreeS(l);
// list + empty list
listEmptyS(l)
- listAppendS(&l2, l);
+ r = listAppendS(&l2, l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
@@ -13932,16 +15498,19 @@ START_TEST(listAppendST)
listFreeS(l);
// empty list + empty list
listEmptyS(l)
- listAppendS(&l, l);
+ r = listAppendS(&l, l);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmptyS(l));
listFreeS(l);
// NULL list + list = duplicate
l = NULL;
- listAppendS(&l,l2);
+ r = listAppendS(&l,l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listEqS(l,l2));
listFreeS(l);
// list + NULL list
- listAppendS(&l2, NULL);
+ r = listAppendS(&l2, NULL);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
@@ -13949,7 +15518,8 @@ START_TEST(listAppendST)
ck_assert_str_eq(l2[7],"4444");
listFreeS(l2);
// NULL list pointer
- listAppendS(NULL,l2);
+ r = listAppendS(NULL,l2);
+ ck_assert_ptr_eq(r, null);
// should not crash
END_TEST
@@ -13957,19 +15527,29 @@ END_TEST
START_TEST(iListAppendST)
- char **l = NULL;
+ char **l = NULL;
char **l2 = NULL;
+ char **r = null;
// lists
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- iListAppendS(&l2,l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = iListAppendS(&l2,l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
@@ -13977,33 +15557,48 @@ START_TEST(iListAppendST)
ck_assert_str_eq(l2[7],"4444");
free(l);
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- iListAppendS(&l,l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = iListAppendS(&l,l);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
listFreeS(l);
// empty list + list
listEmptyS(l)
- iListAppendS(&l, l2);
+ r = iListAppendS(&l, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listEqS(l,l2));
free(l2);
listFreeS(l);
// list + empty list
l2 = NULL;
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- listPushS(&l2, "1");
- listPushS(&l2, "22");
- listPushS(&l2, "333");
- listPushS(&l2, "4444");
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "1");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "22");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "333");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "4444");
+ ck_assert_ptr_eq(r, l2);
listEmptyS(l)
- iListAppendS(&l2, l);
+ r = iListAppendS(&l2, l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
@@ -14014,28 +15609,36 @@ START_TEST(iListAppendST)
// empty list + empty list
listEmptyS(l);
listEmptyS(l2);
- iListAppendS(&l, l2);
+ r = iListAppendS(&l, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmptyS(l));
listFreeS(l);
listFreeS(l2);
// NULL list + list = duplicate
l = NULL;
l2 = NULL;
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- iListAppendS(&l,l2);
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = iListAppendS(&l,l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listEqS(l,l2));
free(l);
// list + NULL list
- iListAppendS(&l2, NULL);
+ r = iListAppendS(&l2, NULL);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),4);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
listFreeS(l2);
// NULL list pointer
- iListAppendS(NULL,l2);
+ r = iListAppendS(NULL,l2);
+ ck_assert_ptr_eq(r, null);
// should not crash
END_TEST
@@ -14043,37 +15646,53 @@ END_TEST
START_TEST(iListAppendNSmashST)
- char **l = NULL;
+ char **l = NULL;
char **l2 = NULL;
+ char **r = null;
// lists
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- iListAppendNSmashS(&l2,l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = iListAppendNSmashS(&l2,l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
ck_assert_str_eq(l2[4],"1");
ck_assert_str_eq(l2[7],"4444");
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- iListAppendNSmashS(&l,l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = iListAppendNSmashS(&l,l);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
listFreeS(l);
// empty list + list
listEmptyS(l)
- iListAppendNSmashS(&l, l2);
+ r = iListAppendNSmashS(&l, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "A");
ck_assert_str_eq(l[3], "DDDD");
ck_assert_str_eq(l[4],"1");
@@ -14081,16 +15700,25 @@ START_TEST(iListAppendNSmashST)
listFreeS(l);
// list + empty list
l2 = NULL;
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- listPushS(&l2, "1");
- listPushS(&l2, "22");
- listPushS(&l2, "333");
- listPushS(&l2, "4444");
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "1");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "22");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "333");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "4444");
+ ck_assert_ptr_eq(r, l2);
listEmptyS(l)
- iListAppendNSmashS(&l2, l);
+ r = iListAppendNSmashS(&l2, l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
@@ -14100,29 +15728,37 @@ START_TEST(iListAppendNSmashST)
// empty list + empty list
listEmptyS(l);
listEmptyS(l2);
- iListAppendNSmashS(&l, l2);
+ r = iListAppendNSmashS(&l, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmptyS(l));
listFreeS(l);
// NULL list + list = duplicate
l = NULL;
l2 = NULL;
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- iListAppendNSmashS(&l,l2);
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = iListAppendNSmashS(&l,l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "A");
ck_assert_str_eq(l[1], "BB");
ck_assert_str_eq(l[2], "CCC");
ck_assert_str_eq(l[3], "DDDD");
// list + NULL list
- iListAppendNSmashS(&l, NULL);
+ r = iListAppendNSmashS(&l, NULL);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "A");
ck_assert_str_eq(l[3], "DDDD");
listFreeS(l);
// NULL list pointer
- iListAppendNSmashS(NULL,l);
+ r = iListAppendNSmashS(NULL,l);
+ ck_assert_ptr_eq(r, null);
// should not crash
END_TEST
@@ -14132,17 +15768,27 @@ START_TEST(listShiftST)
char **l = NULL;
char **l2 = NULL;
+ char **r = null;
// lists
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- listShiftS(&l2,l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = listShiftS(&l2,l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[4], "A");
ck_assert_str_eq(l2[7], "DDDD");
@@ -14150,11 +15796,16 @@ START_TEST(listShiftST)
ck_assert_str_eq(l2[3],"4444");
listFreeS(l);
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listShiftS(&l,l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listShiftS(&l,l);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),8);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
@@ -14163,12 +15814,14 @@ START_TEST(listShiftST)
listFreeS(l);
// empty list + list
listEmptyS(l)
- listShiftS(&l, l2);
+ r = listShiftS(&l, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listEqS(l,l2));
listFreeS(l);
// list + empty list
listEmptyS(l)
- listShiftS(&l2, l);
+ r = listShiftS(&l2, l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[4], "A");
ck_assert_str_eq(l2[7], "DDDD");
@@ -14177,16 +15830,19 @@ START_TEST(listShiftST)
listFreeS(l);
// empty list + empty list
listEmptyS(l)
- listShiftS(&l, l);
+ r = listShiftS(&l, l);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmptyS(l));
listFreeS(l);
// NULL list + list = duplicate
l = NULL;
- listShiftS(&l,l2);
+ r = listShiftS(&l,l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listEqS(l,l2));
listFreeS(l);
// list + NULL list
- listShiftS(&l2, NULL);
+ r = listShiftS(&l2, NULL);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[4], "A");
ck_assert_str_eq(l2[7], "DDDD");
@@ -14194,7 +15850,8 @@ START_TEST(listShiftST)
ck_assert_str_eq(l2[3],"4444");
listFreeS(l2);
// NULL list pointer
- listShiftS(NULL,l2);
+ r = listShiftS(NULL,l2);
+ ck_assert_ptr_eq(r, null);
// should not crash
@@ -14205,17 +15862,27 @@ START_TEST(iListShiftST)
char **l = NULL;
char **l2 = NULL;
+ char **r = null;
// lists
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- iListShiftS(&l2,l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = iListShiftS(&l2,l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[4], "A");
ck_assert_str_eq(l2[7], "DDDD");
@@ -14223,33 +15890,48 @@ START_TEST(iListShiftST)
ck_assert_str_eq(l2[3],"4444");
free(l);
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- iListShiftS(&l,l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = iListShiftS(&l,l);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
listFreeS(l);
// empty list + list
listEmptyS(l)
- iListShiftS(&l, l2);
+ r = iListShiftS(&l, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listEqS(l,l2));
free(l2);
listFreeS(l);
// list + empty list
l2 = NULL;
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- listPushS(&l2, "1");
- listPushS(&l2, "22");
- listPushS(&l2, "333");
- listPushS(&l2, "4444");
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "1");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "22");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "333");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "4444");
+ ck_assert_ptr_eq(r, l2);
listEmptyS(l)
- iListShiftS(&l2, l);
+ r = iListShiftS(&l2, l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
@@ -14260,28 +15942,36 @@ START_TEST(iListShiftST)
// empty list + empty list
listEmptyS(l);
listEmptyS(l2);
- iListShiftS(&l, l2);
+ r = iListShiftS(&l, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmptyS(l));
listFreeS(l);
listFreeS(l2);
// NULL list + list = duplicate
l = NULL;
l2 = NULL;
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- iListShiftS(&l,l2);
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = iListShiftS(&l,l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listEqS(l,l2));
free(l);
// list + NULL list
- iListShiftS(&l2, NULL);
+ r = iListShiftS(&l2, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l2),4);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
listFreeS(l2);
// NULL list pointer
- iListShiftS(NULL,l2);
+ r = iListShiftS(NULL,l2);
+ ck_assert_ptr_eq(r, null);
// should not crash
@@ -14290,37 +15980,53 @@ END_TEST
START_TEST(iListShiftNSmashST)
- char **l = NULL;
+ char **l = NULL;
char **l2 = NULL;
+ char **r = null;
// lists
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- iListShiftNSmashS(&l2,l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = iListShiftNSmashS(&l2,l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[4], "A");
ck_assert_str_eq(l2[7], "DDDD");
ck_assert_str_eq(l2[0],"1");
ck_assert_str_eq(l2[3],"4444");
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- iListShiftNSmashS(&l,l);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = iListShiftNSmashS(&l,l);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
listFreeS(l);
// empty list + list
listEmptyS(l)
- iListShiftNSmashS(&l, l2);
+ r = iListShiftNSmashS(&l, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[4], "A");
ck_assert_str_eq(l[7], "DDDD");
ck_assert_str_eq(l[0],"1");
@@ -14328,16 +16034,25 @@ START_TEST(iListShiftNSmashST)
listFreeS(l);
// list + empty list
l2 = NULL;
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- listPushS(&l2, "1");
- listPushS(&l2, "22");
- listPushS(&l2, "333");
- listPushS(&l2, "4444");
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "1");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "22");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "333");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "4444");
+ ck_assert_ptr_eq(r, l2);
listEmptyS(l)
- iListShiftNSmashS(&l2, l);
+ r = iListShiftNSmashS(&l2, l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),8);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
@@ -14347,29 +16062,37 @@ START_TEST(iListShiftNSmashST)
// empty list + empty list
listEmptyS(l);
listEmptyS(l2);
- iListShiftNSmashS(&l, l2);
+ r = iListShiftNSmashS(&l, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmptyS(l));
listFreeS(l);
// NULL list + list = duplicate
l = NULL;
l2 = NULL;
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
- iListShiftNSmashS(&l,l2);
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
+ r = iListShiftNSmashS(&l,l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "A");
ck_assert_str_eq(l[1], "BB");
ck_assert_str_eq(l[2], "CCC");
ck_assert_str_eq(l[3], "DDDD");
// list + NULL list
- iListShiftNSmashS(&l, NULL);
+ r = iListShiftNSmashS(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "A");
ck_assert_str_eq(l[3], "DDDD");
listFreeS(l);
// NULL list pointer
- iListShiftNSmashS(NULL,l);
+ r = iListShiftNSmashS(NULL,l);
+ ck_assert_ptr_eq(r, null);
// should not crash
@@ -14378,19 +16101,28 @@ END_TEST
START_TEST(listAddST)
- char **l = NULL;
+ char **l = NULL;
char **l2 = NULL;
char **l3;
+ char **r = null;
// lists
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l2, "A");
- listPushS(&l2, "BB");
- listPushS(&l2, "CCC");
- listPushS(&l2, "DDDD");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l2, "A");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "BB");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "CCC");
+ ck_assert_ptr_eq(r, l2);
+ r = listPushS(&l2, "DDDD");
+ ck_assert_ptr_eq(r, l2);
l3 = listAddS(l2,l);
ck_assert_uint_eq(listLengthS(l3),8);
ck_assert_str_eq(l3[0], "A");
@@ -14436,12 +16168,17 @@ START_TEST(listSliceST)
char **l = NULL;
char **l2;
+ char **r = null;
// list negative index
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listSliceS(l, 1,-1);
ck_assert_uint_eq(listLengthS(l2),2);
ck_assert_str_eq(l2[0], "22");
@@ -14462,8 +16199,10 @@ START_TEST(listSliceST)
listFreeS(l);
// negative start last element
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
l2 = listSliceS(l, -1,0);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "22");
@@ -14471,8 +16210,10 @@ START_TEST(listSliceST)
listFreeS(l2);
// start = end
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
l2 = listSliceS(l, 1,1);
ck_assert_uint_eq(listLengthS(l2),0);
ck_assert_ptr_eq(l2[0], NULL);
@@ -14494,12 +16235,17 @@ START_TEST(iListCopyST)
char **l = NULL;
char **l2;
+ char **r = null;
// list negative index
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = iListCopyS(l, 1,-1);
ck_assert_uint_eq(listLengthS(l2),2);
ck_assert_str_eq(l2[0], "22");
@@ -14508,10 +16254,14 @@ START_TEST(iListCopyST)
listFreeS(l);
// start outside
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(iListCopyS(l, 20,-4), NULL);
// end outside
l2 = iListCopyS(l, 2,40);
@@ -14522,18 +16272,24 @@ START_TEST(iListCopyST)
listFreeS(l);
// end negative and outside
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(iListCopyS(l, 2,-40), NULL);
// end before start
ck_assert_ptr_eq(iListCopyS(l, 3,2), NULL);
listFreeS(l);
// negative start last element
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
l2 = iListCopyS(l, -1,0);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "22");
@@ -14541,8 +16297,10 @@ START_TEST(iListCopyST)
listFreeS(l);
// start = end
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
l2 = iListCopyS(l, 1,1);
ck_assert_uint_eq(listLengthS(l2),0);
ck_assert_ptr_eq(l2[0], NULL);
@@ -14563,62 +16321,87 @@ END_TEST
START_TEST(iListSliceST)
char **l = NULL;
+ char **r = null;
// list negative index
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- iListSliceS(&l, 1,-1);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = iListSliceS(&l, 1,-1);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),2);
ck_assert_str_eq(l[0], "22");
ck_assert_str_eq(l[1], "333");
// start outside
- listPushS(&l, "1");
- listPushS(&l, "22");
- iListSliceS(&l, 20,-4);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = iListSliceS(&l, 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),0);
// end outside
- iListSliceS(&l, 2,40);
+ r = iListSliceS(&l, 2,40);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),0);
// end negative and outside
- iListSliceS(&l, 2,-40);
+ r = iListSliceS(&l, 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),0);
// end before start
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l, "55555");
- iListSliceS(&l, 3,2);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "55555");
+ ck_assert_ptr_eq(r, l);
+ r = iListSliceS(&l, 3,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),0);
listFreeS(l);
// negative start last element
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
- iListSliceS(&l, -1,0);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = iListSliceS(&l, -1,0);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),1);
ck_assert_str_eq(l[0], "22");
listFreeS(l);
// start = end
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
- iListSliceS(&l, 1,1);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = iListSliceS(&l, 1,1);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),0);
ck_assert_ptr_eq(l[0], NULL);
listFreeS(l);
// empty list
listEmptyS(l)
- iListSliceS(&l, 0,0);
+ r = iListSliceS(&l, 0,0);
+ ck_assert_ptr_eq(r, null);
ck_assert(listIsEmptyS(l));
- iListSliceS(&l, -1,0);
+ r = iListSliceS(&l, -1,0);
+ ck_assert_ptr_eq(r, null);
ck_assert(listIsEmptyS(l));
listFreeS(l);
// NULL list
l = NULL;
- iListSliceS(&l, 2,-4);
+ r = iListSliceS(&l, 2,-4);
+ ck_assert_ptr_eq(r, null);
// NULL var
- iListSliceS(NULL, 2,-4);
+ r = iListSliceS(NULL, 2,-4);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -14628,12 +16411,17 @@ START_TEST(listCropST)
char **l = NULL;
char **l2;
+ char **r = null;
// list negative index
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listCropS(l, 1,-1);
ck_assert_uint_eq(listLengthS(l2),2);
ck_assert_str_eq(l2[0], "22");
@@ -14654,10 +16442,14 @@ START_TEST(listCropST)
listFreeS(l);
// end negative and outside
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(listCropS(l, 2,-40), NULL);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
@@ -14672,8 +16464,10 @@ START_TEST(listCropST)
listFreeS(l);
// negative start last element
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
l2 = listCropS(l, -1,0);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "22");
@@ -14683,8 +16477,10 @@ START_TEST(listCropST)
listFreeS(l2);
// start = end
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
l2 = listCropS(l, 1,1);
ck_assert_uint_eq(listLengthS(l2),0);
ck_assert_ptr_eq(l2[0], NULL);
@@ -14709,12 +16505,17 @@ START_TEST(iListCropST)
char **l = NULL;
char **l2;
+ char **r = null;
// list negative index
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = iListCropS(&l, 1,-1);
ck_assert_uint_eq(listLengthS(l2),2);
ck_assert_str_eq(l2[0], "22");
@@ -14735,10 +16536,14 @@ START_TEST(iListCropST)
listFreeS(l);
// end negative and outside
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(iListCropS(&l, 2,-40), NULL);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
@@ -14753,8 +16558,10 @@ START_TEST(iListCropST)
listFreeS(l);
// negative start last element
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
l2 = iListCropS(&l, -1,0);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "22");
@@ -14764,8 +16571,10 @@ START_TEST(iListCropST)
listFreeS(l2);
// start = end
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
l2 = iListCropS(&l, 1,1);
ck_assert_uint_eq(listLengthS(l2),0);
ck_assert_ptr_eq(l2[0], NULL);
@@ -14792,12 +16601,17 @@ START_TEST(listCropElemST)
char **l = NULL;
char *r;
+ char **r2 = null;
// positive index
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r2 = listPushS(&l, "1");
+ ck_assert_ptr_eq(r2, l);
+ r2 = listPushS(&l, "22");
+ ck_assert_ptr_eq(r2, l);
+ r2 = listPushS(&l, "333");
+ ck_assert_ptr_eq(r2, l);
+ r2 = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r2, l);
r = listCropElemS(l, 1);
ck_assert_str_eq(r, "22");
ck_assert_str_eq(l[0], "1");
@@ -14832,12 +16646,17 @@ START_TEST(iListCropElemST)
char **l = NULL;
char *r;
+ char **r2 = null;
// positive index
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r2 = listPushS(&l, "1");
+ ck_assert_ptr_eq(r2, l);
+ r2 = listPushS(&l, "22");
+ ck_assert_ptr_eq(r2, l);
+ r2 = listPushS(&l, "333");
+ ck_assert_ptr_eq(r2, l);
+ r2 = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r2, l);
r = iListCropElemS(&l, 1);
ck_assert_str_eq(r, "22");
ck_assert_str_eq(l[0], "1");
@@ -14942,11 +16761,13 @@ START_TEST(iListInsertST)
char **l;
char **l2;
+ char **r = null;
// insert
l = listCreateS("1","22");
l2 = listCreateS("lib");
- iListInsertS(&l, 0, l2);
+ r = iListInsertS(&l, 0, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),3);
ck_assert_str_eq(l[0], "lib");
ck_assert_str_eq(l[1], "1");
@@ -14956,7 +16777,8 @@ START_TEST(iListInsertST)
// negative index
l = listCreateS("1","22");
l2 = listCreateS("lib");
- iListInsertS(&l, -1, l2);
+ r = iListInsertS(&l, -1, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),3);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
@@ -14966,7 +16788,8 @@ START_TEST(iListInsertST)
// edge
l = listCreateS("1","22");
l2 = listCreateS("lib");
- iListInsertS(&l, 2, l2);
+ r = iListInsertS(&l, 2, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),3);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
@@ -14976,18 +16799,21 @@ START_TEST(iListInsertST)
// outside list
l = listCreateS("1","22");
l2 = listCreateS("lib");
- iListInsertS(&l, 4, l2);
+ r = iListInsertS(&l, 4, l2);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
- iListInsertS(&l, -4, l2);
+ r = iListInsertS(&l, -4, l2);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
listFreeS(l);
// negative index in a one element list
l = listCreateS("1");
- iListInsertS(&l, -1, l2);
+ r = iListInsertS(&l, -1, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "lib");
free(l2);
@@ -14995,45 +16821,53 @@ START_TEST(iListInsertST)
// empty list
listEmptyS(l);
l2 = listCreateS("lib");
- iListInsertS(&l, 0, l2);
+ r = iListInsertS(&l, 0, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "lib");
free(l2);
listFreeS(l);
listEmptyS(l);
l2 = listCreateS("lib");
- iListInsertS(&l, -1, l2);
+ r = iListInsertS(&l, -1, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "lib");
free(l2);
listFreeS(l);
// empty insert list
l = listCreateS("1");
listEmptyS(l2);
- iListInsertS(&l, 0, l2);
+ r = iListInsertS(&l, 0, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "1");
listFreeS(l2);
// NULL insert string
- iListInsertS(&l, 0, NULL);
+ r = iListInsertS(&l, 0, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(l[0], "1");
listFreeS(l);
// NULL list and list to insert at index 0
l = NULL;
l2 = listCreateS("lib");
- iListInsertS(&l, 0, l2);
+ r = iListInsertS(&l, 0, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "lib");
free(l2);
listFreeS(l);
// NULL list and list to insert at non 0 index
l = NULL;
l2 = listCreateS("lib");
- iListInsertS(&l, -1, l2);
+ r = iListInsertS(&l, -1, l2);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
listFreeS(l2);
// NULL list
l = NULL;
- iListInsertS(&l, 0, NULL);
+ r = iListInsertS(&l, 0, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iListInsertS(NULL, 0, NULL);
+ r = iListInsertS(NULL, 0, NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -15047,7 +16881,8 @@ START_TEST(iListInsertNFreeST)
// insert
l = listCreateS("1","22");
l2 = listCreateS("lib");
- iListInsertNFreeS(&l, 0, l2);
+ r = iListInsertNFreeS(&l, 0, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),3);
ck_assert_str_eq(l[0], "lib");
ck_assert_str_eq(l[1], "1");
@@ -15056,7 +16891,8 @@ START_TEST(iListInsertNFreeST)
// negative index
l = listCreateS("1","22");
l2 = listCreateS("lib");
- iListInsertNFreeS(&l, -1, l2);
+ r = iListInsertNFreeS(&l, -1, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),3);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
@@ -15065,7 +16901,8 @@ START_TEST(iListInsertNFreeST)
// edge
l = listCreateS("1","22");
l2 = listCreateS("lib");
- iListInsertNFreeS(&l, 2, l2);
+ r = iListInsertNFreeS(&l, 2, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),3);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
@@ -15093,34 +16930,40 @@ START_TEST(iListInsertNFreeST)
// negative index in a one element list
l = listCreateS("1");
l2 = listCreateS("lib");
- iListInsertNFreeS(&l, -1, l2);
+ r = iListInsertNFreeS(&l, -1, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "lib");
listFreeS(l);
// empty list
listEmptyS(l);
l2 = listCreateS("lib");
- iListInsertNFreeS(&l, 0, l2);
+ r = iListInsertNFreeS(&l, 0, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "lib");
listFreeS(l);
listEmptyS(l);
l2 = listCreateS("lib");
- iListInsertNFreeS(&l, -1, l2);
+ r = iListInsertNFreeS(&l, -1, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "lib");
listFreeS(l);
// empty insert list
l = listCreateS("1");
listEmptyS(l2);
- iListInsertNFreeS(&l, 0, l2);
+ r = iListInsertNFreeS(&l, 0, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "1");
// NULL insert string
- iListInsertNFreeS(&l, 0, NULL);
+ r = iListInsertNFreeS(&l, 0, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(l[0], "1");
listFreeS(l);
// NULL list
l = NULL;
l2 = listCreateS("lib");
- iListInsertNFreeS(&l, 0, l2);
+ r = iListInsertNFreeS(&l, 0, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "lib");
listFreeS(l);
// NULL var
@@ -15255,10 +17098,12 @@ END_TEST
START_TEST(iListInjectST)
char **l;
+ char **r = null;
// insert
l = listCreateS("1","22");
- iListInjectS(&l, 0, strdup("lib"));
+ r = iListInjectS(&l, 0, strdup("lib"));
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),3);
ck_assert_str_eq(l[0], "lib");
ck_assert_str_eq(l[1], "1");
@@ -15266,7 +17111,8 @@ START_TEST(iListInjectST)
listFreeS(l);
// negative index
l = listCreateS("1","22");
- iListInjectS(&l, -1, strdup("lib"));
+ r = iListInjectS(&l, -1, strdup("lib"));
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),3);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
@@ -15274,7 +17120,8 @@ START_TEST(iListInjectST)
listFreeS(l);
// edge
l = listCreateS("1","22");
- iListInjectS(&l, 2, strdup("lib"));
+ r = iListInjectS(&l, 2, strdup("lib"));
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),3);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
@@ -15282,46 +17129,55 @@ START_TEST(iListInjectST)
listFreeS(l);
// outside list
l = listCreateS("1","22");
- iListInjectS(&l, 4, "lib");
+ r = iListInjectS(&l, 4, "lib");
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
- iListInjectS(&l, -4, "lib");
+ r = iListInjectS(&l, -4, "lib");
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
listFreeS(l);
// negative index in a one element list
l = listCreateS("1");
- iListInjectS(&l, -1, strdup("lib"));
+ r = iListInjectS(&l, -1, strdup("lib"));
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "lib");
listFreeS(l);
// empty list
listEmptyS(l);
- iListInjectS(&l, 0, strdup("lib"));
+ r = iListInjectS(&l, 0, strdup("lib"));
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "lib");
listFreeS(l);
listEmptyS(l);
- iListInjectS(&l, -1, strdup("lib"));
+ r = iListInjectS(&l, -1, strdup("lib"));
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "lib");
listFreeS(l);
// NULL insert string
l = listCreateS("1");
- iListInjectS(&l, 0, NULL);
+ r = iListInjectS(&l, 0, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(l[0], "1");
listFreeS(l);
// NULL list and non zero index
l = NULL;
- iListInjectS(&l, 1, "");
+ r = iListInjectS(&l, 1, "");
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// NULL list and zero index
l = NULL;
- iListInjectS(&l, 0, "aa");
+ r = iListInjectS(&l, 0, "aa");
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "aa");
free(l);
// NULL var
- ck_assert_ptr_eq(iListInjectS(NULL, 0, ""), NULL);
+ r = iListInjectS(NULL, 0, "");
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -15330,10 +17186,12 @@ END_TEST
START_TEST(iListInjectCharST)
char **l;
+ char **r = null;
// insert
l = listCreateS("1","22");
- iListInjectCharS(&l, 1, 'a');
+ r = iListInjectCharS(&l, 1, 'a');
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),3);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "a");
@@ -15341,15 +17199,18 @@ START_TEST(iListInjectCharST)
listFreeS(l);
// NULL list and zero index
l = NULL;
- iListInjectCharS(&l, 0, 'a');
+ r = iListInjectCharS(&l, 0, 'a');
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "a");
listFreeS(l);
// NULL list and non zero index
l = NULL;
- iListInjectCharS(&l, 1, 'a');
+ r = iListInjectCharS(&l, 1, 'a');
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(l, NULL);
// NULL var
- ck_assert_ptr_eq(iListInjectCharS(NULL, 1, 'a'), NULL);
+ r = iListInjectCharS(NULL, 1, 'a');
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -15358,12 +17219,17 @@ START_TEST(listDelST)
char **l = NULL;
char **l2;
+ char **r = null;
// list negative index
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listDelS(l, 1,-1);
ck_assert_uint_eq(listLengthS(l2),2);
ck_assert_str_eq(l2[0], "1");
@@ -15384,8 +17250,10 @@ START_TEST(listDelST)
listFreeS(l);
// negative start last element
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
l2 = listDelS(l, -1,0);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "1");
@@ -15393,8 +17261,10 @@ START_TEST(listDelST)
listFreeS(l2);
// start negative and outside (delete complete list because end is 0 (=len))
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
l2 = listDelS(l, -3,0);
ck_assert_uint_eq(listLengthS(l2),0);
ck_assert_ptr_eq(l2[0], NULL);
@@ -15402,8 +17272,10 @@ START_TEST(listDelST)
listFreeS(l2);
// start = end
l = NULL;
- listPushS(&l, "1");
- listPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
l2 = listDelS(l, 1,1);
ck_assert_uint_eq(listLengthS(l2),2);
ck_assert_str_eq(l2[0], "1");
@@ -15425,82 +17297,117 @@ END_TEST
START_TEST(iListDelST)
char **l = NULL;
+ char **r = null;
// list negative index
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- iListDelS(&l, 1,-1);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = iListDelS(&l, 1,-1);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "4444");
- iListEmptySF(&l);
+ r = iListEmptySF(&l);
+ ck_assert_ptr_eq(r, l);
// start outside
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- iListDelS(&l, 20,-4);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = iListDelS(&l, 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
// end outside
- iListDelS(&l, 2,40);
+ r = iListDelS(&l, 2,40);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
- iListEmptySF(&l);
+ r = iListEmptySF(&l);
+ ck_assert_ptr_eq(r, l);
// end negative and outside
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- iListDelS(&l, 2,-40);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = iListDelS(&l, 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
// end before start
- iListDelS(&l, 3,2);
+ r = iListDelS(&l, 3,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
- iListEmptySF(&l);
+ r = iListEmptySF(&l);
+ ck_assert_ptr_eq(r, l);
// negative start last element
- listPushS(&l, "1");
- listPushS(&l, "22");
- iListDelS(&l, -1,0);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = iListDelS(&l, -1,0);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),1);
ck_assert_str_eq(l[0], "1");
- iListEmptySF(&l);
+ r = iListEmptySF(&l);
+ ck_assert_ptr_eq(r, l);
// start negative and outside (delete complete list because end is 0 (=len))
- listPushS(&l, "1");
- listPushS(&l, "22");
- iListDelS(&l, -3,0);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = iListDelS(&l, -3,0);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),0);
ck_assert_ptr_eq(l[0], NULL);
// start = end
// (l is empty from previous test)
- listPushS(&l, "1");
- listPushS(&l, "22");
- iListDelS(&l, 1,1);
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = iListDelS(&l, 1,1);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
listFreeS(l);
// empty list
listEmptyS(l);
- iListDelS(&l, 0,0);
+ r = iListDelS(&l, 0,0);
+ ck_assert_ptr_eq(r, null);
ck_assert(listIsEmptyS(l));
- iListDelS(&l, -1,0);
+ r = iListDelS(&l, -1,0);
+ ck_assert_ptr_eq(r, null);
ck_assert(listIsEmptyS(l));
listFreeS(l);
// NULL list
l = NULL;
- iListDelS(&l, 2,-4);
+ r = iListDelS(&l, 2,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iListDelS(NULL, 2,-4);
+ r = iListDelS(NULL, 2,-4);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -15509,22 +17416,32 @@ END_TEST
START_TEST(iListRemoveST)
char **l = NULL;
+ char **r = null;
// list negative index
- listPushS(&l, "1");
- iListPushS(&l, "22");
- iListPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = iListPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = iListPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
iListRemoveS(&l, 1,-1);
ck_assert_uint_eq(listLengthS(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "4444");
- iListEmptySF(&l);
+ r = iListEmptySF(&l);
+ ck_assert_ptr_eq(r, l);
// start outside
- listPushS(&l, "1");
- listPushS(&l, "22");
- iListPushS(&l, "333");
- iListPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = iListPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = iListPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
iListRemoveS(&l, 20,-4);
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "1");
@@ -15534,12 +17451,17 @@ START_TEST(iListRemoveST)
ck_assert_uint_eq(listLengthS(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
- iListEmptySF(&l);
+ r = iListEmptySF(&l);
+ ck_assert_ptr_eq(r, l);
// end negative and outside
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
iListRemoveS(&l, 2,-40);
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "1");
@@ -15549,24 +17471,32 @@ START_TEST(iListRemoveST)
ck_assert_uint_eq(listLengthS(l),4);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
- iListEmptySF(&l);
+ r = iListEmptySF(&l);
+ ck_assert_ptr_eq(r, l);
// negative start last element
- listPushS(&l, "1");
- iListPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = iListPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
iListRemoveS(&l, -1,0);
ck_assert_uint_eq(listLengthS(l),1);
ck_assert_str_eq(l[0], "1");
- iListEmptySF(&l);
+ r = iListEmptySF(&l);
+ ck_assert_ptr_eq(r, l);
// start negative and outside (delete complete list because end is 0 (=len))
- iListPushS(&l, "1");
- iListPushS(&l, "22");
+ r = iListPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = iListPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
iListRemoveS(&l, -3,0);
ck_assert_uint_eq(listLengthS(l),0);
ck_assert_ptr_eq(l[0], NULL);
// start = end
// (l is empty from previous test)
- listPushS(&l, "1");
- listPushS(&l, "22");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
iListRemoveS(&l, 1,1);
ck_assert_uint_eq(listLengthS(l),2);
ck_assert_str_eq(l[0], "1");
@@ -15594,12 +17524,17 @@ START_TEST(listDelElemST)
char **l = NULL;
char **l2;
+ char **r = null;
// positive index
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listDelElemS(l, 1);
ck_assert_str_eq(l2[0], "1");
ck_assert_str_eq(l2[1], "333");
@@ -15635,10 +17570,14 @@ START_TEST(iListDelElemST)
char **r;
// positive index
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
r = iListDelElemS(&l, 1);
ck_assert_ptr_ne(r, null);
ck_assert_str_eq(l[0], "1");
@@ -15675,10 +17614,14 @@ START_TEST(iListRemoveElemST)
char **r;
// positive index
- listPushS(&l, "1");
- iListPushS(&l, "22");
- listPushS(&l, "333");
- iListPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = iListPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = iListPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
r = iListRemoveElemS(&l, 1);
ck_assert_ptr_ne(r, null);
ck_assert_str_eq(l[0], "1");
@@ -15830,12 +17773,17 @@ START_TEST(listEqST)
char **l = NULL;
char **l2;
+ char **r = null;
// identical lists
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listDupS(l);
ck_assert(listEqS(l,l2));
// NULL lists
@@ -15858,12 +17806,17 @@ END_TEST
START_TEST(listHasST)
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert(listHasS(l, "1"));
// NULL list
ck_assert(!listHasS(NULL, "1"));
@@ -15881,12 +17834,17 @@ END_TEST
START_TEST(listHasCharST)
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert(listHasCharS(l, '1'));
// NULL list
ck_assert(!listHasCharS(NULL, '1'));
@@ -15901,12 +17859,17 @@ END_TEST
START_TEST(listIndexOfST)
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listIndexOfS(l, "1"),0);
// NULL list
ck_assert_uint_eq(listIndexOfS(NULL, "1"),-1);
@@ -15924,12 +17887,17 @@ END_TEST
START_TEST(listIndexOfCharST)
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listIndexOfCharS(l, '1'),0);
// NULL list
ck_assert_uint_eq(listIndexOfCharS(NULL, '1'),-1);
@@ -15944,14 +17912,21 @@ END_TEST
START_TEST(listBinarySearchST)
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l, "5");
- listPushS(&l, "6");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "5");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "6");
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listBinarySearchS(l, "1"),0);
// NULL list
ck_assert_uint_eq(listBinarySearchS(NULL, "1"),-1);
@@ -15969,14 +17944,21 @@ END_TEST
START_TEST(listBinarySearchCharST)
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l, "5");
- listPushS(&l, "6");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "5");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "6");
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listBinarySearchCharS(l, '1'),0);
// NULL list
ck_assert_uint_eq(listBinarySearchCharS(NULL, '1'),-1);
@@ -15994,12 +17976,17 @@ START_TEST(listUniqST)
char **l = NULL;
char **l2;
+ char **r = null;
// list with unique elements
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listUniqS(l);
ck_assert(listEqS(l,l2));
// list with identical elements
@@ -16014,7 +18001,8 @@ START_TEST(listUniqST)
listFreeS(l2);
// list with one element
l = NULL;
- listPushS(&l, "1");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
l2 = listUniqS(l);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "1");
@@ -16037,14 +18025,20 @@ START_TEST(iListUniqST)
char **l = NULL;
char **l2;
+ char **r = null;
// list with unique elements
- listPushS(&l, "1");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listDupS(l);
- iListUniqS(&l2);
+ r = iListUniqS(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert(listEqS(l,l2));
// list with identical elements
l[2][0] = '2';
@@ -16052,16 +18046,19 @@ START_TEST(iListUniqST)
l[2][2] = 0;
listFreeS(l2);
l2 = listDupS(l);
- iListUniqS(&l2);
+ r = iListUniqS(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),3);
ck_assert_str_eq(l2[2], "4444");
listFreeS(l);
listFreeS(l2);
// list with one element
l = NULL;
- listPushS(&l, "1");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
l2 = listDupS(l);
- iListUniqS(&l2);
+ r = iListUniqS(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "1");
listFreeS(l);
@@ -16069,17 +18066,20 @@ START_TEST(iListUniqST)
// empty list
listEmptyS(l)
l2 = listDupS(l);
- iListUniqS(&l2);
+ r = iListUniqS(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),0);
ck_assert_ptr_eq(l2[0], NULL);
listFreeS(l);
listFreeS(l2);
// NULL list
l = NULL;
- iListUniqS(&l);
+ r = iListUniqS(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iListUniqS(NULL);
+ r = iListUniqS(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -16088,14 +18088,21 @@ START_TEST(icListEqST)
char **l = NULL;
char **l2;
+ char **r2 = null;
+ char *r = null;
// identical lists
- listPushS(&l, "1");
- listPushS(&l, "bb");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r2 = listPushS(&l, "1");
+ ck_assert_ptr_eq(r2, l);
+ r2 = listPushS(&l, "bb");
+ ck_assert_ptr_eq(r2, l);
+ r2 = listPushS(&l, "333");
+ ck_assert_ptr_eq(r2, l);
+ r2 = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r2, l);
l2 = listDupS(l);
- iUpperS(&l2[1]);
+ r = iUpperS(&l2[1]);
+ ck_assert_ptr_eq(r, l2[1]);
ck_assert(icListEqS(l,l2));
// NULL lists
ck_assert(!icListEqS(NULL,l));
@@ -16118,12 +18125,17 @@ END_TEST
START_TEST(icListHasST)
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "a");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "a");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert(icListHasS(l, "A"));
// NULL list
ck_assert(!icListHasS(NULL, "1"));
@@ -16142,12 +18154,17 @@ END_TEST
START_TEST(icListHasCharST)
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "A");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "A");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert(icListHasCharS(l, 'a'));
// NULL list
ck_assert(!icListHasCharS(NULL, '1'));
@@ -16162,12 +18179,17 @@ END_TEST
START_TEST(icListIndexOfST)
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "a");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "a");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(icListIndexOfS(l, "A"),0);
// NULL list
ck_assert_uint_eq(icListIndexOfS(NULL, "1"),-1);
@@ -16186,12 +18208,17 @@ END_TEST
START_TEST(icListIndexOfCharST)
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "A");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "A");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(icListIndexOfCharS(l, 'a'),0);
// NULL list
ck_assert_uint_eq(icListIndexOfCharS(NULL, '1'),-1);
@@ -16206,15 +18233,23 @@ END_TEST
START_TEST(icListBinarySearchST)
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "a");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l, "ccc");
- listPushS(&l, "6");
- iListSortS(&l);
+ r = listPushS(&l, "a");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "ccc");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "6");
+ ck_assert_ptr_eq(r, l);
+ r = iListSortS(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(icListBinarySearchS(l, "A"),4);
// NULL list
ck_assert_uint_eq(icListBinarySearchS(NULL, "1"),-1);
@@ -16233,15 +18268,23 @@ END_TEST
START_TEST(icListBinarySearchCharST)
char **l = NULL;
+ char **r = null;
// string
- listPushS(&l, "A");
- listPushS(&l, "22");
- listPushS(&l, "333");
- listPushS(&l, "4444");
- listPushS(&l, "C");
- listPushS(&l, "6");
- iListSortS(&l);
+ r = listPushS(&l, "A");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "22");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "C");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "6");
+ ck_assert_ptr_eq(r, l);
+ r = iListSortS(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(icListBinarySearchCharS(l, 'a'),4);
// NULL list
ck_assert_uint_eq(icListBinarySearchCharS(NULL, '1'),-1);
@@ -16259,12 +18302,17 @@ START_TEST(icListUniqST)
char **l = NULL;
char **l2;
+ char **r = null;
// list with unique elements
- listPushS(&l, "1");
- listPushS(&l, "bb");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "bb");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = icListUniqS(l);
ck_assert(listEqS(l,l2));
// list with identical elements
@@ -16279,7 +18327,8 @@ START_TEST(icListUniqST)
listFreeS(l2);
// list with one element
l = NULL;
- listPushS(&l, "1");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
l2 = icListUniqS(l);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "1");
@@ -16303,14 +18352,20 @@ START_TEST(iicListUniqST)
char **l = NULL;
char **l2;
+ char **r = null;
// list with unique elements
- listPushS(&l, "1");
- listPushS(&l, "BB");
- listPushS(&l, "333");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "BB");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "333");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listDupS(l);
- iicListUniqS(&l2);
+ r = iicListUniqS(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert(listEqS(l,l2));
// list with identical elements
l[2][0] = 'b';
@@ -16318,16 +18373,19 @@ START_TEST(iicListUniqST)
l[2][2] = 0;
listFreeS(l2);
l2 = listDupS(l);
- iicListUniqS(&l2);
+ r = iicListUniqS(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),3);
ck_assert_str_eq(l2[2], "4444");
listFreeS(l);
listFreeS(l2);
// list with one element
l = NULL;
- listPushS(&l, "1");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
l2 = listDupS(l);
- iicListUniqS(&l2);
+ r = iicListUniqS(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),1);
ck_assert_str_eq(l2[0], "1");
listFreeS(l);
@@ -16335,17 +18393,20 @@ START_TEST(iicListUniqST)
// empty list
listEmptyS(l)
l2 = listDupS(l);
- iicListUniqS(&l2);
+ r = iicListUniqS(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),0);
ck_assert_ptr_eq(l2[0], NULL);
listFreeS(l);
listFreeS(l2);
// NULL list
l = NULL;
- iicListUniqS(&l);
+ r = iicListUniqS(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iicListUniqS(NULL);
+ r = iicListUniqS(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -16355,12 +18416,17 @@ START_TEST(listCompactST)
char **l = NULL;
char **l2;
+ char **r = null;
// list with empty elements
- listPushS(&l, "1");
- listPushS(&l, "");
- listPushS(&l, "");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listCompactS(l);
ck_assert_uint_eq(listLengthS(l2),2);
ck_assert_str_eq(l2[1], "4444");
@@ -16383,39 +18449,50 @@ START_TEST(iListCompactST)
char **l = NULL;
char **l2;
+ char **r = null;
// list with empty elements
- listPushS(&l, "1");
- listPushS(&l, "");
- listPushS(&l, "");
- listPushS(&l, "4444");
+ r = listPushS(&l, "1");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "");
+ ck_assert_ptr_eq(r, l);
+ r = listPushS(&l, "4444");
+ ck_assert_ptr_eq(r, l);
l2 = listDupS(l);
- iListCompactS(&l2);
+ r = iListCompactS(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),2);
ck_assert_str_eq(l2[1], "4444");
listFreeS(l);
listFreeS(l2);
// list with an empty string
l = NULL;
- listPushS(&l, "");
- iListCompactS(&l);
+ r = listPushS(&l, "");
+ ck_assert_ptr_eq(r, l);
+ r = iListCompactS(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLengthS(l),0);
ck_assert_ptr_eq(l[0], NULL);
listFreeS(l);
// empty list
listEmptyS(l)
l2 = listDupS(l);
- iListCompactS(&l2);
+ r = iListCompactS(&l2);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLengthS(l2),0);
ck_assert_ptr_eq(l2[0], NULL);
listFreeS(l);
listFreeS(l2);
// NULL list
l = NULL;
- iListCompactS(&l);
+ r = iListCompactS(&l);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iListCompactS(NULL);
+ r = iListCompactS(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -16460,20 +18537,26 @@ START_TEST(iListEmptyFT)
void **l = NULL;
char *s1 = "lib";
char *s2 = "sheepy";
+ void **r = null;
// empty list
- listPush(&l, s1);
- listPush(&l, s2);
- iListEmptyF(&l);
+ r = listPush(&l, s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, s2);
+ ck_assert_ptr_eq(r, l);
+ r = iListEmptyF(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmpty(l));
free(l);
// NULL list
l = NULL;
- iListEmptyF(&l);
+ r = iListEmptyF(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmpty(l));
free(l);
// NULL var
- iListEmptyF(NULL);
+ r = iListEmptyF(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -16483,10 +18566,13 @@ START_TEST(listIsEmptyT)
void **l = NULL;
char *s1 = "lib";
char *s2 = "sheepy";
+ void **r = null;
// non empty list
- listPush(&l, s1);
- listPush(&l, s2);
+ r = listPush(&l, s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, s2);
+ ck_assert_ptr_eq(r, l);
// check ck_assert_ptr_null not available in jessie
ck_assert_ptr_ne(l, NULL);
ck_assert(!listIsEmpty(l));
@@ -16556,31 +18642,38 @@ START_TEST(listPushT)
void **l = NULL;
char *s = "sheepy";
char *s2 = "SHEEPY";
+ void **r = null;
// push strings and NULL list
- listPush(&l, (void *)s);
+ r = listPush(&l, (void *)s);
+ ck_assert_ptr_eq(r, l);
// check ck_assert_ptr_null not available in jessie
ck_assert_ptr_ne(l, NULL);
ck_assert_str_eq(l[0], "sheepy");
- listPush(&l, (void *)s2);
+ r = listPush(&l, (void *)s2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[1], "SHEEPY");
ck_assert_str_eq(l[0], "sheepy");
// push NULL
- listPush(&l, NULL);
+ r = listPush(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l[2], NULL);
free(l);
// NULL list and NULL string
l = NULL;
- listPush(&l, NULL);
+ r = listPush(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// empty list
listEmpty(l);
- listPush(&l, (void *)s);
+ r = listPush(&l, (void *)s);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "sheepy");
ck_assert_ptr_eq(l[1], NULL);
free(l);
// NULL pointer to list
- listPush(NULL, NULL);
+ r = listPush(NULL, NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -16588,13 +18681,16 @@ END_TEST
START_TEST(listPopT)
void **l = NULL;
- char *s1 = "sheepy";
+ char *s1 = "sheepy";
char *s2 = "SHEEPY";
char *s;
+ void **r = null;
// pop string
- listPush(&l, (void *)s1);
- listPush(&l, (void *)s2);
+ r = listPush(&l, (void *)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void *)s2);
+ ck_assert_ptr_eq(r, l);
s = (char *)listPop(&l);
ck_assert_str_eq(s, "SHEEPY");
ck_assert_uint_eq(listLength(l),1);
@@ -16619,31 +18715,38 @@ START_TEST(listPrependT)
void **l = NULL;
char *s1 = "sheepy";
char *s2 = "SHEEPY";
+ void **r = null;
// push strings and NULL list
- listPrepend(&l, (void *)s1);
+ r = listPrepend(&l, (void *)s1);
+ ck_assert_ptr_eq(r, l);
// check ck_assert_ptr_null not available in jessie
ck_assert_ptr_ne(l, NULL);
ck_assert_str_eq(l[0], "sheepy");
- listPrepend(&l, (void *)s2);
+ r = listPrepend(&l, (void *)s2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "SHEEPY");
ck_assert_str_eq(l[1], "sheepy");
// push NULL
- listPrepend(&l, NULL);
+ r = listPrepend(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(l[0], "SHEEPY");
free(l);
// NULL list and NULL string`
l = NULL;
- listPrepend(&l, NULL);
+ r = listPrepend(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// empty list
listEmpty(l)
- listPrepend(&l, (void *)s1);
+ r = listPrepend(&l, (void *)s1);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "sheepy");
ck_assert_ptr_eq(l[1], NULL);
free(l);
// NULL pointer to list
- listPrepend(NULL, NULL);
+ r = listPrepend(NULL, NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -16654,10 +18757,13 @@ START_TEST(listDequeueT)
char *s1 = "sheepy";
char *s2 = "SHEEPY";
char *s;
+ void **r = null;
// pop string
- listPush(&l, (void *)s1);
- listPush(&l, (void *)s2);
+ r = listPush(&l, (void *)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void *)s2);
+ ck_assert_ptr_eq(r, l);
s = listDequeue(&l);
ck_assert_str_eq(s, "sheepy");
ck_assert_uint_eq(listLength(l),1);
@@ -16682,9 +18788,13 @@ START_TEST(listFreeT)
void **l = NULL;
char *s1 = strdup("sheepy");
char *s2 = strdup("SHEEPY");
+ void **r = null;
+
// not possible to know if a pointer is already freed
- listPush(&l, (void *)s1);
- listPush(&l, (void *)s2);
+ r = listPush(&l, (void *)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void *)s2);
+ ck_assert_ptr_eq(r, l);
listFree(l);
// empty list
listEmpty(l);
@@ -16700,9 +18810,13 @@ START_TEST(listFreeManyT)
void **l1 = NULL;
char *s1 = strdup("sheepy");
char *s2 = strdup("SHEEPY");
+ void **r = null;
+
// not possible to know if a pointer is already freed
- listPush(&l1, (void *)s1);
- listPush(&l1, (void *)s2);
+ r = listPush(&l1, (void *)s1);
+ ck_assert_ptr_eq(r, l1);
+ r = listPush(&l1, (void *)s2);
+ ck_assert_ptr_eq(r, l1);
void **l2 = listEmptyF();
listFreeMany(l1, l2);
@@ -16737,12 +18851,17 @@ START_TEST(listGetT)
char *s2 = "22";
char *s3 = "333";
char *s4 = "4444";
+ void **r = null;
// get string
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(listGet(l, 0), "1");
// negative index
ck_assert_str_eq(listGet(l, -1), "4444");
@@ -16752,8 +18871,10 @@ START_TEST(listGetT)
free(l);
// negative index in a one element list
l = NULL;
- listPush(&l, (void*)s1);
- listPush(&l, NULL);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_ne(listGet(l,-1), NULL);
free(l);
// empty list
@@ -16775,23 +18896,33 @@ START_TEST(listSetT)
char *s4 = "4444";
char *sA = "@@";
char *sB = "|";
+ void **r = null;
// get string
- listPush(&l, (void*)sA);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)sB);
- listPush(&l, (void*)s4);
- listSet(l, 0, (void*)s1);
+ r = listPush(&l, (void*)sA);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)sB);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
+ r = listSet(l, 0, (void*)s1);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(listGet(l, 0), "1");
// negative index
- listSet(l, -2, (void*)s3);
+ r = listSet(l, -2, (void*)s3);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(listGet(l, -2), "333");
// outside list
// list is unchanged
- listSet(l, 10, (void*)s1);
- listSet(l, -10, (void*)s1);
+ r = listSet(l, 10, (void*)s1);
+ ck_assert_ptr_eq(r, null);
+ r = listSet(l, -10, (void*)s1);
+ ck_assert_ptr_eq(r, null);
// NULL s var
- listSet(l, -2, NULL);
+ r = listSet(l, -2, NULL);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
ck_assert_str_eq(l[2], "333");
@@ -16799,18 +18930,23 @@ START_TEST(listSetT)
free(l);
// negative index in a one element list
l = NULL;
- listPush(&l, (void*)s1);
- listPush(&l, NULL);
- listSet(l, -1, (void*)s1);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, NULL);
+ ck_assert_ptr_eq(r, null);
+ r = listSet(l, -1, (void*)s1);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(listGet(l,-1), "1");
free(l);
// empty list - should not crash
listEmpty(l);
- listSet(l, 0, (void*)s1);
+ r = listSet(l, 0, (void*)s1);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(listGet(l,0),NULL);
free(l);
// NULL list
- listSet(NULL, 0, (void*)s1);
+ r = listSet(NULL, 0, (void*)s1);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(listGet(NULL, 0), NULL);
END_TEST
@@ -16824,12 +18960,17 @@ START_TEST(listDupT)
char *s2 = "22";
char *s3 = "333";
char *s4 = "4444";
+ void **r = null;
// list
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
l2 = listDup(l);
ck_assert_uint_eq(listLength(l2),4);
ck_assert_str_eq(l2[0], "1");
@@ -16856,12 +18997,17 @@ START_TEST(listReverseT)
char *s2 = "22";
char *s3 = "333";
char *s4 = "4444";
+ void **r = null;
// list
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
l2 = listReverse(l);
ck_assert_uint_eq(listLength(l2),4);
ck_assert_str_eq(l2[0], "4444");
@@ -16887,28 +19033,37 @@ START_TEST(iListReverseT)
char *s2 = "22";
char *s3 = "333";
char *s4 = "4444";
+ void **r = null;
// list
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
- iListReverse(&l);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
+ r = iListReverse(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLength(l),4);
ck_assert_str_eq(l[0], "4444");
ck_assert_str_eq(l[3], "1");
free(l);
/* // empty list */
listEmpty(l);
- iListReverse(&l);
+ r = iListReverse(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmpty(l));
free(l);
// NULL list
l = NULL;
- iListReverse(&l);
+ r = iListReverse(&l);
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iListReverse(NULL);
+ r = iListReverse(NULL);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -16924,10 +19079,14 @@ START_TEST(listCatT)
char *s4 = "sheepy";
// cat lists
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s1);
- listPush(&l2, (void*)s3);
- listPush(&l2, (void*)s4);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l2, (void*)s3);
+ ck_assert_ptr_eq(r, l2);
+ r = listPush(&l2, (void*)s4);
+ ck_assert_ptr_eq(r, l2);
r = listCat(l,l2);
ck_assert_str_eq(r[0], "#@#");
ck_assert_str_eq(r[1], "1");
@@ -16942,8 +19101,10 @@ START_TEST(listCatT)
// cat empty list with list
listEmpty(l);
l2 = NULL;
- listPush(&l2, (void*)s3);
- listPush(&l2, (void*)s4);
+ r = listPush(&l2, (void*)s3);
+ ck_assert_ptr_eq(r, l2);
+ r = listPush(&l2, (void*)s4);
+ ck_assert_ptr_eq(r, l2);
r = listCat(l, l2);
ck_assert_str_eq(r[0], "lib");
ck_assert_str_eq(r[1], "sheepy");
@@ -16964,17 +19125,27 @@ START_TEST(listAppendT)
char *sB = "BB";
char *sC = "CCC";
char *sD = "DDDD";
+ void **r = null;
// lists
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
- listPush(&l2, (void*)sA);
- listPush(&l2, (void*)sB);
- listPush(&l2, (void*)sC);
- listPush(&l2, (void*)sD);
- listAppend(&l2,l);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l2, (void*)sA);
+ ck_assert_ptr_eq(r, l2);
+ r = listPush(&l2, (void*)sB);
+ ck_assert_ptr_eq(r, l2);
+ r = listPush(&l2, (void*)sC);
+ ck_assert_ptr_eq(r, l2);
+ r = listPush(&l2, (void*)sD);
+ ck_assert_ptr_eq(r, l2);
+ r = listAppend(&l2,l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLength(l2),8);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
@@ -16983,18 +19154,24 @@ START_TEST(listAppendT)
free(l);
// append list to itself - no change
l = NULL;
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
- listAppend(&l,l);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
+ r = listAppend(&l,l);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLength(l),4);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
free(l);
// empty list + list
listEmpty(l);
- listAppend(&l, l2);
+ r = listAppend(&l, l2);
+ ck_assert_ptr_eq(r, l);
//ck_assert(listEqS(l,l2));
ck_assert_uint_eq(listLength(l),listLength(l2));
ck_assert_str_eq(l2[0], l[0]);
@@ -17004,7 +19181,8 @@ START_TEST(listAppendT)
free(l);
// list + empty list
listEmptyS(l);
- listAppend(&l2, l);
+ r = listAppend(&l2, l);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLength(l2),8);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
@@ -17015,31 +19193,39 @@ START_TEST(listAppendT)
// empty list + empty list
listEmpty(l);
listEmpty(l2);
- listAppend(&l, l2);
+ r = listAppend(&l, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert(listIsEmpty(l));
free(l);
free(l2);
// NULL list + list = duplicate
l = NULL;
l2 = NULL;
- listPush(&l2, (void*)sA);
- listPush(&l2, (void*)sB);
- listPush(&l2, (void*)sC);
- listPush(&l2, (void*)sD);
- listAppend(&l,l2);
+ r = listPush(&l2, (void*)sA);
+ ck_assert_ptr_eq(r, l2);
+ r = listPush(&l2, (void*)sB);
+ ck_assert_ptr_eq(r, l2);
+ r = listPush(&l2, (void*)sC);
+ ck_assert_ptr_eq(r, l2);
+ r = listPush(&l2, (void*)sD);
+ ck_assert_ptr_eq(r, l2);
+ r = listAppend(&l,l2);
+ ck_assert_ptr_eq(r, l);
//ck_assert(listEqS(l,l2));
ck_assert_uint_eq(listLength(l),listLength(l2));
ck_assert_str_eq(l2[0], l[0]);
ck_assert_str_eq(l2[3], l[3]);
free(l);
// list + NULL list
- listAppend(&l2, NULL);
+ r = listAppend(&l2, NULL);
+ ck_assert_ptr_eq(r, l2);
ck_assert_uint_eq(listLength(l2),4);
ck_assert_str_eq(l2[0], "A");
ck_assert_str_eq(l2[3], "DDDD");
free(l2);
// NULL list pointer
- listAppend(NULL,l2);
+ r = listAppend(NULL,l2);
+ ck_assert_ptr_eq(r, null);
// should not crash
END_TEST
@@ -17058,16 +19244,25 @@ START_TEST(listAddT)
char *sB = "BB";
char *sC = "CCC";
char *sD = "DDDD";
+ void **r = null;
// lists
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
- listPush(&l2, (void*)sA);
- listPush(&l2, (void*)sB);
- listPush(&l2, (void*)sC);
- listPush(&l2, (void*)sD);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l2, (void*)sA);
+ ck_assert_ptr_eq(r, l2);
+ r = listPush(&l2, (void*)sB);
+ ck_assert_ptr_eq(r, l2);
+ r = listPush(&l2, (void*)sC);
+ ck_assert_ptr_eq(r, l2);
+ r = listPush(&l2, (void*)sD);
+ ck_assert_ptr_eq(r, l2);
l3 = listAdd(l2,l);
ck_assert_uint_eq(listLength(l3),8);
ck_assert_str_eq(l3[0], "A");
@@ -17129,12 +19324,17 @@ START_TEST(listSliceT)
char *s2 = "22";
char *s3 = "333";
char *s4 = "4444";
+ void **r = null;
// list negative index
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
l2 = listSlice(l, 1,-1);
ck_assert_uint_eq(listLength(l2),2);
ck_assert_str_eq(l2[0], "22");
@@ -17143,10 +19343,14 @@ START_TEST(listSliceT)
free(l2);
// start outside
l = NULL;
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(listSlice(l, 20,-4), NULL);
// end outside
l2 = listSlice(l, 2,40);
@@ -17157,18 +19361,24 @@ START_TEST(listSliceT)
free(l2);
// end negative and outside
l = NULL;
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
ck_assert_ptr_eq(listSlice(l, 2,-40), NULL);
// end before start
ck_assert_ptr_eq(listSlice(l, 3,2), NULL);
free(l);
// negative start last element
l = NULL;
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
l2 = listSlice(l, -1,0);
ck_assert_uint_eq(listLength(l2),1);
ck_assert_str_eq(l2[0], "22");
@@ -17176,8 +19386,10 @@ START_TEST(listSliceT)
free(l2);
// start = end
l = NULL;
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
l2 = listSlice(l, 1,1);
ck_assert_uint_eq(listLength(l2),0);
ck_assert_ptr_eq(l2[0], NULL);
@@ -17202,61 +19414,85 @@ START_TEST(iListSliceT)
char *s2 = "22";
char *s3 = "333";
char *s4 = "4444";
+ void **r = null;
// list negative index
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
- iListSlice(&l, 1,-1);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
+ r = iListSlice(&l, 1,-1);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLength(l),2);
ck_assert_str_eq(l[0], "22");
ck_assert_str_eq(l[1], "333");
// start outside
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- iListSlice(&l, 20,-4);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = iListSlice(&l, 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLength(l),0);
// end outside
- iListSlice(&l, 2,40);
+ r = iListSlice(&l, 2,40);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLength(l),0);
// end negative and outside
- iListSlice(&l, 2,-40);
+ r = iListSlice(&l, 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLength(l),0);
// end before start
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
- iListSlice(&l, 3,2);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
+ r = iListSlice(&l, 3,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLength(l),0);
free(l);
// negative start last element
l = NULL;
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- iListSlice(&l, -1,0);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = iListSlice(&l, -1,0);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLength(l),1);
ck_assert_str_eq(l[0], "22");
free(l);
// start = end
l = NULL;
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- iListSlice(&l, 1,1);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = iListSlice(&l, 1,1);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLength(l),0);
ck_assert_ptr_eq(l[0], NULL);
free(l);
// empty list
listEmpty(l)
- iListSlice(&l, 0,0);
+ r = iListSlice(&l, 0,0);
+ ck_assert_ptr_eq(r, null);
ck_assert(listIsEmpty(l));
- iListSlice(&l, -1,0);
+ r = iListSlice(&l, -1,0);
+ ck_assert_ptr_eq(r, null);
ck_assert(listIsEmpty(l));
free(l);
// NULL list
l = NULL;
- iListSlice(&l, 2,-4);
+ r = iListSlice(&l, 2,-4);
+ ck_assert_ptr_eq(r, null);
// NULL var
- iListSlice(NULL, 2,-4);
+ r = iListSlice(NULL, 2,-4);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -17336,11 +19572,13 @@ START_TEST(iListInsertT)
char *s1 = "1";
char *s2 = "22";
char *s3 = "lib";
+ void **r = null;
// insert
l = listCreate((void*)s1, (void*)s2);
l2 = listCreate((void*)s3);
- iListInsert(&l, 0, l2);
+ r = iListInsert(&l, 0, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLength(l),3);
ck_assert_str_eq(l[0], "lib");
ck_assert_str_eq(l[1], "1");
@@ -17350,7 +19588,8 @@ START_TEST(iListInsertT)
// negative index
l = listCreate((void*)s1, (void*)s2);
l2 = listCreate((void*)s3);
- iListInsert(&l, -1, l2);
+ r = iListInsert(&l, -1, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLength(l),3);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
@@ -17360,7 +19599,8 @@ START_TEST(iListInsertT)
// edge
l = listCreate((void*)s1, (void*)s2);
l2 = listCreate((void*)s3);
- iListInsert(&l, 2, l2);
+ r = iListInsert(&l, 2, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLength(l),3);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
@@ -17370,18 +19610,21 @@ START_TEST(iListInsertT)
// outside list
l = listCreate((void*)s1, (void*)s2);
l2 = listCreate((void*)s3);
- iListInsert(&l, 4, l2);
+ r = iListInsert(&l, 4, l2);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLength(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
- iListInsert(&l, -4, l2);
+ r = iListInsert(&l, -4, l2);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLength(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
free(l);
// negative index in a one element list
l = listCreate((void*)s1);
- iListInsert(&l, -1, l2);
+ r = iListInsert(&l, -1, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "lib");
free(l2);
@@ -17389,26 +19632,31 @@ START_TEST(iListInsertT)
// empty list
listEmpty(l);
l2 = listCreate((void*)s3);
- iListInsert(&l, 0, l2);
+ r = iListInsert(&l, 0, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "lib");
free(l2);
free(l);
// empty insert list
l = listCreate((void*)s1);
listEmpty(l2);
- iListInsert(&l, 0, l2);
+ r = iListInsert(&l, 0, l2);
+ ck_assert_ptr_eq(r, l);
ck_assert_str_eq(l[0], "1");
free(l2);
// NULL insert string
- iListInsert(&l, 0, NULL);
+ r = iListInsert(&l, 0, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_str_eq(l[0], "1");
free(l);
// NULL list
l = NULL;
- iListInsert(&l, 0, NULL);
+ r = iListInsert(&l, 0, NULL);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iListInsert(NULL, 0, NULL);
+ r = iListInsert(NULL, 0, NULL);
+ ck_assert_ptr_eq(r, NULL);
END_TEST
@@ -17422,12 +19670,17 @@ START_TEST(listDelT)
char *s2 = "22";
char *s3 = "333";
char *s4 = "4444";
+ void **r = null;
// list negative index
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
l2 = listDel(l, 1,-1);
ck_assert_uint_eq(listLength(l2),2);
ck_assert_str_eq(l2[0], "1");
@@ -17448,8 +19701,10 @@ START_TEST(listDelT)
free(l);
// negative start last element
l = NULL;
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
l2 = listDel(l, -1,0);
ck_assert_uint_eq(listLength(l2),1);
ck_assert_str_eq(l2[0], "1");
@@ -17457,8 +19712,10 @@ START_TEST(listDelT)
free(l2);
// start negative and outside (delete complete list because end is 0 (=len))
l = NULL;
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
l2 = listDel(l, -3,0);
ck_assert_uint_eq(listLength(l2),0);
ck_assert_ptr_eq(l2[0], NULL);
@@ -17466,8 +19723,10 @@ START_TEST(listDelT)
free(l2);
// start = end
l = NULL;
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
l2 = listDel(l, 1,1);
ck_assert_uint_eq(listLength(l2),2);
ck_assert_str_eq(l2[0], "1");
@@ -17493,82 +19752,117 @@ START_TEST(iListDelT)
char *s2 = "22";
char *s3 = "333";
char *s4 = "4444";
+ void **r = null;
// list negative index
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
- iListDel(&l, 1,-1);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
+ r = iListDel(&l, 1,-1);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLength(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "4444");
- iListEmptyF(&l);
+ r = iListEmptyF(&l);
+ ck_assert_ptr_eq(r, l);
// start outside
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
- iListDel(&l, 20,-4);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
+ r = iListDel(&l, 20,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLength(l),4);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
// end outside
- iListDel(&l, 2,40);
+ r = iListDel(&l, 2,40);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLength(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
- iListEmptyF(&l);
+ r = iListEmptyF(&l);
+ ck_assert_ptr_eq(r, l);
// end negative and outside
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- listPush(&l, (void*)s3);
- listPush(&l, (void*)s4);
- iListDel(&l, 2,-40);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s3);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s4);
+ ck_assert_ptr_eq(r, l);
+ r = iListDel(&l, 2,-40);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLength(l),4);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
// end before start
- iListDel(&l, 3,2);
+ r = iListDel(&l, 3,2);
+ ck_assert_ptr_eq(r, null);
ck_assert_uint_eq(listLength(l),4);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[3], "4444");
- iListEmptyF(&l);
+ r = iListEmptyF(&l);
+ ck_assert_ptr_eq(r, l);
// negative start last element
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- iListDel(&l, -1,0);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = iListDel(&l, -1,0);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLength(l),1);
ck_assert_str_eq(l[0], "1");
- iListEmptyF(&l);
+ r = iListEmptyF(&l);
+ ck_assert_ptr_eq(r, l);
// start negative and outside (delete complete list because end is 0 (=len))
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- iListDel(&l, -3,0);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = iListDel(&l, -3,0);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLength(l),0);
ck_assert_ptr_eq(l[0], NULL);
// start = end
// (l is empty from previous test)
- listPush(&l, (void*)s1);
- listPush(&l, (void*)s2);
- iListDel(&l, 1,1);
+ r = listPush(&l, (void*)s1);
+ ck_assert_ptr_eq(r, l);
+ r = listPush(&l, (void*)s2);
+ ck_assert_ptr_eq(r, l);
+ r = iListDel(&l, 1,1);
+ ck_assert_ptr_eq(r, l);
ck_assert_uint_eq(listLength(l),2);
ck_assert_str_eq(l[0], "1");
ck_assert_str_eq(l[1], "22");
free(l);
// empty list
listEmpty(l);
- iListDel(&l, 0,0);
+ r = iListDel(&l, 0,0);
+ ck_assert_ptr_eq(r, null);
ck_assert(listIsEmpty(l));
- iListDel(&l, -1,0);
+ r = iListDel(&l, -1,0);
+ ck_assert_ptr_eq(r, null);
ck_assert(listIsEmpty(l));
free(l);
// NULL list
l = NULL;
- iListDel(&l, 2,-4);
+ r = iListDel(&l, 2,-4);
+ ck_assert_ptr_eq(r, null);
ck_assert_ptr_eq(l, NULL);
// NULL var
- iListDel(NULL, 2,-4);
+ r = iListDel(NULL, 2,-4);
+ ck_assert_ptr_eq(r, null);
END_TEST
@@ -17823,7 +20117,8 @@ END_TEST
START_TEST(getMonotonicTimeT)
- getMonotonicTime();
+ uint64_t r = getMonotonicTime();
+ ck_assert_uint_ne(r, 0);
END_TEST
@@ -18042,6 +20337,19 @@ Suite * libsheepySuite(void) {
tcase_add_test(tc_core, stripCtrlST);
tcase_add_test(tc_core, iStripCtrlST);
tcase_add_test(tc_core, bStripCtrlST);
+ tcase_add_test(tc_core, quoteST);
+ tcase_add_test(tc_core, bQuoteST);
+ tcase_add_test(tc_core, bLQuoteST);
+ tcase_add_test(tc_core, quoteLenST);
+ tcase_add_test(tc_core, escapeST);
+ tcase_add_test(tc_core, bEscapeST);
+ tcase_add_test(tc_core, bLEscapeST);
+ tcase_add_test(tc_core, escapeLenST);
+ tcase_add_test(tc_core, nibbleToHexT);
+ tcase_add_test(tc_core, cEscapeST);
+ tcase_add_test(tc_core, bCEscapeST);
+ tcase_add_test(tc_core, bLCEscapeST);
+ tcase_add_test(tc_core, cEscapeLenST);
tcase_add_test(tc_core, isNumberT);
tcase_add_test(tc_core, isIntT);
tcase_add_test(tc_core, parseIntT);
@@ -18394,13 +20702,13 @@ Suite * libsheepySuite(void) {
tcase_add_test(tc_core, iListDelT);
//tcase_add_test(tc_core, listSortT);
//tcase_add_test(tc_core, iListSortT);
- //tcase_add_test(tc_core, listEqST);
- //tcase_add_test(tc_core, listIndexOfST);
- //tcase_add_test(tc_core, listBinarySearchST);
- //tcase_add_test(tc_core, listUniqST);
- //tcase_add_test(tc_core, iListUniqST);
- //tcase_add_test(tc_core, listCompactST);
- //tcase_add_test(tc_core, iListCompactST);
+ //tcase_add_test(tc_core, listEqT);
+ //tcase_add_test(tc_core, listIndexOfT);
+ //tcase_add_test(tc_core, listBinarySearchT);
+ //tcase_add_test(tc_core, listUniqT);
+ //tcase_add_test(tc_core, iListUniqT);
+ //tcase_add_test(tc_core, listCompactT);
+ //tcase_add_test(tc_core, iListCompactT);
tcase_add_test(tc_core, ringInitT);
tcase_add_test(tc_core, ringEmptyT);
tcase_add_test(tc_core, ringIsEmptyT);