1 // Tests the generated perfect hash function.
3 // The -v option prints diagnostics as to whether a word is in the set
4 // or not. Without -v the program is useful for timing.
6 #include "ace/OS_NS_string.h"
7 #include "ace/OS_NS_stdio.h"
9 static const int MAX_LEN
= 80;
12 const char *in_word_set (const char *str
, unsigned int len
);
15 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
17 int verbose
= argc
> 1 && ACE_OS::strcmp (argv
[1], ACE_TEXT("-v")) == 0 ? 1 : 0;
20 while (ACE_OS::fgets (buf
, sizeof buf
, stdin
) != 0)
22 size_t len
= ACE_OS::strlen (buf
) - 1;
24 if (in_word_set (buf
, len
) && verbose
)
25 ACE_OS::printf ("in word set %s\n", buf
);
27 ACE_OS::printf ("NOT in word set %s\n", buf
);