Changeset 2622
- Timestamp:
- Dec 3, 2004, 3:17:49 PM (22 years ago)
- Location:
- trunk/psLib/test/collections
- Files:
-
- 1 added
- 2 edited
-
tst_psHash02.c (modified) (3 diffs)
-
verified/tst_psHash02.stderr (modified) (1 diff)
-
verified/tst_psHash02.stdout (added)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/test/collections/tst_psHash02.c
r2392 r2622 49 49 psS32 memLeaks = 0; 50 50 51 printPositiveTestHeader(stdout, 52 "psHash functions", 53 "psHashAdd()"); 51 printPositiveTestHeader(stdout,"psHash functions","psHashLookup"); 54 52 55 53 myHashTable = psHashAlloc(NUM_HASH_TABLE_BUCKETS); … … 68 66 fprintf(stderr, "%s: Hash table entry for key %s was %s (should be %s).\n", 69 67 __func__, myKeys[i], id->name, myData[i]); 68 return 1; 70 69 } 71 70 i++; 72 71 } 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); 73 76 id = psHashLookup(myHashTable, "BogusKey"); 74 77 if (id != NULL) { 75 78 fprintf(stderr, "%s: Hash table entry for key %s was not NULL.\n", 76 79 __func__, "BogusKey"); 80 return 2; 77 81 } 82 printFooter(stdout,"psHashLookup","Invalid key",true); 78 83 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 80 104 psFree(myHashTable); 81 105 … … 86 110 psMemCheckCorruption(1); 87 111 88 printFooter(stdout,89 "psHash functions",90 "psHashAdd()",91 testStatus);92 93 112 return (!testStatus); 94 113 } -
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.
