From f7548d6d28c313cf80e6f3ef89aed16a19815df1 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 28 Apr 2024 11:51:24 +0200 Subject: Adding upstream version 1:2.3.19.1+dfsg1. Signed-off-by: Daniel Baumann --- src/lib/test-str-table.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/lib/test-str-table.c (limited to 'src/lib/test-str-table.c') diff --git a/src/lib/test-str-table.c b/src/lib/test-str-table.c new file mode 100644 index 0000000..ea97d14 --- /dev/null +++ b/src/lib/test-str-table.c @@ -0,0 +1,33 @@ +/* Copyright (c) 2014-2018 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(); +} -- cgit v1.2.3