dovecot-2.2: lib: test-array - fatal tests

dovecot at dovecot.org dovecot at dovecot.org
Tue Nov 25 01:54:06 UTC 2014


details:   http://hg.dovecot.org/dovecot-2.2/rev/9141a16aff4e
changeset: 18113:9141a16aff4e
user:      Phil Carmody <phil at dovecot.fi>
date:      Tue Nov 25 03:44:55 2014 +0200
description:
lib: test-array - fatal tests
Tests both of the i_asserts which aren't already protected by TYPEOF compile-time
checks.

Signed-off-by: Phil Carmody <phil at dovecot.fi>

diffstat:

 src/lib/test-array.c |  25 +++++++++++++++++++++++++
 src/lib/test-lib.c   |   1 +
 src/lib/test-lib.h   |   1 +
 3 files changed, 27 insertions(+), 0 deletions(-)

diffs (54 lines):

diff -r 5522d5ce87a5 -r 9141a16aff4e src/lib/test-array.c
--- a/src/lib/test-array.c	Tue Nov 25 03:44:31 2014 +0200
+++ b/src/lib/test-array.c	Tue Nov 25 03:44:55 2014 +0200
@@ -176,3 +176,28 @@
 	test_array_cmp();
 	test_array_cmp_str();
 }
+
+enum fatal_test_state fatal_array(int stage)
+{
+	switch(stage) {
+	case 0: {
+		ARRAY(double) ad;
+		test_begin("fatal_array");
+		t_array_init(&ad, 3);
+		(void)array_idx(&ad, 3);
+		return FATAL_TEST_FAILURE;
+	} break;
+
+	case 1: {
+		ARRAY(double) ad;
+		ARRAY(short) as;
+		t_array_init(&ad, 2);
+		t_array_init(&as, 8);
+		array_copy(&ad.arr, 1, &as.arr, 0, 4);
+		return FATAL_TEST_FAILURE;
+	} break;
+
+	}
+	test_end();
+	return FATAL_TEST_FINISHED;
+}
diff -r 5522d5ce87a5 -r 9141a16aff4e src/lib/test-lib.c
--- a/src/lib/test-lib.c	Tue Nov 25 03:44:31 2014 +0200
+++ b/src/lib/test-lib.c	Tue Nov 25 03:44:55 2014 +0200
@@ -52,6 +52,7 @@
 		NULL
 	};
 	static enum fatal_test_state (*fatal_functions[])(int) = {
+		fatal_array,
 		fatal_data_stack,
 		fatal_mempool,
 		fatal_printf_format_fix,
diff -r 5522d5ce87a5 -r 9141a16aff4e src/lib/test-lib.h
--- a/src/lib/test-lib.h	Tue Nov 25 03:44:31 2014 +0200
+++ b/src/lib/test-lib.h	Tue Nov 25 03:44:55 2014 +0200
@@ -6,6 +6,7 @@
 
 void test_aqueue(void);
 void test_array(void);
+enum fatal_test_state fatal_array(int);
 void test_base32(void);
 void test_base64(void);
 void test_bits(void);


More information about the dovecot-cvs mailing list