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 d20b5a9c9b4c066ce435a57747385e65b6f976b9..e5a25507cbc4d56a27b4d826310fc078d0b6ad00 100644 (file)
@@ -253,7 +253,7 @@ static void TestMSetHashlist (void)
                                             ChrPtr(MSetStr), 
                                             MessageNumbers[nTest][InMSet][j]);
                                CU_FAIL(ChrPtr(Assert));
-                               printf(ChrPtr(Assert));
+                               printf("%s", ChrPtr(Assert));
                        }
                        else
                        {
@@ -273,7 +273,7 @@ static void TestMSetHashlist (void)
                                             ChrPtr(MSetStr), 
                                             MessageNumbers[nTest][NotInMSet][j]);
                                CU_FAIL(ChrPtr(Assert));
-                               printf(ChrPtr(Assert));
+                               printf("%s", ChrPtr(Assert));
                        }
                        else
                        {
index b3446081abcd86e9cc694a6f8b6dca98bf23ce66..24ca8d1d34e2930fa06a4d4881014e51e14b4ebd 100644 (file)
@@ -137,7 +137,6 @@ static void worker_entry(testfunc F)
 {
        int ssock;
        int i = 0;
-       int fail_this_transaction = 0;
        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 */
-               fail_this_transaction = 0;
                ssock = -1; 
                errno = EAGAIN;
                do {
index 3bac8bbeb04f3dbc6d250bcd2622cb348d981a33..2515c298e6ee909f7be6ccbfe401a48a311284d5 100644 (file)
@@ -621,7 +621,7 @@ static void AddStrBufSimpleTests(void)
 
 int main(int argc, char* argv[])
 {
-       int i;
+       ///int i;
        setvbuf(stdout, NULL, _IONBF, 0);
 
        StartLibCitadel(8);
index b06227a14b18543e897adf012409eaf1cf316837..fb67fb5a750978d631dedd242d310a5378cc3f5e 100644 (file)
@@ -93,6 +93,7 @@ static void TestStripAllBut(void) {
        };
 
        char foo[128];
+       StrBuf *Test = NewStrBuf();;
 
        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]);
+
+
+               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]);
        }
 }