IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Jul 13, 2006, 4:26:25 PM (20 years ago)
Author:
drobbin
Message:

Added str check test for error handling of psString fxns, namely stringSubstitute. Edited memory and type to include MemCheck's for string, line, and region. Added is_psType function to check for NULLs and native types first. <-will have to update all fxns next wrt to this change. Added psStringAlloc, stringFree, regionFree. Added doxygen comments.

File:
1 edited

Legend:

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

    r7880 r7901  
    2020 *  @author  Eric Van Alst, MHPCC
    2121 *
    22  *  @version $Revision: 1.10 $  $Name: not supported by cvs2svn $
    23  *  @date  $Date: 2006-07-12 21:25:39 $
     22 *  @version $Revision: 1.11 $  $Name: not supported by cvs2svn $
     23 *  @date  $Date: 2006-07-14 02:26:25 $
    2424 *
    2525 *  Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii
     
    5353static psS32 testStrSplit00(void);
    5454static psS32 testNULLStrings(void);
     55static psS32 testStrCheck(void);
    5556
    5657testDescription tests[] = {
     
    7475                              {testStrSplit00,15, "Test String Splitting", 0, false},
    7576                              {testNULLStrings,666, "Test NULL String Error Handling", 0, false},
     77                              {testStrCheck,16, "Test String Allocation and MemCheck", 0, false},
    7678                              {NULL}
    7779                          };
     
    709711    return 0;
    710712}
     713
     714psS32 testStrCheck(void)
     715{
     716    psString str = NULL;
     717    str = psStringAlloc(10);
     718    strcpy(str, "Hello");
     719    if (!psMemCheckString(str)) {
     720        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     721                "psString wasn't properly allocated!\n");
     722        return 1;
     723    }
     724    if (!psMemCheckType(PS_DATA_STRING, str)) {
     725        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     726                "psString wasn't properly allocated!\n");
     727        return 2;
     728    }
     729    psFree(str);
     730
     731    char charStr[10];
     732    if (psMemCheckType(PS_DATA_STRING, charStr)) {
     733        psError(PS_ERR_BAD_PARAMETER_VALUE, true,
     734                "Input string is not a psDataType!!!  (Should have returned false)\n");
     735        return 3;
     736    }
     737
     738    return 0;
     739}
     740
Note: See TracChangeset for help on using the changeset viewer.