lighttpd 1.4.x https://www.lighttpd.net/
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

82 lines
2.8 KiB

#include "first.h"
#include <assert.h>
#include <stdio.h>
#include <stdlib.h>
#include "array.h"
#include "buffer.h"
static void test_array_insert_value (void) {
data_string *ds;
array *a = array_init();
array_insert_value(a, CONST_STR_LEN("def"));
ds = (data_string *)a->data[0];
assert(NULL != ds);
assert(buffer_is_equal_string(ds->value, CONST_STR_LEN("def")));
array_free(a);
}
static void test_array_insert_key_value (void) {
data_string *ds;
array *a = array_init();
array_insert_key_value(a, CONST_STR_LEN("abc"), CONST_STR_LEN("alfrag"));
ds = (data_string *)array_get_element_klen(a, CONST_STR_LEN("does-not-exist"));
assert(NULL == ds);
ds = (data_string *)array_get_element_klen(a, CONST_STR_LEN("abc"));
assert(NULL != ds);
assert(buffer_is_equal_string(ds->key, CONST_STR_LEN("abc")));
assert(buffer_is_equal_string(ds->value, CONST_STR_LEN("alfrag")));
array_insert_key_value(a, CONST_STR_LEN("abc"), CONST_STR_LEN("hameplman"));
ds = (data_string *)array_get_element_klen(a, CONST_STR_LEN("does-not-exist"));
assert(NULL == ds);
ds = (data_string *)array_get_element_klen(a, CONST_STR_LEN("abc"));
assert(NULL != ds);
assert(buffer_is_equal_string(ds->key, CONST_STR_LEN("abc")));
assert(buffer_is_equal_string(ds->value, CONST_STR_LEN("alfrag, hameplman")));
array_insert_key_value(a, CONST_STR_LEN("123"), CONST_STR_LEN("alfrag"));
ds = (data_string *)array_get_element_klen(a, CONST_STR_LEN("does-not-exist"));
assert(NULL == ds);
ds = (data_string *)array_get_element_klen(a, CONST_STR_LEN("123"));
assert(NULL != ds);
assert(buffer_is_equal_string(ds->key, CONST_STR_LEN("123")));
assert(buffer_is_equal_string(ds->value, CONST_STR_LEN("alfrag")));
array_free(a);
}
static void test_array_set_key_value (void) {
data_string *ds;
array *a = array_init();
array_set_key_value(a, CONST_STR_LEN("abc"), CONST_STR_LEN("def"));
ds = (data_string *)array_get_element_klen(a, CONST_STR_LEN("does-not-exist"));
assert(NULL == ds);
ds = (data_string *)array_get_element_klen(a, CONST_STR_LEN("abc"));
assert(NULL != ds);
assert(buffer_is_equal_string(ds->key, CONST_STR_LEN("abc")));
assert(buffer_is_equal_string(ds->value, CONST_STR_LEN("def")));
array_set_key_value(a, CONST_STR_LEN("abc"), CONST_STR_LEN("ghi"));
ds = (data_string *)array_get_element_klen(a, CONST_STR_LEN("does-not-exist"));
assert(NULL == ds);
ds = (data_string *)array_get_element_klen(a, CONST_STR_LEN("abc"));
assert(NULL != ds);
assert(buffer_is_equal_string(ds->key, CONST_STR_LEN("abc")));
assert(buffer_is_equal_string(ds->value, CONST_STR_LEN("ghi")));
array_free(a);
}
int main() {
test_array_insert_value();
test_array_insert_key_value();
test_array_set_key_value();
return 0;
}