Back to index

libcitadel  8.12
Defines | Functions | Variables
stringbuf_test.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include "stringbuf_test.h"
#include "../lib/libcitadel.h"

Go to the source code of this file.

Defines

#define SHOW_ME_VAPPEND_PRINTF

Functions

static void TEST_StrBufAppendPrintf (StrBuf *WBuf, const char *format,...)
static void TestRevalidateStrBuf (StrBuf *Buf)
static void TestCreateBuf (void)
static void TestBufNumbers (void)
static void TestStrBufPeek (void)
static void TestBufStringManipulation (void)
static void NextTokenizerIterateBuf (StrBuf *Buf, int NTokens)
static void TestNextTokenizer_EndWithEmpty (void)
static void TestNextTokenizer_StartWithEmpty (void)
static void TestNextTokenizer_Empty (void)
static void TestNextTokenizer_TwoEmpty (void)
static void TestNextTokenizer_One (void)
static void TestNextTokenizer_Sequence (void)
static void NextLineterateBuf (StrBuf *Buf, int NLines)
static void TestNextLine_Empty (void)
static void TestNextLine_OneLine (void)
static void TestNextLine_TwoLinesMissingCR (void)
static void TestNextLine_twolines (void)
static void TestNextLine_LongLine (void)
static void TestStrBufRemove_token_NotThere (void)
static void TestStrBufUrlescAppend (void)
static void AddStrBufSimpleTests (void)
int main (int argc, char *argv[])

Variables

int Quiet = 0

Define Documentation

Definition at line 22 of file stringbuf_test.c.


Function Documentation

static void AddStrBufSimpleTests ( void  ) [static]

Definition at line 585 of file stringbuf_test.c.

{
       CU_pSuite pGroup = NULL;
       CU_pTest pTest = NULL;

       pGroup = CU_add_suite("TestStringBufSimpleAppenders", NULL, NULL);
       pTest = CU_add_test(pGroup, "testCreateBuf", TestCreateBuf);
       pTest = CU_add_test(pGroup, "TestBufNumbers", TestBufNumbers);
       pTest = CU_add_test(pGroup, "TestStrBufPeek", TestStrBufPeek);
       pTest = CU_add_test(pGroup, "TestBufStringManipulation", TestBufStringManipulation);


       pGroup = CU_add_suite("TestStringTokenizer", NULL, NULL);
       pTest = CU_add_test(pGroup, "testNextTokenizer_EndWithEmpty", TestNextTokenizer_EndWithEmpty);
       pTest = CU_add_test(pGroup, "testNextTokenizer_StartWithEmpty", TestNextTokenizer_StartWithEmpty);
       pTest = CU_add_test(pGroup, "testNextTokenizer_StartWithEmpty", TestNextTokenizer_StartWithEmpty);
       pTest = CU_add_test(pGroup, "testNextTokenizer_Empty", TestNextTokenizer_Empty);
       pTest = CU_add_test(pGroup, "testNextTokenizer_TwoEmpty", TestNextTokenizer_TwoEmpty);
       pTest = CU_add_test(pGroup, "testNextTokenizer_One", TestNextTokenizer_One);
       pTest = CU_add_test(pGroup, "testNextTokenizer_Sequence", TestNextTokenizer_Sequence);


       pGroup = CU_add_suite("TestStrBufSipLine", NULL, NULL);
       pTest = CU_add_test(pGroup, "TestNextLine_Empty", TestNextLine_Empty);
       pTest = CU_add_test(pGroup, "TestNextLine_OneLine", TestNextLine_OneLine);
       pTest = CU_add_test(pGroup, "TestNextLine_TwoLinesMissingCR", TestNextLine_TwoLinesMissingCR);
       pTest = CU_add_test(pGroup, "TestNextLine_twolines", TestNextLine_twolines);
       pTest = CU_add_test(pGroup, "TestNextLine_LongLine", TestNextLine_LongLine);
       
       pGroup = CU_add_suite("TestStrBufRemove_token", NULL, NULL);
       pTest = CU_add_test(pGroup, "TestStrBufRemove_token_NotThere", TestStrBufRemove_token_NotThere);

       pGroup = CU_add_suite("TestStrBuf_escapers", NULL, NULL);
       pTest = CU_add_test(pGroup, "TestStrBufUrlescAppend", TestStrBufUrlescAppend);
}

Here is the call graph for this function:

Here is the caller graph for this function:

int main ( int  argc,
char *  argv[] 
)

CU_automated_run_tests();

Definition at line 622 of file stringbuf_test.c.

{
       int i;
       setvbuf(stdout, NULL, _IONBF, 0);

       StartLibCitadel(8);
       CU_BOOL Run = CU_FALSE ;

       if (argc > 0)
              Quiet = 1; // todo: -q ;-)
//     for (i=0; i< 100000; i++) {
       CU_set_output_filename("TestAutomated");
       if (CU_initialize_registry()) {
              printf("\nInitialize of test Registry failed.");
//     }
       
       Run = CU_TRUE ;
       AddStrBufSimpleTests();
       
       if (CU_TRUE == Run) {
              //CU_console_run_tests();
              printf("\nTests completed with return value %d.\n", CU_basic_run_tests());
    
       }
       
       CU_cleanup_registry();
       }
       return 0;
}

Here is the call graph for this function:

static void NextLineterateBuf ( StrBuf Buf,
int  NLines 
) [static]

Definition at line 427 of file stringbuf_test.c.

{
       int n = 0;
       const char *pCh = NULL;
       StrBuf *OneLine;
       StrBuf *ConcatenatedLines;
       long CountTokens = 0;
       
       TestRevalidateStrBuf(Buf);
                          
       OneLine = NewStrBuf();
       ConcatenatedLines = NewStrBuf();

       if (!Quiet) printf("\n");

       if (StrLength(Buf) > 0) 
              do 
              {
                     n = StrBufSipLine(OneLine, Buf, &pCh);
                     
                     CountTokens++;
                     
                     if (!Quiet) printf("Line: >%s< >%s<\n", 
                                      ChrPtr(OneLine), 
                                      ((pCh != NULL) && (pCh != StrBufNOTNULL))? pCh : "N/A");
                     TestRevalidateStrBuf(OneLine);
                     CU_ASSERT(CountTokens <= NLines);
                     StrBufAppendBuf(ConcatenatedLines, OneLine, 0);
                     
                     if ((pCh == StrBufNOTNULL) && 
                         (*(ChrPtr(Buf) + StrLength(Buf) - 1) != '\n'))
                     {
                     }
                     else 
                            StrBufAppendBufPlain(ConcatenatedLines, HKEY("\n"), 0);
                     
              } 
              while ((pCh != StrBufNOTNULL) &&
                     (pCh != NULL));
       

       if (!Quiet) printf("\n\nTemplate: >%s<\n", ChrPtr(Buf));
       if (!Quiet) printf("\n\nAfter: >%s<\n", ChrPtr(ConcatenatedLines));
       CU_ASSERT_NSTRING_EQUAL(ChrPtr(ConcatenatedLines), 
                            ChrPtr(Buf), 
                            StrLength(Buf));

       FreeStrBuf(&OneLine);
       FreeStrBuf(&ConcatenatedLines);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void NextTokenizerIterateBuf ( StrBuf Buf,
int  NTokens 
) [static]

Definition at line 328 of file stringbuf_test.c.

{
       long FoundTokens;
       const char *pCh = NULL;
       StrBuf *Buf2;
       long CountTokens = 0;
       long HaveNextToken = 0;
       long HaveNextTokenF = 0;

       TestRevalidateStrBuf(Buf);
       FoundTokens = StrBufNum_tokens(Buf, ',');
       if (!Quiet) 
              printf("\n\nTemplate: >%s< %d, %ld\n", 
                     ChrPtr(Buf), 
                     NTokens, 
                     FoundTokens);

       CU_ASSERT(FoundTokens == NTokens);

       Buf2 = NewStrBuf();
       while (HaveNextToken = StrBufHaveNextToken(Buf, &pCh),
              HaveNextTokenF = StrBufExtract_NextToken(Buf2, Buf, &pCh, ','),
              (HaveNextTokenF>= 0))
       {
              CountTokens++;
              
              if (!Quiet) printf("Token: >%s< >%s< %ld:%ld\n", 
                               ChrPtr(Buf2), 
                               ((pCh != NULL) && (pCh != StrBufNOTNULL))? pCh : "N/A", 
                               HaveNextToken, 
                               HaveNextTokenF);
              TestRevalidateStrBuf(Buf2);

              CU_ASSERT(HaveNextToken == (HaveNextTokenF >= 0));
              
              CU_ASSERT(CountTokens <= NTokens);
       } 
       CU_ASSERT(HaveNextToken == (HaveNextTokenF >= 0));
       FreeStrBuf(&Buf2);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void TEST_StrBufAppendPrintf ( StrBuf WBuf,
const char *  format,
  ... 
) [static]

Definition at line 29 of file stringbuf_test.c.

{
       va_list arg_ptr;

       if (WBuf == NULL)
              return;

       va_start(arg_ptr, format);
       StrBufVAppendPrintf(WBuf, format, arg_ptr);
       va_end(arg_ptr);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void TestBufNumbers ( void  ) [static]

Definition at line 172 of file stringbuf_test.c.

{
       StrBuf *Buf;
       StrBuf *Buf2;
       StrBuf *Buf3;
       char *ch;
       int i;

       Buf2 = NewStrBuf();
       Buf3 = NewStrBufPlain(HKEY("abcd"));
       Buf = NewStrBufPlain(HKEY("123456"));
       CU_ASSERT(StrBufIsNumber(Buf) == 1);
       CU_ASSERT(StrBufIsNumber(NULL) == 0);
       CU_ASSERT(StrBufIsNumber(Buf2) == 0);
       CU_ASSERT(StrBufIsNumber(Buf3) == 0);

       CU_ASSERT(StrTol(Buf) == 123456);
       CU_ASSERT(StrTol(NULL) == 0);
       CU_ASSERT(StrTol(Buf2) == 0);

       CU_ASSERT(StrToi(Buf) == 123456);
       CU_ASSERT(StrToi(NULL) == 0);
       CU_ASSERT(StrToi(Buf2) == 0);
       ch = SmashStrBuf(NULL);
       CU_ASSERT(ch == NULL);
       i = StrLength(Buf);
       ch = SmashStrBuf(&Buf);
       CU_ASSERT(strlen(ch) == i);
       free(ch);
       FreeStrBuf(&Buf2);
       FreeStrBuf(&Buf3);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void TestBufStringManipulation ( void  ) [static]

Definition at line 235 of file stringbuf_test.c.

{
       long len, i = 0;
       StrBuf *dest = NewStrBuf ();
       StrBuf *Buf = NewStrBufPlain(HKEY("1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890"));

       StrBufSub(dest, Buf, -5, i);
       len = StrLength(Buf);
       for (i = 0; i < len + 10; i++)
       {
              StrBufSub(dest, Buf, 5, i);
              if (i + 5 < len)
              {
                     CU_ASSERT(StrLength(dest) == i);
              }
              else
              {
                     CU_ASSERT(StrLength(dest) == len - 5);
              }
       }
       FreeStrBuf(&dest);
       dest = NewStrBuf ();
       StrBufSub(dest, Buf, -5, 200);

       StrBufCutLeft(Buf, 5);
       CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"67890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890");
       CU_ASSERT(StrLength(Buf) == 95);

       StrBufCutRight(Buf, 5);
       CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345");
       CU_ASSERT(StrLength(Buf) == 90);

       StrBufCutAt(Buf, 80, NULL);
       CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"67890123456789012345678901234567890123456789012345678901234567890123456789012345");
       CU_ASSERT(StrLength(Buf) == 80);

       StrBufCutAt(Buf, -1, ChrPtr(Buf) + 70);
       CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"6789012345678901234567890123456789012345678901234567890123456789012345");
       CU_ASSERT(StrLength(Buf) == 70);


       StrBufCutAt(Buf, 0, ChrPtr(Buf) + 60);
       CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"678901234567890123456789012345678901234567890123456789012345");
       CU_ASSERT(StrLength(Buf) == 60);

       StrBufCutAt(Buf, 0, ChrPtr(Buf) + 70);
       CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"678901234567890123456789012345678901234567890123456789012345");
       CU_ASSERT(StrLength(Buf) == 60);

       StrBufCutAt(Buf, 70, NULL);
       CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"678901234567890123456789012345678901234567890123456789012345");
       CU_ASSERT(StrLength(Buf) == 60);


       StrBufCutLeft(Buf, 70);
       CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"");
       CU_ASSERT(StrLength(Buf) == 0);

       StrBufPlain(Buf, HKEY("678901234567890123456789012345678901234567890123456789012345"));
       StrBufCutRight(Buf, 70);
       CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"");
       CU_ASSERT(StrLength(Buf) == 0);

       FreeStrBuf(&dest);
       FreeStrBuf(&Buf);

       Buf = NewStrBufPlain(HKEY(" \tabc\t "));
       StrBufTrim(Buf);
       CU_ASSERT_STRING_EQUAL(ChrPtr(Buf),"abc");
       CU_ASSERT(StrLength(Buf) == 3);

       StrBufUpCase(NULL);
       FlushStrBuf(Buf);
       StrBufUpCase(Buf);
       StrBufPlain(Buf, HKEY("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"));
       StrBufUpCase(Buf);

       CU_ASSERT_STRING_EQUAL(ChrPtr(Buf), "ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");


       StrBufLowerCase(NULL);
       FlushStrBuf(Buf);
       StrBufLowerCase(Buf);
       StrBufPlain(Buf, HKEY("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"));
       StrBufLowerCase(Buf);

       CU_ASSERT_STRING_EQUAL(ChrPtr(Buf), "abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz0123456789");


       FreeStrBuf(&Buf);

}

Here is the call graph for this function:

Here is the caller graph for this function:

static void TestCreateBuf ( void  ) [static]

Definition at line 47 of file stringbuf_test.c.

{
       StrBuf *Buf;
       StrBuf *Buf2;
       long len;
       long i;

       Buf = NewStrBuf();
       CU_ASSERT(Buf != NULL);
       FreeStrBuf(&Buf);

       Buf = NewStrBufPlain(ChrPtr(NULL), StrLength(NULL));
       CU_ASSERT(Buf != NULL);
       FreeStrBuf(&Buf);

       /* make it alloc a bigger buffer... */
       Buf = NewStrBufPlain(NULL, SIZ);
       CU_ASSERT(Buf != NULL);
       FreeStrBuf(&Buf);


       Buf = NewStrBufDup(NULL);
       CU_ASSERT(Buf != NULL);
       StrBufPlain(Buf, "abc", -1);
       TestRevalidateStrBuf(Buf);
       StrBufPlain(Buf, HKEY("abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"));
       TestRevalidateStrBuf(Buf);
       FreeStrBuf(&Buf);

       FlushStrBuf(NULL);
       FLUSHStrBuf(NULL);

       CU_ASSERT(Buf == NULL);
       Buf = NewStrBufPlain(HKEY("ABC"));
       TestRevalidateStrBuf(Buf);
       CU_ASSERT(StrLength(Buf) == 3);
       CU_ASSERT_NSTRING_EQUAL("ABC", ChrPtr(Buf), 3);

       len = StrLength(Buf);
       for (i=0; i< 500; i ++)
       {
              StrBufAppendBufPlain(Buf, HKEY("ABC"), 0);
              len += 3;
              CU_ASSERT(StrLength(Buf) == len);
       }      
       StrBufShrinkToFit(Buf, 1);
       FlushStrBuf(Buf);
       CU_ASSERT(StrLength(Buf) == 0);
       ReAdjustEmptyBuf(Buf, 1, 1);
       TestRevalidateStrBuf(Buf);
       FreeStrBuf(&Buf);
       CU_ASSERT(Buf == NULL);
       
       Buf = NewStrBufPlain(HKEY("ABC"));
       TestRevalidateStrBuf(Buf);
       len = StrLength(Buf);
       for (i=0; i< 500; i ++)
       {
              StrBufAppendPrintf(Buf, "%s", "ABC");
              len += 3;
              CU_ASSERT(StrLength(Buf) == len);         
       }
       TestRevalidateStrBuf(Buf);
       StrBufShrinkToFit(Buf, 1);
       TestRevalidateStrBuf(Buf);
       FreeStrBuf(&Buf);


       Buf = NewStrBufPlain(HKEY("ABC"));
       Buf2 = NewStrBufPlain(HKEY("------"));
       TestRevalidateStrBuf(Buf);
       len = StrLength(Buf);
       for (i=0; i< 50; i ++)
       {
              StrBufPrintf(Buf, "%s", ChrPtr(Buf2));
              CU_ASSERT(StrLength(Buf) == StrLength(Buf2));           

              StrBufAppendBufPlain(Buf2, HKEY("ABCDEFG"), 0);
       }
       TestRevalidateStrBuf(Buf);
       StrBufShrinkToFit(Buf, 1);
       TestRevalidateStrBuf(Buf);
       FreeStrBuf(&Buf);
       FreeStrBuf(&Buf2);   


       Buf = NewStrBufPlain(HKEY("ABC"));
       TestRevalidateStrBuf(Buf);
       len = StrLength(Buf);
       for (i=0; i< 500; i ++)
       {
              TEST_StrBufAppendPrintf(Buf, "%s", "ABC");
              len += 3;
              CU_ASSERT(StrLength(Buf) == len);         
       }
       TestRevalidateStrBuf(Buf);
       StrBufShrinkToFit(Buf, 1);
       TestRevalidateStrBuf(Buf);


       Buf2 = NewStrBufDup(Buf);
       CU_ASSERT(StrLength(Buf) == StrLength(Buf2));           
       
       CU_ASSERT_NSTRING_EQUAL(ChrPtr(Buf2), ChrPtr(Buf), StrLength(Buf2));
       
       CU_ASSERT(StrBufIsNumber(Buf) == 0);

       FlushStrBuf(Buf2);
       CU_ASSERT(StrLength(Buf2) == 0);

       FLUSHStrBuf(Buf);
       CU_ASSERT(StrLength(Buf) == 0);

       HFreeStrBuf(NULL);
       HFreeStrBuf(Buf2);
       CU_ASSERT(Buf2 != NULL);

       FreeStrBuf(&Buf);
       CU_ASSERT(Buf == NULL);
       
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void TestNextLine_Empty ( void  ) [static]

Definition at line 479 of file stringbuf_test.c.

{
       StrBuf *Buf;

       Buf = NewStrBufPlain(HKEY(""));
       NextLineterateBuf(Buf, 0);
       FreeStrBuf(&Buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void TestNextLine_LongLine ( void  ) [static]

Definition at line 518 of file stringbuf_test.c.

{
       StrBuf *Buf;

       Buf = NewStrBufPlain(HKEY("abcde\n1234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890\n"));
       NextLineterateBuf(Buf, 2);
       FreeStrBuf(&Buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void TestNextLine_OneLine ( void  ) [static]

Definition at line 489 of file stringbuf_test.c.

{
       StrBuf *Buf;

       Buf = NewStrBufPlain(HKEY("abc\n"));
       NextLineterateBuf(Buf, 1);
       FreeStrBuf(&Buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void TestNextLine_twolines ( void  ) [static]

Definition at line 509 of file stringbuf_test.c.

{
       StrBuf *Buf;

       Buf = NewStrBufPlain(HKEY("abc\ncde\n"));
       NextLineterateBuf(Buf, 2);
       FreeStrBuf(&Buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void TestNextLine_TwoLinesMissingCR ( void  ) [static]

Definition at line 499 of file stringbuf_test.c.

{
       StrBuf *Buf;

       Buf = NewStrBufPlain(HKEY("abc\ncde"));
       NextLineterateBuf(Buf, 2);
       FreeStrBuf(&Buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void TestNextTokenizer_Empty ( void  ) [static]

Definition at line 389 of file stringbuf_test.c.

{
       StrBuf *Buf;

       Buf = NewStrBufPlain(HKEY(""));
       NextTokenizerIterateBuf(Buf, 0);
       FreeStrBuf(&Buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void TestNextTokenizer_EndWithEmpty ( void  ) [static]

Definition at line 371 of file stringbuf_test.c.

{
       StrBuf *Buf;

       Buf = NewStrBufPlain(HKEY("abc,abc, 1, ,,"));
       NextTokenizerIterateBuf(Buf, 6);
       FreeStrBuf(&Buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void TestNextTokenizer_One ( void  ) [static]

Definition at line 407 of file stringbuf_test.c.

{
       StrBuf *Buf;

       Buf = NewStrBufPlain(HKEY("one"));
       NextTokenizerIterateBuf(Buf, 1);
       FreeStrBuf(&Buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void TestNextTokenizer_Sequence ( void  ) [static]

Definition at line 416 of file stringbuf_test.c.

{
       StrBuf *Buf;
        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";
        Buf = NewStrBufPlain(teststring, -1);
       NextTokenizerIterateBuf(Buf, 67);
       FreeStrBuf(&Buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void TestNextTokenizer_StartWithEmpty ( void  ) [static]

Definition at line 380 of file stringbuf_test.c.

{
       StrBuf *Buf;

       Buf = NewStrBufPlain(HKEY(",cde,abc, 1, ,,bbb"));
       NextTokenizerIterateBuf(Buf, 7);
       FreeStrBuf(&Buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void TestNextTokenizer_TwoEmpty ( void  ) [static]

Definition at line 398 of file stringbuf_test.c.

{
       StrBuf *Buf;

       Buf = NewStrBufPlain(HKEY(","));
       NextTokenizerIterateBuf(Buf, 2);
       FreeStrBuf(&Buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void TestRevalidateStrBuf ( StrBuf Buf) [static]

Definition at line 41 of file stringbuf_test.c.

{
       CU_ASSERT(strlen(ChrPtr(Buf)) == StrLength(Buf));
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void TestStrBufPeek ( void  ) [static]

Definition at line 205 of file stringbuf_test.c.

{
       StrBuf *Buf;
       const char *pch;

       Buf = NewStrBufPlain(HKEY("0123456"));
       pch = ChrPtr(Buf);

       CU_ASSERT(StrBufPeek(NULL, pch + 4, -1, 'A') == -1);

       CU_ASSERT(StrBufPeek(Buf, pch + 4, -1, 'A') == 4);
       CU_ASSERT_STRING_EQUAL(ChrPtr(Buf), "0123A56");

       CU_ASSERT(StrBufPeek(Buf, pch - 1, -1, 'A') == -1);
       CU_ASSERT_STRING_EQUAL(ChrPtr(Buf), "0123A56");

       CU_ASSERT(StrBufPeek(Buf, pch + 10, -1, 'A') == -1);
       CU_ASSERT_STRING_EQUAL(ChrPtr(Buf), "0123A56");

       CU_ASSERT(StrBufPeek(Buf, NULL, -1, 'A') == -1);
       CU_ASSERT_STRING_EQUAL(ChrPtr(Buf), "0123A56");

       CU_ASSERT(StrBufPeek(Buf, NULL, 10, 'A') == -1);
       CU_ASSERT_STRING_EQUAL(ChrPtr(Buf), "0123A56");

       CU_ASSERT(StrBufPeek(Buf, NULL, 5, 'A') == 5);
       CU_ASSERT_STRING_EQUAL(ChrPtr(Buf), "0123AA6");
       FreeStrBuf(&Buf);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void TestStrBufRemove_token_NotThere ( void  ) [static]

Definition at line 528 of file stringbuf_test.c.

{
//     StrBuf *Test = NewStrBufPlain(HKEY(" 127.0.0.1"));
       StrBuf *Test = NewStrBufPlain(HKEY(" 10.122.44.30, 10.122.44.30"));
       StrBufRemove_token(Test, 0, ',');
       TestRevalidateStrBuf(Test);
       FreeStrBuf(&Test);
}

Here is the call graph for this function:

Here is the caller graph for this function:

static void TestStrBufUrlescAppend ( void  ) [static]

Definition at line 538 of file stringbuf_test.c.

{
       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";
       StrBuf *In = NewStrBufPlain(HKEY( " +#&;`'|*?-~<>^()[]{}/$\"\\"));
       StrBuf *Out = NewStrBuf();

       StrBufUrlescAppend (Out, In, NULL);
       if (!Quiet) printf ("%s<\n%s<\n%s\n", ChrPtr(In), ChrPtr(Out), expect);
       CU_ASSERT_STRING_EQUAL(ChrPtr(Out), expect);
       FreeStrBuf(&In);
       FreeStrBuf(&Out);
}

Here is the call graph for this function:

Here is the caller graph for this function:


Variable Documentation

int Quiet = 0

Definition at line 25 of file stringbuf_test.c.