static unsigned int failure_count;
static unsigned int total_count;
static unsigned int expected_errors;
+static char *expected_error_str;
struct test_istream {
struct istream_private istream;
total_count++;
}
+void
+test_expect_error_string(const char *substr)
+{
+ i_assert(expected_errors == 0);
+ expected_errors = 1;
+ expected_error_str = i_strdup(substr);
+}
void
test_expect_errors(unsigned int expected)
{
void
test_expect_no_more_errors(void)
{
- test_assert(expected_errors == 0);
+ test_assert(expected_errors == 0 && expected_error_str == NULL);
expected_errors = 0;
}
}
#endif
if (expected_errors > 0) {
+ if (expected_error_str != NULL) {
+ test_assert(strstr(format, expected_error_str) != NULL);
+ i_free(expected_error_str);
+ }
expected_errors--;
return;
}
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_no_more_errors(void);
void test_end(void);