test/map_tests.c

Sun, 15 Jan 2012 14:12:34 +0100

author
Mike Becker <universe@uap-core.de>
date
Sun, 15 Jan 2012 14:12:34 +0100
changeset 22
76cdd8209f1f
parent 20
db7d9860dbbd
child 29
bce0d7f2912b
permissions
-rw-r--r--

added ucx_dlist_remove and tests + fixed makefile error

/*
 *
 */

#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