Mercurial > dovecot > core-2.2
view src/auth/test-db-dict.c @ 21390:2e2563132d5f
Updated copyright notices to include the year 2017.
author | Stephan Bosch <stephan.bosch@dovecot.fi> |
---|---|
date | Wed, 11 Jan 2017 02:51:13 +0100 |
parents | 0f22db71df7a |
children | cb108f786fb4 |
line wrap: on
line source
/* Copyright (c) 2013-2017 Dovecot authors, see the included COPYING file */ #include "lib.h" #include "array.h" #include "db-dict.h" #include "test-common.h" static void test_db_dict_parse_cache_key(void) { struct db_dict_key keys[] = { { "key0", "%d and %n", NULL, NULL, 0 }, { "key1", "%{foo}%r%{bar}", NULL, NULL, 0 }, { "key2", "%{test1}/path", NULL, NULL, 0 }, { "key3", "path2/%{test2}", NULL, NULL, 0 }, { "key4", "%{plop}", NULL, NULL, 0 }, { "key5", "%{unused}", NULL, NULL, 0 } }; struct db_dict_field fields[] = { { "name1", "hello %{dict:key0} %l and %{dict:key1}" }, { "name2", "%{dict:key2} also %{extra} plus" } }; const struct db_dict_key *objects[] = { &keys[3], &keys[4] }; buffer_t keybuf, fieldbuf, objectbuf; ARRAY_TYPE(db_dict_key) keyarr; ARRAY_TYPE(db_dict_field) fieldarr; ARRAY_TYPE(db_dict_key_p) objectarr; test_begin("db dict parse cache key"); buffer_create_from_const_data(&keybuf, keys, sizeof(keys)); buffer_create_from_const_data(&fieldbuf, fields, sizeof(fields)); buffer_create_from_const_data(&objectbuf, objects, sizeof(objects)); array_create_from_buffer(&keyarr, &keybuf, sizeof(keys[0])); array_create_from_buffer(&fieldarr, &fieldbuf, sizeof(fields[0])); array_create_from_buffer(&objectarr, &objectbuf, sizeof(objects[0])); test_assert(strcmp(db_dict_parse_cache_key(&keyarr, &fieldarr, &objectarr), "\t%d and %n\t%l\t%{foo}%r%{bar}\t%{test1}/path\t%{extra}\tpath2/%{test2}\t%{plop}") == 0); test_end(); } int main(void) { static void (*test_functions[])(void) = { test_db_dict_parse_cache_key, NULL }; return test_run(test_functions); }