test/map_tests.c

Thu, 05 Jan 2012 14:53:54 +0100

author
Olaf Wintermann <olaf.wintermann@gmail.com>
date
Thu, 05 Jan 2012 14:53:54 +0100
changeset 20
db7d9860dbbd
child 29
bce0d7f2912b
permissions
-rw-r--r--

added some map functions

     1 /*
     2  *
     3  */
     5 #include <stdio.h>
     6 #include <stdlib.h>
     7 #include <string.h>
     9 #include "map_tests.h"
    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     }
    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);
    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     }
    43     return 0;
    44 }

mercurial