2 #define _XOPEN_SOURCE 700
11 #define set(k,v) do{ \
12 e = hsearch((ENTRY){.key = k, .data = (void*)v}, ENTER); \
13 if (!e || strcmp(e->key, k) != 0) \
14 t_error("hsearch ENTER %s %d failed\n", k, v); \
17 #define get(k) hsearch((ENTRY){.key = k, .data = 0}, FIND)
19 #define getdata(e) ((intptr_t)(e)->data)
25 if (hcreate(-1) || errno
!= ENOMEM
)
26 t_error("hcreate((size_t)-1) should fail with ENOMEM got %s\n", strerror(errno
));
28 t_error("hcreate(13) failed\n");
40 t_error("hsearch FIND a failed\n");
42 t_error("hsearch FIND c should fail\n");
44 if (e
&& getdata(e
) != 7)
45 t_error("hsearch ENTER g 10 returned data %d, wanted 7\n", getdata(e
));
47 if (e
&& getdata(e
) != 7)
48 t_error("hsearch ENTER g 10 returned data %d, wanted 7\n", getdata(e
));
50 if (e
&& getdata(e
) != 10)
51 t_error("hsearch ENTER j 10 returned data %d, wanted 10\n", getdata(e
));