view src/lib/test-str-table.c @ 18137:3009a1a6f6d5

global: freshen copyright Robomatically: git ls-files | xargs perl -p -i -e 's/(\d+)-201[0-4]/$1-2015/g;s/ (201[0-4]) Dovecot/ $1-2015 Dovecot/' Happy 2015 everyone! Signed-off-by: Phil Carmody <phil@dovecot.fi>
author Phil Carmody <phil@dovecot.fi>
date Mon, 05 Jan 2015 22:20:10 +0200
parents 4c956747c36f
children 0f22db71df7a
line wrap: on
line source

/* Copyright (c) 2014-2015 Dovecot authors, see the included COPYING file */

#include "test-lib.h"
#include "str-table.h"

void test_str_table(void)
{
	struct str_table *table;
	const char *key1, *key2, *key1_copy, *key2_copy;

	test_begin("str_table");
	table = str_table_init();

	key1 = str_table_ref(table, "str1");
	key2 = str_table_ref(table, "str2");
	test_assert(key1 != key2);
	key1_copy = str_table_ref(table, "str1");
	test_assert(key1_copy == key1);
	key2_copy = str_table_ref(table, "str2");
	test_assert(key2_copy == key2);

	str_table_unref(table, &key1);
	test_assert(key1 == NULL);
	str_table_unref(table, &key1_copy);

	str_table_unref(table, &key2);
	str_table_unref(table, &key2_copy);
	test_assert(str_table_is_empty(table));

	str_table_deinit(&table);
	test_assert(table == NULL);
	test_end();
}