IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 6278 for trunk/psLib/test/sys


Ignore:
Timestamp:
Feb 1, 2006, 10:40:56 AM (20 years ago)
Author:
drobbin
Message:

Added error handling to psString for NULL string inputs.

Location:
trunk/psLib/test/sys
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/sys/tst_psString.c

    r6218 r6278  
    2020 *  @author  Eric Van Alst, MHPCC
    2121 *
    22  *  @version $Revision: 1.3 $  $Name: not supported by cvs2svn $
    23  *  @date  $Date: 2006-01-27 01:49:05 $
     22 *  @version $Revision: 1.4 $  $Name: not supported by cvs2svn $
     23 *  @date  $Date: 2006-02-01 20:40:56 $
    2424 *
    2525 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5252
    5353static psS32 testStrSplit00(void);
     54static psS32 testNULLStrings(void);
    5455
    5556testDescription tests[] = {
     
    7273                              {testStrPrepend03,14, "Test prepend null-op", 0, false},
    7374                              {testStrSplit00,15, "Test String Splitting", 0, false},
     75                              {testNULLStrings,666, "Test NULL String Error Handling", 0, false},
    7476                              {NULL}
    7577                          };
     
    619621}
    620622
     623static psS32 testNULLStrings(void)
     624{
     625    psString nullTest = NULL;
     626    psString output = NULL;
     627    ssize_t outSize = 0;
     628    char** nullDest = NULL;
     629    char** test;
     630    //psStringCopy should return NULL for NULL input string
     631    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     632    output = psStringCopy(nullTest);
     633    if (output != NULL) {
     634        psError(PS_ERR_BAD_PARAMETER_NULL, false,
     635                "psStringCopy failed to return NULL for NULL input string.\n");
     636        return 1;
     637    }
     638    //psStringNCopy should return NULL for NULL input string
     639    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     640    output = psStringNCopy(nullTest, 100);
     641    if (output != NULL) {
     642        psError(PS_ERR_BAD_PARAMETER_NULL, false,
     643                "psStringNCopy failed to return NULL for NULL input string.\n");
     644        return 2;
     645    }
     646
     647    //psStringAppend should return 0 for NULL input destination
     648    outSize = psStringAppend(nullDest, "");
     649    if (outSize != 0) {
     650        psError(PS_ERR_BAD_PARAMETER_NULL, false,
     651                "psStringAppend failed to return 0 for NULL input destination.\n");
     652        return 3;
     653    }
     654    //psStringAppend should return 0 for NULL input format
     655    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     656    outSize = psStringAppend(test, nullTest);
     657    if (outSize != 0) {
     658        psError(PS_ERR_BAD_PARAMETER_NULL, false,
     659                "psStringAppend failed to return 0 for NULL input format.\n");
     660        return 4;
     661    }
     662    //psStringPrepend should return 0 for NULL input destination
     663    outSize = psStringPrepend(nullDest, " ");
     664    if (outSize != 0) {
     665        psError(PS_ERR_BAD_PARAMETER_NULL, false,
     666                "psStringPrepend failed to return 0 for NULL input destination.\n");
     667        return 3;
     668    }
     669    //psStringPrepend should return 0 for NULL input format
     670    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     671    outSize = psStringPrepend(test, nullTest);
     672    if (outSize != 0) {
     673        psError(PS_ERR_BAD_PARAMETER_NULL, false,
     674                "psStringPrepend failed to return 0 for NULL input format.\n");
     675        return 4;
     676    }
     677    //psStringSplit should return NULL for NULL input string
     678    psList *nullList = NULL;
     679    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     680    nullList = psStringSplit(nullTest, ",");
     681    if (nullList != NULL) {
     682        psError(PS_ERR_BAD_PARAMETER_NULL, false,
     683                "psStringSplit failed to return NULL for NULL input string.\n");
     684        return 5;
     685    }
     686    //psStringSplit should return NULL for NULL input splitter
     687    psLogMsg(__func__,PS_LOG_INFO,"Following should generate error message");
     688    nullList = psStringSplit("Hello World", nullTest);
     689    if (nullList != NULL) {
     690        psError(PS_ERR_BAD_PARAMETER_NULL, false,
     691                "psStringSplit failed to return NULL for NULL input splitter.\n");
     692        return 6;
     693    }
     694
     695    return 0;
     696}
     697
  • trunk/psLib/test/sys/verified/tst_psString.stderr

    r6218 r6278  
    6868\**********************************************************************************/
    6969
     70<DATE><TIME>|<HOST>|E|psStringAppend (FILE:LINENO)
     71    Unallowable operation: format is NULL.
     72<DATE><TIME>|<HOST>|E|psStringAppend (FILE:LINENO)
     73    Unallowable operation: format is NULL.
    7074
    7175---> TESTPOINT PASSED (psString{Test append NULL handling} | tst_psString.c)
     
    104108\**********************************************************************************/
    105109
     110<DATE><TIME>|<HOST>|E|psStringPrepend (FILE:LINENO)
     111    Unallowable operation: format is NULL.
     112<DATE><TIME>|<HOST>|E|psStringPrepend (FILE:LINENO)
     113    Unallowable operation: format is NULL.
    106114
    107115---> TESTPOINT PASSED (psString{Test prepend NULL handling} | tst_psString.c)
     
    146154---> TESTPOINT PASSED (psString{Test String Splitting} | tst_psString.c)
    147155
     156/***************************** TESTPOINT ******************************************\
     157*             TestFile: tst_psString.c                                             *
     158*            TestPoint: psString{Test NULL String Error Handling}                  *
     159*             TestType: Positive                                                   *
     160\**********************************************************************************/
     161
     162<DATE><TIME>|<HOST>|I|testNULLStrings
     163    Following should generate error message
     164<DATE><TIME>|<HOST>|E|psStringCopy (FILE:LINENO)
     165    Unallowable operation: string is NULL.
     166<DATE><TIME>|<HOST>|I|testNULLStrings
     167    Following should generate error message
     168<DATE><TIME>|<HOST>|E|psStringNCopy (FILE:LINENO)
     169    Unallowable operation: string is NULL.
     170<DATE><TIME>|<HOST>|I|testNULLStrings
     171    Following should generate error message
     172<DATE><TIME>|<HOST>|E|psStringAppend (FILE:LINENO)
     173    Unallowable operation: format is NULL.
     174<DATE><TIME>|<HOST>|I|testNULLStrings
     175    Following should generate error message
     176<DATE><TIME>|<HOST>|E|psStringPrepend (FILE:LINENO)
     177    Unallowable operation: format is NULL.
     178<DATE><TIME>|<HOST>|I|testNULLStrings
     179    Following should generate error message
     180<DATE><TIME>|<HOST>|E|psStringSplit (FILE:LINENO)
     181    Unallowable operation: string is NULL.
     182<DATE><TIME>|<HOST>|I|testNULLStrings
     183    Following should generate error message
     184<DATE><TIME>|<HOST>|E|psStringSplit (FILE:LINENO)
     185    Unallowable operation: splitters is NULL.
     186
     187---> TESTPOINT PASSED (psString{Test NULL String Error Handling} | tst_psString.c)
     188
Note: See TracChangeset for help on using the changeset viewer.