summaryrefslogtreecommitdiffstats
path: root/src/doveadm/test-doveadm-util.c
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:51:24 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 09:51:24 +0000
commitf7548d6d28c313cf80e6f3ef89aed16a19815df1 (patch)
treea3f6f2a3f247293bee59ecd28e8cd8ceb6ca064a /src/doveadm/test-doveadm-util.c
parentInitial commit. (diff)
downloaddovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.tar.xz
dovecot-f7548d6d28c313cf80e6f3ef89aed16a19815df1.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/doveadm/test-doveadm-util.c')
-rw-r--r--src/doveadm/test-doveadm-util.c48
1 files changed, 48 insertions, 0 deletions
diff --git a/src/doveadm/test-doveadm-util.c b/src/doveadm/test-doveadm-util.c
new file mode 100644
index 0000000..aec1b39
--- /dev/null
+++ b/src/doveadm/test-doveadm-util.c
@@ -0,0 +1,48 @@
+/* Copyright (c) 2016-2018 Dovecot authors, see the included COPYING file */
+
+#include "lib.h"
+#include "test-common.h"
+#include "doveadm-settings.h"
+#include "doveadm-util.h"
+
+struct doveadm_settings *doveadm_settings; /* just to avoid linker error */
+
+static void test_i_strccdascmp(void)
+{
+ test_begin("i_strccdascmp()");
+
+ test_assert(i_strccdascmp("", "")==0);
+ test_assert(i_strccdascmp("", "-")!=0);
+ test_assert(i_strccdascmp("-", "")!=0);
+ test_assert(i_strccdascmp("-", "-")==0);
+ test_assert(i_strccdascmp("-\0baz", "-\0bar")==0);
+ test_assert(i_strccdascmp("", "a")!=0);
+ test_assert(i_strccdascmp("a", "")!=0);
+ test_assert(i_strccdascmp("a", "a")==0);
+ test_assert(i_strccdascmp("a-", "a-")==0);
+ test_assert(i_strccdascmp("a-a", "a-a")==0);
+ test_assert(i_strccdascmp("ca", "ba")!=0);
+
+ test_assert(i_strccdascmp("camel case", "camel case")==0);
+ test_assert(i_strccdascmp("camel case", "camel-case")==0);
+ test_assert(i_strccdascmp("camel case", "camelCase")==0);
+
+ test_assert(i_strccdascmp("camel case", "camel-case")==0);
+ test_assert(i_strccdascmp("camel-case", "camel-case")==0);
+ test_assert(i_strccdascmp("camelCase", "camel-case")==0);
+
+ test_assert(i_strccdascmp("camel case", "camel Case")==-i_strccdascmp("camel Case", "camel case"));
+ test_assert(i_strccdascmp("camel-case", "camel Case")==-i_strccdascmp("camel Case", "camel-case"));
+ test_assert(i_strccdascmp("camel dase", "camel case")==-i_strccdascmp("camel case", "camel dase"));
+
+ test_end();
+}
+
+int main(void)
+{
+ static void (*const test_functions[])(void) = {
+ test_i_strccdascmp,
+ NULL
+ };
+ return test_run(test_functions);
+}