commit 3b3faba7b2d04667231ef7b65b19815a3e7fa14e
parent 0bf7cc66ad10c412ce7b75671e72f6c57c51efdf
Author: Remy Noulin <loader2x@gmail.com>
Date: Sat, 9 Jan 2021 13:33:36 +0100
fix bugs in libsheepy.c, add tests for libsheepy.c and libsheepySmall.c
release/libsheepy.c | 9 +-
src/json/libsheepyObjectCuTest.c | 1 +
src/json/libsheepyObjectTest.c | 2 +
src/libsheepy.c | 9 +-
src/libsheepyCuTest.c | 182 ++++++++++++++++++++++++++++++++++++---
src/libsheepySmallCuTest.c | 44 ++++++++++
src/libsheepySmallTest.c | 44 ++++++++++
src/libsheepyTest.c | 182 ++++++++++++++++++++++++++++++++++++---
8 files changed, 447 insertions(+), 26 deletions(-)
Diffstat:
8 files changed, 447 insertions(+), 26 deletions(-)
diff --git a/release/libsheepy.c b/release/libsheepy.c
@@ -51536,7 +51536,7 @@ char **iListInjectS(char ***list, intmax_t index, char *toInject) {
if (index) {
return(NULL);
}
- listPushS(list, toInject);
+ iListPushS(list, toInject);
return(*list);
}
@@ -51594,8 +51594,13 @@ char **iListInjectCharS(char ***list, intmax_t index, char toInject) {
return(NULL);
}
+ if (!*list && index) {
+ return(NULL);
+ }
+
charToS(s, toInject);
- return(listInjectS(*list, index, s));
+ *list = iListInjectS(list, index, strdup(s));
+ return(*list);
}
/**
diff --git a/src/json/libsheepyObjectCuTest.c b/src/json/libsheepyObjectCuTest.c
@@ -2344,6 +2344,7 @@ void toBasetT(CuTest *tc UNUSED) {
+
int main(int n UNUSED, char**v UNUSED) {
// disable btrace to make the test run faster
btraceDisable();
diff --git a/src/json/libsheepyObjectTest.c b/src/json/libsheepyObjectTest.c
@@ -2332,6 +2332,7 @@ END_TEST
+
Suite * libsheepySuite(void) {
Suite *s;
TCase *tc_core;
@@ -2367,6 +2368,7 @@ Suite * libsheepySuite(void) {
tcase_add_test(tc_core, toSmalltT);
tcase_add_test(tc_core, toBasetT);
+
suite_add_tcase(s, tc_core);
return s;
diff --git a/src/libsheepy.c b/src/libsheepy.c
@@ -51592,7 +51592,7 @@ char **iListInjectS(char ***list, intmax_t index, char *toInject) {
if (index) {
return(NULL);
}
- listPushS(list, toInject);
+ iListPushS(list, toInject);
return(*list);
}
@@ -51650,8 +51650,13 @@ char **iListInjectCharS(char ***list, intmax_t index, char toInject) {
return(NULL);
}
+ if (!*list && index) {
+ return(NULL);
+ }
+
charToS(s, toInject);
- return(listInjectS(*list, index, s));
+ *list = iListInjectS(list, index, strdup(s));
+ return(*list);
}
/**
diff --git a/src/libsheepyCuTest.c b/src/libsheepyCuTest.c
@@ -4348,34 +4348,34 @@ void bLicReplaceST(CuTest *tc UNUSED) {
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);
+ bLicReplaceS(s, sizeof s, "#","^^",1);
ck_assert_str_eq(s, "^^ee#ee#ad");
// replace one time
strcpy(s, "AA##ee##ee#");
- bLReplaceS(s, sizeof s, "##","|",1);
+ bLicReplaceS(s, sizeof s, "##","|",1);
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);
+ bLicReplaceS(s, sizeof s, "##",NULL,1);
ck_assert_str_eq(s, "AAee##ee#");
// empty string
bEmptyS(s);
- bLReplaceS(s, sizeof s, "##",NULL,1);
+ bLicReplaceS(s, sizeof s, "##",NULL,1);
ck_assert_str_eq(s, "");
// empty old delimiter
strcpy(s, "qwe");
- bLReplaceS(s, sizeof s, "","|",1);
+ bLicReplaceS(s, sizeof s, "","|",1);
ck_assert_str_eq(s, "qwe");
// NULL old delimiter
strcpy(s, "qwe");
- bLReplaceS(s, sizeof s, NULL,"|",1);
+ bLicReplaceS(s, sizeof s, NULL,"|",1);
ck_assert_str_eq(s, "qwe");
// size 0 - no change
strcpy(s, "qwe");
- bLReplaceS(s, 0, "q","|",1);
+ bLicReplaceS(s, 0, "q","|",1);
ck_assert_str_eq(s, "qwe");
// NULL var
- ck_assert_ptr_eq(bLReplaceS(NULL, sizeof s, "##","|",1), NULL);
+ ck_assert_ptr_eq(bLicReplaceS(NULL, sizeof s, "##","|",1), NULL);
}
@@ -14592,6 +14592,7 @@ void iListSliceST(CuTest *tc UNUSED) {
// end before start
listPushS(&l, "333");
listPushS(&l, "4444");
+ listPushS(&l, "55555");
iListSliceS(&l, 3,2);
ck_assert_uint_eq(listLengthS(l),0);
listFreeS(l);
@@ -15315,17 +15316,49 @@ void iListInjectST(CuTest *tc UNUSED) {
iListInjectS(&l, 0, NULL);
ck_assert_str_eq(l[0], "1");
listFreeS(l);
- // NULL list
+ // NULL list and non zero index
l = NULL;
- iListInjectS(&l, 0, NULL);
+ iListInjectS(&l, 1, "");
ck_assert_ptr_eq(l, NULL);
+ // NULL list and zero index
+ l = NULL;
+ iListInjectS(&l, 0, "aa");
+ ck_assert_str_eq(l[0], "aa");
+ free(l);
// NULL var
- iListInjectS(NULL, 0, NULL);
+ ck_assert_ptr_eq(iListInjectS(NULL, 0, ""), NULL);
}
+void iListInjectCharST(CuTest *tc UNUSED) {
+
+ char **l;
+
+ // insert
+ l = listCreateS("1","22");
+ iListInjectCharS(&l, 1, 'a');
+ ck_assert_uint_eq(listLengthS(l),3);
+ ck_assert_str_eq(l[0], "1");
+ ck_assert_str_eq(l[1], "a");
+ ck_assert_str_eq(l[2], "22");
+ listFreeS(l);
+ // NULL list and zero index
+ l = NULL;
+ iListInjectCharS(&l, 0, 'a');
+ ck_assert_str_eq(l[0], "a");
+ listFreeS(l);
+ // NULL list and non zero index
+ l = NULL;
+ iListInjectCharS(&l, 1, 'a');
+ ck_assert_ptr_eq(l, NULL);
+ // NULL var
+ ck_assert_ptr_eq(iListInjectCharS(NULL, 1, 'a'), NULL);
+
+}
+
+
void listDelST(CuTest *tc UNUSED) {
char **l = NULL;
@@ -15478,6 +15511,90 @@ void iListDelST(CuTest *tc UNUSED) {
}
+void iListRemoveST(CuTest *tc UNUSED) {
+
+ char **l = NULL;
+
+ // list negative index
+ listPushS(&l, "1");
+ iListPushS(&l, "22");
+ iListPushS(&l, "333");
+ listPushS(&l, "4444");
+ 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);
+ // start outside
+ listPushS(&l, "1");
+ listPushS(&l, "22");
+ iListPushS(&l, "333");
+ iListPushS(&l, "4444");
+ iListRemoveS(&l, 20,-4);
+ ck_assert_uint_eq(listLengthS(l),4);
+ ck_assert_str_eq(l[0], "1");
+ ck_assert_str_eq(l[3], "4444");
+ // end outside
+ iListRemoveS(&l, 2,40);
+ ck_assert_uint_eq(listLengthS(l),2);
+ ck_assert_str_eq(l[0], "1");
+ ck_assert_str_eq(l[1], "22");
+ iListEmptySF(&l);
+ // end negative and outside
+ listPushS(&l, "1");
+ listPushS(&l, "22");
+ listPushS(&l, "333");
+ listPushS(&l, "4444");
+ iListRemoveS(&l, 2,-40);
+ ck_assert_uint_eq(listLengthS(l),4);
+ ck_assert_str_eq(l[0], "1");
+ ck_assert_str_eq(l[3], "4444");
+ // end before start
+ iListRemoveS(&l, 3,2);
+ ck_assert_uint_eq(listLengthS(l),4);
+ ck_assert_str_eq(l[0], "1");
+ ck_assert_str_eq(l[3], "4444");
+ iListEmptySF(&l);
+ // negative start last element
+ listPushS(&l, "1");
+ iListPushS(&l, "22");
+ iListRemoveS(&l, -1,0);
+ ck_assert_uint_eq(listLengthS(l),1);
+ ck_assert_str_eq(l[0], "1");
+ iListEmptySF(&l);
+ // start negative and outside (delete complete list because end is 0 (=len))
+ iListPushS(&l, "1");
+ iListPushS(&l, "22");
+ 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");
+ iListRemoveS(&l, 1,1);
+ 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);
+ iListRemoveS(&l, 0,0);
+ ck_assert(listIsEmptyS(l));
+ iListRemoveS(&l, -1,0);
+ ck_assert(listIsEmptyS(l));
+ listFreeS(l);
+ // NULL list
+ l = NULL;
+ iListRemoveS(&l, 2,-4);
+ ck_assert_ptr_eq(l, NULL);
+ // NULL var
+ ck_assert_ptr_eq(iListRemoveS(NULL, 2,-4), NULL);
+
+
+}
+
+
void listDelElemST(CuTest *tc UNUSED) {
char **l = NULL;
@@ -15557,6 +15674,46 @@ void iListDelElemST(CuTest *tc UNUSED) {
}
+void iListRemoveElemST(CuTest *tc UNUSED) {
+
+ char **l = NULL;
+ char **r;
+
+ // positive index
+ listPushS(&l, "1");
+ iListPushS(&l, "22");
+ listPushS(&l, "333");
+ iListPushS(&l, "4444");
+ r = iListRemoveElemS(&l, 1);
+ ck_assert_ptr_ne(r, null);
+ ck_assert_str_eq(l[0], "1");
+ ck_assert_str_eq(l[1], "333");
+ ck_assert_str_eq(l[2], "4444");
+ ck_assert_ptr_eq(l[3], null);
+ // list negative index
+ r = iListRemoveElemS(&l, -1);
+ ck_assert_ptr_ne(r, null);
+ ck_assert_str_eq(l[0], "1");
+ ck_assert_str_eq(l[1], "333");
+ ck_assert_ptr_eq(l[2], null);
+ // index outside
+ ck_assert_ptr_eq(iListRemoveElemS(&l, 20), NULL);
+ ck_assert_ptr_eq(iListRemoveElemS(&l, -4), NULL);
+ listFreeS(l);
+ // empty list
+ listEmptyS(l)
+ ck_assert_ptr_eq(iListRemoveElemS(&l, 0), NULL);
+ ck_assert_ptr_eq(iListRemoveElemS(&l, -1), NULL);
+ listFreeS(l);
+ // NULL list
+ l = null;
+ ck_assert_ptr_eq(iListRemoveElemS(&l, 2), NULL);
+ ck_assert_ptr_eq(iListRemoveElemS(NULL, 2), NULL);
+
+
+}
+
+
void execOutT(CuTest *tc UNUSED) {
char **l;
@@ -18175,10 +18332,13 @@ int main(int n UNUSED, char**v UNUSED) {
SUITE_ADD_TEST(suite, listInjectST);
SUITE_ADD_TEST(suite, listInjectCharST);
SUITE_ADD_TEST(suite, iListInjectST);
+ SUITE_ADD_TEST(suite, iListInjectCharST);
SUITE_ADD_TEST(suite, listDelST);
SUITE_ADD_TEST(suite, iListDelST);
+ SUITE_ADD_TEST(suite, iListRemoveST);
SUITE_ADD_TEST(suite, listDelElemST);
SUITE_ADD_TEST(suite, iListDelElemST);
+ SUITE_ADD_TEST(suite, iListRemoveElemST);
SUITE_ADD_TEST(suite, execOutT);
SUITE_ADD_TEST(suite, systemOutfT);
SUITE_ADD_TEST(suite, systemfT);
diff --git a/src/libsheepySmallCuTest.c b/src/libsheepySmallCuTest.c
@@ -823,6 +823,27 @@ void sDictGetT(CuTest *tc UNUSED) {
}
+void sDictGetPT(CuTest *tc UNUSED) {
+
+ sDictt *o;
+ o = allocSDict();
+ // elements
+ sBoolt *b = allocSBool(false);
+ sDictPushTiny(&o, "a", (smallt *) b);
+ sContainert *c = allocSContainer(strdup("sheepy"));
+ sDictPushTiny(&o, "c", (smallt *) c);
+ sStringt *s = allocSStringTiny("");
+ sDictPushTiny(&o, "s", (smallt *) s);
+ sBoolt **bb = (sBoolt **)sDictGetP(o, "a");
+ ck_assert_uint_eq((*bb)->type, BOOL);
+ // invalid key
+ ck_assert_ptr_eq(sDictGetP(o, "X"), NULL);
+ free(c->data);
+ sDictFreeTiny(o);
+
+}
+
+
void sDictSetPT(CuTest *tc UNUSED) {
sDictt *o = NULL;
@@ -1117,6 +1138,27 @@ void sArrayGetT(CuTest *tc UNUSED) {
}
+void sArrayGetPT(CuTest *tc UNUSED) {
+
+ sArrayt *a = allocSArray();
+ sBoolt *b = allocSBool(false);
+ sArrayPushTiny(&a, (smallt *) b);
+ sDoublet *D = allocSDouble(10);
+ sArrayPushTiny(&a, (smallt *) D);
+ sStringt *s = allocSStringTiny("sheepy");
+ sArrayPushTiny(&a, (smallt *) s);
+ sArrayPushTiny(&a, NULL);
+ sArrayPushTiny(&a, NULL);
+ b = (sBoolt *) sArrayGetP(a, 0);
+ ck_assert(!b->value);
+ ck_assert_uint_eq(a->count, 5);
+ // TODO depends on defines SARRAY_REALLOC_STEPS and SARRAY_MIN_ELEMENTS
+ ck_assert_uint_eq(a->maxCount, 8);
+ sArrayFreeTiny(a);
+
+}
+
+
void sArraySetPT(CuTest *tc UNUSED) {
sArrayt *a = allocSArray();
@@ -1710,6 +1752,7 @@ int main(int n UNUSED, char**v UNUSED) {
SUITE_ADD_TEST(suite, sDictDuplicateT);
SUITE_ADD_TEST(suite, sArrayDuplicateT);
SUITE_ADD_TEST(suite, sDictGetT);
+ SUITE_ADD_TEST(suite, sDictGetPT);
SUITE_ADD_TEST(suite, sDictSetPT);
SUITE_ADD_TEST(suite, sDictSetT);
SUITE_ADD_TEST(suite, sDictPushT);
@@ -1721,6 +1764,7 @@ int main(int n UNUSED, char**v UNUSED) {
SUITE_ADD_TEST(suite, sArrayPopT);
SUITE_ADD_TEST(suite, sArrayDequeueT);
SUITE_ADD_TEST(suite, sArrayGetT);
+ SUITE_ADD_TEST(suite, sArrayGetPT);
SUITE_ADD_TEST(suite, sArraySetPT);
SUITE_ADD_TEST(suite, sArraySetT);
SUITE_ADD_TEST(suite, sArrayReverseT);
diff --git a/src/libsheepySmallTest.c b/src/libsheepySmallTest.c
@@ -812,6 +812,27 @@ START_TEST(sDictGetT)
END_TEST
+START_TEST(sDictGetPT)
+
+ sDictt *o;
+ o = allocSDict();
+ // elements
+ sBoolt *b = allocSBool(false);
+ sDictPushTiny(&o, "a", (smallt *) b);
+ sContainert *c = allocSContainer(strdup("sheepy"));
+ sDictPushTiny(&o, "c", (smallt *) c);
+ sStringt *s = allocSStringTiny("");
+ sDictPushTiny(&o, "s", (smallt *) s);
+ sBoolt **bb = (sBoolt **)sDictGetP(o, "a");
+ ck_assert_uint_eq((*bb)->type, BOOL);
+ // invalid key
+ ck_assert_ptr_eq(sDictGetP(o, "X"), NULL);
+ free(c->data);
+ sDictFreeTiny(o);
+
+END_TEST
+
+
START_TEST(sDictSetPT)
sDictt *o = NULL;
@@ -1106,6 +1127,27 @@ START_TEST(sArrayGetT)
END_TEST
+START_TEST(sArrayGetPT)
+
+ sArrayt *a = allocSArray();
+ sBoolt *b = allocSBool(false);
+ sArrayPushTiny(&a, (smallt *) b);
+ sDoublet *D = allocSDouble(10);
+ sArrayPushTiny(&a, (smallt *) D);
+ sStringt *s = allocSStringTiny("sheepy");
+ sArrayPushTiny(&a, (smallt *) s);
+ sArrayPushTiny(&a, NULL);
+ sArrayPushTiny(&a, NULL);
+ b = (sBoolt *) sArrayGetP(a, 0);
+ ck_assert(!b->value);
+ ck_assert_uint_eq(a->count, 5);
+ // TODO depends on defines SARRAY_REALLOC_STEPS and SARRAY_MIN_ELEMENTS
+ ck_assert_uint_eq(a->maxCount, 8);
+ sArrayFreeTiny(a);
+
+END_TEST
+
+
START_TEST(sArraySetPT)
sArrayt *a = allocSArray();
@@ -1702,6 +1744,7 @@ Suite * libsheepySuite(void) {
tcase_add_test(tc_core, sArrayTypeStringsT);
tcase_add_test(tc_core, sArrayTypesT);
tcase_add_test(tc_core, sDictGetT);
+ tcase_add_test(tc_core, sDictGetPT);
tcase_add_test(tc_core, sDictSetPT);
tcase_add_test(tc_core, sDictSetT);
tcase_add_test(tc_core, sDictPushT);
@@ -1713,6 +1756,7 @@ Suite * libsheepySuite(void) {
tcase_add_test(tc_core, sArrayPopT);
tcase_add_test(tc_core, sArrayDequeueT);
tcase_add_test(tc_core, sArrayGetT);
+ tcase_add_test(tc_core, sArrayGetPT);
tcase_add_test(tc_core, sArraySetPT);
tcase_add_test(tc_core, sArraySetT);
tcase_add_test(tc_core, sArrayReverseT);
diff --git a/src/libsheepyTest.c b/src/libsheepyTest.c
@@ -4337,34 +4337,34 @@ START_TEST(bLicReplaceST)
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);
+ bLicReplaceS(s, sizeof s, "#","^^",1);
ck_assert_str_eq(s, "^^ee#ee#ad");
// replace one time
strcpy(s, "AA##ee##ee#");
- bLReplaceS(s, sizeof s, "##","|",1);
+ bLicReplaceS(s, sizeof s, "##","|",1);
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);
+ bLicReplaceS(s, sizeof s, "##",NULL,1);
ck_assert_str_eq(s, "AAee##ee#");
// empty string
bEmptyS(s);
- bLReplaceS(s, sizeof s, "##",NULL,1);
+ bLicReplaceS(s, sizeof s, "##",NULL,1);
ck_assert_str_eq(s, "");
// empty old delimiter
strcpy(s, "qwe");
- bLReplaceS(s, sizeof s, "","|",1);
+ bLicReplaceS(s, sizeof s, "","|",1);
ck_assert_str_eq(s, "qwe");
// NULL old delimiter
strcpy(s, "qwe");
- bLReplaceS(s, sizeof s, NULL,"|",1);
+ bLicReplaceS(s, sizeof s, NULL,"|",1);
ck_assert_str_eq(s, "qwe");
// size 0 - no change
strcpy(s, "qwe");
- bLReplaceS(s, 0, "q","|",1);
+ bLicReplaceS(s, 0, "q","|",1);
ck_assert_str_eq(s, "qwe");
// NULL var
- ck_assert_ptr_eq(bLReplaceS(NULL, sizeof s, "##","|",1), NULL);
+ ck_assert_ptr_eq(bLicReplaceS(NULL, sizeof s, "##","|",1), NULL);
END_TEST
@@ -14581,6 +14581,7 @@ START_TEST(iListSliceST)
// end before start
listPushS(&l, "333");
listPushS(&l, "4444");
+ listPushS(&l, "55555");
iListSliceS(&l, 3,2);
ck_assert_uint_eq(listLengthS(l),0);
listFreeS(l);
@@ -15304,17 +15305,49 @@ START_TEST(iListInjectST)
iListInjectS(&l, 0, NULL);
ck_assert_str_eq(l[0], "1");
listFreeS(l);
- // NULL list
+ // NULL list and non zero index
l = NULL;
- iListInjectS(&l, 0, NULL);
+ iListInjectS(&l, 1, "");
ck_assert_ptr_eq(l, NULL);
+ // NULL list and zero index
+ l = NULL;
+ iListInjectS(&l, 0, "aa");
+ ck_assert_str_eq(l[0], "aa");
+ free(l);
// NULL var
- iListInjectS(NULL, 0, NULL);
+ ck_assert_ptr_eq(iListInjectS(NULL, 0, ""), NULL);
END_TEST
+START_TEST(iListInjectCharST)
+
+ char **l;
+
+ // insert
+ l = listCreateS("1","22");
+ iListInjectCharS(&l, 1, 'a');
+ ck_assert_uint_eq(listLengthS(l),3);
+ ck_assert_str_eq(l[0], "1");
+ ck_assert_str_eq(l[1], "a");
+ ck_assert_str_eq(l[2], "22");
+ listFreeS(l);
+ // NULL list and zero index
+ l = NULL;
+ iListInjectCharS(&l, 0, 'a');
+ ck_assert_str_eq(l[0], "a");
+ listFreeS(l);
+ // NULL list and non zero index
+ l = NULL;
+ iListInjectCharS(&l, 1, 'a');
+ ck_assert_ptr_eq(l, NULL);
+ // NULL var
+ ck_assert_ptr_eq(iListInjectCharS(NULL, 1, 'a'), NULL);
+
+END_TEST
+
+
START_TEST(listDelST)
char **l = NULL;
@@ -15467,6 +15500,90 @@ START_TEST(iListDelST)
END_TEST
+START_TEST(iListRemoveST)
+
+ char **l = NULL;
+
+ // list negative index
+ listPushS(&l, "1");
+ iListPushS(&l, "22");
+ iListPushS(&l, "333");
+ listPushS(&l, "4444");
+ 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);
+ // start outside
+ listPushS(&l, "1");
+ listPushS(&l, "22");
+ iListPushS(&l, "333");
+ iListPushS(&l, "4444");
+ iListRemoveS(&l, 20,-4);
+ ck_assert_uint_eq(listLengthS(l),4);
+ ck_assert_str_eq(l[0], "1");
+ ck_assert_str_eq(l[3], "4444");
+ // end outside
+ iListRemoveS(&l, 2,40);
+ ck_assert_uint_eq(listLengthS(l),2);
+ ck_assert_str_eq(l[0], "1");
+ ck_assert_str_eq(l[1], "22");
+ iListEmptySF(&l);
+ // end negative and outside
+ listPushS(&l, "1");
+ listPushS(&l, "22");
+ listPushS(&l, "333");
+ listPushS(&l, "4444");
+ iListRemoveS(&l, 2,-40);
+ ck_assert_uint_eq(listLengthS(l),4);
+ ck_assert_str_eq(l[0], "1");
+ ck_assert_str_eq(l[3], "4444");
+ // end before start
+ iListRemoveS(&l, 3,2);
+ ck_assert_uint_eq(listLengthS(l),4);
+ ck_assert_str_eq(l[0], "1");
+ ck_assert_str_eq(l[3], "4444");
+ iListEmptySF(&l);
+ // negative start last element
+ listPushS(&l, "1");
+ iListPushS(&l, "22");
+ iListRemoveS(&l, -1,0);
+ ck_assert_uint_eq(listLengthS(l),1);
+ ck_assert_str_eq(l[0], "1");
+ iListEmptySF(&l);
+ // start negative and outside (delete complete list because end is 0 (=len))
+ iListPushS(&l, "1");
+ iListPushS(&l, "22");
+ 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");
+ iListRemoveS(&l, 1,1);
+ 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);
+ iListRemoveS(&l, 0,0);
+ ck_assert(listIsEmptyS(l));
+ iListRemoveS(&l, -1,0);
+ ck_assert(listIsEmptyS(l));
+ listFreeS(l);
+ // NULL list
+ l = NULL;
+ iListRemoveS(&l, 2,-4);
+ ck_assert_ptr_eq(l, NULL);
+ // NULL var
+ ck_assert_ptr_eq(iListRemoveS(NULL, 2,-4), NULL);
+
+
+END_TEST
+
+
START_TEST(listDelElemST)
char **l = NULL;
@@ -15546,6 +15663,46 @@ START_TEST(iListDelElemST)
END_TEST
+START_TEST(iListRemoveElemST)
+
+ char **l = NULL;
+ char **r;
+
+ // positive index
+ listPushS(&l, "1");
+ iListPushS(&l, "22");
+ listPushS(&l, "333");
+ iListPushS(&l, "4444");
+ r = iListRemoveElemS(&l, 1);
+ ck_assert_ptr_ne(r, null);
+ ck_assert_str_eq(l[0], "1");
+ ck_assert_str_eq(l[1], "333");
+ ck_assert_str_eq(l[2], "4444");
+ ck_assert_ptr_eq(l[3], null);
+ // list negative index
+ r = iListRemoveElemS(&l, -1);
+ ck_assert_ptr_ne(r, null);
+ ck_assert_str_eq(l[0], "1");
+ ck_assert_str_eq(l[1], "333");
+ ck_assert_ptr_eq(l[2], null);
+ // index outside
+ ck_assert_ptr_eq(iListRemoveElemS(&l, 20), NULL);
+ ck_assert_ptr_eq(iListRemoveElemS(&l, -4), NULL);
+ listFreeS(l);
+ // empty list
+ listEmptyS(l)
+ ck_assert_ptr_eq(iListRemoveElemS(&l, 0), NULL);
+ ck_assert_ptr_eq(iListRemoveElemS(&l, -1), NULL);
+ listFreeS(l);
+ // NULL list
+ l = null;
+ ck_assert_ptr_eq(iListRemoveElemS(&l, 2), NULL);
+ ck_assert_ptr_eq(iListRemoveElemS(NULL, 2), NULL);
+
+
+END_TEST
+
+
START_TEST(execOutT)
char **l;
@@ -18168,10 +18325,13 @@ Suite * libsheepySuite(void) {
tcase_add_test(tc_core, listInjectST);
tcase_add_test(tc_core, listInjectCharST);
tcase_add_test(tc_core, iListInjectST);
+ tcase_add_test(tc_core, iListInjectCharST);
tcase_add_test(tc_core, listDelST);
tcase_add_test(tc_core, iListDelST);
+ tcase_add_test(tc_core, iListRemoveST);
tcase_add_test(tc_core, listDelElemST);
tcase_add_test(tc_core, iListDelElemST);
+ tcase_add_test(tc_core, iListRemoveElemST);
tcase_add_test(tc_core, execOutT);
tcase_add_test(tc_core, systemOutfT);
tcase_add_test(tc_core, systemfT);