From f8cde1e03f28f4209726374fc544a4a8f97b4608 Mon Sep 17 00:00:00 2001 From: Sina Tavakoli Date: Wed, 8 Jan 2020 13:05:20 +0200 Subject: [PATCH] lib-test: test-common - Add "test_expect_error_string_n_times" function to expect an error output for an arbitrary times. --- src/lib-test/test-common.c | 9 +++++++-- src/lib-test/test-common.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/lib-test/test-common.c b/src/lib-test/test-common.c index 781dbbc67c..b844c7add8 100644 --- a/src/lib-test/test-common.c +++ b/src/lib-test/test-common.c @@ -156,13 +156,18 @@ void test_out_reason(const char *name, bool success, const char *reason) } void -test_expect_error_string(const char *substr) +test_expect_error_string_n_times(const char *substr, unsigned int times) { i_assert(expected_errors == 0); - expected_errors = 1; + expected_errors = times; expected_error_str = i_strdup(substr); } void +test_expect_error_string(const char *substr) +{ + test_expect_error_string_n_times(substr, 1); +} +void test_expect_errors(unsigned int expected) { i_assert(expected_errors == 0); diff --git a/src/lib-test/test-common.h b/src/lib-test/test-common.h index 96a814969f..88bd7bace8 100644 --- a/src/lib-test/test-common.h +++ b/src/lib-test/test-common.h @@ -40,6 +40,7 @@ bool test_has_failed(void); /* If you're testing nasty cases which you want to warn, surround the noisy op with these */ void test_expect_errors(unsigned int expected); void test_expect_error_string(const char *substr); /* expect just 1 message matching the printf format */ +void test_expect_error_string_n_times(const char *substr, unsigned int times); /* expect just n messages matching the printf format */ void test_expect_no_more_errors(void); /* Note that test_expect_error{s,_string}() effectively begin with a check equivalent to test_expect_no_more_errors(), so you don't need the latter explicitly if following -- 2.47.3