adding a test case
[IRC.git] / Robust / src / Runtime / DSTM / interface / tests / testllookup.c
1 #include <stdio.h>
2 #include "llookup.h"
3 extern lhashtable_t llookup;
4
5 main() 
6 {
7         int i, mid;
8
9         if (lhashCreate(10, 0.20) == 1) {
10                 printf("lhashCreate error\n");  //creates hashtable
11         }
12         for (i = 1; i <= 7; i++) {      // Checks the insert() and resize() 
13                 if (lhashInsert(10*i, i) == 1) 
14                         printf("lhashInsert error\n");
15         }
16
17         i = lhashRemove(10);//Delete first element in the  hashtable
18         if(i == 1)
19                 printf("lhashRemove error ");
20         
21         for (i = 1; i <=7; i++) { // Check if it can search for all oids in hash table
22                 mid = lhashSearch(10*i);
23                 if (mid != i) 
24                         printf("lhashSearch error - mid = %d\n", mid);
25                 else
26                         printf("lhashSearch oid = %d mid = %d\n",10*i, mid);
27         }
28
29         i = lhashRemove(60);
30         if(i == 1)
31                 printf("lhashRemove error ");
32         
33         for (i = 1; i <= 7; i++) {      //Prints all left over elements inside hash after deletion and prints error if element not found in hash
34                 mid = lhashSearch(10*i);
35                 if (mid != i) 
36                         printf("lhashSearch error - mid = %d\n", mid);
37                 else
38                         printf("lhashSearch oid = %d mid = %d\n",10*i, mid);
39         }
40
41         printf(" The total number of elements in table : %d\n", llookup.numelements);
42
43 }