summaryrefslogtreecommitdiffstats
path: root/src/doveadm/test-doveadm-util.c
blob: aec1b39ae192e4ae33641f8d17cc5e729bbdea6e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
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);
}