IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Sep 7, 2004, 2:09:36 PM (22 years ago)
Author:
desonia
Message:

updated tests.

Location:
trunk/psLib/test/sysUtils
Files:
4 edited

Legend:

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

    r1406 r1714  
    1717 *  @author  Eric Van Alst, MHPCC
    1818 *
    19  *  @version $Revision: 1.7 $  $Name: not supported by cvs2svn $
    20  *  @date  $Date: 2004-08-06 22:34:06 $
     19 *  @version $Revision: 1.8 $  $Name: not supported by cvs2svn $
     20 *  @date  $Date: 2004-09-08 00:09:36 $
    2121 *
    2222 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2828#include "psTest.h"
    2929
     30static int testStringCopy00(void);
     31static int testStringCopy01(void);
     32static int testStringCopy02(void);
     33static int testStringCopy03(void);
     34static int testStringCopy04(void);
     35static int testStringCopy05(void);
     36static int testStringCopy06(void);
     37
     38testDescription tests[] = {
     39                              {testStringCopy00, 0, "Verify string copy", 0, false},
     40                              {testStringCopy01, 1, "Verify empty string copy", 0, false},
     41                              {testStringCopy02, 2, "Verify string copy with length", 0, false},
     42                              {testStringCopy03, 3, "Verify empty string copy with length", 0, false},
     43                              {testStringCopy04, 4, "Copy string to larger string", 0, false},
     44                              {testStringCopy05, 5, "Copy string with negative size", 0, false},
     45                              {testStringCopy06, 6, "Verify creation of string literal", 0, false},
     46                              {NULL}
     47                          };
     48
     49int main( int argc, char* argv[] )
     50{
     51    psLogSetLevel( PS_LOG_INFO );
     52
     53    return ( ! runTestSuite( stderr, "psString", tests, argc, argv ) );
     54}
     55
     56/*
    3057int main( int argc,
    3158          char * argv[] )
     
    4673    int   memBlockAllocated = 0;
    4774    psMemBlock ***memBlockPtr = NULL;
     75 
     76*/
     77
     78static int testStringCopy00(void)
     79{
     80    char  stringval[20] = "E R R O R";
     81    int   result = 0;
     82    int   result1 = 0;
     83    char  *strResult;
    4884
    4985    // Test point #1 Verify string copy - psStringCopy
    50     printPositiveTestHeader(stderr,"psStringCopy","Verify string copy");
    5186    strResult = psStringCopy(stringval);
    5287    // Perform string compare
     
    6398        fprintf(stderr, "             changed           src = %s expected %s\n",strResult,
    6499                stringval);
    65         tpResult = false;
    66         tpFails++;
    67     } else {
    68         tpResult = true;
    69     }
     100        return 1;
     101    }
     102
    70103    // Free memory allocated
    71104    psFree(strResult);
    72     printFooter(stderr, "psStringCopy","Verify string copy", tpResult);
     105
     106    return 0;
     107}
     108
     109static int testStringCopy01(void)
     110{
     111    char  *emptyval = "";
     112    int   result = 0;
     113    char  *strResult;
    73114
    74115    // Test point #2 Verify empty string copy - psStringCopy
    75     printPositiveTestHeader(stderr,"psStringCopy","Verify empty string copy");
    76116    strResult = psStringCopy(emptyval);
    77117    // Perform string compare
     
    81121        fprintf(stderr,"                               src = %s expected %s\n",
    82122                strResult, emptyval);
    83         tpResult = false;
    84         tpFails++;
    85     } else {
    86         tpResult = true;
    87     }
     123        return 1;
     124    }
     125
    88126    // Free memory allocated
    89127    psFree(strResult);
    90     printFooter(stderr, "psStringCopy","Verify empty string copy", tpResult);
     128
     129    return 0;
     130}
     131
     132static int testStringCopy02(void)
     133{
     134    int   result = 0;
     135    int   result1 = 0;
     136    char  *strResult;
     137    char  stringval1[20] = "e r r o r";
     138    int   substringlen = 6;
     139    char  *substringval = "e r r";
    91140
    92141    // Test point #3 Verify string copy with length - psStringNCopy
    93     printPositiveTestHeader(stderr,"psStringNCopy","Verify string copy with length");
    94142    strResult = psStringNCopy(stringval1, substringlen);
    95143    // Perform string compare and get string length
     
    105153        fprintf(stderr,"                               src = %s expected %s\n",
    106154                strResult, substringval);
    107         tpResult = false;
    108         tpFails++;
    109     } else {
    110         tpResult = true;
     155        return 1;
    111156    }
    112157    // Free memory allocated
    113158    psFree(strResult);
    114     printFooter(stderr, "psStringNCopy","Verify string copy with length", tpResult);
     159
     160    return 0;
     161}
     162
     163static int testStringCopy03(void)
     164{
     165    int   result = 0;
     166    int   result1 = 0;
     167    char  *strResult;
     168    char  *stringvalnocopy = "F A I L";
    115169
    116170    // Test point #4 Verify empty string copy with length - psStringNCopy
    117     printPositiveTestHeader(stderr,"psStringNCopy", "Verify empty string copy with length");
    118171    strResult = psStringNCopy(stringvalnocopy, 0);
    119172    // Perform string compare and get sting length
     
    124177        fprintf(stderr,"                               src = %s didn't expected %s\n",
    125178                strResult, stringvalnocopy);
    126         tpResult = false;
    127         tpFails++;
    128     } else {
    129         tpResult = true;
     179        return 1;
    130180    }
    131181    // Free memory
    132182    psFree(strResult);
    133     printFooter(stderr, "psStringNCopy","Verify empty string copy with length", tpResult);
     183
     184    return 0;
     185}
     186
     187static int testStringCopy04(void)
     188{
     189    int   result = 0;
     190    int   result1 = 0;
     191    char  *strResult;
     192    char  stringval[20] = "E R R O R";
     193    int   increaseSize = 5;
    134194
    135195    // Test point #5 Copy string to larger string - psStringNCopy
    136     printPositiveTestHeader(stderr,"psStringNCopy", "Copy string to larger string");
    137196    strResult = psStringNCopy(stringval, (strlen(stringval) + increaseSize));
    138197    // Perform string compare and get string length
     
    147206        fprintf(stderr,"                     strlne result = %d expected %d\n",result1,
    148207                (int)strlen(stringval));
    149         tpResult = false;
    150         tpFails++;
    151     } else {
    152         tpResult = true;
     208        return 1;
    153209    }
    154210    // Free memory
    155211    psFree(strResult);
    156     printFooter(stderr, "psStringNCopy", "Copy string to larger string", tpResult);
     212
     213    return 0;
     214}
     215
     216static int testStringCopy05(void)
     217{
     218    char  *strResult;
     219    char  stringval[20] = "E R R O R";
     220    int   negativeSize = -5;
    157221
    158222    // Test point #6 Copy string with negative size - psStringNCopy
    159     printPositiveTestHeader(stderr,"psStringNCopy", "Copy string with negative size");
    160223    strResult = psStringNCopy(stringval, negativeSize);
    161224    if ( strResult != NULL ) {
    162225        fprintf(stderr,"Failed test point #6 return value = %ld expected NULL\n",
    163226                (unsigned long)strResult);
    164         tpResult = false;
    165         tpFails++;
    166     } else {
    167         tpResult = true;
     227        return 1;
    168228    }
    169229    // Memory should not have been allocated
    170     printFooter(stderr, "psStringNCopy", "Copy string with negative size", tpResult);
     230
     231    return 0;
     232}
     233
     234static int testStringCopy06(void)
     235{
     236    char  *strResult;
     237    char  stringval[20] = "E R R O R";
     238    int   result = 0;
    171239
    172240    // Test point #7 Verify creation of string literal - PS_STRING
    173     printPositiveTestHeader(stderr,"PS_STRING","Verify creation of string literal");
    174241    strResult = PS_STRING(E R R O R);
    175242    result = strcmp(strResult, stringval);
    176243    if ( result != 0 ) {
    177244        fprintf(stderr,"Failed test point #7 strcmp result = %d expected %d",result,0);
    178         tpResult = false;
    179         tpFails++;
    180     } else {
    181         tpResult = true;
     245        return 1;
    182246    }
    183247    // Memory should not have been allocated
    184     printFooter(stderr, "PS_STRING", "Verify creation of string literal", tpResult);
    185 
    186     // Check for memory leaks
    187     memBlockAllocated = psMemCheckLeaks(0, memBlockPtr, stderr);
    188     if ( memBlockAllocated != 0 ) {
    189         fprintf(stderr,"Failed - Memory leaks detected - Blocks still allocated = %d\n",
    190                 memBlockAllocated);
    191         tpFails++;
    192     }
    193 
    194     // Display test driver fail message if tpFail not zero
    195     if ( tpFails != 0 ) {
    196         fprintf(stderr,"Failed test driver  testpoint fail = %d expected %d\n",
    197                 tpFails, 0);
    198     }
    199 
    200     // Return number of test points which failed
    201     return tpFails;
    202 }
    203 
     248
     249    return 0;
     250}
  • trunk/psLib/test/sysUtils/tst_psStringCopy.c

    r1406 r1714  
    1717 *  @author  Eric Van Alst, MHPCC
    1818 *
    19  *  @version $Revision: 1.7 $  $Name: not supported by cvs2svn $
    20  *  @date  $Date: 2004-08-06 22:34:06 $
     19 *  @version $Revision: 1.8 $  $Name: not supported by cvs2svn $
     20 *  @date  $Date: 2004-09-08 00:09:36 $
    2121 *
    2222 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2828#include "psTest.h"
    2929
     30static int testStringCopy00(void);
     31static int testStringCopy01(void);
     32static int testStringCopy02(void);
     33static int testStringCopy03(void);
     34static int testStringCopy04(void);
     35static int testStringCopy05(void);
     36static int testStringCopy06(void);
     37
     38testDescription tests[] = {
     39                              {testStringCopy00, 0, "Verify string copy", 0, false},
     40                              {testStringCopy01, 1, "Verify empty string copy", 0, false},
     41                              {testStringCopy02, 2, "Verify string copy with length", 0, false},
     42                              {testStringCopy03, 3, "Verify empty string copy with length", 0, false},
     43                              {testStringCopy04, 4, "Copy string to larger string", 0, false},
     44                              {testStringCopy05, 5, "Copy string with negative size", 0, false},
     45                              {testStringCopy06, 6, "Verify creation of string literal", 0, false},
     46                              {NULL}
     47                          };
     48
     49int main( int argc, char* argv[] )
     50{
     51    psLogSetLevel( PS_LOG_INFO );
     52
     53    return ( ! runTestSuite( stderr, "psString", tests, argc, argv ) );
     54}
     55
     56/*
    3057int main( int argc,
    3158          char * argv[] )
     
    4673    int   memBlockAllocated = 0;
    4774    psMemBlock ***memBlockPtr = NULL;
     75 
     76*/
     77
     78static int testStringCopy00(void)
     79{
     80    char  stringval[20] = "E R R O R";
     81    int   result = 0;
     82    int   result1 = 0;
     83    char  *strResult;
    4884
    4985    // Test point #1 Verify string copy - psStringCopy
    50     printPositiveTestHeader(stderr,"psStringCopy","Verify string copy");
    5186    strResult = psStringCopy(stringval);
    5287    // Perform string compare
     
    6398        fprintf(stderr, "             changed           src = %s expected %s\n",strResult,
    6499                stringval);
    65         tpResult = false;
    66         tpFails++;
    67     } else {
    68         tpResult = true;
    69     }
     100        return 1;
     101    }
     102
    70103    // Free memory allocated
    71104    psFree(strResult);
    72     printFooter(stderr, "psStringCopy","Verify string copy", tpResult);
     105
     106    return 0;
     107}
     108
     109static int testStringCopy01(void)
     110{
     111    char  *emptyval = "";
     112    int   result = 0;
     113    char  *strResult;
    73114
    74115    // Test point #2 Verify empty string copy - psStringCopy
    75     printPositiveTestHeader(stderr,"psStringCopy","Verify empty string copy");
    76116    strResult = psStringCopy(emptyval);
    77117    // Perform string compare
     
    81121        fprintf(stderr,"                               src = %s expected %s\n",
    82122                strResult, emptyval);
    83         tpResult = false;
    84         tpFails++;
    85     } else {
    86         tpResult = true;
    87     }
     123        return 1;
     124    }
     125
    88126    // Free memory allocated
    89127    psFree(strResult);
    90     printFooter(stderr, "psStringCopy","Verify empty string copy", tpResult);
     128
     129    return 0;
     130}
     131
     132static int testStringCopy02(void)
     133{
     134    int   result = 0;
     135    int   result1 = 0;
     136    char  *strResult;
     137    char  stringval1[20] = "e r r o r";
     138    int   substringlen = 6;
     139    char  *substringval = "e r r";
    91140
    92141    // Test point #3 Verify string copy with length - psStringNCopy
    93     printPositiveTestHeader(stderr,"psStringNCopy","Verify string copy with length");
    94142    strResult = psStringNCopy(stringval1, substringlen);
    95143    // Perform string compare and get string length
     
    105153        fprintf(stderr,"                               src = %s expected %s\n",
    106154                strResult, substringval);
    107         tpResult = false;
    108         tpFails++;
    109     } else {
    110         tpResult = true;
     155        return 1;
    111156    }
    112157    // Free memory allocated
    113158    psFree(strResult);
    114     printFooter(stderr, "psStringNCopy","Verify string copy with length", tpResult);
     159
     160    return 0;
     161}
     162
     163static int testStringCopy03(void)
     164{
     165    int   result = 0;
     166    int   result1 = 0;
     167    char  *strResult;
     168    char  *stringvalnocopy = "F A I L";
    115169
    116170    // Test point #4 Verify empty string copy with length - psStringNCopy
    117     printPositiveTestHeader(stderr,"psStringNCopy", "Verify empty string copy with length");
    118171    strResult = psStringNCopy(stringvalnocopy, 0);
    119172    // Perform string compare and get sting length
     
    124177        fprintf(stderr,"                               src = %s didn't expected %s\n",
    125178                strResult, stringvalnocopy);
    126         tpResult = false;
    127         tpFails++;
    128     } else {
    129         tpResult = true;
     179        return 1;
    130180    }
    131181    // Free memory
    132182    psFree(strResult);
    133     printFooter(stderr, "psStringNCopy","Verify empty string copy with length", tpResult);
     183
     184    return 0;
     185}
     186
     187static int testStringCopy04(void)
     188{
     189    int   result = 0;
     190    int   result1 = 0;
     191    char  *strResult;
     192    char  stringval[20] = "E R R O R";
     193    int   increaseSize = 5;
    134194
    135195    // Test point #5 Copy string to larger string - psStringNCopy
    136     printPositiveTestHeader(stderr,"psStringNCopy", "Copy string to larger string");
    137196    strResult = psStringNCopy(stringval, (strlen(stringval) + increaseSize));
    138197    // Perform string compare and get string length
     
    147206        fprintf(stderr,"                     strlne result = %d expected %d\n",result1,
    148207                (int)strlen(stringval));
    149         tpResult = false;
    150         tpFails++;
    151     } else {
    152         tpResult = true;
     208        return 1;
    153209    }
    154210    // Free memory
    155211    psFree(strResult);
    156     printFooter(stderr, "psStringNCopy", "Copy string to larger string", tpResult);
     212
     213    return 0;
     214}
     215
     216static int testStringCopy05(void)
     217{
     218    char  *strResult;
     219    char  stringval[20] = "E R R O R";
     220    int   negativeSize = -5;
    157221
    158222    // Test point #6 Copy string with negative size - psStringNCopy
    159     printPositiveTestHeader(stderr,"psStringNCopy", "Copy string with negative size");
    160223    strResult = psStringNCopy(stringval, negativeSize);
    161224    if ( strResult != NULL ) {
    162225        fprintf(stderr,"Failed test point #6 return value = %ld expected NULL\n",
    163226                (unsigned long)strResult);
    164         tpResult = false;
    165         tpFails++;
    166     } else {
    167         tpResult = true;
     227        return 1;
    168228    }
    169229    // Memory should not have been allocated
    170     printFooter(stderr, "psStringNCopy", "Copy string with negative size", tpResult);
     230
     231    return 0;
     232}
     233
     234static int testStringCopy06(void)
     235{
     236    char  *strResult;
     237    char  stringval[20] = "E R R O R";
     238    int   result = 0;
    171239
    172240    // Test point #7 Verify creation of string literal - PS_STRING
    173     printPositiveTestHeader(stderr,"PS_STRING","Verify creation of string literal");
    174241    strResult = PS_STRING(E R R O R);
    175242    result = strcmp(strResult, stringval);
    176243    if ( result != 0 ) {
    177244        fprintf(stderr,"Failed test point #7 strcmp result = %d expected %d",result,0);
    178         tpResult = false;
    179         tpFails++;
    180     } else {
    181         tpResult = true;
     245        return 1;
    182246    }
    183247    // Memory should not have been allocated
    184     printFooter(stderr, "PS_STRING", "Verify creation of string literal", tpResult);
    185 
    186     // Check for memory leaks
    187     memBlockAllocated = psMemCheckLeaks(0, memBlockPtr, stderr);
    188     if ( memBlockAllocated != 0 ) {
    189         fprintf(stderr,"Failed - Memory leaks detected - Blocks still allocated = %d\n",
    190                 memBlockAllocated);
    191         tpFails++;
    192     }
    193 
    194     // Display test driver fail message if tpFail not zero
    195     if ( tpFails != 0 ) {
    196         fprintf(stderr,"Failed test driver  testpoint fail = %d expected %d\n",
    197                 tpFails, 0);
    198     }
    199 
    200     // Return number of test points which failed
    201     return tpFails;
    202 }
    203 
     248
     249    return 0;
     250}
  • trunk/psLib/test/sysUtils/verified/tst_psMemory.stderr

    r1694 r1714  
    115115<DATE><TIME>|<HOST>|I| TPmultipleFree|Next should be an error about multiple freeing.
    116116<DATE><TIME>|<HOST>|E|psLib.sysUtils.|Memory block 1 was freed but still used.
    117 <DATE><TIME>|<HOST>|E|psLib.sysUtils.|Block 1 allocated at tst_psMemory.c:<LINENO> freed more than once at tst_psMemory.c:<LINENO>
     117<DATE><TIME>|<HOST>|E|psLib.sysUtils.|Block 1 allocated at tst_psMemory.c:<LINENO> freed more than once at tst_psMemory.c:<LINENO>.
    118118<DATE><TIME>|<HOST>|A|memProblemCallb|Detected a problem in the memory system at tst_psMemory.c:<LINENO>
    119119
  • trunk/psLib/test/sysUtils/verified/tst_psStringCopy.stderr

    r1404 r1714  
    11/***************************** TESTPOINT ******************************************\
    22*             TestFile: tst_psStringCopy.c                                         *
    3 *            TestPoint: psStringCopy{Verify string copy}                           *
     3*            TestPoint: psString{Verify string copy}                               *
    44*             TestType: Positive                                                   *
    55\**********************************************************************************/
    66
    77
    8 ---> TESTPOINT PASSED (psStringCopy{Verify string copy} | tst_psStringCopy.c)
     8---> TESTPOINT PASSED (psString{Verify string copy} | tst_psStringCopy.c)
    99
    1010/***************************** TESTPOINT ******************************************\
    1111*             TestFile: tst_psStringCopy.c                                         *
    12 *            TestPoint: psStringCopy{Verify empty string copy}                     *
     12*            TestPoint: psString{Verify empty string copy}                         *
    1313*             TestType: Positive                                                   *
    1414\**********************************************************************************/
    1515
    1616
    17 ---> TESTPOINT PASSED (psStringCopy{Verify empty string copy} | tst_psStringCopy.c)
     17---> TESTPOINT PASSED (psString{Verify empty string copy} | tst_psStringCopy.c)
    1818
    1919/***************************** TESTPOINT ******************************************\
    2020*             TestFile: tst_psStringCopy.c                                         *
    21 *            TestPoint: psStringNCopy{Verify string copy with length}              *
     21*            TestPoint: psString{Verify string copy with length}                   *
    2222*             TestType: Positive                                                   *
    2323\**********************************************************************************/
    2424
    2525
    26 ---> TESTPOINT PASSED (psStringNCopy{Verify string copy with length} | tst_psStringCopy.c)
     26---> TESTPOINT PASSED (psString{Verify string copy with length} | tst_psStringCopy.c)
    2727
    2828/***************************** TESTPOINT ******************************************\
    2929*             TestFile: tst_psStringCopy.c                                         *
    30 *            TestPoint: psStringNCopy{Verify empty string copy with length}        *
     30*            TestPoint: psString{Verify empty string copy with length}             *
    3131*             TestType: Positive                                                   *
    3232\**********************************************************************************/
    3333
    3434
    35 ---> TESTPOINT PASSED (psStringNCopy{Verify empty string copy with length} | tst_psStringCopy.c)
     35---> TESTPOINT PASSED (psString{Verify empty string copy with length} | tst_psStringCopy.c)
    3636
    3737/***************************** TESTPOINT ******************************************\
    3838*             TestFile: tst_psStringCopy.c                                         *
    39 *            TestPoint: psStringNCopy{Copy string to larger string}                *
     39*            TestPoint: psString{Copy string to larger string}                     *
    4040*             TestType: Positive                                                   *
    4141\**********************************************************************************/
    4242
    4343
    44 ---> TESTPOINT PASSED (psStringNCopy{Copy string to larger string} | tst_psStringCopy.c)
     44---> TESTPOINT PASSED (psString{Copy string to larger string} | tst_psStringCopy.c)
    4545
    4646/***************************** TESTPOINT ******************************************\
    4747*             TestFile: tst_psStringCopy.c                                         *
    48 *            TestPoint: psStringNCopy{Copy string with negative size}              *
     48*            TestPoint: psString{Copy string with negative size}                   *
    4949*             TestType: Positive                                                   *
    5050\**********************************************************************************/
    5151
    52 <DATE><TIME>|<HOST>|E|     psString.c|psStringNCopy with negative count specified -5
     52<DATE><TIME>|<HOST>|E|psLib.sysUtils.|Can not copy a negative number of characters (-5)
    5353
    54 ---> TESTPOINT PASSED (psStringNCopy{Copy string with negative size} | tst_psStringCopy.c)
     54---> TESTPOINT PASSED (psString{Copy string with negative size} | tst_psStringCopy.c)
    5555
    5656/***************************** TESTPOINT ******************************************\
    5757*             TestFile: tst_psStringCopy.c                                         *
    58 *            TestPoint: PS_STRING{Verify creation of string literal}               *
     58*            TestPoint: psString{Verify creation of string literal}                *
    5959*             TestType: Positive                                                   *
    6060\**********************************************************************************/
    6161
    6262
    63 ---> TESTPOINT PASSED (PS_STRING{Verify creation of string literal} | tst_psStringCopy.c)
     63---> TESTPOINT PASSED (psString{Verify creation of string literal} | tst_psStringCopy.c)
    6464
Note: See TracChangeset for help on using the changeset viewer.