annotate src/lib/test-wildcard-match.c @ 22955:812e5c961328

fts: Indexing virtual mailbox didn't always index the last mails
author Timo Sirainen <timo.sirainen@dovecot.fi>
date Thu, 03 May 2018 18:33:00 +0300
parents cb108f786fb4
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
22713
cb108f786fb4 Updated copyright notices to include the year 2018.
Stephan Bosch <stephan.bosch@dovecot.fi>
parents: 21390
diff changeset
1 /* Copyright (c) 2014-2018 Dovecot authors, see the included COPYING file */
17727
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
2
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
3 #include "test-lib.h"
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
4 #include "wildcard-match.h"
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
5
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
6 static struct {
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
7 const char *data;
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
8 const char *mask;
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
9 bool result;
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
10 } tests[] = {
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
11 { "foo", "*", TRUE },
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
12 { "foo", "*foo*", TRUE },
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
13 { "foo", "foo", TRUE },
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
14 { "foo", "f*o*o", TRUE },
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
15 { "foo", "f??", TRUE },
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
16 { "foo", "f?o", TRUE },
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
17 { "foo", "*??", TRUE },
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
18 { "foo", "???", TRUE },
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
19 { "foo", "f??*", TRUE },
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
20 { "foo", "???*", TRUE },
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
21
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
22 { "foo", "", FALSE },
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
23 { "foo", "f", FALSE },
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
24 { "foo", "fo", FALSE },
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
25 { "foo", "fooo", FALSE },
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
26 { "foo", "????", FALSE },
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
27 { "foo", "f*o*o*o", FALSE },
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
28 { "foo", "f???*", FALSE },
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
29
18294
91852459f388 lib: Minor improvement to test-wildcard-match unit test.
Timo Sirainen <tss@iki.fi>
parents: 18137
diff changeset
30 { "*foo", "foo", FALSE },
91852459f388 lib: Minor improvement to test-wildcard-match unit test.
Timo Sirainen <tss@iki.fi>
parents: 18137
diff changeset
31 { "foo*", "foo", FALSE },
91852459f388 lib: Minor improvement to test-wildcard-match unit test.
Timo Sirainen <tss@iki.fi>
parents: 18137
diff changeset
32 { "*foo*", "foo", FALSE },
91852459f388 lib: Minor improvement to test-wildcard-match unit test.
Timo Sirainen <tss@iki.fi>
parents: 18137
diff changeset
33
17727
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
34 { "", "*", TRUE },
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
35 { "", "", TRUE },
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
36 { "", "?", FALSE }
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
37 };
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
38
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
39 void test_wildcard_match(void)
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
40 {
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
41 unsigned int i;
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
42
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
43 test_begin("wildcard_match()");
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
44 for (i = 0; i < N_ELEMENTS(tests); i++) {
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
45 test_assert_idx(wildcard_match(tests[i].data, tests[i].mask) == tests[i].result, i);
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
46 }
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
47 test_end();
d1d4beff99f7 lib: Added unit tests for wildcard_match()
Timo Sirainen <tss@iki.fi>
parents:
diff changeset
48 }