Back to index

libcitadel  8.12
stringbuf_test.c
Go to the documentation of this file.
00001 /*
00002  *  CUnit - A Unit testing framework library for C.
00003  *  Copyright (C) 2001  Anil Kumar
00004  *  
00005  *  This library is open source software; you can redistribute it and/or
00006  *  modify it under the terms of the GNU Library General Public
00007  *  License as published by the Free Software Foundation; either
00008  *  version 2 of the License, or (at your option) any later version.
00009  *
00010  *  This library is distributed in the hope that it will be useful,
00011  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  *  Library General Public License for more details.
00014  */
00015 
00016 #include <stdio.h>
00017 #include <stdlib.h>
00018 #include <string.h>
00019 #include <stdarg.h>
00020 
00021 #include "stringbuf_test.h"
00022 #define SHOW_ME_VAPPEND_PRINTF
00023 #include "../lib/libcitadel.h"
00024 
00025 int Quiet = 0;
00026 /*
00027  * Stolen from wc_printf; we need to test that other printf too... 
00028  */
00029 static void TEST_StrBufAppendPrintf(StrBuf *WBuf, const char *format,...)
00030 {
00031        va_list arg_ptr;
00032 
00033        if (WBuf == NULL)
00034               return;
00035 
00036        va_start(arg_ptr, format);
00037        StrBufVAppendPrintf(WBuf, format, arg_ptr);
00038        va_end(arg_ptr);
00039 }
00040 
00041 static void TestRevalidateStrBuf(StrBuf *Buf)
00042 {
00043        CU_ASSERT(strlen(ChrPtr(Buf)) == StrLength(Buf));
00044 }
00045 
00046 
00047 static void TestCreateBuf(void)
00048 {
00049        StrBuf *Buf;
00050        StrBuf *Buf2;
00051        long len;
00052        long i;
00053 
00054        Buf = NewStrBuf();
00055        CU_ASSERT(Buf != NULL);
00056        FreeStrBuf(&Buf);
00057 
00058        Buf = NewStrBufPlain(ChrPtr(NULL), StrLength(NULL));
00059        CU_ASSERT(Buf != NULL);
00060        FreeStrBuf(&Buf);
00061 
00062        /* make it alloc a bigger buffer... */
00063        Buf = NewStrBufPlain(NULL, SIZ);
00064        CU_ASSERT(Buf != NULL);
00065        FreeStrBuf(&Buf);
00066 
00067 
00068        Buf = NewStrBufDup(NULL);
00069        CU_ASSERT(Buf != NULL);
00070        StrBufPlain(Buf, "abc", -1);
00071        TestRevalidateStrBuf(Buf);
00072        StrBufPlain(Buf, HKEY("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"));
00073        TestRevalidateStrBuf(Buf);
00074        FreeStrBuf(&Buf);
00075 
00076        FlushStrBuf(NULL);
00077        FLUSHStrBuf(NULL);
00078 
00079        CU_ASSERT(Buf == NULL);
00080        Buf = NewStrBufPlain(HKEY("ABC"));
00081        TestRevalidateStrBuf(Buf);
00082        CU_ASSERT(StrLength(Buf) == 3);
00083        CU_ASSERT_NSTRING_EQUAL("ABC", ChrPtr(Buf), 3);
00084 
00085        len = StrLength(Buf);
00086        for (i=0; i< 500; i ++)
00087        {
00088               StrBufAppendBufPlain(Buf, HKEY("ABC"), 0);
00089               len += 3;
00090               CU_ASSERT(StrLength(Buf) == len);
00091        }      
00092        StrBufShrinkToFit(Buf, 1);
00093        FlushStrBuf(Buf);
00094        CU_ASSERT(StrLength(Buf) == 0);
00095        ReAdjustEmptyBuf(Buf, 1, 1);
00096        TestRevalidateStrBuf(Buf);
00097        FreeStrBuf(&Buf);
00098        CU_ASSERT(Buf == NULL);
00099        
00100        Buf = NewStrBufPlain(HKEY("ABC"));
00101        TestRevalidateStrBuf(Buf);
00102        len = StrLength(Buf);
00103        for (i=0; i< 500; i ++)
00104        {
00105               StrBufAppendPrintf(Buf, "%s", "ABC");
00106               len += 3;
00107               CU_ASSERT(StrLength(Buf) == len);         
00108        }
00109        TestRevalidateStrBuf(Buf);
00110        StrBufShrinkToFit(Buf, 1);
00111        TestRevalidateStrBuf(Buf);
00112        FreeStrBuf(&Buf);
00113 
00114 
00115        Buf = NewStrBufPlain(HKEY("ABC"));
00116        Buf2 = NewStrBufPlain(HKEY("------"));
00117        TestRevalidateStrBuf(Buf);
00118        len = StrLength(Buf);
00119        for (i=0; i< 50; i ++)
00120        {
00121               StrBufPrintf(Buf, "%s", ChrPtr(Buf2));
00122               CU_ASSERT(StrLength(Buf) == StrLength(Buf2));           
00123 
00124               StrBufAppendBufPlain(Buf2, HKEY("ABCDEFG"), 0);
00125        }
00126        TestRevalidateStrBuf(Buf);
00127        StrBufShrinkToFit(Buf, 1);
00128        TestRevalidateStrBuf(Buf);
00129        FreeStrBuf(&Buf);
00130        FreeStrBuf(&Buf2);   
00131 
00132 
00133        Buf = NewStrBufPlain(HKEY("ABC"));
00134        TestRevalidateStrBuf(Buf);
00135        len = StrLength(Buf);
00136        for (i=0; i< 500; i ++)
00137        {
00138               TEST_StrBufAppendPrintf(Buf, "%s", "ABC");
00139               len += 3;
00140               CU_ASSERT(StrLength(Buf) == len);         
00141        }
00142        TestRevalidateStrBuf(Buf);
00143        StrBufShrinkToFit(Buf, 1);
00144        TestRevalidateStrBuf(Buf);
00145 
00146 
00147        Buf2 = NewStrBufDup(Buf);
00148        CU_ASSERT(StrLength(Buf) == StrLength(Buf2));           
00149        
00150        CU_ASSERT_NSTRING_EQUAL(ChrPtr(Buf2), ChrPtr(Buf), StrLength(Buf2));
00151        
00152        CU_ASSERT(StrBufIsNumber(Buf) == 0);
00153 
00154        FlushStrBuf(Buf2);
00155        CU_ASSERT(StrLength(Buf2) == 0);
00156 
00157        FLUSHStrBuf(Buf);
00158        CU_ASSERT(StrLength(Buf) == 0);
00159 
00160        HFreeStrBuf(NULL);
00161        HFreeStrBuf(Buf2);
00162        CU_ASSERT(Buf2 != NULL);
00163 
00164        FreeStrBuf(&Buf);
00165        CU_ASSERT(Buf == NULL);
00166        
00167 }
00168 
00169 
00170 
00171 
00172 static void TestBufNumbers(void)
00173 {
00174        StrBuf *Buf;
00175        StrBuf *Buf2;
00176        StrBuf *Buf3;
00177        char *ch;
00178        int i;
00179 
00180        Buf2 = NewStrBuf();
00181        Buf3 = NewStrBufPlain(HKEY("abcd"));
00182        Buf = NewStrBufPlain(HKEY("123456"));
00183        CU_ASSERT(StrBufIsNumber(Buf) == 1);
00184        CU_ASSERT(StrBufIsNumber(NULL) == 0);
00185        CU_ASSERT(StrBufIsNumber(Buf2) == 0);
00186        CU_ASSERT(StrBufIsNumber(Buf3) == 0);
00187 
00188        CU_ASSERT(StrTol(Buf) == 123456);
00189        CU_ASSERT(StrTol(NULL) == 0);
00190        CU_ASSERT(StrTol(Buf2) == 0);
00191 
00192        CU_ASSERT(StrToi(Buf) == 123456);
00193        CU_ASSERT(StrToi(NULL) == 0);
00194        CU_ASSERT(StrToi(Buf2) == 0);
00195        ch = SmashStrBuf(NULL);
00196        CU_ASSERT(ch == NULL);
00197        i = StrLength(Buf);
00198        ch = SmashStrBuf(&Buf);
00199        CU_ASSERT(strlen(ch) == i);
00200        free(ch);
00201        FreeStrBuf(&Buf2);
00202        FreeStrBuf(&Buf3);
00203 }
00204 
00205 static void TestStrBufPeek(void)
00206 {
00207        StrBuf *Buf;
00208        const char *pch;
00209 
00210        Buf = NewStrBufPlain(HKEY("0123456"));
00211        pch = ChrPtr(Buf);
00212 
00213        CU_ASSERT(StrBufPeek(NULL, pch + 4, -1, 'A') == -1);
00214 
00215        CU_ASSERT(StrBufPeek(Buf, pch + 4, -1, 'A') == 4);
00216        CU_ASSERT_STRING_EQUAL(ChrPtr(Buf), "0123A56");
00217 
00218        CU_ASSERT(StrBufPeek(Buf, pch - 1, -1, 'A') == -1);
00219        CU_ASSERT_STRING_EQUAL(ChrPtr(Buf), "0123A56");
00220 
00221        CU_ASSERT(StrBufPeek(Buf, pch + 10, -1, 'A') == -1);
00222        CU_ASSERT_STRING_EQUAL(ChrPtr(Buf), "0123A56");
00223 
00224        CU_ASSERT(StrBufPeek(Buf, NULL, -1, 'A') == -1);
00225        CU_ASSERT_STRING_EQUAL(ChrPtr(Buf), "0123A56");
00226 
00227        CU_ASSERT(StrBufPeek(Buf, NULL, 10, 'A') == -1);
00228        CU_ASSERT_STRING_EQUAL(ChrPtr(Buf), "0123A56");
00229 
00230        CU_ASSERT(StrBufPeek(Buf, NULL, 5, 'A') == 5);
00231        CU_ASSERT_STRING_EQUAL(ChrPtr(Buf), "0123AA6");
00232        FreeStrBuf(&Buf);
00233 }
00234 
00235 static void TestBufStringManipulation(void)
00236 {
00237        long len, i = 0;
00238        StrBuf *dest = NewStrBuf ();
00239        StrBuf *Buf = NewStrBufPlain(HKEY("1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"));
00240 
00241        StrBufSub(dest, Buf, -5, i);
00242        len = StrLength(Buf);
00243        for (i = 0; i < len + 10; i++)
00244        {
00245               StrBufSub(dest, Buf, 5, i);
00246               if (i + 5 < len)
00247               {
00248                      CU_ASSERT(StrLength(dest) == i);
00249               }
00250               else
00251               {
00252                      CU_ASSERT(StrLength(dest) == len - 5);
00253               }
00254        }
00255        FreeStrBuf(&dest);
00256        dest = NewStrBuf ();
00257        StrBufSub(dest, Buf, -5, 200);
00258 
00259        StrBufCutLeft(Buf, 5);
00260        CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"67890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
00261        CU_ASSERT(StrLength(Buf) == 95);
00262 
00263        StrBufCutRight(Buf, 5);
00264        CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345");
00265        CU_ASSERT(StrLength(Buf) == 90);
00266 
00267        StrBufCutAt(Buf, 80, NULL);
00268        CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"67890123456789012345678901234567890123456789012345678901234567890123456789012345");
00269        CU_ASSERT(StrLength(Buf) == 80);
00270 
00271        StrBufCutAt(Buf, -1, ChrPtr(Buf) + 70);
00272        CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"6789012345678901234567890123456789012345678901234567890123456789012345");
00273        CU_ASSERT(StrLength(Buf) == 70);
00274 
00275 
00276        StrBufCutAt(Buf, 0, ChrPtr(Buf) + 60);
00277        CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"678901234567890123456789012345678901234567890123456789012345");
00278        CU_ASSERT(StrLength(Buf) == 60);
00279 
00280        StrBufCutAt(Buf, 0, ChrPtr(Buf) + 70);
00281        CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"678901234567890123456789012345678901234567890123456789012345");
00282        CU_ASSERT(StrLength(Buf) == 60);
00283 
00284        StrBufCutAt(Buf, 70, NULL);
00285        CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"678901234567890123456789012345678901234567890123456789012345");
00286        CU_ASSERT(StrLength(Buf) == 60);
00287 
00288 
00289        StrBufCutLeft(Buf, 70);
00290        CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"");
00291        CU_ASSERT(StrLength(Buf) == 0);
00292 
00293        StrBufPlain(Buf, HKEY("678901234567890123456789012345678901234567890123456789012345"));
00294        StrBufCutRight(Buf, 70);
00295        CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"");
00296        CU_ASSERT(StrLength(Buf) == 0);
00297 
00298        FreeStrBuf(&dest);
00299        FreeStrBuf(&Buf);
00300 
00301        Buf = NewStrBufPlain(HKEY(" \tabc\t "));
00302        StrBufTrim(Buf);
00303        CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"abc");
00304        CU_ASSERT(StrLength(Buf) == 3);
00305 
00306        StrBufUpCase(NULL);
00307        FlushStrBuf(Buf);
00308        StrBufUpCase(Buf);
00309        StrBufPlain(Buf, HKEY("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"));
00310        StrBufUpCase(Buf);
00311 
00312        CU_ASSERT_STRING_EQUAL(ChrPtr(Buf), "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
00313 
00314 
00315        StrBufLowerCase(NULL);
00316        FlushStrBuf(Buf);
00317        StrBufLowerCase(Buf);
00318        StrBufPlain(Buf, HKEY("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"));
00319        StrBufLowerCase(Buf);
00320 
00321        CU_ASSERT_STRING_EQUAL(ChrPtr(Buf), "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789");
00322 
00323 
00324        FreeStrBuf(&Buf);
00325 
00326 }
00327 
00328 static void NextTokenizerIterateBuf(StrBuf *Buf, int NTokens)
00329 {
00330        long FoundTokens;
00331        const char *pCh = NULL;
00332        StrBuf *Buf2;
00333        long CountTokens = 0;
00334        long HaveNextToken = 0;
00335        long HaveNextTokenF = 0;
00336 
00337        TestRevalidateStrBuf(Buf);
00338        FoundTokens = StrBufNum_tokens(Buf, ',');
00339        if (!Quiet) 
00340               printf("\n\nTemplate: >%s< %d, %ld\n", 
00341                      ChrPtr(Buf), 
00342                      NTokens, 
00343                      FoundTokens);
00344 
00345        CU_ASSERT(FoundTokens == NTokens);
00346 
00347        Buf2 = NewStrBuf();
00348        while (HaveNextToken = StrBufHaveNextToken(Buf, &pCh),
00349               HaveNextTokenF = StrBufExtract_NextToken(Buf2, Buf, &pCh, ','),
00350               (HaveNextTokenF>= 0))
00351        {
00352               CountTokens++;
00353               
00354               if (!Quiet) printf("Token: >%s< >%s< %ld:%ld\n", 
00355                                ChrPtr(Buf2), 
00356                                ((pCh != NULL) && (pCh != StrBufNOTNULL))? pCh : "N/A", 
00357                                HaveNextToken, 
00358                                HaveNextTokenF);
00359               TestRevalidateStrBuf(Buf2);
00360 
00361               CU_ASSERT(HaveNextToken == (HaveNextTokenF >= 0));
00362               
00363               CU_ASSERT(CountTokens <= NTokens);
00364        } 
00365        CU_ASSERT(HaveNextToken == (HaveNextTokenF >= 0));
00366        FreeStrBuf(&Buf2);
00367 }
00368 
00369 
00370 
00371 static void TestNextTokenizer_EndWithEmpty(void)
00372 {
00373        StrBuf *Buf;
00374 
00375        Buf = NewStrBufPlain(HKEY("abc,abc, 1, ,,"));
00376        NextTokenizerIterateBuf(Buf, 6);
00377        FreeStrBuf(&Buf);
00378 }
00379 
00380 static void TestNextTokenizer_StartWithEmpty(void)
00381 {
00382        StrBuf *Buf;
00383 
00384        Buf = NewStrBufPlain(HKEY(",cde,abc, 1, ,,bbb"));
00385        NextTokenizerIterateBuf(Buf, 7);
00386        FreeStrBuf(&Buf);
00387 }
00388 
00389 static void TestNextTokenizer_Empty(void)
00390 {
00391        StrBuf *Buf;
00392 
00393        Buf = NewStrBufPlain(HKEY(""));
00394        NextTokenizerIterateBuf(Buf, 0);
00395        FreeStrBuf(&Buf);
00396 }
00397 
00398 static void TestNextTokenizer_TwoEmpty(void)
00399 {
00400        StrBuf *Buf;
00401 
00402        Buf = NewStrBufPlain(HKEY(","));
00403        NextTokenizerIterateBuf(Buf, 2);
00404        FreeStrBuf(&Buf);
00405 }
00406 
00407 static void TestNextTokenizer_One(void)
00408 {
00409        StrBuf *Buf;
00410 
00411        Buf = NewStrBufPlain(HKEY("one"));
00412        NextTokenizerIterateBuf(Buf, 1);
00413        FreeStrBuf(&Buf);
00414 }
00415 
00416 static void TestNextTokenizer_Sequence(void)
00417 {
00418        StrBuf *Buf;
00419         char *teststring = "40:24524,24662,24673,27869:27935,28393,28426,31247:31258,31731,31749,31761,31778,31782,31801:31803,31813,31904,31915,33708,33935,34619,34672,34720:34723,34766,34835,37594,38854,39235,39942,40030,40142,40520,40815,40907,41201,41578,41781,41954,42292,43110,43565,43801,43998,44180,44241,44295,44401,44561,44635,44798,44861,44946,45022,45137:45148,45166,45179,45707,47114,47141:47157,47194,47314,47349,47386,47489,47496,47534:47543,54460,54601,54637:54652";
00420         Buf = NewStrBufPlain(teststring, -1);
00421        NextTokenizerIterateBuf(Buf, 67);
00422        FreeStrBuf(&Buf);
00423 }
00424 
00425 
00426 
00427 static void NextLineterateBuf(StrBuf *Buf, int NLines)
00428 {
00429        int n = 0;
00430        const char *pCh = NULL;
00431        StrBuf *OneLine;
00432        StrBuf *ConcatenatedLines;
00433        long CountTokens = 0;
00434        
00435        TestRevalidateStrBuf(Buf);
00436                           
00437        OneLine = NewStrBuf();
00438        ConcatenatedLines = NewStrBuf();
00439 
00440        if (!Quiet) printf("\n");
00441 
00442        if (StrLength(Buf) > 0) 
00443               do 
00444               {
00445                      n = StrBufSipLine(OneLine, Buf, &pCh);
00446                      
00447                      CountTokens++;
00448                      
00449                      if (!Quiet) printf("Line: >%s< >%s<\n", 
00450                                       ChrPtr(OneLine), 
00451                                       ((pCh != NULL) && (pCh != StrBufNOTNULL))? pCh : "N/A");
00452                      TestRevalidateStrBuf(OneLine);
00453                      CU_ASSERT(CountTokens <= NLines);
00454                      StrBufAppendBuf(ConcatenatedLines, OneLine, 0);
00455                      
00456                      if ((pCh == StrBufNOTNULL) && 
00457                          (*(ChrPtr(Buf) + StrLength(Buf) - 1) != '\n'))
00458                      {
00459                      }
00460                      else 
00461                             StrBufAppendBufPlain(ConcatenatedLines, HKEY("\n"), 0);
00462                      
00463               } 
00464               while ((pCh != StrBufNOTNULL) &&
00465                      (pCh != NULL));
00466        
00467 
00468        if (!Quiet) printf("\n\nTemplate: >%s<\n", ChrPtr(Buf));
00469        if (!Quiet) printf("\n\nAfter: >%s<\n", ChrPtr(ConcatenatedLines));
00470        CU_ASSERT_NSTRING_EQUAL(ChrPtr(ConcatenatedLines), 
00471                             ChrPtr(Buf), 
00472                             StrLength(Buf));
00473 
00474        FreeStrBuf(&OneLine);
00475        FreeStrBuf(&ConcatenatedLines);
00476 }
00477 
00478 
00479 static void TestNextLine_Empty(void)
00480 {
00481        StrBuf *Buf;
00482 
00483        Buf = NewStrBufPlain(HKEY(""));
00484        NextLineterateBuf(Buf, 0);
00485        FreeStrBuf(&Buf);
00486 }
00487 
00488 
00489 static void TestNextLine_OneLine(void)
00490 {
00491        StrBuf *Buf;
00492 
00493        Buf = NewStrBufPlain(HKEY("abc\n"));
00494        NextLineterateBuf(Buf, 1);
00495        FreeStrBuf(&Buf);
00496 }
00497 
00498 
00499 static void TestNextLine_TwoLinesMissingCR(void)
00500 {
00501        StrBuf *Buf;
00502 
00503        Buf = NewStrBufPlain(HKEY("abc\ncde"));
00504        NextLineterateBuf(Buf, 2);
00505        FreeStrBuf(&Buf);
00506 }
00507 
00508 
00509 static void TestNextLine_twolines(void)
00510 {
00511        StrBuf *Buf;
00512 
00513        Buf = NewStrBufPlain(HKEY("abc\ncde\n"));
00514        NextLineterateBuf(Buf, 2);
00515        FreeStrBuf(&Buf);
00516 }
00517 
00518 static void TestNextLine_LongLine(void)
00519 {
00520        StrBuf *Buf;
00521 
00522        Buf = NewStrBufPlain(HKEY("abcde\n1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\n"));
00523        NextLineterateBuf(Buf, 2);
00524        FreeStrBuf(&Buf);
00525 }
00526 
00527 
00528 static void TestStrBufRemove_token_NotThere(void)
00529 {
00530 //     StrBuf *Test = NewStrBufPlain(HKEY(" 127.0.0.1"));
00531        StrBuf *Test = NewStrBufPlain(HKEY(" 10.122.44.30, 10.122.44.30"));
00532        StrBufRemove_token(Test, 0, ',');
00533        TestRevalidateStrBuf(Test);
00534        FreeStrBuf(&Test);
00535 }
00536 
00537 
00538 static void TestStrBufUrlescAppend(void)
00539 {
00540        const char *expect = "%20%2B%23%26%3B%60%27%7C%2A%3F%2D%7E%3C%3E%5E%28%29%5B%5D%7B%7D%2F%24%22%5C";
00541        StrBuf *In = NewStrBufPlain(HKEY( " +#&;`'|*?-~<>^()[]{}/$\"\\"));
00542        StrBuf *Out = NewStrBuf();
00543 
00544        StrBufUrlescAppend (Out, In, NULL);
00545        if (!Quiet) printf ("%s<\n%s<\n%s\n", ChrPtr(In), ChrPtr(Out), expect);
00546        CU_ASSERT_STRING_EQUAL(ChrPtr(Out), expect);
00547        FreeStrBuf(&In);
00548        FreeStrBuf(&Out);
00549 }
00550 
00551 /*
00552 Some samples from the original...
00553        CU_ASSERT_EQUAL(10, 10);
00554        CU_ASSERT_EQUAL(0, -0);
00555        CU_ASSERT_EQUAL(-12, -12);
00556        CU_ASSERT_NOT_EQUAL(10, 11);
00557        CU_ASSERT_NOT_EQUAL(0, -1);
00558        CU_ASSERT_NOT_EQUAL(-12, -11);
00559        CU_ASSERT_PTR_EQUAL((void*)0x100, (void*)0x100);
00560        CU_ASSERT_PTR_NOT_EQUAL((void*)0x100, (void*)0x101);
00561        CU_ASSERT_PTR_NULL(NULL);
00562        CU_ASSERT_PTR_NULL(0x0);
00563        CU_ASSERT_PTR_NOT_NULL((void*)0x23);
00564        CU_ASSERT_STRING_EQUAL(str1, str2);
00565        CU_ASSERT_STRING_NOT_EQUAL(str1, str2);
00566        CU_ASSERT_NSTRING_EQUAL(str1, str2, strlen(str1));
00567        CU_ASSERT_NSTRING_EQUAL(str1, str1, strlen(str1));
00568        CU_ASSERT_NSTRING_EQUAL(str1, str1, strlen(str1) + 1);
00569        CU_ASSERT_NSTRING_NOT_EQUAL(str1, str2, 3);
00570        CU_ASSERT_NSTRING_NOT_EQUAL(str1, str3, strlen(str1) + 1);
00571        CU_ASSERT_DOUBLE_EQUAL(10, 10.0001, 0.0001);
00572        CU_ASSERT_DOUBLE_EQUAL(10, 10.0001, -0.0001);
00573        CU_ASSERT_DOUBLE_EQUAL(-10, -10.0001, 0.0001);
00574        CU_ASSERT_DOUBLE_EQUAL(-10, -10.0001, -0.0001);
00575        CU_ASSERT_DOUBLE_NOT_EQUAL(10, 10.001, 0.0001);
00576        CU_ASSERT_DOUBLE_NOT_EQUAL(10, 10.001, -0.0001);
00577        CU_ASSERT_DOUBLE_NOT_EQUAL(-10, -10.001, 0.0001);
00578        CU_ASSERT_DOUBLE_NOT_EQUAL(-10, -10.001, -0.0001);
00579 */
00580 
00581 
00582 
00583 
00584 
00585 static void AddStrBufSimpleTests(void)
00586 {
00587        CU_pSuite pGroup = NULL;
00588        CU_pTest pTest = NULL;
00589 
00590        pGroup = CU_add_suite("TestStringBufSimpleAppenders", NULL, NULL);
00591        pTest = CU_add_test(pGroup, "testCreateBuf", TestCreateBuf);
00592        pTest = CU_add_test(pGroup, "TestBufNumbers", TestBufNumbers);
00593        pTest = CU_add_test(pGroup, "TestStrBufPeek", TestStrBufPeek);
00594        pTest = CU_add_test(pGroup, "TestBufStringManipulation", TestBufStringManipulation);
00595 
00596 
00597        pGroup = CU_add_suite("TestStringTokenizer", NULL, NULL);
00598        pTest = CU_add_test(pGroup, "testNextTokenizer_EndWithEmpty", TestNextTokenizer_EndWithEmpty);
00599        pTest = CU_add_test(pGroup, "testNextTokenizer_StartWithEmpty", TestNextTokenizer_StartWithEmpty);
00600        pTest = CU_add_test(pGroup, "testNextTokenizer_StartWithEmpty", TestNextTokenizer_StartWithEmpty);
00601        pTest = CU_add_test(pGroup, "testNextTokenizer_Empty", TestNextTokenizer_Empty);
00602        pTest = CU_add_test(pGroup, "testNextTokenizer_TwoEmpty", TestNextTokenizer_TwoEmpty);
00603        pTest = CU_add_test(pGroup, "testNextTokenizer_One", TestNextTokenizer_One);
00604        pTest = CU_add_test(pGroup, "testNextTokenizer_Sequence", TestNextTokenizer_Sequence);
00605 
00606 
00607        pGroup = CU_add_suite("TestStrBufSipLine", NULL, NULL);
00608        pTest = CU_add_test(pGroup, "TestNextLine_Empty", TestNextLine_Empty);
00609        pTest = CU_add_test(pGroup, "TestNextLine_OneLine", TestNextLine_OneLine);
00610        pTest = CU_add_test(pGroup, "TestNextLine_TwoLinesMissingCR", TestNextLine_TwoLinesMissingCR);
00611        pTest = CU_add_test(pGroup, "TestNextLine_twolines", TestNextLine_twolines);
00612        pTest = CU_add_test(pGroup, "TestNextLine_LongLine", TestNextLine_LongLine);
00613        
00614        pGroup = CU_add_suite("TestStrBufRemove_token", NULL, NULL);
00615        pTest = CU_add_test(pGroup, "TestStrBufRemove_token_NotThere", TestStrBufRemove_token_NotThere);
00616 
00617        pGroup = CU_add_suite("TestStrBuf_escapers", NULL, NULL);
00618        pTest = CU_add_test(pGroup, "TestStrBufUrlescAppend", TestStrBufUrlescAppend);
00619 }
00620 
00621 
00622 int main(int argc, char* argv[])
00623 {
00624        int i;
00625        setvbuf(stdout, NULL, _IONBF, 0);
00626 
00627        StartLibCitadel(8);
00628        CU_BOOL Run = CU_FALSE ;
00629 
00630        if (argc > 0)
00631               Quiet = 1; // todo: -q ;-)
00632 //     for (i=0; i< 100000; i++) {
00633        CU_set_output_filename("TestAutomated");
00634        if (CU_initialize_registry()) {
00635               printf("\nInitialize of test Registry failed.");
00636 //     }
00637        
00638        Run = CU_TRUE ;
00639        AddStrBufSimpleTests();
00640        
00641        if (CU_TRUE == Run) {
00642               //CU_console_run_tests();
00643               printf("\nTests completed with return value %d.\n", CU_basic_run_tests());
00644     
00646        }
00647        
00648        CU_cleanup_registry();
00649        }
00650        return 0;
00651 }