static bool test_success;
static unsigned int failure_count;
static unsigned int total_count;
+static unsigned int expected_errors;
struct test_istream {
struct istream_private istream;
total_count++;
}
+void
+test_expect_errors(unsigned int expected)
+{
+ i_assert(expected_errors == 0);
+ expected_errors = expected;
+}
+void
+test_expect_no_more_errors(void)
+{
+ test_assert(expected_errors == 0);
+ expected_errors = 0;
+}
+
static void ATTR_FORMAT(2, 0)
test_error_handler(const struct failure_context *ctx,
const char *format, va_list args)
return;
}
#endif
+ if (expected_errors > 0) {
+ expected_errors--;
+ return;
+ }
test_success = FALSE;
}
void test_assert_failed(const char *code, const char *file, unsigned int line);
void test_assert_failed_idx(const char *code, const char *file, unsigned int line, long long i);
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_no_more_errors(void);
void test_end(void);
void test_out(const char *name, bool success);