1
0
mirror of https://git.savannah.gnu.org/git/gperf.git synced 2025-12-02 13:09:22 +00:00

Add tests for 8-bit clean comparison and binary comparison.

This commit is contained in:
Bruno Haible
2000-08-20 20:35:53 +00:00
parent 3354d156d6
commit ac65860e4b
8 changed files with 161 additions and 1 deletions

45
tests/test2.c Normal file
View File

@@ -0,0 +1,45 @@
/*
Tests the generated perfect hash function.
The -v option prints diagnostics as to whether a word is in
the set or not. Without -v the program is useful for timing.
*/
#include <stdio.h>
#define MAX_LEN 80
int
main (argc, argv)
int argc;
char *argv[];
{
int verbose = argc > 1 ? 1 : 0;
char buf[2*MAX_LEN];
int buflen;
for (;;)
{
/* Simulate gets(buf) with 2 bytes per character. */
char *p = buf;
while (fread (p, 2, 1, stdin) == 1)
{
if ((p[0] << 8) + p[1] == '\n')
break;
p += 2;
}
buflen = p - buf;
if (buflen == 0)
break;
if (in_word_set (buf, buflen) && verbose)
printf ("in word set ");
else if (verbose)
printf ("NOT in word set ");
for (p = buf; p < buf + buflen; p++)
printf ("%02X", (unsigned char) *p);
printf("\n");
}
return 0;
}