Tests: add StrBufStripAllBut and compare it to stripallbut
authorWilfried Goesgens <dothebart@citadel.org>
Tue, 8 Oct 2013 22:02:33 +0000 (00:02 +0200)
committerWilfried Goesgens <dothebart@citadel.org>
Tue, 8 Oct 2013 22:02:33 +0000 (00:02 +0200)
  - fix some compiler warnings

libcitadel/tests/hashlist_test.c
libcitadel/tests/stringbuf_IO_test.c
libcitadel/tests/stringbuf_test.c
libcitadel/tests/stripallbut_test.c

index d20b5a9..e5a2550 100644 (file)
@@ -253,7 +253,7 @@ static void TestMSetHashlist (void)
                                             ChrPtr(MSetStr), 
                                             MessageNumbers[nTest][InMSet][j]);
                                CU_FAIL(ChrPtr(Assert));
                                             ChrPtr(MSetStr), 
                                             MessageNumbers[nTest][InMSet][j]);
                                CU_FAIL(ChrPtr(Assert));
-                               printf(ChrPtr(Assert));
+                               printf("%s", ChrPtr(Assert));
                        }
                        else
                        {
                        }
                        else
                        {
@@ -273,7 +273,7 @@ static void TestMSetHashlist (void)
                                             ChrPtr(MSetStr), 
                                             MessageNumbers[nTest][NotInMSet][j]);
                                CU_FAIL(ChrPtr(Assert));
                                             ChrPtr(MSetStr), 
                                             MessageNumbers[nTest][NotInMSet][j]);
                                CU_FAIL(ChrPtr(Assert));
-                               printf(ChrPtr(Assert));
+                               printf("%s", ChrPtr(Assert));
                        }
                        else
                        {
                        }
                        else
                        {
index b344608..24ca8d1 100644 (file)
@@ -137,7 +137,6 @@ static void worker_entry(testfunc F)
 {
        int ssock;
        int i = 0;
 {
        int ssock;
        int i = 0;
-       int fail_this_transaction = 0;
        int ret;
        struct timeval tv;
        fd_set readset, tempset;
        int ret;
        struct timeval tv;
        fd_set readset, tempset;
@@ -150,7 +149,6 @@ static void worker_entry(testfunc F)
 
        do {
                /* Only one thread can accept at a time */
 
        do {
                /* Only one thread can accept at a time */
-               fail_this_transaction = 0;
                ssock = -1; 
                errno = EAGAIN;
                do {
                ssock = -1; 
                errno = EAGAIN;
                do {
index 3bac8bb..2515c29 100644 (file)
@@ -621,7 +621,7 @@ static void AddStrBufSimpleTests(void)
 
 int main(int argc, char* argv[])
 {
 
 int main(int argc, char* argv[])
 {
-       int i;
+       ///int i;
        setvbuf(stdout, NULL, _IONBF, 0);
 
        StartLibCitadel(8);
        setvbuf(stdout, NULL, _IONBF, 0);
 
        StartLibCitadel(8);
index b06227a..fb67fb5 100644 (file)
@@ -93,6 +93,7 @@ static void TestStripAllBut(void) {
        };
 
        char foo[128];
        };
 
        char foo[128];
+       StrBuf *Test = NewStrBuf();;
 
        for (i=0; i<(sizeof(teststrings) / sizeof (char *)); ++i) {
                strcpy(foo, teststrings[i]);
 
        for (i=0; i<(sizeof(teststrings) / sizeof (char *)); ++i) {
                strcpy(foo, teststrings[i]);
@@ -100,6 +101,15 @@ static void TestStripAllBut(void) {
 
                CU_ASSERT_STRING_EQUAL(foo, strippedstrings[i]);
                CU_ASSERT_EQUAL(strlen(foo), strippedlens[i]);
 
                CU_ASSERT_STRING_EQUAL(foo, strippedstrings[i]);
                CU_ASSERT_EQUAL(strlen(foo), strippedlens[i]);
+
+
+               StrBufPlain(Test, teststrings[i], -1);
+               StrBufStripAllBut(Test, '<', '>');
+
+               CU_ASSERT_STRING_EQUAL(ChrPtr(Test), strippedstrings[i]);
+               CU_ASSERT_EQUAL(StrLength(Test), strippedlens[i]);
+
+               printf("[%s] -> [%s][%s][%s]\n", teststrings[i], foo, ChrPtr(Test), strippedstrings[i]);
        }
 }
 
        }
 }