diff options
Diffstat (limited to 'src/doveadm/test-doveadm-util.c')
-rw-r--r-- | src/doveadm/test-doveadm-util.c | 48 |
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); +} |