dovecot-2.2: test-var-expand: Added more unit tests for %variabl...

dovecot at dovecot.org dovecot at dovecot.org
Mon Mar 17 14:57:57 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/cb2607ffa93a
changeset: 17160:cb2607ffa93a
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Mar 17 16:57:36 2014 +0200
description:
test-var-expand: Added more unit tests for %variable offsets/lengths.

diffstat:

 src/lib/test-var-expand.c |  28 ++++++++++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)

diffs (45 lines):

diff -r 97d31cbbfe01 -r cb2607ffa93a src/lib/test-var-expand.c
--- a/src/lib/test-var-expand.c	Mon Mar 17 16:57:21 2014 +0200
+++ b/src/lib/test-var-expand.c	Mon Mar 17 16:57:36 2014 +0200
@@ -16,6 +16,33 @@
 	unsigned int idx, size;
 };
 
+static void test_var_expand_ranges(void)
+{
+	static struct var_expand_test tests[] = {
+		{ "%v", "value1234" },
+		{ "%3v", "val" },
+		{ "%3.2v", "ue" },
+		{ "%3.-2v", "ue12" },
+		{ "%-3.2v", "23" },
+		{ "%0.-1v", "value123" },
+		{ "%-4.-1v", "123" }
+	};
+	static struct var_expand_table table[] = {
+		{ 'v', "value1234", NULL },
+		{ '\0', NULL, NULL }
+	};
+	string_t *str = t_str_new(128);
+	unsigned int i;
+
+	test_begin("var_expand");
+	for (i = 0; i < N_ELEMENTS(tests); i++) {
+		str_truncate(str, 0);
+		var_expand(str, tests[i].in, table);
+		test_assert(strcmp(tests[i].out, str_c(str)) == 0);
+	}
+	test_end();
+}
+
 static void test_var_expand_builtin(void)
 {
 	static struct var_expand_test tests[] = {
@@ -75,6 +102,7 @@
 
 void test_var_expand(void)
 {
+	test_var_expand_ranges();
 	test_var_expand_builtin();
 	test_var_get_key_range();
 }


More information about the dovecot-cvs mailing list