IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 2622


Ignore:
Timestamp:
Dec 3, 2004, 3:17:49 PM (22 years ago)
Author:
evanalst
Message:

Add additional cases for psHashLookup.

Location:
trunk/psLib/test/collections
Files:
1 added
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/test/collections/tst_psHash02.c

    r2392 r2622  
    4949    psS32 memLeaks        = 0;
    5050
    51     printPositiveTestHeader(stdout,
    52                             "psHash functions",
    53                             "psHashAdd()");
     51    printPositiveTestHeader(stdout,"psHash functions","psHashLookup");
    5452
    5553    myHashTable = psHashAlloc(NUM_HASH_TABLE_BUCKETS);
     
    6866            fprintf(stderr, "%s: Hash table entry for key %s was %s (should be %s).\n",
    6967                    __func__, myKeys[i], id->name, myData[i]);
     68            return 1;
    7069        }
    7170        i++;
    7271    }
     72    printFooter(stdout,"psHash functions","psHashLookup",true);
     73
     74    // Use an invalid key in the hash table: verify no item is returned
     75    printNegativeTestHeader(stdout,"psHashLookup","Invalid key","Key is not found in the table",0);
    7376    id = psHashLookup(myHashTable, "BogusKey");
    7477    if (id != NULL) {
    7578        fprintf(stderr, "%s: Hash table entry for key %s was not NULL.\n",
    7679                __func__, "BogusKey");
     80        return 2;
    7781    }
     82    printFooter(stdout,"psHashLookup","Invalid key",true);
    7883
    79     //    psHashFree(myHashTable, NULL);
     84    // Lookup with null table
     85    printNegativeTestHeader(stdout,"psHashLookup","NULL table","Can not lookup with NULL table",0);
     86    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message: psHashLookup with null table");
     87    id = psHashLookup(NULL,"ENTRY01");
     88    if (id != NULL) {
     89        psError(PS_ERR_UNKNOWN,true,"psHashLookup retrieved an entry from NULL hash table.");
     90        return 3;
     91    }
     92    printFooter(stdout,"psHashLookup","NULL table",true);
     93
     94    // Lookup with null key
     95    printNegativeTestHeader(stdout,"psHashLookup","NULL key","Can not lookup with NULL key.",0);
     96    psLogMsg(__func__,PS_LOG_INFO,"Following should generate an error message: psHashLookup with null key");
     97    id = psHashLookup(myHashTable,NULL);
     98    if (id != NULL) {
     99        psError(PS_ERR_UNKNOWN,true,"psHashLookup retrieved an entry with NULL key.");
     100        return 4;
     101    }
     102    printFooter(stdout,"psHashLookup","NULL key",true);
     103
    80104    psFree(myHashTable);
    81105
     
    86110    psMemCheckCorruption(1);
    87111
    88     printFooter(stdout,
    89                 "psHash functions",
    90                 "psHashAdd()",
    91                 testStatus);
    92 
    93112    return (!testStatus);
    94113}
  • trunk/psLib/test/collections/verified/tst_psHash02.stderr

    r1421 r2622  
     1<DATE><TIME>|<HOST>|I|main
     2    Following should generate an error message: psHashLookup with null table
     3<DATE><TIME>|<HOST>|E|psHashLookup (psHash.c:<LINENO>)
     4    Input psHash can not be NULL.
     5<DATE><TIME>|<HOST>|I|main
     6    Following should generate an error message: psHashLookup with null key
     7<DATE><TIME>|<HOST>|E|psHashLookup (psHash.c:<LINENO>)
     8    Input key can not be NULL.
Note: See TracChangeset for help on using the changeset viewer.