]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
lib-test: test-common - Add "test_expect_error_string_n_times" function to expect...
authorSina Tavakoli <sina.tavakoli@open-xchange.com>
Wed, 8 Jan 2020 11:05:20 +0000 (13:05 +0200)
committerSina Tavakoli <sina.tavakoli@open-xchange.com>
Thu, 9 Jan 2020 12:18:02 +0000 (14:18 +0200)
src/lib-test/test-common.c
src/lib-test/test-common.h

index 781dbbc67c32ac09463954cfc7b663db509ffbb2..b844c7add82d8cf36a35cce0feaf1ecdef4d33d9 100644 (file)
@@ -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);
index 96a814969fabdd85e1a08283a36717aa174cb7da..88bd7bace81a7f914a7f18e2ca72d3e064f4997b 100644 (file)
@@ -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