Initial import from FreeBSD RELENG_4:
[dragonfly.git] / contrib / gperf / tests / test.c
1 /*
2    Tests the generated perfect hash function.
3    The -v option prints diagnostics as to whether a word is in 
4    the set or not.  Without -v the program is useful for timing.
5 */ 
6   
7 #include <stdio.h>
8
9 #define MAX_LEN 80
10
11 int 
12 main (argc, argv) 
13      int   argc;
14      char *argv[];
15 {
16   int  verbose = argc > 1 ? 1 : 0;
17   char buf[MAX_LEN];
18
19   while (gets (buf)) 
20     if (in_word_set (buf, strlen (buf)) && verbose) 
21       printf ("in word set %s\n", buf);
22     else if (verbose) 
23       printf ("NOT in word set %s\n", buf);
24
25   return 0;
26 }