1 | #include <search.h> |
2 | #include <stdio.h> |
3 | |
4 | static int |
5 | do_test (void) |
6 | { |
7 | if (hcreate (nel: 1) == 0) |
8 | { |
9 | puts (s: "hcreate failed" ); |
10 | return 1; |
11 | } |
12 | ENTRY e; |
13 | e.key = (char *) "a" ; |
14 | e.data = (char *) "b" ; |
15 | if (hsearch (item: e, action: ENTER) == NULL) |
16 | { |
17 | puts (s: "ENTER failed" ); |
18 | return 1; |
19 | } |
20 | ENTRY s; |
21 | s.key = (char *) "c" ; |
22 | if (hsearch (item: s, action: FIND) != NULL) |
23 | { |
24 | puts (s: "FIND succeeded" ); |
25 | return 1; |
26 | } |
27 | return 0; |
28 | } |
29 | |
30 | #define TEST_FUNCTION do_test () |
31 | #include "../test-skeleton.c" |
32 | |