1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/test/map_tests.c Thu Jan 05 14:53:54 2012 +0100 1.3 @@ -0,0 +1,44 @@ 1.4 +/* 1.5 + * 1.6 + */ 1.7 + 1.8 +#include <stdio.h> 1.9 +#include <stdlib.h> 1.10 +#include <string.h> 1.11 + 1.12 +#include "map_tests.h" 1.13 + 1.14 +int map_tests() { 1.15 + printf(" Test ucx_map_new\n"); 1.16 + UcxMap *map = ucx_map_new(16); 1.17 + if(map == NULL) { 1.18 + return -1; 1.19 + } 1.20 + 1.21 + printf(" Test ucx_map_put\n"); 1.22 + char *txt = "text/plain"; 1.23 + char *xml = "text/xml"; 1.24 + ucx_map_cstr_put(map, "txt", txt); 1.25 + ucx_map_cstr_put(map, "xml", xml); 1.26 + 1.27 + printf(" Test ucx_map_get\n"); 1.28 + if(ucx_map_cstr_get(map, "txt") != txt) { 1.29 + fprintf(stderr, "ucx_map_get failed\n"); 1.30 + return -1; 1.31 + } 1.32 + char xmlkey[4]; 1.33 + xmlkey[0] = 'x'; 1.34 + xmlkey[1] = 'm'; 1.35 + xmlkey[2] = 'l'; 1.36 + xmlkey[3] = 0; 1.37 + if(ucx_map_cstr_get(map, xmlkey) != xml) { 1.38 + fprintf(stderr, "ucx_map_get failed\n"); 1.39 + return -1; 1.40 + } 1.41 + if(ucx_map_cstr_get(map, "nokey") != NULL) { 1.42 + fprintf(stderr, "ucx_map_get failed\n"); 1.43 + return -1; 1.44 + } 1.45 + 1.46 + return 0; 1.47 +}