test/map_tests.c

Sat, 18 Feb 2012 18:36:30 +0100

author
Mike Becker <universe@uap-core.de>
date
Sat, 18 Feb 2012 18:36:30 +0100
changeset 27
22644e2572bc
parent 20
db7d9860dbbd
child 29
bce0d7f2912b
permissions
-rw-r--r--

removed old foreach + refactored list tests

/*
 *
 */

#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