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#include <string.h>
9
10#if defined __STDC__ || defined __cplusplus
11extern char * in_word_set (const char *, int);
12#else
13extern char * in_word_set ();
14#endif
15
16#define MAX_LEN 80
17
18int
19main (argc, argv)
20     int   argc;
21     char *argv[];
22{
23  int  verbose = argc > 1 ? 1 : 0;
24  char buf[MAX_LEN];
25
26  while (fgets (buf, MAX_LEN, stdin))
27    {
28      if (strlen (buf) > 0 && buf[strlen (buf) - 1] == '\n')
29        buf[strlen (buf) - 1] = '\0';
30
31      if (in_word_set (buf, strlen (buf)))
32        {
33          if (verbose)
34            printf ("in word set %s\n", buf);
35        }
36      else
37        {
38          if (verbose)
39            printf ("NOT in word set %s\n", buf);
40        }
41    }
42
43  return 0;
44}
45