IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Apr 28, 2004, 12:00:02 PM (22 years ago)
Author:
evanalst
Message:

Add addition information to STDERR if test points fail.

File:
1 edited

Legend:

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

    r532 r543  
    1111 *    5) Copy string to larger string - psStringNCopy
    1212 *    6) Copy string with negative size - psStringNCopy
    13  
     13 *
    1414 *  Return:   Number of test points which failed
    1515 *
    1616 *  @author  Eric Van Alst, MHPCC
    1717 *
    18  *  @version $Revision: 1.1 $  $Name: not supported by cvs2svn $
    19  *  @date  $Date: 2004-04-27 22:57:09 $
     18 *  @version $Revision: 1.2 $  $Name: not supported by cvs2svn $
     19 *  @date  $Date: 2004-04-28 22:00:02 $
    2020 *
    2121 *  Copyright 2004 Maui High Performance Computing Center, University of Hawaii
     
    2727#include "psTest.h"
    2828
    29 int main(void)
     29int main( int argc,
     30          char * argv[] )
    3031{
    3132    bool  tpResult = false;
     
    3839    int   increaseSize = 5;
    3940    int   negativeSize = -5;
     41    int   result = 0;
     42    int   result1 = 0;
    4043
    4144    // Test point #1 Verify string copy - psStringCopy
    4245    printPositiveTestHeader(stderr,"psStringCopy","Verify string copy");
    4346    strResult = psStringCopy(stringval);
    44     if ( strcmp(strResult, stringval) != 0 ) {
     47    // Perform string compare
     48    result = strcmp(strResult, stringval);
     49    if ( result != 0 ) {
     50        fprintf(stderr, "Failed test point #1 strcmp result = %d expected 0\n",result);
    4551        tpResult = false;
    4652        tpFails++;
     
    5359    printPositiveTestHeader(stderr,"psStringCopy","Verify empty string copy");
    5460    strResult = psStringCopy(emptyval);
    55     if ( strcmp(strResult, emptyval) != 0 ) {
     61    // Perform string compare
     62    result = strcmp(strResult, emptyval);
     63    if ( result != 0 ) {
     64        fprintf(stderr,"Failed test point #2 strcmp result = %d expected 0\n",result);
    5665        tpResult = false;
    5766        tpFails++;
     
    6473    printPositiveTestHeader(stderr,"psStringNCopy","Verify string copy with length");
    6574    strResult = psStringNCopy(stringval, substringlen);
    66     if ( strcmp(strResult, substringval) != 0 ) {
     75    // Perform string compare and get string length
     76    result = strcmp(strResult, substringval);
     77    result1 = strlen(strResult);
     78    if ( ( result != 0 ) ||
     79            ( result1 != substringlen ) ) {
     80        fprintf(stderr,"Failed test point #3 strcmp result = %d expected 0\n",result);
     81        fprintf(stderr,"                     strlen result = %d expected %d\n",
     82                result1, substringlen);
    6783        tpResult = false;
    6884        tpFails++;
     
    7591    printPositiveTestHeader(stderr,"psStringNCopy", "Verify empty string copy with length");
    7692    strResult = psStringNCopy(stringval, 0);
    77     if ( (strcmp(strResult, emptyval) != 0 ) ||
    78             (strlen(strResult) != strlen(emptyval) ) ) {
     93    // Perform string compare and get sting length
     94    result = strcmp(strResult, emptyval);
     95    result1 = strlen(strResult);
     96    if ( ( result != 0 ) ||
     97            ( result1 != strlen(emptyval) ) ) {
     98        fprintf(stderr,"Failed test point #4 strcmp result = %d expected %d\n",result,0);
     99        fprintf(stderr,"                     strlen result = %d expected %d\n",result1,
     100                (int)strlen(emptyval));
    79101        tpResult = false;
    80102        tpFails++;
     
    87109    printPositiveTestHeader(stderr,"psStringNCopy", "Copy string to larger string");
    88110    strResult = psStringNCopy(stringval, (strlen(stringval) + increaseSize));
     111    // Perform string compare and get string length
     112    result = strcmp(strResult, stringval);
     113    result1 = strlen(strResult);
    89114    // The strings should still compare
    90     if ( ( strcmp(strResult, stringval) != 0 ) ||
    91             ( strlen(strResult) != strlen(stringval) ) ) {
     115    if ( ( result != 0 ) ||
     116            ( result1 != strlen(stringval) ) ) {
     117        fprintf(stderr,"Failed test point #5 strcmp result = %d expected %d\n",result,0);
     118        fprintf(stderr,"                     strlne result = %d expected %d\n",result1,
     119                (int)strlen(stringval));
    92120        tpResult = false;
    93121        tpFails++;
     
    101129    strResult = psStringNCopy(stringval, negativeSize);
    102130    if ( strResult != NULL ) {
     131        fprintf(stderr,"Failed test point #6 return value = %ld expected NULL\n",
     132                (unsigned long)strResult);
    103133        tpResult = false;
    104134        tpFails++;
     
    108138    printFooter(stderr, "psStringNCopy", "Copy string with negative size", tpResult);
    109139
     140    // Display test driver fail message if tpFail not zero
     141    if ( tpFails != 0 ) {
     142        fprintf(stderr,"Failed test driver  testpoint fail = %d expected %d\n",
     143                tpFails, 0);
     144    }
     145
    110146    // Return number of test points which failed
    111147    return tpFails;
Note: See TracChangeset for help on using the changeset viewer.