test-user-directory.c revision e34d170f8f0e084bd94bfbc1a7085ece67e508df
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen/* Copyright (c) 2012 Dovecot authors, see the included COPYING file */
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainenunsigned int mail_user_hash(const char *username ATTR_UNUSED,
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainenverify_user_directory(struct user_directory *dir, unsigned int user_count)
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen while ((user = user_directory_iter_next(iter)) != NULL) {
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen test_assert(prev == NULL || user->prev->next == user);
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen test_assert(prev == NULL || prev->next == NULL);
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainenstatic void test_user_directory_ascending(void)
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen struct mail_host *host = t_new(struct mail_host, 1);
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen unsigned int i;
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen dir = user_directory_init(USER_DIR_TIMEOUT, "%u");
e34d170f8f0e084bd94bfbc1a7085ece67e508dfTimo Sirainen (void)user_directory_add(dir, 1, host, ioloop_time + count+1);
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen for (i = 0; i < count; i++)
e34d170f8f0e084bd94bfbc1a7085ece67e508dfTimo Sirainen (void)user_directory_add(dir, i+2, host, ioloop_time + i);
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainenstatic void test_user_directory_descending(void)
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen struct mail_host *host = t_new(struct mail_host, 1);
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen unsigned int i;
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen dir = user_directory_init(USER_DIR_TIMEOUT, "%u");
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen for (i = 0; i < count; i++)
e34d170f8f0e084bd94bfbc1a7085ece67e508dfTimo Sirainen (void)user_directory_add(dir, i+1, host, ioloop_time - i);
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen struct mail_host *host = t_new(struct mail_host, 1);
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen dir = user_directory_init(USER_DIR_TIMEOUT, "%u");
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen for (i = 0; i < count; i++) {
e34d170f8f0e084bd94bfbc1a7085ece67e508dfTimo Sirainen (void)user_directory_add(dir, i+1, host, timestamp);
447bf65ddb82ec279e7386828748ef47e199a6afTimo Sirainen static void (*test_functions[])(void) = {