|
1 /* |
|
2 * |
|
3 */ |
|
4 |
|
5 #include <stdio.h> |
|
6 #include <stdlib.h> |
|
7 #include <string.h> |
|
8 |
|
9 #include "map_tests.h" |
|
10 |
|
11 int map_tests() { |
|
12 printf(" Test ucx_map_new\n"); |
|
13 UcxMap *map = ucx_map_new(16); |
|
14 if(map == NULL) { |
|
15 return -1; |
|
16 } |
|
17 |
|
18 printf(" Test ucx_map_put\n"); |
|
19 char *txt = "text/plain"; |
|
20 char *xml = "text/xml"; |
|
21 ucx_map_cstr_put(map, "txt", txt); |
|
22 ucx_map_cstr_put(map, "xml", xml); |
|
23 |
|
24 printf(" Test ucx_map_get\n"); |
|
25 if(ucx_map_cstr_get(map, "txt") != txt) { |
|
26 fprintf(stderr, "ucx_map_get failed\n"); |
|
27 return -1; |
|
28 } |
|
29 char xmlkey[4]; |
|
30 xmlkey[0] = 'x'; |
|
31 xmlkey[1] = 'm'; |
|
32 xmlkey[2] = 'l'; |
|
33 xmlkey[3] = 0; |
|
34 if(ucx_map_cstr_get(map, xmlkey) != xml) { |
|
35 fprintf(stderr, "ucx_map_get failed\n"); |
|
36 return -1; |
|
37 } |
|
38 if(ucx_map_cstr_get(map, "nokey") != NULL) { |
|
39 fprintf(stderr, "ucx_map_get failed\n"); |
|
40 return -1; |
|
41 } |
|
42 |
|
43 return 0; |
|
44 } |