test/map_tests.c

Thu, 09 Feb 2012 10:40:19 +0100

author
Mike Becker <universe@uap-core.de>
date
Thu, 09 Feb 2012 10:40:19 +0100
changeset 25
3192553c0df1
parent 20
db7d9860dbbd
child 29
bce0d7f2912b
permissions
-rw-r--r--

changed hgignore filter

/*
 *
 */

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include "map_tests.h"

int map_tests() {
    printf("   Test ucx_map_new\n");
    UcxMap *map = ucx_map_new(16);
    if(map == NULL) {
        return -1;
    }

    printf("   Test ucx_map_put\n");
    char *txt = "text/plain";
    char *xml = "text/xml";
    ucx_map_cstr_put(map, "txt", txt);
    ucx_map_cstr_put(map, "xml", xml);

    printf("   Test ucx_map_get\n");
    if(ucx_map_cstr_get(map, "txt") != txt) {
        fprintf(stderr, "ucx_map_get failed\n");
        return -1;
    }
    char xmlkey[4];
    xmlkey[0] = 'x';
    xmlkey[1] = 'm';
    xmlkey[2] = 'l';
    xmlkey[3] = 0;
    if(ucx_map_cstr_get(map, xmlkey) != xml) {
        fprintf(stderr, "ucx_map_get failed\n");
        return -1;
    }
    if(ucx_map_cstr_get(map, "nokey") != NULL) {
        fprintf(stderr, "ucx_map_get failed\n");
        return -1;
    }

    return 0;
}

mercurial