summaryrefslogtreecommitdiff
path: root/misc/bug-hsearch1.c
blob: 6097b5ad041020a247102efa09285a4944bd54c3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include <search.h>
#include <stdio.h>

static int
do_test (void)
{
  if (hcreate (1) == 0)
    {
      puts ("hcreate failed");
      return 1;
    }
  ENTRY e;
  e.key = (char *) "a";
  e.data = (char *) "b";
  if (hsearch (e, ENTER) == NULL)
    {
      puts ("ENTER failed");
      return 1;
    }
  ENTRY s;
  s.key = (char *) "c";
  if (hsearch (s, FIND) != NULL)
    {
      puts ("FIND succeeded");
      return 1;
    }
  return 0;
}

#define TEST_FUNCTION do_test ()
#include "../test-skeleton.c"