Cross Reference: test-str-table.c
xref
: /
dovecot
/
src
/
lib
/
test-str-table.c
Home
History
Annotate
Line#
Navigate
Download
Search
only in
./
bcb4e51a409d94ae670de96afb8483a4f7855294
Stephan Bosch
/* Copyright (c) 2014-2018 Dovecot authors, see the included COPYING file */
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
#
include
"
test-lib.h
"
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
#
include
"
str-table.h
"
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
void
test_str_table
(
void
)
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
{
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
struct
str_table
*
table
;
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
const
char
*
key1
, *
key2
, *
key1_copy
, *
key2_copy
;
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
test_begin
(
"str_table"
);
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
table
=
str_table_init
();
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
key1
=
str_table_ref
(
table
,
"str1"
);
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
key2
=
str_table_ref
(
table
,
"str2"
);
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
test_assert
(
key1
!=
key2
);
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
key1_copy
=
str_table_ref
(
table
,
"str1"
);
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
test_assert
(
key1_copy
==
key1
);
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
key2_copy
=
str_table_ref
(
table
,
"str2"
);
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
test_assert
(
key2_copy
==
key2
);
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
str_table_unref
(
table
, &
key1
);
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
test_assert
(
key1
==
NULL
);
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
str_table_unref
(
table
, &
key1_copy
);
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
str_table_unref
(
table
, &
key2
);
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
str_table_unref
(
table
, &
key2_copy
);
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
test_assert
(
str_table_is_empty
(
table
));
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
str_table_deinit
(&
table
);
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
test_assert
(
table
==
NULL
);
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
test_end
();
639587335dfe5d66dc7034817b3e685458ecbee1
Timo Sirainen
}