test-mail-index-transaction-update.c revision 67641f44b660d4f1cced9970b6ef38381ab487e9
/* Copyright (c) 2009-2013 Dovecot authors, see the included COPYING file */
#include "lib.h"
#include "array.h"
#include "test-common.h"
#include "mail-index-private.h"
#include "mail-index-transaction-private.h"
#include <stdlib.h>
static struct mail_index_header hdr;
static struct mail_index_record rec;
const struct mail_index_header *
{
return &hdr;
}
const struct mail_index_record *
{
return &rec;
}
{
}
{
return FALSE;
}
{
return hdr.messages_count;
}
{
}
struct mail_keywords *
const ARRAY_TYPE(keyword_indexes)
{
return NULL;
}
{
}
static struct mail_index_transaction *
{
struct mail_index_transaction *t;
return t;
}
static void test_mail_index_append(void)
{
struct mail_index_transaction *t;
const struct mail_index_record *appends;
const struct seq_range *saved_uids;
unsigned int count;
t = mail_index_transaction_new();
test_begin("mail index append");
mail_index_append(t, 0, &seq);
test_assert(t->log_updates);
mail_index_append(t, 0, &seq);
test_assert(!t->appends_nonsorted);
test_end();
/* test with some uids */
t = mail_index_transaction_new();
test_begin("mail index append with uids");
mail_index_append(t, 0, &seq);
test_assert(!t->appends_nonsorted);
mail_index_append(t, 0, &seq);
test_end();
}
static void test_mail_index_flag_update_fastpath(void)
{
struct mail_index_transaction *t;
const struct mail_index_flag_update *updates;
unsigned int count;
t = mail_index_transaction_new();
test_begin("mail index flag update fast paths");
test_assert(t->last_update_idx == 0);
test_assert(t->last_update_idx == 0);
test_assert(!t->log_updates);
test_end();
}
static void test_mail_index_flag_update_simple_merges(void)
{
struct mail_index_transaction *t;
const struct mail_index_flag_update *updates;
unsigned int count;
t = mail_index_transaction_new();
test_begin("mail index flag update simple merges");
test_assert(t->last_update_idx == 0);
test_assert(t->last_update_idx == 0);
test_assert(t->last_update_idx == 0);
test_assert(t->last_update_idx == 0);
test_end();
}
static void test_mail_index_flag_update_complex_merges(void)
{
struct mail_index_transaction *t;
const struct mail_index_flag_update *updates;
unsigned int count;
t = mail_index_transaction_new();
test_begin("mail index flag update complex merges");
test_end();
}
static void
flags_array_check(struct mail_index_transaction *t,
{
const struct mail_index_flag_update *updates;
if (array_is_created(&t->updates))
else {
count = 0;
}
if (i > 0) {
}
}
}
static void test_mail_index_flag_update_random(void)
{
struct mail_index_transaction *t;
enum modify_type modify_type;
t = mail_index_transaction_new();
test_begin("mail index flag update random");
for (r = 0; r < 1000; r++) {
switch (rand() % 3) {
case 0:
break;
case 1:
break;
case 2:
break;
default:
i_unreached();
}
change);
}
test_end();
}
static void test_mail_index_cancel_flag_updates(void)
{
struct mail_index_transaction *t;
const struct mail_index_flag_update *updates;
unsigned int count;
t = mail_index_transaction_new();
test_begin("mail index cancel flag updates");
test_end();
}
static void test_mail_index_flag_update_appends(void)
{
struct mail_index_transaction *t;
const struct mail_index_record *appends;
const struct mail_index_flag_update *updates;
unsigned int count;
t = mail_index_transaction_new();
test_begin("mail index flag update appends");
mail_index_append(t, 0, &seq);
mail_index_append(t, 0, &seq);
mail_index_append(t, 0, &seq);
test_end();
}
static bool test_flag_update_pos(struct mail_index_transaction *t,
{
unsigned int i, j, count;
for (i = 0; i < idx; i++) {
return FALSE;
}
}
}
return TRUE;
}
static void test_mail_index_transaction_get_flag_update_pos(void)
{
struct mail_index_transaction *t;
test_begin("mail index transaction get flag update pos");
t = mail_index_transaction_new();
test_end();
}
static void test_mail_index_modseq_update(void)
{
struct mail_index_transaction *t;
const struct mail_transaction_modseq_update *ups;
unsigned int count;
test_begin("mail index modseq update");
t = mail_index_transaction_new();
/* modseq=1 updates are ignored: */
test_end();
}
static void test_mail_index_expunge(void)
{
static guid_128_t empty_guid = { 0, };
struct mail_index_transaction *t;
const struct mail_transaction_expunge_guid *expunges;
unsigned int i, count;
test_begin("mail index expunge");
t = mail_index_transaction_new();
for (i = 0; i < sizeof(guid2); i++) {
guid2[i] = i + 1;
guid3[i] = i ^ 0xff;
guid4[i] = i + 0x80;
}
mail_index_expunge(t, 1);
mail_index_expunge(t, 5);
test_end();
}
int main(void)
{
static void (*test_functions[])(void) = {
};
return test_run(test_functions);
}