diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:51:24 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-28 09:51:24 +0000 |
commit | f7548d6d28c313cf80e6f3ef89aed16a19815df1 (patch) | |
tree | a3f6f2a3f247293bee59ecd28e8cd8ceb6ca064a /src/lib-dict/test-dict.c | |
parent | Initial commit. (diff) | |
download | dovecot-upstream.tar.xz dovecot-upstream.zip |
Adding upstream version 1:2.3.19.1+dfsg1.upstream/1%2.3.19.1+dfsg1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'src/lib-dict/test-dict.c')
-rw-r--r-- | src/lib-dict/test-dict.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/lib-dict/test-dict.c b/src/lib-dict/test-dict.c new file mode 100644 index 0000000..04864ff --- /dev/null +++ b/src/lib-dict/test-dict.c @@ -0,0 +1,46 @@ +/* Copyright (c) 2010-2018 Dovecot authors, see the included COPYING file */ + +#include "lib.h" +#include "dict-private.h" +#include "test-common.h" + +struct dict dict_driver_client; +struct dict dict_driver_file; +struct dict dict_driver_memcached; +struct dict dict_driver_memcached_ascii; +struct dict dict_driver_redis; + +static void test_dict_escape(void) +{ + static const char *input[] = { + "", "", + "foo", "foo", + "foo\\", "foo\\\\", + "foo\\bar", "foo\\\\bar", + "\\bar", "\\\\bar", + "foo/", "foo\\|", + "foo/bar", "foo\\|bar", + "/bar", "\\|bar", + "////", "\\|\\|\\|\\|", + "/", "\\|" + }; + unsigned int i; + + test_begin("dict escape"); + for (i = 0; i < N_ELEMENTS(input); i += 2) { + test_assert(strcmp(dict_escape_string(input[i]), input[i+1]) == 0); + test_assert(strcmp(dict_unescape_string(input[i+1]), input[i]) == 0); + } + test_assert(strcmp(dict_unescape_string("x\\"), "x") == 0); + test_assert(strcmp(dict_unescape_string("\\"), "") == 0); + test_end(); +} + +int main(void) +{ + static void (*const test_functions[])(void) = { + test_dict_escape, + NULL + }; + return test_run(test_functions); +} |