Back to index

libcitadel  8.12
Defines | Functions
stripallbut_test.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
#include <CUnit/CUnit.h>
#include <CUnit/Basic.h>
#include <CUnit/TestDB.h>
#include <unistd.h>
#include <ctype.h>
#include <assert.h>
#include "../lib/libcitadel.h"

Go to the source code of this file.

Defines

#define CUNIT_AUTOMATED_H_SEEN

Functions

CU_EXPORT void CU_automated_run_tests (void)
CU_EXPORT CU_ErrorCode CU_list_tests_to_file (void)
CU_EXPORT void CU_set_output_filename (const char *szFilenameRoot)
static void TestStripAllBut (void)
static void AddStringToolsTests (void)
int main (int argc, char *argv[])

Define Documentation

Definition at line 23 of file stripallbut_test.c.


Function Documentation

static void AddStringToolsTests ( void  ) [static]

Definition at line 108 of file stripallbut_test.c.

{
       CU_pSuite pGroup = NULL;
       CU_pTest pTest = NULL;

       pGroup = CU_add_suite("TestStringTools", NULL, NULL);
       pTest = CU_add_test(pGroup, "testStripAllBut", TestStripAllBut);
}

Here is the call graph for this function:

Here is the caller graph for this function:

CU_EXPORT void CU_automated_run_tests ( void  )
CU_EXPORT CU_ErrorCode CU_list_tests_to_file ( void  )
CU_EXPORT void CU_set_output_filename ( const char *  szFilenameRoot)
int main ( int  argc,
char *  argv[] 
)

Definition at line 117 of file stripallbut_test.c.

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

       StartLibCitadel(8);

       CU_set_output_filename("TestAutomated");
       if (CU_initialize_registry()) {
              printf("\nInitialize of test Registry failed.");
              return 1;
       }
       AddStringToolsTests();
       
       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 TestStripAllBut ( void  ) [static]

Definition at line 46 of file stripallbut_test.c.

                                  {
       int i;
       long l;

       char *teststrings[] = {
              "Nmm <fghjk> tyutyu",
              "Sdd <> ghhjjkk",
              "<>",
              "",
              "Sdd <",
              "Df Ghjkl>",
              ">< bggt",
              "FSDFSDFSDFSDF<><><>bggt",
              "FSDFSDFSDF<><eoeo><>bggt",
              "Abc<QWER>",
              "><",
              "Zxcv<dy<<lkj>>>"
       };

       char *strippedstrings[] = {
              "fghjk",
              "",
              "",
              "",
              "Sdd <",
              "Df Ghjkl>",
              ">< bggt",
              "FSDFSDFSDFSDF<><><>bggt",
              "FSDFSDFSDF<><eoeo><>bggt",
              "QWER",
              "><",
              "lkj"
       };

       long strippedlens[] = {
              5,
              0,
              0,
              0,
              5,
              9,
              7,
              23,
              24,
              4,
              2,
              3
       };

       char foo[128];

       for (i=0; i<(sizeof(teststrings) / sizeof (char *)); ++i) {
              strcpy(foo, teststrings[i]);
              l = stripallbut(foo, '<', '>');

              CU_ASSERT_STRING_EQUAL(foo, strippedstrings[i]);
              CU_ASSERT_EQUAL(strlen(foo), strippedlens[i]);
       }
}

Here is the call graph for this function:

Here is the caller graph for this function: