test-var-expand.c revision 1bc529e36d36f9a525c6af023ae014ebc6cdb440
/* Copyright (c) 2009-2014 Dovecot authors, see the included COPYING file */
#include "test-lib.h"
#include "str.h"
#include "env-util.h"
#include "hostpid.h"
#include "var-expand.h"
struct var_expand_test {
const char *in;
const char *out;
};
struct var_get_key_range_test {
const char *in;
};
static void test_var_expand_ranges(void)
{
static struct var_expand_test tests[] = {
{ "%v", "value1234" },
{ "%3v", "val" },
{ "%3.2v", "ue" },
{ "%3.-2v", "ue12" },
{ "%-3.2v", "23" },
{ "%0.-1v", "value123" },
{ "%-4.-1v", "123" }
};
static struct var_expand_table table[] = {
};
unsigned int i;
test_begin("var_expand");
for (i = 0; i < N_ELEMENTS(tests); i++) {
str_truncate(str, 0);
}
test_end();
}
static void test_var_expand_builtin(void)
{
static struct var_expand_test tests[] = {
{ "%{hostname}", NULL },
{ "%{pid}", NULL },
{ "a%{env:FOO}b", "abaRb" },
{ "%50Hv", "1f" },
{ "%50Hw", "2e" },
{ "%50Nv", "25" },
{ "%50Nw", "e" }
};
static struct var_expand_table table[] = {
};
unsigned int i;
env_put("FOO=baR");
test_begin("var_expand");
for (i = 0; i < N_ELEMENTS(tests); i++) {
str_truncate(str, 0);
}
test_end();
}
static void test_var_get_key_range(void)
{
static struct var_get_key_range_test tests[] = {
{ "", 0, 0 },
{ "{", 1, 0 },
{ "k", 0, 1 },
{ "{key}", 1, 3 },
{ "5.5Rk", 4, 1 },
{ "5.5R{key}", 5, 3 },
{ "{key", 1, 3 }
};
test_begin("var_get_key_range");
for (i = 0; i < N_ELEMENTS(tests); i++) {
}
test_end();
}
void test_var_expand(void)
{
}