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